forked from ZwiiCMS-Team/ZwiiCampus
backup ok
This commit is contained in:
parent
2abc9812dc
commit
7ac5d9589c
@ -35,7 +35,8 @@ class course extends common
|
||||
'userHistory' => self::GROUP_EDITOR,
|
||||
'usersHistoryExport' => self::GROUP_EDITOR,
|
||||
'userHistoryExport' => self::GROUP_EDITOR,
|
||||
'courseBackup' => self::GROUP_ADMIN,
|
||||
'backup' => self::GROUP_EDITOR,
|
||||
'restore' => self::GROUP_EDITOR,
|
||||
];
|
||||
|
||||
public static $courseAccess = [
|
||||
@ -108,15 +109,14 @@ class course extends common
|
||||
'help' => 'Éditer'
|
||||
]),
|
||||
template::button('courseDownload' . $courseId, [
|
||||
'href' => helper::baseUrl() . 'course/courseBackup/' . $courseId,
|
||||
'value' => template::ico('download'),
|
||||
'href' => helper::baseUrl() . 'course/backup/' . $courseId,
|
||||
'value' => template::ico('download-cloud'),
|
||||
'help' => 'Sauvegarder'
|
||||
]),
|
||||
template::button('courseUpload' . $courseId, [
|
||||
'href' => helper::baseUrl() . 'course',
|
||||
'value' => template::ico('upload'),
|
||||
'href' => helper::baseUrl() . 'course/restore/',
|
||||
'value' => template::ico('upload-cloud'),
|
||||
'help' => 'Restaurer',
|
||||
'disabled' => true,
|
||||
]),
|
||||
template::button('courseDelete' . $courseId, [
|
||||
'class' => 'courseDelete buttonRed',
|
||||
@ -1330,8 +1330,18 @@ class course extends common
|
||||
* Sauvegarde d'un cours sans option
|
||||
*/
|
||||
|
||||
public function courseBackup()
|
||||
public function backup()
|
||||
{
|
||||
|
||||
// Accès refusé
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
||||
) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'access' => false
|
||||
]);
|
||||
} else {
|
||||
$courseId = $this->getUrl(2);
|
||||
|
||||
// Participants avec historiques
|
||||
@ -1353,17 +1363,15 @@ class course extends common
|
||||
// Génère une archive ZIP
|
||||
$this->makeZip(self::TEMP_DIR . $courseId . '-' . date('Y-m-d-H-i-s', time()) . '.zip', self::DATA_DIR . $courseId);
|
||||
|
||||
if (!is_dir(self::FILE_DIR . 'source/backup')) {
|
||||
mkdir(self::FILE_DIR . 'source/backup');
|
||||
}
|
||||
|
||||
$success = false;
|
||||
$message = helper::translate('Erreur : sauvegarde non générée !');
|
||||
// Transférer dans RFM
|
||||
if (file_exists(self::TEMP_DIR . $courseId . '-' . date('Y-m-d-H-i-s', time()) . '.zip')) {
|
||||
if (!is_dir(self::FILE_DIR . 'source/' . $courseId )) {
|
||||
mkdir(self::FILE_DIR . 'source/' . $courseId );
|
||||
}
|
||||
if (!is_dir(self::FILE_DIR . 'source/' . $courseId . '/backup/')) {
|
||||
mkdir(self::FILE_DIR . 'source/' . $courseId . '/backup/');
|
||||
|
||||
}
|
||||
copy(self::TEMP_DIR . $courseId . '-' . date('Y-m-d-H-i-s', time()) . '.zip', self::FILE_DIR . 'source/' . $courseId . '/backup/' . $courseId . '-' . date('Y-m-d-H-i-s', time()) . '.zip');
|
||||
unlink(self::TEMP_DIR . $courseId . '-' . date('Y-m-d-H-i-s', time()) . '.zip');
|
||||
@ -1377,9 +1385,23 @@ class course extends common
|
||||
'state' => $success,
|
||||
'notification' => $message,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sauvegarde d'un cours sans option
|
||||
*/
|
||||
|
||||
public function restore()
|
||||
{
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'title' => helper::translate('Restaurer un espace'),
|
||||
'view' => 'restore'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Autorise l'accès à un contenu
|
||||
|
20
core/module/course/view/restore/restore.css
Normal file
20
core/module/course/view/restore/restore.css
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* This file is part of Zwii.
|
||||
*
|
||||
* For full copyright and license information, please see the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @author Rémi Jean <remi.jean@outlook.com>
|
||||
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
||||
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
||||
* @copyright Copyright (C) 2018-2023, Frédéric Tempez
|
||||
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
|
||||
/** @import url("site/data/admin.css"); */
|
||||
|
||||
/** NE PAS EFFACER
|
||||
* admin.css
|
||||
*/
|
33
core/module/course/view/restore/restore.php
Normal file
33
core/module/course/view/restore/restore.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php echo template::formOpen('courseRestoreForm'); ?>
|
||||
<div class="row">
|
||||
<div class="col1">
|
||||
<?php echo template::button('courseRestoreBack', [
|
||||
'class' => 'buttonGrey',
|
||||
'href' => helper::baseUrl() . 'course',
|
||||
'value' => template::ico('left')
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col2 offset9">
|
||||
<?php echo template::submit('courseRestoreSubmit', [
|
||||
'value' => 'Valider'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<div class="block">
|
||||
<h4>
|
||||
<?php echo helper::translate('Sélectionner une archive'); ?>
|
||||
</h4>
|
||||
<div class="row">
|
||||
<div class="col10 offset1">
|
||||
<?php echo template::file('courseRestoreCSVFile', [
|
||||
'language' => $this->getData(['course', $this->getUser('id'), 'language']),
|
||||
//'label' => 'Fichier de sauvegarde :'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo template::formClose(); ?>
|
Loading…
Reference in New Issue
Block a user