From 831d01987dc6ec65d9c0b069cc3ac6ddf066bc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Fri, 7 Feb 2025 12:28:20 +0100 Subject: [PATCH] "role" pour "group" --- core/class/layout.class.php | 30 ++++---- core/class/router.class.php | 16 ++--- core/core.php | 36 +++++----- core/layout/main.php | 4 +- core/module/course/course.php | 44 ++++++------ .../course/view/userReport/userReport.php | 4 +- core/module/install/install.php | 2 +- core/module/install/ressource/defaultdata.php | 24 +++---- core/module/page/page.php | 4 +- core/module/sitemap/sitemap.php | 4 +- core/module/user/user.php | 72 +++++++++---------- core/module/user/view/edit/edit.php | 18 ++--- core/vendor/filemanager/config/config.php | 2 +- module/blog/blog.php | 20 +++--- module/blog/view/add/add.php | 2 +- module/blog/view/article/article.php | 6 +- module/blog/view/edit/edit.php | 2 +- module/blog/view/index/index.php | 6 +- module/form/form.php | 6 +- module/form/ressource/defaultdata.php | 2 +- module/form/view/option/option.php | 4 +- 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 | 10 +-- module/suscribe/view/edit/edit.php | 6 +- 27 files changed, 167 insertions(+), 167 deletions(-) diff --git a/core/class/layout.class.php b/core/class/layout.class.php index 47b93d5..5cd3dc3 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('group') >= self::GROUP_MEMBER && $this->getUser('group') < self::GROUP_ADMIN + $this->getUser('role') >= self::GROUP_MEMBER && $this->getUser('role') < self::GROUP_ADMIN && $this->getData(['theme', 'footer', 'memberBar']) === true ) { $items .= 'getUser('group') === self::GROUP_MEMBER + $this->getUser('role') === 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('group')) { + switch ($this->getUser('role')) { 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('group') === self::GROUP_MEMBER + $this->getUser('role') === 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('group') < self::GROUP_EDITOR + and $this->getUser('role') < 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('group') < self::GROUP_EDITOR + and $this->getUser('role') < 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('group') >= self::GROUP_EDITOR) { + if ($this->getUser('role') >= self::GROUP_EDITOR) { if (is_array($this->getCoursesByProfil())) { $leftItems .= '
  • '; $leftItems .= ''; @@ -1122,11 +1122,11 @@ class layout extends common $rightItems = ''; if ( ( - $this->getUser('group') === self::GROUP_EDITOR + $this->getUser('role') === self::GROUP_EDITOR && $this->getUser('permission', 'filemanager') === true && $this->getUser('permission', 'folder', (self::$siteContent === 'home' ? 'homePath' : 'coursePath')) !== 'none' ) - || $this->getUser('group') === self::GROUP_ADMIN + || $this->getUser('role') === 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('group') >= self::GROUP_ADMIN + && $this->getUser('role') >= self::GROUP_ADMIN ) { $rightItems .= '
  • ' . template::ico('flag', [ 'help' => 'Langues', @@ -1211,7 +1211,7 @@ class layout extends common } // Boutons depuis le groupe éditeur if ( - $this->getUser('group') >= self::GROUP_EDITOR + $this->getUser('role') >= 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('group') >= self::GROUP_EDITOR + and $this->getUser('role') >= 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 793fee4..694f1bf 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('group') < common::GROUP_ADMIN + $this->getUser('role') < 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('group') === common::GROUP_BANNED + and ($this->getUser('role') === 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('group') < common::GROUP_ADMIN + and $this->getUser('role') < 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), 'group']) === common::GROUP_VISITOR + $this->getData(['page', $this->getUrl(0), 'role']) === common::GROUP_VISITOR or ($this->isConnected() === true - // and $this->getUser('group') >= $this->getData(['page', $this->getUrl(0), 'group']) + // and $this->getUser('role') >= $this->getData(['page', $this->getUrl(0), 'role']) // Modification qui tient compte du profil de la page - and ($this->getUser('group') * 10 + $this->getUser('profil')) >= ($this->getData(['page', $this->getUrl(0), 'group']) * 10 + $this->getData(['page', $this->getUrl(0), 'profil'])) + and ($this->getUser('role') * 10 + $this->getUser('profil')) >= ($this->getData(['page', $this->getUrl(0), 'role']) * 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('group') < common::GROUP_EDITOR + and $this->getUser('role') < common::GROUP_EDITOR ) ) { $access = false; @@ -709,7 +709,7 @@ class core extends common if ( ($module::$actions[$action] === common::GROUP_VISITOR or ($this->isConnected() === true - and $this->getUser('group') >= $module::$actions[$action] + and $this->getUser('role') >= $module::$actions[$action] and $this->getUser('permission', $moduleId, $action) ) ) diff --git a/core/core.php b/core/core.php index aa21758..101b65d 100644 --- a/core/core.php +++ b/core/core.php @@ -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, 'group']) === self::GROUP_VISITOR + and ($this->getData(['page', $pageId, 'role']) === self::GROUP_VISITOR or ($this->getUser('authKey') === $this->getInput('ZWII_AUTH_KEY') - //and $this->getUser('group') >= $this->getData(['page', $pageId, 'group']) + //and $this->getUser('role') >= $this->getData(['page', $pageId, 'role']) // Modification qui tient compte du profil de la page - and ($this->getUser('group') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'group']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil'])) + and ($this->getUser('role') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'role']) * 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, 'group']) === self::GROUP_VISITOR + $this->getData(['page', $pageId, 'role']) === self::GROUP_VISITOR and - $this->getData(['page', $parentId, 'group']) === self::GROUP_VISITOR + $this->getData(['page', $parentId, 'role']) === self::GROUP_VISITOR ) or ( $this->getUser('authKey') === $this->getInput('ZWII_AUTH_KEY') and - $this->getUser('group') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'group']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil']) + $this->getUser('role') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'role']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil']) ) ) @@ -1048,33 +1048,33 @@ class common public function getPermission($key1, $key2 = null) { // Administrateur, toutes les permissions - if ($this->getUser('group') === self::GROUP_ADMIN) { + if ($this->getUser('role') === self::GROUP_ADMIN) { return true; - } elseif ($this->getUser('group') <= self::GROUP_VISITOR) { // Groupe sans autorisation + } elseif ($this->getUser('role') <= self::GROUP_VISITOR) { // Groupe sans autorisation return false; } elseif ( // Groupe avec profil, consultation des autorisations sur deux clés $key1 && $key2 && $this->user - && $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1]) - && array_key_exists($key2, $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1])) + && $this->getData(['profil', $this->user['role'], $this->user['profil'], $key1]) + && array_key_exists($key2, $this->getData(['profil', $this->user['role'], $this->user['profil'], $key1])) ) { - return $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1, $key2]); + return $this->getData(['profil', $this->user['role'], $this->user['profil'], $key1, $key2]); // Groupe avec profil, consultation des autorisations sur une seule clé } elseif ( $key1 && $this->user - && $this->getData(['profil', $this->user['group'], $this->user['profil']]) - && array_key_exists($key1, $this->getData(['profil', $this->user['group'], $this->user['profil']])) + && $this->getData(['profil', $this->user['role'], $this->user['profil']]) + && array_key_exists($key1, $this->getData(['profil', $this->user['role'], $this->user['profil']])) ) { - return $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1]); + return $this->getData(['profil', $this->user['role'], $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('group') >= $module::$actions[$key2]; + return $this->getUser('role') >= $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, 'group']) !== 0 || + $this->getData(['page', $parentPageId, 'role']) !== 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, 'group']) !== 0 || $this->getData(['page', $childKey, 'disable']) === true) { + if ($this->getData(['page', $childKey, 'role']) !== 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('group')) { + switch ($this->getUser('role')) { case self::GROUP_ADMIN: // Affiche tout return $courses; diff --git a/core/layout/main.php b/core/layout/main.php index 749f6e8..c1f23c6 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -35,7 +35,7 @@ - getUser('group') > self::GROUP_MEMBER) : ?> + getUser('role') > 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('group') > self::GROUP_MEMBER + and $this->getUser('role') > self::GROUP_MEMBER ) { echo '