From a53dc4983e3da35babeb45d0bef4cdd0ffc1553b Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sat, 30 Sep 2023 19:04:55 +0200 Subject: [PATCH] =?UTF-8?q?Autorise=20l'acc=C3=A8=20admin=20et=20auteur=20?= =?UTF-8?q?lorsque=20le=20cours=20est=20ferm=C3=A9,=20affiche=20plus=20d'i?= =?UTF-8?q?nfos=20sur=20le=20cours=20dans=20l'index=20des=20cours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/course/course.php | 15 ++++++++++++--- core/module/course/view/index/index.php | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/module/course/course.php b/core/module/course/course.php index 8205d7d..8d676e6 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -57,10 +57,15 @@ class course extends common ksort($courseIdShortTitle); foreach ($courseIdShortTitle as $courseId => $courseTitle) { $categorieUrl = helper::baseUrl(!helper::checkRewrite()) . 'course/swap/' . $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
%s
%s
', $this->getData(['course', $courseId, 'description']), $access, $enrolment); self::$courses[] = [ $courseTitle, - $this->getData(['course', $courseId, 'author']), - $this->getData(['course', $courseId, 'description']), + $author, + $description, '' . $categorieUrl . '', template::button('courseEdit' . $courseId, [ 'href' => helper::baseUrl() . 'course/edit/' . $courseId, @@ -311,7 +316,8 @@ class course extends common ) { $_SESSION['ZWII_SITE_CONTENT'] = $courseId; } - // l'étudiant est inscrit dans le cours ET le cours est ouvert + // l'étudiant est inscrit dans le cours ET le cours est ouvert + // ou un admin est connecté ou le prof du cours elseif ( $this->courseIsUserEnroled($courseId) && $this->courseIsAvailable($courseId) @@ -495,6 +501,9 @@ class course extends common if ($courseId === 'home') { return true; } + if ($this->getUser('group') === self::GROUP_ADMIN || $this->getUser('id') === $this->getData(['group', $courseId, 'author'])) { + return true; + } $access = $this->getData(['course', $courseId, 'access']); switch ($access) { case self::COURSE_ACCESS_OPEN: diff --git a/core/module/course/view/index/index.php b/core/module/course/view/index/index.php index 3ede56f..a58a4b0 100644 --- a/core/module/course/view/index/index.php +++ b/core/module/course/view/index/index.php @@ -22,7 +22,7 @@ - +