Filtre avant cours

This commit is contained in:
Fred Tempez 2023-11-21 11:00:02 +01:00
parent 6c0a4cd884
commit 06f74c1be7

View File

@ -74,16 +74,21 @@ class course extends common
public function index() public function index()
{ {
if ($this->getCoursesByUser($this->getUser('id'), $this->getUser('group'))) { self::$courses = array();
if (
$this->getUser('id')
&& $this->getUser('group')
&& $this->getCoursesByUser($this->getUser('id'), $this->getUser('group'))
) {
foreach ($this->getCoursesByUser($this->getUser('id'), $this->getUser('group')) as $courseId => $courseValue) { foreach ($this->getCoursesByUser($this->getUser('id'), $this->getUser('group')) as $courseId => $courseValue) {
$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 = isset($authorId)
? 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[$courseValue ['access']]; $access = self::$courseAccess[$courseValue['access']];
$enrolment = self::$courseEnrolment[$courseValue ['enrolment']]; $enrolment = self::$courseEnrolment[$courseValue['enrolment']];
$description = sprintf('%s<br />%s<br />%s<br />', $courseValue ['description'], $access, $enrolment); $description = sprintf('%s<br />%s<br />%s<br />', $courseValue['description'], $access, $enrolment);
self::$courses[] = [ self::$courses[] = [
$courseValue['title'], $courseValue['title'],
$author, $author,