ZwiiCampus/core/include/update.inc.php

48 lines
2.0 KiB
PHP
Raw Normal View History

<?php
/**
* Mises à jour suivant les versions de ZwiiCampus
*/
if (
$this->getData(['core', 'dataVersion']) < 1700
) {
// 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) {
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]);
$this->setData(['profil', $group, $profil, 'folder', 'coursePath', $path]);
$this->deleteData(['profil', $group, $profil, 'folder', 'path']);
}
}
}
$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();