From 5dc51a62cec8db7bbc1846fb00b45dd3572c22b8 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Wed, 3 Apr 2024 16:59:04 +0200 Subject: [PATCH] =?UTF-8?q?1.8.00=20initialise=20avec=20la=20cr=C3=A9ation?= =?UTF-8?q?=20des=20bases=20dans=20les=20espaces=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 8 ++++++-- core/include/update.inc.php | 29 +++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/core/core.php b/core/core.php index 5042924..5a44517 100644 --- a/core/core.php +++ b/core/core.php @@ -51,7 +51,7 @@ class common const ACCESS_TIMER = 1800; // Numéro de version - const ZWII_VERSION = '1.7.09'; + const ZWII_VERSION = '1.8.00'; // URL autoupdate const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/'; @@ -224,7 +224,6 @@ class common 'user' => '', 'language' => '', 'profil' => '', - 'enrolment' => '', 'category' => '', ]; @@ -232,6 +231,7 @@ class common 'page' => '', 'module' => '', 'theme' => '', + 'enrolment' => '', ]; public static $fontsWebSafe = [ @@ -598,6 +598,10 @@ class common return file_put_contents(self::DATA_DIR . $path . '/content/' . $page . '.html', $value); } + public function getEnrolment($courseId, $keys =[]) { + $data = json_decode(file_get_contents(self::DATA_DIR . $courseId .'.json'), true); + return $data[$keys[0]]; + } /** diff --git a/core/include/update.inc.php b/core/include/update.inc.php index d982a4f..2389954 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -10,7 +10,7 @@ if ( ) { // Supprime la variable path des profils, seul l'accès à l'espace et autorisé. foreach (['1', '2'] as $group) { - foreach ( array_keys($this->getData(['profil', $group])) as $profil) { + foreach (array_keys($this->getData(['profil', $group])) as $profil) { if (is_null($this->getData(['profil', $group, $profil, 'folder', 'path'])) === false) { $path = $this->getData(['profil', $group, $profil, 'folder', 'path']); $this->setData(['profil', $group, $profil, 'folder', 'homePath', $path]); @@ -20,4 +20,29 @@ if ( } } $this->setData(['core', 'dataVersion', 1700]); -} \ No newline at end of file +} + +// Déplacement des +if ( + $this->getData(['core', 'dataVersion']) < 1800 +) { + + // Déplace les incriptions dans les cours + if (file_exists(self::DATA_DIR . 'enrolment.json')) { + $old_enrolment = json_decode(file_get_contents(self::DATA_DIR . 'enrolment.json'), true); + $old_enrolment = $old_enrolment['enrolment']; + foreach ($this->getData(['course']) as $courseId => $courseValues) { + if (array_key_exists($courseId, $old_enrolment)) { + file_put_contents(self::DATA_DIR . $courseId . '/enrolment.json', json_encode(['enrolment' => [$courseId => $old_enrolment[$courseId]]], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), LOCK_EX); + } else { + // Création d'une structure vide + file_put_contents(self::DATA_DIR . $courseId . '/enrolment.json', json_encode(['enrolment' => [$courseId => []]], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), LOCK_EX); + } + } + } + unlink(self::DATA_DIR . 'enrolment.json'); + $this->setData(['core', 'dataVersion', 1800]); +} +$t = $this->getEnrolment(['65d749713a217']); +var_dump($t); +dei(); \ No newline at end of file