ZwiiCampus/core/include/update.inc.php

51 lines
2.0 KiB
PHP

<?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('6571b5913e87e', ['pablorodriguez', 'history', 'les-titres-ou-headers']);
echo"<pre>";
var_dump($t);
die();
*/