From eceed6b233f2b229fb039cd273d0ba2138bb944a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Wed, 5 Feb 2025 07:36:13 +0100 Subject: [PATCH 1/9] 1.21 branche beta --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc76b84..ab4bba7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ZwiiCampus 1.21.00 +# ZwiiCampus 1.21.00 beta ZwiiCampus (Learning Management System) est logiciel auteur destiné à mettre en ligne des tutoriels. Il dispose de plusieurs modalités d'ouverture et d'accès des contenus. Basé sur la version 13 du CMS Zwii, la structure logicielle est solide, le framework de Zwii est éprouvé. From 90fee8136519265823630a43c3652611aa07919b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Wed, 5 Feb 2025 07:36:37 +0100 Subject: [PATCH 2/9] Revert "1.21 renomme group en role" This reverts commit 07e390d818e63f873af1d5b154dd316609c8a269. --- core/class/layout.class.php | 32 ++-- core/class/router.class.php | 23 ++- core/core.php | 44 +++--- core/include/update.inc.php | 48 ++---- core/layout/main.php | 4 +- core/module/config/view/connect/connect.php | 2 +- core/module/course/course.php | 70 ++++----- .../course/view/userReport/userReport.php | 4 +- core/module/install/install.php | 2 +- core/module/install/ressource/defaultdata.php | 24 +-- core/module/install/ressource/i18n/en_EN.json | 12 +- core/module/install/ressource/i18n/es.json | 10 +- core/module/install/ressource/i18n/fr_FR.json | 10 +- core/module/page/page.php | 16 +- core/module/page/view/edit/edit.php | 4 +- core/module/sitemap/sitemap.php | 4 +- core/module/user/ressource/template.csv | 2 +- core/module/user/user.php | 144 +++++++++--------- core/module/user/view/add/add.php | 2 +- core/module/user/view/edit/edit.php | 24 +-- core/module/user/view/import/import.php | 2 +- core/module/user/view/index/index.php | 2 +- core/module/user/view/profilAdd/profilAdd.php | 2 +- .../user/view/profilEdit/profilEdit.php | 2 +- core/vendor/filemanager/config/config.php | 14 +- module/blog/blog.php | 24 +-- module/blog/i18n/de.json | 2 +- module/blog/i18n/en_EN.json | 2 +- module/blog/i18n/es.json | 2 +- module/blog/i18n/fr_FR.json | 2 +- module/blog/i18n/gr_GR.json | 2 +- module/blog/i18n/it.json | 2 +- module/blog/i18n/pt_PT.json | 2 +- module/blog/i18n/tr_TR.json | 2 +- module/blog/view/add/add.php | 2 +- module/blog/view/article/article.php | 8 +- module/blog/view/edit/edit.php | 2 +- module/blog/view/index/index.php | 8 +- module/form/form.php | 12 +- module/form/i18n/de.json | 2 +- module/form/i18n/en_EN.json | 2 +- module/form/i18n/es.json | 2 +- module/form/i18n/fr_FR.json | 2 +- module/form/i18n/gr_GR.json | 2 +- module/form/i18n/it.json | 2 +- module/form/i18n/pt_PT.json | 2 +- module/form/i18n/tr_TR.json | 2 +- module/form/ressource/defaultdata.php | 2 +- module/form/view/option/option.php | 6 +- module/news/view/article/article.php | 2 +- module/news/view/index/index.php | 2 +- module/redirection/redirection.php | 2 +- module/search/search.php | 4 +- module/suscribe/suscribe.php | 18 +-- module/suscribe/view/edit/edit.php | 10 +- 55 files changed, 303 insertions(+), 334 deletions(-) diff --git a/core/class/layout.class.php b/core/class/layout.class.php index af49430..47b93d5 100644 --- a/core/class/layout.class.php +++ b/core/class/layout.class.php @@ -353,7 +353,7 @@ class layout extends common } // Affichage de la barre de membre simple if ( - $this->getUser('role') >= self::GROUP_MEMBER && $this->getUser('role') < self::GROUP_ADMIN + $this->getUser('group') >= self::GROUP_MEMBER && $this->getUser('group') < self::GROUP_ADMIN && $this->getData(['theme', 'footer', 'memberBar']) === true ) { $items .= 'getUser('role') === self::GROUP_MEMBER + $this->getUser('group') === self::GROUP_MEMBER && $this->getData(['theme', 'menu', 'selectSpace']) === true ) { if ($this->getCoursesByProfil()) { @@ -532,7 +532,7 @@ class layout extends common && $this->getData(['course', self::$siteContent, 'enrolment']) >= 1 ) { $href = ''; - switch ($this->getUser('role')) { + switch ($this->getUser('group')) { case self::GROUP_MEMBER: $href = helper::baseUrl() . 'course/userReport/' . self::$siteContent . '/' . $this->getUser('id'); break; @@ -565,7 +565,7 @@ class layout extends common * Affichage des boutons gestionnaire de fichiers et mon compte */ if ( - $this->getUser('role') === self::GROUP_MEMBER + $this->getUser('group') === self::GROUP_MEMBER && $this->getData(['theme', 'menu', 'memberBar']) === true ) { @@ -648,7 +648,7 @@ class layout extends common and $this->isConnected() === false ) or ($this->getData(['page', $parentPageId, 'disable']) === true and $this->isConnected() === true - and $this->getUser('role') < self::GROUP_EDITOR + and $this->getUser('group') < self::GROUP_EDITOR ) ) { $pageUrl = ($this->getData(['config', 'homePageId']) === $this->getUrl(0)) ? helper::baseUrl(false) : helper::baseUrl() . $this->getUrl(0); @@ -714,7 +714,7 @@ class layout extends common and $this->isConnected() === false ) or ($this->getData(['page', $childKey, 'disable']) === true and $this->isConnected() === true - and $this->getUser('role') < self::GROUP_EDITOR + and $this->getUser('group') < self::GROUP_EDITOR ) ) { $pageUrl = ($this->getData(['config', 'homePageId']) === $this->getUrl(0)) ? helper::baseUrl(false) : helper::baseUrl() . $this->getUrl(0); @@ -975,7 +975,7 @@ class layout extends common * Les admins voient tous les contenus * Les enseignants les contenus dont ils sont auteurs */ - if ($this->getUser('role') >= self::GROUP_EDITOR) { + if ($this->getUser('group') >= self::GROUP_EDITOR) { if (is_array($this->getCoursesByProfil())) { $leftItems .= '
  • '; $leftItems .= ''; @@ -1122,11 +1122,11 @@ class layout extends common $rightItems = ''; if ( ( - $this->getUser('role') === self::GROUP_EDITOR + $this->getUser('group') === self::GROUP_EDITOR && $this->getUser('permission', 'filemanager') === true && $this->getUser('permission', 'folder', (self::$siteContent === 'home' ? 'homePath' : 'coursePath')) !== 'none' ) - || $this->getUser('role') === self::GROUP_ADMIN + || $this->getUser('group') === self::GROUP_ADMIN ) { $folder = '&fldr=/' . (self::$siteContent === 'home' ? '' : self::$siteContent); $rightItems .= '
  • ' . template::ico('folder', [ @@ -1137,7 +1137,7 @@ class layout extends common } if ( self::$siteContent === 'home' - && $this->getUser('role') >= self::GROUP_ADMIN + && $this->getUser('group') >= self::GROUP_ADMIN ) { $rightItems .= '
  • ' . template::ico('flag', [ 'help' => 'Langues', @@ -1209,9 +1209,9 @@ class layout extends common 'href' => helper::baseUrl() . 'plugin' ]) . '
  • '; } - // Boutons depuis le role éditeur + // Boutons depuis le groupe éditeur if ( - $this->getUser('role') >= self::GROUP_EDITOR + $this->getUser('group') >= self::GROUP_EDITOR && $this->getUser('permission', 'user', 'edit') ) { @@ -1297,7 +1297,7 @@ class layout extends common $vars .= 'var baseUrlQs = ' . json_encode(helper::baseUrl()) . ';'; if ( $this->isConnected() === true - and $this->getUser('role') >= self::GROUP_EDITOR + and $this->getUser('group') >= self::GROUP_EDITOR ) { $vars .= 'var privateKey = ' . json_encode(md5_file(self::DATA_DIR . 'core.json')) . ';'; } diff --git a/core/class/router.class.php b/core/class/router.class.php index 0a1f01b..793fee4 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -446,7 +446,7 @@ class core extends common && $this->getData(['course', self::$siteContent, 'enrolment']) > 0 // Le userId n'est pas celui d'un admis ni le compte d'un gestionnaire de cet espace && ( - $this->getUser('role') < common::GROUP_ADMIN + $this->getUser('group') < common::GROUP_ADMIN || $this->getUser('id') !== $this->getData(['course', common::$siteContent, 'author']) ) ) { @@ -473,7 +473,7 @@ class core extends common // Force la déconnexion des membres bannis ou d'une seconde session if ( $this->isConnected() === true - and ($this->getUser('role') === common::GROUP_BANNED + and ($this->getUser('group') === common::GROUP_BANNED or ($_SESSION['csrf'] !== $this->getData(['user', $this->getUser('id'), 'accessCsrf']) and $this->getData(['config', 'connect', 'autoDisconnect']) === true) ) @@ -488,7 +488,7 @@ class core extends common and $this->getUrl(1) !== 'login' and ($this->isConnected() === false or ($this->isConnected() === true - and $this->getUser('role') < common::GROUP_ADMIN + and $this->getUser('group') < common::GROUP_ADMIN ) ) ) { @@ -505,11 +505,11 @@ class core extends common $access = null; if ($this->getData(['page', $this->getUrl(0)]) !== null) { if ( - $this->getData(['page', $this->getUrl(0), 'role']) === common::GROUP_VISITOR + $this->getData(['page', $this->getUrl(0), 'group']) === common::GROUP_VISITOR or ($this->isConnected() === true - // and $this->getUser('role') >= $this->getData(['page', $this->getUrl(0), 'role']) + // and $this->getUser('group') >= $this->getData(['page', $this->getUrl(0), 'group']) // Modification qui tient compte du profil de la page - and ($this->getUser('role') * 10 + $this->getUser('profil')) >= ($this->getData(['page', $this->getUrl(0), 'role']) * 10 + $this->getData(['page', $this->getUrl(0), 'profil'])) + and ($this->getUser('group') * 10 + $this->getUser('profil')) >= ($this->getData(['page', $this->getUrl(0), 'group']) * 10 + $this->getData(['page', $this->getUrl(0), 'profil'])) ) ) { $access = true; @@ -526,7 +526,7 @@ class core extends common and $this->isConnected() === false ) or ($this->getData(['page', $this->getUrl(0), 'disable']) === true and $this->isConnected() === true - and $this->getUser('role') < common::GROUP_EDITOR + and $this->getUser('group') < common::GROUP_EDITOR ) ) { $access = false; @@ -567,10 +567,7 @@ class core extends common */ $accessInfo['userName'] = ''; $accessInfo['pageId'] = ''; - if ( - is_array($this->getData(['user'])) - && empty($this->getData(['user'])) === false - ) { + if ($this->getData(['user'])) { foreach ($this->getData(['user']) as $userId => $userIds) { if (!is_null($this->getData(['user', $userId, 'accessUrl']))) { $t = explode('/', $this->getData(['user', $userId, 'accessUrl'])); @@ -708,11 +705,11 @@ class core extends common if (array_key_exists($action, $module::$actions)) { $module->$action(); $output = $module->output; - // Check le role de l'utilisateur + // Check le groupe de l'utilisateur if ( ($module::$actions[$action] === common::GROUP_VISITOR or ($this->isConnected() === true - and $this->getUser('role') >= $module::$actions[$action] + and $this->getUser('group') >= $module::$actions[$action] and $this->getUser('permission', $moduleId, $action) ) ) diff --git a/core/core.php b/core/core.php index bca7180..029b918 100644 --- a/core/core.php +++ b/core/core.php @@ -28,7 +28,7 @@ class common const GROUP_VISITOR = 0; const GROUP_MEMBER = 1; const GROUP_EDITOR = 2; - // Role MODERATOR, compatibilité avec les anciens modules : + // Groupe MODERATOR, compatibilité avec les anciens modules : const GROUP_MODERATOR = 2; const GROUP_ADMIN = 3; const SIGNATURE_ID = 1; @@ -821,11 +821,11 @@ class common // Page parent $this->getData(['page', $pageId, 'parentPageId']) === "" // Ignore les pages dont l'utilisateur n'a pas accès - and ($this->getData(['page', $pageId, 'role']) === self::GROUP_VISITOR + and ($this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR or ($this->getUser('authKey') === $this->getInput('ZWII_AUTH_KEY') - //and $this->getUser('role') >= $this->getData(['page', $pageId, 'role']) + //and $this->getUser('group') >= $this->getData(['page', $pageId, 'group']) // Modification qui tient compte du profil de la page - and ($this->getUser('role') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'role']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil'])) + and ($this->getUser('group') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'group']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil'])) ) ) @@ -848,14 +848,14 @@ class common // Ignore les pages dont l'utilisateur n'a pas accès and ( ( - $this->getData(['page', $pageId, 'role']) === self::GROUP_VISITOR + $this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR and - $this->getData(['page', $parentId, 'role']) === self::GROUP_VISITOR + $this->getData(['page', $parentId, 'group']) === self::GROUP_VISITOR ) or ( $this->getUser('authKey') === $this->getInput('ZWII_AUTH_KEY') and - $this->getUser('role') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'role']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil']) + $this->getUser('group') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'group']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil']) ) ) @@ -1042,39 +1042,39 @@ class common /** * Retourne les permissions de l'utilisateur connecté - * @param int $key Clé de la valeur du role + * @param int $key Clé de la valeur du groupe * @return string|null */ public function getPermission($key1, $key2 = null) { // Administrateur, toutes les permissions - if ($this->getUser('role') === self::GROUP_ADMIN) { + if ($this->getUser('group') === self::GROUP_ADMIN) { return true; - } elseif ($this->getUser('role') <= self::GROUP_VISITOR) { // Role sans autorisation + } elseif ($this->getUser('group') <= self::GROUP_VISITOR) { // Groupe sans autorisation return false; } elseif ( - // Role avec profil, consultation des autorisations sur deux clés + // Groupe avec profil, consultation des autorisations sur deux clés $key1 && $key2 && $this->user - && $this->getData(['profil', $this->user['role'], $this->user['profil'], $key1]) - && array_key_exists($key2, $this->getData(['profil', $this->user['role'], $this->user['profil'], $key1])) + && $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1]) + && array_key_exists($key2, $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1])) ) { - return $this->getData(['profil', $this->user['role'], $this->user['profil'], $key1, $key2]); - // Role avec profil, consultation des autorisations sur une seule clé + return $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1, $key2]); + // Groupe avec profil, consultation des autorisations sur une seule clé } elseif ( $key1 && $this->user - && $this->getData(['profil', $this->user['role'], $this->user['profil']]) - && array_key_exists($key1, $this->getData(['profil', $this->user['role'], $this->user['profil']])) + && $this->getData(['profil', $this->user['group'], $this->user['profil']]) + && array_key_exists($key1, $this->getData(['profil', $this->user['group'], $this->user['profil']])) ) { - return $this->getData(['profil', $this->user['role'], $this->user['profil'], $key1]); + return $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1]); } else { // Une permission non spécifiée dans le profil est autorisée selon la valeur de $actions if (class_exists($key1)) { $module = new $key1; if (array_key_exists($key2, $module::$actions)) { - return $this->getUser('role') >= $module::$actions[$key2]; + return $this->getUser('group') >= $module::$actions[$key2]; } } return false; @@ -1169,7 +1169,7 @@ class common foreach ($this->getHierarchy() as $parentPageId => $childrenPageIds) { // Exclure les barres et les pages non publiques et les pages masquées if ( - $this->getData(['page', $parentPageId, 'role']) !== 0 || + $this->getData(['page', $parentPageId, 'group']) !== 0 || $this->getData(['page', $parentPageId, 'block']) === 'bar' ) { continue; @@ -1197,7 +1197,7 @@ class common } // Sous-pages foreach ($childrenPageIds as $childKey) { - if ($this->getData(['page', $childKey, 'role']) !== 0 || $this->getData(['page', $childKey, 'disable']) === true) { + if ($this->getData(['page', $childKey, 'group']) !== 0 || $this->getData(['page', $childKey, 'disable']) === true) { continue; } // Cas de la page d'accueil ne pas dupliquer l'URL @@ -1624,7 +1624,7 @@ function makeThumb($src, $dest, $desired_width) $courses = $this->getData([('course')]); $courses = helper::arraycolumn($courses, 'title', 'SORT_ASC'); $filter = array(); - switch ($this->getUser('role')) { + switch ($this->getUser('group')) { case self::GROUP_ADMIN: // Affiche tout return $courses; diff --git a/core/include/update.inc.php b/core/include/update.inc.php index ba4d7f6..9af1375 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -9,13 +9,13 @@ if ( $this->getData(['core', 'dataVersion']) < 1700 ) { // Supprime la variable path des profils, seul l'accès à l'espace et autorisé. - foreach (['1', '2'] as $role) { - foreach (array_keys($this->getData(['profil', $role])) as $profil) { - if (is_null($this->getData(['profil', $role, $profil, 'folder', 'path'])) === false) { - $path = $this->getData(['profil', $role, $profil, 'folder', 'path']); - $this->setData(['profil', $role, $profil, 'folder', 'homePath', $path]); - $this->setData(['profil', $role, $profil, 'folder', 'coursePath', $path]); - $this->deleteData(['profil', $role, $profil, 'folder', 'path']); + 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']); } } } @@ -58,15 +58,14 @@ if ( 'theme' => ['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); // Insérer la variable hidePages si elle n'existe pas if (isset($d['theme']['menu']['hidePages']) === false) { - $result = array_replace_recursive($d, $a); - file_put_contents(self::DATA_DIR . $courseId . '/theme.json', json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); + $result = array_replace_recursive($d, $a); + file_put_contents(self::DATA_DIR . $courseId . '/theme.json', json_encode($result,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); } // Forcer la régénération du fichier theme.css if (file_exists(self::DATA_DIR . $courseId . '/theme.css')) { @@ -75,30 +74,3 @@ if ( } $this->setData(['core', 'dataVersion', 12002]); } - -if ( - $this->getData(['core', 'dataVersion']) < 12100 -) { - // Renommer Group en Role - if ( - is_array($this->getData(['user'])) - && empty($this->getData(['user'])) === false - ) { - $t = $this->getData(['user']); - foreach ($t 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'); - //$this->setData(['core', 'dataVersion', 12100]); -} diff --git a/core/layout/main.php b/core/layout/main.php index c1f23c6..749f6e8 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -35,7 +35,7 @@ - getUser('role') > self::GROUP_MEMBER) : ?> + getUser('group') > self::GROUP_MEMBER) : ?> showBar(); ?> @@ -48,7 +48,7 @@ $this->getData(['theme', 'menu', 'position']) === 'top' and $this->getData(['theme', 'menu', 'fixed']) === true and $this->isConnected() === true - and $this->getUser('role') > self::GROUP_MEMBER + and $this->getUser('group') > self::GROUP_MEMBER ) { echo '