1.5.00 getCoursesByUser devient getCoursesByProfil

This commit is contained in:
Fred Tempez 2024-02-12 15:16:46 +01:00
parent e80564c106
commit 3ebb305cae
3 changed files with 15 additions and 17 deletions

View File

@ -499,10 +499,10 @@ class layout extends common
$this->getUser('group') === self::GROUP_MEMBER $this->getUser('group') === self::GROUP_MEMBER
&& $this->getData(['theme', 'menu', 'selectSpace']) === true && $this->getData(['theme', 'menu', 'selectSpace']) === true
) { ) {
if ($this->getCoursesByUser()) { if ($this->getCoursesByProfil()) {
$itemsRight .= '<li><select id="menuSelectCourse" >'; $itemsRight .= '<li><select id="menuSelectCourse" >';
$itemsRight .= '<option name="' . helper::translate('Accueil') . '" value="' . helper::baseUrl(true) . 'course/swap/home" ' . ('home' === self::$siteContent ? 'selected' : '') . '>' . helper::translate('Accueil') . '</option>'; $itemsRight .= '<option name="' . helper::translate('Accueil') . '" value="' . helper::baseUrl(true) . 'course/swap/home" ' . ('home' === self::$siteContent ? 'selected' : '') . '>' . helper::translate('Accueil') . '</option>';
foreach ($this->getCoursesByUser() as $courseId => $value) { foreach ($this->getCoursesByProfil() as $courseId => $value) {
$itemsRight .= '<option name="' . $this->getData(['course', $courseId, 'title']) . '" value="' . helper::baseUrl(true) . 'course/swap/' . $courseId . '" ' . ($courseId === self::$siteContent ? 'selected' : '') . '>' . $this->getData(['course', $courseId, 'title']) . '</option>'; $itemsRight .= '<option name="' . $this->getData(['course', $courseId, 'title']) . '" value="' . helper::baseUrl(true) . 'course/swap/' . $courseId . '" ' . ($courseId === self::$siteContent ? 'selected' : '') . '>' . $this->getData(['course', $courseId, 'title']) . '</option>';
} }
$itemsRight .= '</select></li>'; $itemsRight .= '</select></li>';
@ -921,10 +921,10 @@ class layout extends common
* Les enseignants les contenus dont ils sont auteurs * Les enseignants les contenus dont ils sont auteurs
*/ */
if ($this->getUser('group') >= self::GROUP_EDITOR) { if ($this->getUser('group') >= self::GROUP_EDITOR) {
if ($this->getCoursesByUser()) { if ($this->getCoursesByProfil()) {
$leftItems .= '<li><select id="barSelectCourse" >'; $leftItems .= '<li><select id="barSelectCourse" >';
$leftItems .= '<option name="' . helper::translate('Accueil') . '" value="' . helper::baseUrl(true) . 'course/swap/home" ' . ('home' === self::$siteContent ? 'selected' : '') . '>' . helper::translate('Accueil') . '</option>'; $leftItems .= '<option name="' . helper::translate('Accueil') . '" value="' . helper::baseUrl(true) . 'course/swap/home" ' . ('home' === self::$siteContent ? 'selected' : '') . '>' . helper::translate('Accueil') . '</option>';
foreach ($this->getCoursesByUser() as $courseId => $value) { foreach ($this->getCoursesByProfil() as $courseId => $value) {
$leftItems .= '<option name="' . $this->getData(['course', $courseId, 'title']) . '" value="' . helper::baseUrl(true) . 'course/swap/' . $courseId . '" ' . ($courseId === self::$siteContent ? 'selected' : '') . '>' . $this->getData(['course', $courseId, 'title']) . '</option>'; $leftItems .= '<option name="' . $this->getData(['course', $courseId, 'title']) . '" value="' . helper::baseUrl(true) . 'course/swap/' . $courseId . '" ' . ($courseId === self::$siteContent ? 'selected' : '') . '>' . $this->getData(['course', $courseId, 'title']) . '</option>';
} }
$leftItems .= '</select></li>'; $leftItems .= '</select></li>';

View File

@ -1422,7 +1422,7 @@ class common
* CETTE FONCTION N'EST PAS UTILISEE * CETTE FONCTION N'EST PAS UTILISEE
* *
*/ */
public function getCoursesByUser() public function getCoursesByProfil()
{ {
$courses = $this->getData([('course')]); $courses = $this->getData([('course')]);
$courses = helper::arraycolumn($courses, 'title', 'SORT_ASC'); $courses = helper::arraycolumn($courses, 'title', 'SORT_ASC');
@ -1434,12 +1434,11 @@ class common
return $courses; return $courses;
case self::GROUP_EDITOR: case self::GROUP_EDITOR:
foreach ($courses as $courseId => $value) { foreach ($courses as $courseId => $value) {
$students = $this->getData(['enrolment', $courseId]);
// Affiche les espaces gérés par l'éditeur, les espaces où il participe et les espaces ouverts // Affiche les espaces gérés par l'éditeur, les espaces où il participe et les espaces ouverts
if ( if (
isset($students[$userId]) === true || ( $this->getData(['enrolment', $courseId]) && array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId])) )
$this->getData(['course', $courseId, 'author']) === $userId || || $this->getUser('id') === $this->getData(['course', $courseId, 'author'])
$this->getData(['course', $courseId, 'enrolment']) === self::COURSE_ENROLMENT_GUEST || $this->getData(['course', $courseId, 'enrolment']) === self::COURSE_ENROLMENT_GUEST
) { ) {
$filter[$courseId] = $courses[$courseId]; $filter[$courseId] = $courses[$courseId];
} }
@ -1448,10 +1447,9 @@ class common
case self::GROUP_MEMBER: case self::GROUP_MEMBER:
foreach ($courses as $courseId => $value) { foreach ($courses as $courseId => $value) {
// Affiche les espaces du participant et les espaces anonymes // Affiche les espaces du participant et les espaces anonymes
$students = $this->getData(['enrolment', $courseId]);
if ( if (
isset($students[$userId]) === true || ($this->getData(['enrolment', $courseId]) && array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId])) )
$this->getData(['course', $courseId, 'enrolment']) === self::COURSE_ENROLMENT_GUEST || $this->getData(['course', $courseId, 'enrolment']) === self::COURSE_ENROLMENT_GUEST
) { ) {
$filter[$courseId] = $courses[$courseId]; $filter[$courseId] = $courses[$courseId];
} }

View File

@ -85,9 +85,9 @@ class course extends common
if ( if (
$this->getUser('id') $this->getUser('id')
&& $this->getUser('group') && $this->getUser('group')
&& $this->getCoursesByUser() && $this->getCoursesByProfil()
) { ) {
foreach ($this->getCoursesByUser() as $courseId => $courseValue) { foreach ($this->getCoursesByProfil() as $courseId => $courseValue) {
/** /**
* Filtres : * Filtres :
* Groupes acceptés : * Groupes acceptés :
@ -1761,9 +1761,9 @@ class course extends common
case self::GROUP_EDITOR: case self::GROUP_EDITOR:
return ( return (
$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])) ) || array_key_exists($this->getUser('id'), $this->getData(['enrolment', $courseId])) )
); );
default: default:
return false; return false;