1.8.00 initialise avec la création des bases dans les espaces WIP

This commit is contained in:
Fred Tempez 2024-04-03 16:59:04 +02:00
parent e8e4f98be0
commit 5dc51a62ce
2 changed files with 33 additions and 4 deletions

View File

@ -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]];
}
/**

View File

@ -21,3 +21,28 @@ if (
}
$this->setData(['core', 'dataVersion', 1700]);
}
// 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();