1.6 Autorisation d'éditer les espaces

This commit is contained in:
Fred Tempez 2024-02-13 10:28:30 +01:00
parent c43ce394e4
commit 13227a5cd4
5 changed files with 38 additions and 14 deletions

View File

@ -929,11 +929,13 @@ class layout extends common
} }
$leftItems .= '</select></li>'; $leftItems .= '</select></li>';
} }
if ($this->getUser('permission', 'course', 'index') === true) {
$leftItems .= '<li>' . template::ico('cubes', [ $leftItems .= '<li>' . template::ico('cubes', [
'href' => helper::baseUrl() . 'course', 'href' => helper::baseUrl() . 'course',
'help' => 'Espaces' 'help' => 'Gérer les espaces'
]) . '</li>'; ]) . '</li>';
} }
}
if ($this->getUser('group') >= self::GROUP_ADMIN) { if ($this->getUser('group') >= self::GROUP_ADMIN) {
$leftItems .= '<li>' . template::ico('brush', [ $leftItems .= '<li>' . template::ico('brush', [
'help' => 'Thème', 'help' => 'Thème',
@ -941,7 +943,8 @@ class layout extends common
]) . '</li>'; ]) . '</li>';
} }
// Liste des pages et bouton de gestion interdit pour l'accueil sauf admin // Liste des pages et bouton de gestion interdit pour l'accueil sauf admin
if (($this->getUser('group') === self::GROUP_EDITOR && self::$siteContent != 'home') if (
($this->getUser('group') === self::GROUP_EDITOR && self::$siteContent != 'home')
|| $this->getUser('group') === self::GROUP_ADMIN || $this->getUser('group') === self::GROUP_ADMIN
) { ) {
$leftItems .= '<li><select id="barSelectPage">'; $leftItems .= '<li><select id="barSelectPage">';

View File

@ -1419,7 +1419,7 @@ class common
* @param string $userId identifiant * @param string $userId identifiant
* @param string $serStatus teacher ou student ou admin * @param string $serStatus teacher ou student ou admin
* *
* CETTE FONCTION N'EST PAS UTILISEE * CETTE FONCTION EST UTILISEE PAR LAYOUT
* *
*/ */
public function getCoursesByProfil() public function getCoursesByProfil()

View File

@ -82,14 +82,14 @@ class course extends common
public function index() public function index()
{ {
// Tableau à transmettre à la fvue
self::$courses = array(); self::$courses = array();
if ( if (
$this->getUser('id') $this->getUser('id')
&& $this->getUser('group') && $this->getUser('group')
&& $this->getCoursesByProfil()
) { ) {
foreach ($this->getCoursesByProfil() as $courseId => $courseValue) { foreach ($this->getData(['course']) as $courseId => $courseValue) {
/** /**
* Filtres : * Filtres :
* Groupes acceptés : * Groupes acceptés :
@ -126,7 +126,7 @@ class course extends common
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => helper::translate('Espaces disponibles'), 'title' => helper::translate('Gestionnaire d\'espaces'),
'view' => 'index', 'view' => 'index',
'vendor' => [ 'vendor' => [
'datatables' 'datatables'
@ -1779,7 +1779,9 @@ class course extends common
$this->getUser('group') === self::$actions[$funtion] $this->getUser('group') === self::$actions[$funtion]
&& &&
($this->getData(['enrolment', $courseId]) && ($this->getUser('id') === $this->getData(['course', $courseId, 'author'])) ($this->getData(['enrolment', $courseId]) && ($this->getUser('id') === $this->getData(['course', $courseId, 'author']))
|| array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId]))) || (// 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]))) )
); );
default: default:
return false; return false;

View File

@ -705,6 +705,9 @@ class user extends common
], ],
'user' => [ 'user' => [
'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN), 'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN),
],
'course' => [
'index' => $this->getInput('profilEditCourseIndex', helper::FILTER_BOOLEAN),
] ]
]; ];

View File

@ -79,6 +79,22 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Gestion des espaces'); ?>
</h4>
<div class="row">
<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>
</div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">