From 52fb225650801a036963844e41fcf6462073085c Mon Sep 17 00:00:00 2001 From: fredtempez Date: Fri, 16 Feb 2024 11:06:54 +0100 Subject: [PATCH] 1.6 Fix last setup editor course permissions --- core/class/layout.class.php | 2 - core/module/course/course.php | 9 +- core/module/user/user.php | 27 +--- core/module/user/view/profilAdd/profilAdd.php | 103 +++++++------ .../user/view/profilEdit/profilEdit.php | 144 +++++++++--------- 5 files changed, 132 insertions(+), 153 deletions(-) diff --git a/core/class/layout.class.php b/core/class/layout.class.php index 0129a62..1464e75 100644 --- a/core/class/layout.class.php +++ b/core/class/layout.class.php @@ -928,8 +928,6 @@ class layout extends common $leftItems .= ''; } $leftItems .= ''; - } - if ($this->getUser('permission', 'course', 'index') === true) { $leftItems .= '
  • ' . template::ico('cubes', [ 'href' => helper::baseUrl() . 'course', 'help' => 'Gérer les espaces' diff --git a/core/module/course/course.php b/core/module/course/course.php index 965408a..1c4c564 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -1651,7 +1651,7 @@ class course extends common // Accès limité aux admins, à l'auteur ou éditeurs inscrits if ( - $this->permissionControl(__FUNCTION__, $courseId) === false + $this->getUser('permission', __CLASS__, __FUNCTION__) === false ) { // Valeurs en sortie $this->addOutput([ @@ -1785,15 +1785,14 @@ class course extends common case self::GROUP_EDITOR: return ( $this->getUser('permission', __CLASS__, $function) + && $this->getUser('group') === self::$actions[$function] && - $this->getUser('group') === self::$actions[$function] - && - // Permission d'accèder aux espaces dans lesquels le membre auteur + // 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 + ( // Permission d'accéder aux espaces dans lesquels le membre est inscrits $this->getData(['enrolment', $courseId]) && $this->getUser('permission', __CLASS__, 'tutor') === true && array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId])) diff --git a/core/module/user/user.php b/core/module/user/user.php index 0f85a52..893b7b6 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -707,29 +707,12 @@ class user extends common 'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN), ], 'course' => [ + // Droit d'intervenir sur tous les espaces 'tutor' => $this->getInput('profilEditCourseTutor', helper::FILTER_BOOLEAN), - 'index' => $this->getInput('profilEditCourseUsers', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUserHistory', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUserExport', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUserAdd', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUsersAdd', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUserDelete', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUsersDelete', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseEdit', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseBackup', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseRestore', helper::FILTER_BOOLEAN), - - 'manage' => $this->getInput('profilEditCourseUsers', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUserHistory', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUserExport', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUserAdd', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUsersAdd', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUserDelete', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseUsersDelete', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseEdit', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseBackup', helper::FILTER_BOOLEAN) - || $this->getInput('profilEditCourseRestore', helper::FILTER_BOOLEAN), - // La suite + // Droit d'accéder à la fenêtre de gestion pour tous les éditeurs et plus + 'index' => $this->getUser('group') >= self::GROUP_EDITOR, + 'manage' => $this->getUser('group') >= self::GROUP_EDITOR, + // Droits spécifiques 'users' => $this->getInput('profilEditCourseUsers', helper::FILTER_BOOLEAN), 'userHistory' => $this->getInput('profilEditCourseUserHistory', helper::FILTER_BOOLEAN), 'userHistoryExport' => $this->getInput('profilEditCourseUserHistoryExport', helper::FILTER_BOOLEAN), diff --git a/core/module/user/view/profilAdd/profilAdd.php b/core/module/user/view/profilAdd/profilAdd.php index 4bfc647..813cd6e 100644 --- a/core/module/user/view/profilAdd/profilAdd.php +++ b/core/module/user/view/profilAdd/profilAdd.php @@ -58,58 +58,6 @@ -getUrl(2) >= self::GROUP_EDITOR): ?> -
    -
    -
    -

    - -

    -
    -
    - -
    -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    @@ -207,6 +155,57 @@
    +
    +
    +
    +

    + +

    +
    +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +

    diff --git a/core/module/user/view/profilEdit/profilEdit.php b/core/module/user/view/profilEdit/profilEdit.php index 522d694..d2a308a 100644 --- a/core/module/user/view/profilEdit/profilEdit.php +++ b/core/module/user/view/profilEdit/profilEdit.php @@ -79,78 +79,6 @@

    -getUrl(2) >= self::GROUP_EDITOR): ?> -
    -
    -
    -

    - -

    -
    -
    - $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'tutor']) - ]); ?> -
    -
    -
    -
    -
    - $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', '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', 'userDelete']), - ]); ?> -
    -
    -
    -
    - $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersAdd']), - ]); ?> -
    -
    - $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']), - ]); ?> -
    -
    - -
    -
    -
    -
    -
    @@ -300,6 +228,78 @@
    getUrl(2) >= self::GROUP_EDITOR): ?> +
    +
    +
    +

    + +

    +
    +
    + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'tutor']) + ]); ?> +
    +
    + +
    +
    + $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', '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', 'userDelete']), + ]); ?> +
    +
    +
    +
    + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersAdd']), + ]); ?> +
    +
    + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']), + ]); ?> +
    +
    +
    +
    +
    +