1.6 Fix last setup editor course permissions

This commit is contained in:
Fred Tempez 2024-02-16 11:06:54 +01:00
parent b5693abbf5
commit 52fb225650
5 changed files with 132 additions and 153 deletions

View File

@ -928,8 +928,6 @@ class layout extends common
$leftItems .= '<option name="' . $this->getData(['course', $courseId, 'title']) . '" value="' . helper::baseUrl(true) . 'course/swap/' . $courseId . '" ' . ($courseId === self::$siteContent ? 'selected' : '') . '>' . $this->getData(['course', $courseId, 'title']) . '</option>';
}
$leftItems .= '</select></li>';
}
if ($this->getUser('permission', 'course', 'index') === true) {
$leftItems .= '<li>' . template::ico('cubes', [
'href' => helper::baseUrl() . 'course',
'help' => 'Gérer les espaces'

View File

@ -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]))

View File

@ -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),

View File

@ -58,58 +58,6 @@
</div>
</div>
</div>
<?php if ($this->getUrl(2) >= self::GROUP_EDITOR): ?>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Gestion des espaces'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::checkbox('profilAddCourseTutor', true, 'Gestion étendue aux espaces du participant'); ?>
</div>
</div>
<div id="courseContainer">
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilAddCourseEdit', true, 'Éditer un espace'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseBackup', true, 'Sauvegarder un espace'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseRestore', true, 'Restaurer un espace'); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilAddCourseUsers', true, 'Voir les participants'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseUserHistory', true, 'Voir historique d\'un participant'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseUserHistoryExport', true, 'Exporter historique d\'un participant'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseUserDelete', true, 'Désinscrire un participant'); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilAddCourseUsersAdd', true, 'Inscrire en masse'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseUsersDelete', true, 'Désinscrire en masse'); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col12">
<div class="block">
@ -207,6 +155,57 @@
</div>
</div>
<div class="row containerPage">
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Gestion des espaces'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::checkbox('profilAddCourseTutor', true, 'Gère les espaces comme auteur et participant'); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilAddCourseEdit', true, 'Éditer un espace'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseBackup', true, 'Sauvegarder un espace'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseRestore', true, 'Restaurer un espace'); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::checkbox('profilAddCourseUsers', true, 'Gérer les participants'); ?>
</div>
</div>
<div id="courseContainer">
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilAddCourseUserHistory', true, 'Voir historique d\'un participant'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseUserHistoryExport', true, 'Exporter historique d\'un participant'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseUserDelete', true, 'Désinscrire un participant'); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilAddCourseUsersAdd', true, 'Inscrire en masse'); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilAddCourseUsersDelete', true, 'Désinscrire en masse'); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col12">
<div class="block">
<h4>

View File

@ -79,78 +79,6 @@
</div>
</div>
</div>
<?php if ($this->getUrl(2) >= self::GROUP_EDITOR): ?>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Gestion des espaces'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::checkbox('profilEditCourseTutor', true, 'Gestion étendue aux espaces du participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'tutor'])
]); ?>
</div>
</div>
<div id="courseContainer">
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilEditCourseEdit', true, 'Éditer un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'edit']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseBackup', true, 'Sauvegarder un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'backup']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseRestore', true, 'Restaurer un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'restore']),
]); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilEditCourseUsers', true, 'Voir les participants', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'users']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseUserHistory', true, 'Voir historique d\'un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistory']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseUserHistoryExport', true, 'Exporter historique d\'un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistoryExport']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseUserDelete', true, 'Désinscrire un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userDelete']),
]); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilEditCourseUsersAdd', true, 'Inscrire en masse', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersAdd']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseUsersDelete', true, 'Désinscrire en masse', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']),
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col12">
<div class="block">
@ -300,6 +228,78 @@
</div>
</div>
<?php if ($this->getUrl(2) >= self::GROUP_EDITOR): ?>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Gestion des espaces'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::checkbox('profilEditCourseTutor', true, 'Gère les espaces comme auteur et participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'tutor'])
]); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilEditCourseEdit', true, 'Éditer un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'edit']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseBackup', true, 'Sauvegarder un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'backup']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseRestore', true, 'Restaurer un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'restore']),
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::checkbox('profilEditCourseUsers', true, 'Gérer les participants', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'users']),
]); ?>
</div>
</div>
<div id="courseContainer">
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilEditCourseUserHistory', true, 'Voir historique d\'un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistory']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseUserHistoryExport', true, 'Exporter historique d\'un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistoryExport']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseUserDelete', true, 'Désinscrire un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userDelete']),
]); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilEditCourseUsersAdd', true, 'Inscrire en masse', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersAdd']),
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseUsersDelete', true, 'Désinscrire en masse', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']),
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">