Droit aux éditeurs sur les cours

This commit is contained in:
Fred Tempez 2023-11-19 21:07:22 +01:00
parent 42a228a689
commit d23148bd6c
3 changed files with 45 additions and 47 deletions

View File

@ -896,8 +896,7 @@ class layout extends common
// Sélecteur de contenu
/**
* Les admins voient tousles contenus
* Les enseignantsles contenus dont ils sont auteurs
* Les étudiantsles contenus dans lesquels ils sont inscrits
* Les enseignants les contenus dont ils sont auteurs
*/
if ($this->getUser('group') >= self::GROUP_EDITOR) {
if ($this->getCoursesByUser($this->getUser('id'), $this->getUser('group'))) {
@ -908,9 +907,6 @@ class layout extends common
}
$leftItems .= '</select></li>';
}
}
// Bouton Gérerles contenus
if ($this->getUser('group') >= self::GROUP_ADMIN) {
$leftItems .= '<li>' . template::ico('cubes', [
'href' => helper::baseUrl() . 'course',
'help' => 'Contenu'

View File

@ -1416,7 +1416,7 @@ class common
// Fonctions pour la gestion des contenus
/**
* Retourneles contenus d'un utilisateur
* Retourne les contenus d'un utilisateur
* @param string $userId identifiant
* @param string $serStatus teacher ou student ou admin
*/
@ -1428,7 +1428,7 @@ class common
return $c;
case self::GROUP_EDITOR:
foreach ($c as $courseId => $value) {
if ($this->getData(['enrolment', $courseId]) !== $userId) {
if ($this->getData(['course', $courseId, 'author']) !== $userId) {
unset($c[$courseId]);
}
}

View File

@ -20,21 +20,21 @@ class course extends common
'swap' => self::GROUP_VISITOR,
'suscribe' => self::GROUP_VISITOR,
'unsuscribe' => self::GROUP_MEMBER,
'index' => self::GROUP_ADMIN,
'edit' => self::GROUP_ADMIN,
'index' => self::GROUP_EDITOR,
'edit' => self::GROUP_EDITOR,
'add' => self::GROUP_ADMIN,
'delete' => self::GROUP_ADMIN,
'category' => self::GROUP_ADMIN,
'categoryAdd' => self::GROUP_ADMIN,
'categoryEdit' => self::GROUP_ADMIN,
'categoryDelete' => self::GROUP_ADMIN,
'user' => self::GROUP_ADMIN,
'userAdd' => self::GROUP_ADMIN,
'userDelete' => self::GROUP_ADMIN,
'userDeleteAll' => self::GROUP_ADMIN,
'userHistory' => self::GROUP_ADMIN,
'usersHistoryExport' => self::GROUP_ADMIN,
'userHistoryExport' => self::GROUP_ADMIN,
'user' => self::GROUP_EDITOR,
'userAdd' => self::GROUP_EDITOR,
'userDelete' => self::GROUP_EDITOR,
'userDeleteAll' => self::GROUP_EDITOR,
'userHistory' => self::GROUP_EDITOR,
'usersHistoryExport' => self::GROUP_EDITOR,
'userHistoryExport' => self::GROUP_EDITOR,
];
public static $courseAccess = [
@ -74,17 +74,18 @@ class course extends common
public function index()
{
$courseIdShortTitle = helper::arrayColumn($this->getData(['course']), 'title');
ksort($courseIdShortTitle);
foreach ($courseIdShortTitle as $courseId => $courseTitle) {
if ($this->getCoursesByUser($this->getUser('id'), $this->getUser('group'))) {
foreach ($this->getCoursesByUser($this->getUser('id'), $this->getUser('group')) as $courseId => $courseValue) {
$categorieUrl = helper::baseUrl() . 'course/suscribe/' . $courseId;
$authorId = $this->getData(['course', $courseId, 'author']);
$author = sprintf('%s %s', $this->getData(['user', $authorId, 'firstname']), $this->getData(['user', $authorId, 'lastname']));
$access = self::$courseAccess[$this->getData(['course', $courseId, 'access'])];
$enrolment = self::$courseEnrolment[$this->getData(['course', $courseId, 'enrolment'])];
$description = sprintf('%s<br />%s<br />%s<br />', $this->getData(['course', $courseId, 'description']), $access, $enrolment);
$author = isset($authorId)
? sprintf('%s %s', $this->getData(['user', $authorId, 'firstname']), $this->getData(['user', $authorId, 'lastname']))
: '';
$access = self::$courseAccess[$courseValue ['access']];
$enrolment = self::$courseEnrolment[$courseValue ['enrolment']];
$description = sprintf('%s<br />%s<br />%s<br />', $courseValue ['description'], $access, $enrolment);
self::$courses[] = [
$courseTitle,
$courseValue['title'],
$author,
$description,
'<a href="' . $categorieUrl . '" target="_blank">' . $categorieUrl . '</a>',
@ -107,6 +108,7 @@ class course extends common
];
}
}
// Valeurs en sortie
$this->addOutput([