From 3c76bcdf4cbe9b983303b6ec0b479798ed57b403 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Tue, 13 Feb 2024 14:55:57 +0100 Subject: [PATCH] 1.6.00 Espaces de l'auteur ou tous les espaces WIP --- core/module/course/course.php | 28 ++-- core/module/course/view/index/index.php | 43 +++---- core/module/user/user.php | 11 +- .../user/view/profilEdit/profilEdit.js.php | 4 +- .../user/view/profilEdit/profilEdit.php | 121 +++++++++--------- 5 files changed, 113 insertions(+), 94 deletions(-) diff --git a/core/module/course/course.php b/core/module/course/course.php index 527e15f..b2f9398 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -24,8 +24,8 @@ class course extends common 'edit' => self::GROUP_EDITOR, // Fait 'manage' => self::GROUP_EDITOR, // Fait 'users' => self::GROUP_EDITOR, // fait - 'usersAdd' => self::GROUP_EDITOR,//Fait - 'usersDelete' => self::GROUP_EDITOR,//Fait + 'usersAdd' => self::GROUP_EDITOR, //Fait + 'usersDelete' => self::GROUP_EDITOR, //Fait 'usersHistoryExport' => self::GROUP_EDITOR, //fait 'userDelete' => self::GROUP_EDITOR, //Fait 'userHistory' => self::GROUP_EDITOR, //Fait @@ -33,7 +33,7 @@ class course extends common 'backup' => self::GROUP_EDITOR, // Fait 'restore' => self::GROUP_EDITOR, //Fait 'clone' => self::GROUP_ADMIN, - 'add' => self::GROUP_ADMIN, + 'add' => self::GROUP_ADMIN, 'delete' => self::GROUP_ADMIN, 'category' => self::GROUP_ADMIN, 'categoryAdd' => self::GROUP_ADMIN, @@ -1212,7 +1212,7 @@ class course extends common self::$userGraph[] = [ helper::dateUTF8('%Y-%m-%d %H:%M:%S', $time), $diff, - html_entity_decode($pages[$pageId]['title']) . ' ('. helper::dateUTF8('%M\'%S"', $diff) . ')' + html_entity_decode($pages[$pageId]['title']) . ' (' . helper::dateUTF8('%M\'%S"', $diff) . ')' ]; } $lastView = $time; @@ -1769,19 +1769,27 @@ class course extends common * Admin : tous les droits * Editor : Inscrits dans le cours ou propriétaire */ - public function permissionControl($funtion, $courseId) + public function permissionControl($function, $courseId) { switch ($this->getUser('group')) { case self::GROUP_ADMIN: return true; case self::GROUP_EDITOR: return ( - $this->getUser('group') === self::$actions[$funtion] + $this->getUser('permission', __CLASS__, $function) && - ($this->getData(['enrolment', $courseId]) && ($this->getUser('id') === $this->getData(['course', $courseId, 'author'])) - || (// permission de gérer tous les espaces dans lesquels l'éditeur est inscrit. - $this->getUser('permission', __CLASS__, 'index') === true && - array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId]))) ) + $this->getUser('group') === self::$actions[$function] + && + // Permission d'accèder aux espaces dans lesquels le membre auteur + ( + $this->getData(['enrolment', $courseId]) && ($this->getUser('id') === $this->getData(['course', $courseId, 'author'])) + ) + || + ( // Permission d'accèder aux esapces dans lesquels le membre est inscrits avec les + $this->getData(['enrolment', $courseId]) + && $this->getUser('permission', __CLASS__, 'author') === true + && array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId])) + ) ); default: return false; diff --git a/core/module/course/view/index/index.php b/core/module/course/view/index/index.php index 85bc779..6310c29 100644 --- a/core/module/course/view/index/index.php +++ b/core/module/course/view/index/index.php @@ -6,41 +6,38 @@ 'value' => template::ico('home') ]); ?> - getUser('group') === self::GROUP_ADMIN): ?> -
- helper::baseUrl() . 'course/restore/', - 'value' => template::ico('upload-cloud'), - 'help' => 'Restaurer' - ]); ?> -
-
- helper::baseUrl() . 'course/category', - 'value' => template::ico('table'), - 'help' => 'Catégories' - ]); ?> -
-
+
+ getUser('permission', 'course', 'add') === true): ?> 'buttonGreen', 'href' => helper::baseUrl() . 'course/add', 'value' => template::ico('plus'), 'help' => 'Ajouter un espace' ]); ?> -
- -
+ +
+
+ getUser('permission', 'course', 'category') === true): ?> + helper::baseUrl() . 'course/category', + 'value' => template::ico('table'), + 'help' => 'Catégories des espaces' + ]); ?> + +
+
+ getUser('permission', 'course', 'restore') === true): ?> helper::baseUrl() . 'course/restore/', 'value' => template::ico('upload-cloud'), - 'help' => 'Restaurer depuis le dossier de l\'espace ' . self::$siteContent + 'help' => 'Restaurer un espace' ]); ?> -
- + + +
- 'dataTables']); ?> + 'dataTables']); ?> \ No newline at end of file diff --git a/core/module/user/user.php b/core/module/user/user.php index 8731801..f90038c 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -707,8 +707,15 @@ class user extends common 'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN), ], 'course' => [ - 'index' => $this->getInput('profilEditCourseIndex', helper::FILTER_BOOLEAN), - 'manage' => $this->getInput('profilEditCourseIndex', helper::FILTER_BOOLEAN), // Les deux fonctions sont groupées + /** + * author vaut false lorsque l'éditeur a les droits de modifier uniquement ses espaces. + * author vaut true lorsque l'éditeur a les droits de modifier uniquement TOUS les espaces. + */ + 'author' => $this->getInput('profilEditCourseAuthor', helper::FILTER_BOOLEAN), + // On autorise l'accès à ces deux pages + 'index' => $this->getInput('profilEditCourseIndex', helper::FILTER_BOOLEAN) && $this->getInput('profilEditCourseAuthor', helper::FILTER_BOOLEAN), + 'manage' => $this->getInput('profilEditCourseIndex', helper::FILTER_BOOLEAN) && $this->getInput('profilEditCourseAuthor', helper::FILTER_BOOLEAN), // Les deux fonctions sont groupées + // La suite 'users' => $this->getInput('profilEditCourseUsers', helper::FILTER_BOOLEAN), 'userHistory' => $this->getInput('profilEditCourseUserHistory', helper::FILTER_BOOLEAN), 'userHistoryExport' => $this->getInput('profilEditCourseUserExport', helper::FILTER_BOOLEAN), diff --git a/core/module/user/view/profilEdit/profilEdit.js.php b/core/module/user/view/profilEdit/profilEdit.js.php index 9147bf9..2f345db 100644 --- a/core/module/user/view/profilEdit/profilEdit.js.php +++ b/core/module/user/view/profilEdit/profilEdit.js.php @@ -19,7 +19,7 @@ $(document).ready(function () { } // Désactive les éléments liés aux espaces - if (!$("#profilEditCourseIndex").prop("checked")) { + if (!$("#profilEditCourseIndex, #profilEditCourseAuthor").prop("checked")) { $("#courseContainer").slideUp(); } else { $("#courseContainer").slideDown(); @@ -71,7 +71,7 @@ $(document).ready(function () { }); // Gérer l'évènement sur les options des espaces - $("#profilEditCourseIndex").change(function () { + $("#profilEditCourseIndex, #profilEditCourseAuthor").change(function () { if (!$(this).is(':checked')) { $('.courseOptions input[type="checkbox"]').prop('checked', false); $("#courseContainer").slideUp(); diff --git a/core/module/user/view/profilEdit/profilEdit.php b/core/module/user/view/profilEdit/profilEdit.php index 03c8431..d6580a8 100644 --- a/core/module/user/view/profilEdit/profilEdit.php +++ b/core/module/user/view/profilEdit/profilEdit.php @@ -79,76 +79,83 @@ -
-
-
-

- -

-
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'index']) - ]); ?> -
-
-
+getUrl(2) >= self::GROUP_EDITOR): ?> +
+
+
+

+ +

-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'edit']), +
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'author']) ]); ?>
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'backup']), - ]); ?> -
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'restore']), +
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'index']) ]); ?>
-
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'users']), - ]); ?> +
+
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'edit']), + ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'backup']), + ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'restore']), + ]); ?> +
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistory']), - ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'users']), + ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistory']), + ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistoryExport']), + ]); ?> +
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistoryExport']), - ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userDelete']), + ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersAdd']), + ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']), + ]); ?> +
-
-
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userDelete']), - ]); ?> -
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersAdd']), - ]); ?> -
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']), - ]); ?> -
-
+
-
+