1.6.00 Espaces de l'auteur ou tous les espaces WIP

This commit is contained in:
Fred Tempez 2024-02-13 14:55:57 +01:00
parent e9e39f5a03
commit 3c76bcdf4c
5 changed files with 113 additions and 94 deletions

View File

@ -24,8 +24,8 @@ class course extends common
'edit' => self::GROUP_EDITOR, // Fait 'edit' => self::GROUP_EDITOR, // Fait
'manage' => self::GROUP_EDITOR, // Fait 'manage' => self::GROUP_EDITOR, // Fait
'users' => self::GROUP_EDITOR, // fait 'users' => self::GROUP_EDITOR, // fait
'usersAdd' => self::GROUP_EDITOR,//Fait 'usersAdd' => self::GROUP_EDITOR, //Fait
'usersDelete' => self::GROUP_EDITOR,//Fait 'usersDelete' => self::GROUP_EDITOR, //Fait
'usersHistoryExport' => self::GROUP_EDITOR, //fait 'usersHistoryExport' => self::GROUP_EDITOR, //fait
'userDelete' => self::GROUP_EDITOR, //Fait 'userDelete' => self::GROUP_EDITOR, //Fait
'userHistory' => self::GROUP_EDITOR, //Fait 'userHistory' => self::GROUP_EDITOR, //Fait
@ -33,7 +33,7 @@ class course extends common
'backup' => self::GROUP_EDITOR, // Fait 'backup' => self::GROUP_EDITOR, // Fait
'restore' => self::GROUP_EDITOR, //Fait 'restore' => self::GROUP_EDITOR, //Fait
'clone' => self::GROUP_ADMIN, 'clone' => self::GROUP_ADMIN,
'add' => self::GROUP_ADMIN, 'add' => self::GROUP_ADMIN,
'delete' => self::GROUP_ADMIN, 'delete' => self::GROUP_ADMIN,
'category' => self::GROUP_ADMIN, 'category' => self::GROUP_ADMIN,
'categoryAdd' => self::GROUP_ADMIN, 'categoryAdd' => self::GROUP_ADMIN,
@ -1212,7 +1212,7 @@ class course extends common
self::$userGraph[] = [ self::$userGraph[] = [
helper::dateUTF8('%Y-%m-%d %H:%M:%S', $time), helper::dateUTF8('%Y-%m-%d %H:%M:%S', $time),
$diff, $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; $lastView = $time;
@ -1769,19 +1769,27 @@ class course extends common
* Admin : tous les droits * Admin : tous les droits
* Editor : Inscrits dans le cours ou propriétaire * Editor : Inscrits dans le cours ou propriétaire
*/ */
public function permissionControl($funtion, $courseId) public function permissionControl($function, $courseId)
{ {
switch ($this->getUser('group')) { switch ($this->getUser('group')) {
case self::GROUP_ADMIN: case self::GROUP_ADMIN:
return true; return true;
case self::GROUP_EDITOR: case self::GROUP_EDITOR:
return ( return (
$this->getUser('group') === self::$actions[$funtion] $this->getUser('permission', __CLASS__, $function)
&& &&
($this->getData(['enrolment', $courseId]) && ($this->getUser('id') === $this->getData(['course', $courseId, 'author'])) $this->getUser('group') === self::$actions[$function]
|| (// permission de gérer tous les espaces dans lesquels l'éditeur est inscrit. &&
$this->getUser('permission', __CLASS__, 'index') === true && // Permission d'accèder aux espaces dans lesquels le membre auteur
array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId]))) ) (
$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: default:
return false; return false;

View File

@ -6,41 +6,38 @@
'value' => template::ico('home') 'value' => template::ico('home')
]); ?> ]); ?>
</div> </div>
<?php if ($this->getUser('group') === self::GROUP_ADMIN): ?> <div class="col1 offset8">
<div class="col1 offset8"> <?php if ($this->getUser('permission', 'course', 'add') === true): ?>
<?php echo template::button('courseUpload', [
'href' => helper::baseUrl() . 'course/restore/',
'value' => template::ico('upload-cloud'),
'help' => 'Restaurer'
]); ?>
</div>
<div class="col1">
<?php echo template::button('courseCategory', [
'href' => helper::baseUrl() . 'course/category',
'value' => template::ico('table'),
'help' => 'Catégories'
]); ?>
</div>
<div class="col1">
<?php echo template::button('courseAdd', [ <?php echo template::button('courseAdd', [
'class' => 'buttonGreen', 'class' => 'buttonGreen',
'href' => helper::baseUrl() . 'course/add', 'href' => helper::baseUrl() . 'course/add',
'value' => template::ico('plus'), 'value' => template::ico('plus'),
'help' => 'Ajouter un espace' 'help' => 'Ajouter un espace'
]); ?> ]); ?>
</div> <?php endif; ?>
<?php else: ?> </div>
<div class="col1 offset10"> <div class="col1">
<?php if ($this->getUser('permission', 'course', 'category') === true): ?>
<?php echo template::button('courseCategory', [
'href' => helper::baseUrl() . 'course/category',
'value' => template::ico('table'),
'help' => 'Catégories des espaces'
]); ?>
<?php endif; ?>
</div>
<div class="col1">
<?php if ($this->getUser('permission', 'course', 'restore') === true): ?>
<?php echo template::button('courseUpload', [ <?php echo template::button('courseUpload', [
'href' => helper::baseUrl() . 'course/restore/', 'href' => helper::baseUrl() . 'course/restore/',
'value' => template::ico('upload-cloud'), 'value' => template::ico('upload-cloud'),
'help' => 'Restaurer depuis le dossier de l\'espace ' . self::$siteContent 'help' => 'Restaurer un espace'
]); ?> ]); ?>
</div> <?php endif; ?>
<?php endif; ?>
</div>
</div> </div>
<?php if ($module::$courses): ?> <?php if ($module::$courses): ?>
<?php echo template::table([4, 4, 3, 1 ], $module::$courses, ['Titre court', 'Description', 'Inscription', '',], ['id' => 'dataTables']); ?> <?php echo template::table([4, 4, 3, 1], $module::$courses, ['Titre court', 'Description', 'Inscription', '',], ['id' => 'dataTables']); ?>
<?php else: ?> <?php else: ?>
<?php echo template::speech('Aucun espace'); ?> <?php echo template::speech('Aucun espace'); ?>
<?php endif; ?> <?php endif; ?>

View File

@ -707,8 +707,15 @@ class user extends common
'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN), 'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN),
], ],
'course' => [ '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), '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('profilEditCourseUserExport', helper::FILTER_BOOLEAN),

View File

@ -19,7 +19,7 @@ $(document).ready(function () {
} }
// Désactive les éléments liés aux espaces // Désactive les éléments liés aux espaces
if (!$("#profilEditCourseIndex").prop("checked")) { if (!$("#profilEditCourseIndex, #profilEditCourseAuthor").prop("checked")) {
$("#courseContainer").slideUp(); $("#courseContainer").slideUp();
} else { } else {
$("#courseContainer").slideDown(); $("#courseContainer").slideDown();
@ -71,7 +71,7 @@ $(document).ready(function () {
}); });
// Gérer l'évènement sur les options des espaces // Gérer l'évènement sur les options des espaces
$("#profilEditCourseIndex").change(function () { $("#profilEditCourseIndex, #profilEditCourseAuthor").change(function () {
if (!$(this).is(':checked')) { if (!$(this).is(':checked')) {
$('.courseOptions input[type="checkbox"]').prop('checked', false); $('.courseOptions input[type="checkbox"]').prop('checked', false);
$("#courseContainer").slideUp(); $("#courseContainer").slideUp();

View File

@ -79,76 +79,83 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <?php if ($this->getUrl(2) >= self::GROUP_EDITOR): ?>
<div class="col12"> <div class="row">
<div class="block"> <div class="col12">
<h4> <div class="block">
<?php echo helper::translate('Gestion des espaces'); ?> <h4>
</h4> <?php echo helper::translate('Gestion des espaces'); ?>
<div class="row"> </h4>
<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 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('profilEditCourseAuthor', true, 'Gérer ses espaces', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'edit']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'author'])
]); ?> ]); ?>
</div> </div>
<div class="col3 courseOptions"> <div class="col3">
<?php echo template::checkbox('profilEditCourseBackup', true, 'Sauvegarder un espace', [ <?php echo template::checkbox('profilEditCourseIndex', true, 'Gérer tous les espaces', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'backup']), 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'index'])
]); ?>
</div>
<div class="col3 courseOptions">
<?php echo template::checkbox('profilEditCourseRestore', true, 'Restaurer un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'restore']),
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div id="courseContainer">
<div class="col3 courseOptions"> <div class="row">
<?php echo template::checkbox('profilEditCourseUsers', true, 'Lister participants', [ <div class="col3 courseOptions">
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'users']), <?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 courseOptions">
<?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 courseOptions">
<?php echo template::checkbox('profilEditCourseRestore', true, 'Restaurer un espace', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'restore']),
]); ?>
</div>
</div> </div>
<div class="col3 courseOptions"> <div class="row">
<?php echo template::checkbox('profilEditCourseUserHistory', true, 'Voir historique d\'un participant', [ <div class="col3 courseOptions">
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistory']), <?php echo template::checkbox('profilEditCourseUsers', true, 'Lister participants', [
]); ?> 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'users']),
]); ?>
</div>
<div class="col3 courseOptions">
<?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 courseOptions">
<?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> </div>
<div class="col3 courseOptions"> <div class="row">
<?php echo template::checkbox('profilEditCourseUserHistoryExport', true, 'Exporter historique d\'un participant', [ <div class="col3 courseOptions">
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userHistoryExport']), <?php echo template::checkbox('profilEditCourseUserDelete', true, 'Désinscrire un participant', [
]); ?> 'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userDelete']),
]); ?>
</div>
<div class="col3 courseOptions">
<?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 courseOptions">
<?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 class="row">
<div class="col3 courseOptions">
<?php echo template::checkbox('profilEditCourseUserDelete', true, 'Désinscrire un participant', [
'checked' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'course', 'userDelete']),
]); ?>
</div>
<div class="col3 courseOptions">
<?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 courseOptions">
<?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>
</div> </div>
</div> <?php endif; ?>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">