diff --git a/core/include/update.inc.php b/core/include/update.inc.php index 9af1375..baec29a 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -4,7 +4,7 @@ * Mises à jour suivant les versions de ZwiiCampus */ - +// Version 1.7.00 if ( $this->getData(['core', 'dataVersion']) < 1700 ) { @@ -22,6 +22,7 @@ if ( $this->setData(['core', 'dataVersion', 1700]); } +// Version 1.8.00 if ( $this->getData(['core', 'dataVersion']) < 1800 ) { @@ -46,6 +47,7 @@ if ( $this->setData(['core', 'dataVersion', 1800]); } +// Version 1.20.02 if ( $this->getData(['core', 'dataVersion']) < 12002 ) { @@ -56,9 +58,12 @@ if ( // Tableau à insérer $a = [ 'theme' => - ['menu' => [ - 'hidePages' => false - ]]]; + [ + 'menu' => [ + 'hidePages' => false + ] + ] + ]; // Parcourir la structure pour écrire dans les fichiers JSON foreach ($this->getData(['course']) as $courseId => $courseValues) { $d = json_decode(file_get_contents(self::DATA_DIR . $courseId . '/theme.json'), true); @@ -74,3 +79,57 @@ if ( } $this->setData(['core', 'dataVersion', 12002]); } + +// Version 1.21.00 + +if ( + $this->getData(['core', 'dataVersion']) < 12100 +) { + /** + * Renomme la clé dans la base des utilisateurs + */ + if ( + is_array($this->getData(['user'])) + && empty($this->getData(['user'])) === false + ) { + foreach ($this->getData(['user']) as $userId => $userValue) { + $d = $this->getData(['user', $userId]); + if (isset($d['group']) && $d['group'] !== '') { + $position = array_search('group', array_keys($d)) + 1; + $l = array_merge( + array_slice($d, 0, $position), + ['role' => $d['group']], + array_slice($d, $position) + ); + unset($l['group']); + $this->setData(['user', $userId, $l], false); + } + } + } + $this->saveDb('user'); + + + /** + * Convertit les pages et les modules + */ + $courses = array_merge($this->getData(['course']), ['home' => array()]); + + foreach ($courses as $courseId => $courseValue) { + // Les pages + $filePath = self::DATA_DIR . $courseId . '/page.json'; + $jsonContent = file_get_contents($filePath); + $updatedJsonContent = str_replace('"group":', '"role":', $jsonContent); + if ($updatedJsonContent !== $jsonContent) { + file_put_contents($filePath, $updatedJsonContent); + } + + // Les modules + $filePath = self::DATA_DIR . $courseId . '/module.json'; + $jsonContent = file_get_contents($filePath); + $updatedJsonContent = str_replace('"group":', '"role":', $jsonContent); + if ($updatedJsonContent !== $jsonContent) { + file_put_contents($filePath, $updatedJsonContent); + } + } + $this->setData(['core', 'dataVersion', 12100]); +} diff --git a/core/module/course/course.php b/core/module/course/course.php index 353df64..72a7667 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -652,7 +652,7 @@ class course extends common case "2": foreach ($groupValue as $profilId => $profilValue) { if ($profilId) { - self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); + self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Rôle %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); $profils[$groupId . $profilId] = 0; } } @@ -823,7 +823,7 @@ class course extends common case "2": foreach ($groupValue as $profilId => $profilValue) { if ($profilId) { - self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); + self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Rôle %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); $profils[$groupId . $profilId] = 0; } } @@ -991,7 +991,7 @@ class course extends common case "2": foreach ($groupValue as $profilId => $profilValue) { if ($profilId) { - self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); + self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Rôle %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); $profils[$groupId . $profilId] = 0; } } diff --git a/core/module/install/ressource/i18n/en_EN.json b/core/module/install/ressource/i18n/en_EN.json index 4abccc8..50bb93f 100644 --- a/core/module/install/ressource/i18n/en_EN.json +++ b/core/module/install/ressource/i18n/en_EN.json @@ -261,9 +261,9 @@ "Grande (220%)": "Grande (220%)", "Grande (300px)": "Grande (300px)", "Gras": "Bold", - "Groupe": "Group", - "Groupe associé": "Associated Group", - "Groupe requis pour accéder à la page :": "Group required to access the page:", + "Rôle": "role", + "Rôle associé": "Associated role", + "Rôle requis pour accéder à la page :": "role required to access the page:", "Groupes": "Groups", "Générer sitemap.xml et robots.txt": "Generate sitemap.xml and robots.txt", "Générer une capture Open Graph": "Generate an Open Graph capture", diff --git a/core/module/install/ressource/i18n/es.json b/core/module/install/ressource/i18n/es.json index 10d3bcb..df2a582 100644 --- a/core/module/install/ressource/i18n/es.json +++ b/core/module/install/ressource/i18n/es.json @@ -261,9 +261,9 @@ "Grande (220%)": "Grande (220%)", "Grande (300px)": "Grande (300px)", "Gras": "Negrita", - "Groupe": "Grupo", - "Groupe associé": "Grupo asociado", - "Groupe requis pour accéder à la page :": "Grupo necesario para acceder a la página:", + "Rôle": "Grupo", + "Rôle associé": "Grupo asociado", + "Rôle requis pour accéder à la page :": "Grupo necesario para acceder a la página:", "Groupes": "Grupos", "Générer sitemap.xml et robots.txt": "Generar sitemap.xml y robots.txt", "Générer une capture Open Graph": "Generar una captura de Open Graph", diff --git a/core/module/install/ressource/i18n/fr_FR.json b/core/module/install/ressource/i18n/fr_FR.json index cd66183..94617a9 100644 --- a/core/module/install/ressource/i18n/fr_FR.json +++ b/core/module/install/ressource/i18n/fr_FR.json @@ -261,9 +261,9 @@ "Grande (220%)": "", "Grande (300px)": "", "Gras": "", - "Groupe": "", - "Groupe associé": "", - "Groupe requis pour accéder à la page :": "", + "Rôle": "", + "Rôle associé": "", + "Rôle requis pour accéder à la page :": "", "Groupes": "", "Générer sitemap.xml et robots.txt": "", "Générer une capture Open Graph": "", diff --git a/core/module/page/view/edit/edit.php b/core/module/page/view/edit/edit.php index 28fcda7..088d077 100644 --- a/core/module/page/view/edit/edit.php +++ b/core/module/page/view/edit/edit.php @@ -359,8 +359,8 @@