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

View File

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

View File

@ -20,21 +20,21 @@ class course extends common
'swap' => self::GROUP_VISITOR, 'swap' => self::GROUP_VISITOR,
'suscribe' => self::GROUP_VISITOR, 'suscribe' => self::GROUP_VISITOR,
'unsuscribe' => self::GROUP_MEMBER, 'unsuscribe' => self::GROUP_MEMBER,
'index' => self::GROUP_ADMIN, 'index' => self::GROUP_EDITOR,
'edit' => self::GROUP_ADMIN, 'edit' => self::GROUP_EDITOR,
'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,
'categoryEdit' => self::GROUP_ADMIN, 'categoryEdit' => self::GROUP_ADMIN,
'categoryDelete' => self::GROUP_ADMIN, 'categoryDelete' => self::GROUP_ADMIN,
'user' => self::GROUP_ADMIN, 'user' => self::GROUP_EDITOR,
'userAdd' => self::GROUP_ADMIN, 'userAdd' => self::GROUP_EDITOR,
'userDelete' => self::GROUP_ADMIN, 'userDelete' => self::GROUP_EDITOR,
'userDeleteAll' => self::GROUP_ADMIN, 'userDeleteAll' => self::GROUP_EDITOR,
'userHistory' => self::GROUP_ADMIN, 'userHistory' => self::GROUP_EDITOR,
'usersHistoryExport' => self::GROUP_ADMIN, 'usersHistoryExport' => self::GROUP_EDITOR,
'userHistoryExport' => self::GROUP_ADMIN, 'userHistoryExport' => self::GROUP_EDITOR,
]; ];
public static $courseAccess = [ public static $courseAccess = [
@ -74,38 +74,40 @@ class course extends common
public function index() public function index()
{ {
$courseIdShortTitle = helper::arrayColumn($this->getData(['course']), 'title'); if ($this->getCoursesByUser($this->getUser('id'), $this->getUser('group'))) {
ksort($courseIdShortTitle); foreach ($this->getCoursesByUser($this->getUser('id'), $this->getUser('group')) as $courseId => $courseValue) {
foreach ($courseIdShortTitle as $courseId => $courseTitle) { $categorieUrl = helper::baseUrl() . 'course/suscribe/' . $courseId;
$categorieUrl = helper::baseUrl() . 'course/suscribe/' . $courseId; $authorId = $this->getData(['course', $courseId, 'author']);
$authorId = $this->getData(['course', $courseId, 'author']); $author = isset($authorId)
$author = sprintf('%s %s', $this->getData(['user', $authorId, 'firstname']), $this->getData(['user', $authorId, 'lastname'])); ? 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'])]; $access = self::$courseAccess[$courseValue ['access']];
$description = sprintf('%s<br />%s<br />%s<br />', $this->getData(['course', $courseId, 'description']), $access, $enrolment); $enrolment = self::$courseEnrolment[$courseValue ['enrolment']];
self::$courses[] = [ $description = sprintf('%s<br />%s<br />%s<br />', $courseValue ['description'], $access, $enrolment);
$courseTitle, self::$courses[] = [
$author, $courseValue['title'],
$description, $author,
'<a href="' . $categorieUrl . '" target="_blank">' . $categorieUrl . '</a>', $description,
template::button('categoryUser' . $courseId, [ '<a href="' . $categorieUrl . '" target="_blank">' . $categorieUrl . '</a>',
'href' => helper::baseUrl() . 'course/user/' . $courseId, template::button('categoryUser' . $courseId, [
'value' => template::ico('users'), 'href' => helper::baseUrl() . 'course/user/' . $courseId,
'help' => 'Inscrits' 'value' => template::ico('users'),
]), 'help' => 'Inscrits'
template::button('courseEdit' . $courseId, [ ]),
'href' => helper::baseUrl() . 'course/edit/' . $courseId, template::button('courseEdit' . $courseId, [
'value' => template::ico('pencil'), 'href' => helper::baseUrl() . 'course/edit/' . $courseId,
'help' => 'Éditer' 'value' => template::ico('pencil'),
]), 'help' => 'Éditer'
template::button('courseDelete' . $courseId, [ ]),
'class' => 'courseDelete buttonRed', template::button('courseDelete' . $courseId, [
'href' => helper::baseUrl() . 'course/delete/' . $courseId, 'class' => 'courseDelete buttonRed',
'value' => template::ico('trash'), 'href' => helper::baseUrl() . 'course/delete/' . $courseId,
'help' => 'Supprimer' 'value' => template::ico('trash'),
]) 'help' => 'Supprimer'
])
]; ];
}
} }
// Valeurs en sortie // Valeurs en sortie