1.6.00 Gestion des droits de l'esapce par un éditeur limité ou étendu

This commit is contained in:
Fred Tempez 2024-02-13 17:56:41 +01:00
parent 3c76bcdf4c
commit ee4fc93afe
4 changed files with 49 additions and 55 deletions

View File

@ -1787,7 +1787,7 @@ class course extends common
|| ||
( // Permission d'accèder aux esapces dans lesquels le membre est inscrits avec les ( // Permission d'accèder aux esapces dans lesquels le membre est inscrits avec les
$this->getData(['enrolment', $courseId]) $this->getData(['enrolment', $courseId])
&& $this->getUser('permission', __CLASS__, 'author') === true && $this->getUser('permission', __CLASS__, 'author') === false
&& array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId])) && array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId]))
) )
); );

View File

@ -525,7 +525,7 @@ class user extends common
? helper::translate(self::$groups[(int) $this->getData(['user', $userId, 'group'])]) ? helper::translate(self::$groups[(int) $this->getData(['user', $userId, 'group'])])
: $this->getData(['profil', $this->getData(['user', $userId, 'group']), $this->getData(['user', $userId, 'profil']), 'name']), : $this->getData(['profil', $this->getData(['user', $userId, 'group']), $this->getData(['user', $userId, 'profil']), 'name']),
$this->getData(['user', $userId, 'tags']), $this->getData(['user', $userId, 'tags']),
helper::dateUTF8('%d/%m/%Y', $this->getData(['user', $userId, 'accessTimer']), self::$i18nUI), helper::dateUTF8('%d/%m/%Y', $this->getData(['user', $userId, 'accessTimer']), self::$i18nUI),
//helper::dateUTF8('%H:%M', $this->getData(['user', $userId, 'accessTimer']), self::$i18nUI), //helper::dateUTF8('%H:%M', $this->getData(['user', $userId, 'accessTimer']), self::$i18nUI),
template::button('userEdit' . $userId, [ template::button('userEdit' . $userId, [
'href' => helper::baseUrl() . 'user/edit/' . $userId, 'href' => helper::baseUrl() . 'user/edit/' . $userId,
@ -556,9 +556,9 @@ class user extends common
$this->addOutput([ $this->addOutput([
'title' => helper::translate('Utilisateurs'), 'title' => helper::translate('Utilisateurs'),
'view' => 'index', 'view' => 'index',
'vendor' => [ 'vendor' => [
'datatables' 'datatables'
] ]
]); ]);
} }
@ -576,7 +576,7 @@ class user extends common
// Stoppe si le profil est affecté // Stoppe si le profil est affecté
foreach ($groups as $userId) { foreach ($groups as $userId) {
if ((string) $this->getData(['user', $userId, 'profil']) === $this->getUrl(3)) { if ((string) $this->getData(['user', $userId, 'profil']) === $this->getUrl(3)) {
$profilUsed= false; $profilUsed = false;
} }
} }
foreach ($this->getData(['profil']) as $groupId => $groupData) { foreach ($this->getData(['profil']) as $groupId => $groupData) {
@ -707,19 +707,34 @@ class user extends common
'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN), 'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN),
], ],
'course' => [ 'course' => [
/**
* 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), 'author' => $this->getInput('profilEditCourseAuthor', helper::FILTER_BOOLEAN),
// On autorise l'accès à ces deux pages 'index' => $this->getInput('profilEditCourseUsers', helper::FILTER_BOOLEAN)
'index' => $this->getInput('profilEditCourseIndex', helper::FILTER_BOOLEAN) && $this->getInput('profilEditCourseAuthor', helper::FILTER_BOOLEAN), || $this->getInput('profilEditCourseUserHistory', helper::FILTER_BOOLEAN)
'manage' => $this->getInput('profilEditCourseIndex', helper::FILTER_BOOLEAN) && $this->getInput('profilEditCourseAuthor', helper::FILTER_BOOLEAN), // Les deux fonctions sont groupées || $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 // La suite
'users' => $this->getInput('profilEditCourseUsers', helper::FILTER_BOOLEAN), 'users' => $this->getInput('profilEditCourseUsers', helper::FILTER_BOOLEAN),
'userHistory' => $this->getInput('profilEditCourseUserHistory', helper::FILTER_BOOLEAN), 'userHistory' => $this->getInput('profilEditCourseUserHistory', helper::FILTER_BOOLEAN),
'userHistoryExport' => $this->getInput('profilEditCourseUserExport', helper::FILTER_BOOLEAN), 'userHistoryExport' => $this->getInput('profilEditCourseUserHistoryExport', helper::FILTER_BOOLEAN),
'userAdd' => $this->getInput('profilEditCourseUserAdd', helper::FILTER_BOOLEAN), 'userAdd' => $this->getInput('profilEditCourseUserAdd', helper::FILTER_BOOLEAN),
'usersAdd' => $this->getInput('profilEditCourseUsersAdd', helper::FILTER_BOOLEAN),
'userDelete' => $this->getInput('profilEditCourseUserDelete', helper::FILTER_BOOLEAN), 'userDelete' => $this->getInput('profilEditCourseUserDelete', helper::FILTER_BOOLEAN),
'usersDelete' => $this->getInput('profilEditCourseUsersDelete', helper::FILTER_BOOLEAN), 'usersDelete' => $this->getInput('profilEditCourseUsersDelete', helper::FILTER_BOOLEAN),
'edit' => $this->getInput('profilEditCourseEdit', helper::FILTER_BOOLEAN), 'edit' => $this->getInput('profilEditCourseEdit', helper::FILTER_BOOLEAN),
@ -954,11 +969,11 @@ class user extends common
// recherche les membres du groupe // recherche les membres du groupe
$groups = helper::arrayColumn($this->getData(['user']), 'group'); $groups = helper::arrayColumn($this->getData(['user']), 'group');
$groups = array_keys($groups, $this->getUrl(2)); $groups = array_keys($groups, $this->getUrl(2));
$flag= true; $flag = true;
// Stoppe si le profil est affecté // Stoppe si le profil est affecté
foreach ($groups as $userId) { foreach ($groups as $userId) {
if ((string) $this->getData(['user', $userId, 'profil']) === $this->getUrl(3)) { if ((string) $this->getData(['user', $userId, 'profil']) === $this->getUrl(3)) {
$flag= false; $flag = false;
} }
} }
if ( if (
@ -1083,8 +1098,9 @@ class user extends common
} else { } else {
$logStatus = 'Connexion réussie'; $logStatus = 'Connexion réussie';
$pageId = $this->getUrl(2); $pageId = $this->getUrl(2);
if ($this->getData(['config', 'page404']) === $pageId if (
|| $this->getData(['config', 'page403']) === $pageId $this->getData(['config', 'page404']) === $pageId
|| $this->getData(['config', 'page403']) === $pageId
) { ) {
$pageId = ''; $pageId = '';
} }

View File

@ -18,13 +18,6 @@ $(document).ready(function () {
$(".filemanager").prop("disabled", true); $(".filemanager").prop("disabled", true);
} }
// Désactive les éléments liés aux espaces
if (!$("#profilEditCourseIndex, #profilEditCourseAuthor").prop("checked")) {
$("#courseContainer").slideUp();
} else {
$("#courseContainer").slideDown();
}
// Désactive les éléments liés au blog // Désactive les éléments liés au blog
if (!$("#profilEditBlogComment").prop("checked")) { if (!$("#profilEditBlogComment").prop("checked")) {
$(".blogEditCommentOptions").prop("disabled", true); $(".blogEditCommentOptions").prop("disabled", true);
@ -70,16 +63,6 @@ $(document).ready(function () {
} }
}); });
// Gérer l'évènement sur les options des espaces
$("#profilEditCourseIndex, #profilEditCourseAuthor").change(function () {
if (!$(this).is(':checked')) {
$('.courseOptions input[type="checkbox"]').prop('checked', false);
$("#courseContainer").slideUp();
} else {
$("#courseContainer").slideDown();
}
});
// Gérer l'évènement sur les commentaires du blog // Gérer l'évènement sur les commentaires du blog
$("#profilEditBlogComment").change(function () { $("#profilEditBlogComment").change(function () {
if (!$(this).is(':checked')) { if (!$(this).is(':checked')) {

View File

@ -87,64 +87,59 @@
<?php echo helper::translate('Gestion des espaces'); ?> <?php echo helper::translate('Gestion des espaces'); ?>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col3"> <div class="col6">
<?php echo template::checkbox('profilEditCourseAuthor', true, 'Gérer ses espaces', [ <?php echo template::checkbox('profilEditCourseAuthor', true, 'Gestion limitée aux espaces du propriétaire', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'author']) 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'author'])
]); ?> ]); ?>
</div> </div>
<div class="col3">
<?php echo template::checkbox('profilEditCourseIndex', true, 'Gérer tous les espaces', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'index'])
]); ?>
</div>
</div> </div>
<div id="courseContainer"> <div id="courseContainer">
<div class="row"> <div class="row">
<div class="col3 courseOptions"> <div class="col3">
<?php echo template::checkbox('profilEditCourseEdit', true, 'Éditer un espace', [ <?php echo template::checkbox('profilEditCourseEdit', true, 'Éditer un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'edit']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'edit']),
]); ?> ]); ?>
</div> </div>
<div class="col3 courseOptions"> <div class="col3">
<?php echo template::checkbox('profilEditCourseBackup', true, 'Sauvegarder un espace', [ <?php echo template::checkbox('profilEditCourseBackup', true, 'Sauvegarder un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'backup']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'backup']),
]); ?> ]); ?>
</div> </div>
<div class="col3 courseOptions"> <div class="col3">
<?php echo template::checkbox('profilEditCourseRestore', true, 'Restaurer un espace', [ <?php echo template::checkbox('profilEditCourseRestore', true, 'Restaurer un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'restore']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'restore']),
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col3 courseOptions"> <div class="col3">
<?php echo template::checkbox('profilEditCourseUsers', true, 'Lister participants', [ <?php echo template::checkbox('profilEditCourseUsers', true, 'Voir les participants', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'users']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'users']),
]); ?> ]); ?>
</div> </div>
<div class="col3 courseOptions"> <div class="col3">
<?php echo template::checkbox('profilEditCourseUserHistory', true, 'Voir historique d\'un participant', [ <?php echo template::checkbox('profilEditCourseUserHistory', true, 'Voir historique d\'un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistory']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistory']),
]); ?> ]); ?>
</div> </div>
<div class="col3 courseOptions"> <div class="col3">
<?php echo template::checkbox('profilEditCourseUserHistoryExport', true, 'Exporter historique d\'un participant', [ <?php echo template::checkbox('profilEditCourseUserHistoryExport', true, 'Exporter historique d\'un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistoryExport']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistoryExport']),
]); ?> ]); ?>
</div> </div>
</div> <div class="col3">
<div class="row">
<div class="col3 courseOptions">
<?php echo template::checkbox('profilEditCourseUserDelete', true, 'Désinscrire un participant', [ <?php echo template::checkbox('profilEditCourseUserDelete', true, 'Désinscrire un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userDelete']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userDelete']),
]); ?> ]); ?>
</div> </div>
<div class="col3 courseOptions"> </div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('profilEditCourseUsersAdd', true, 'Inscrire en masse', [ <?php echo template::checkbox('profilEditCourseUsersAdd', true, 'Inscrire en masse', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersAdd']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersAdd']),
]); ?> ]); ?>
</div> </div>
<div class="col3 courseOptions"> <div class="col3">
<?php echo template::checkbox('profilEditCourseUsersDelete', true, 'Désinscrire en masse', [ <?php echo template::checkbox('profilEditCourseUsersDelete', true, 'Désinscrire en masse', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'usersDelete']),
]); ?> ]); ?>