fix bloquage clé incorrecte

This commit is contained in:
Fred Tempez 2023-10-17 11:21:35 +02:00
parent 6b840ecaa9
commit a025d33ab8

View File

@ -415,7 +415,7 @@ class course extends common
$this->initDB('page', $courseId); $this->initDB('page', $courseId);
$sumPages = $this->countPages($this->getHierarchy(null, false)); $sumPages = $this->countPages($this->getHierarchy(null, false));
// Supprimer les barres // Supprimer les barres
$sumPages = $sumPages - count($this->getHierarchy(null, false, true)); $sumPages = $sumPages - count($this->getHierarchy(null, false, true));
self::$siteContent = $currentSite; self::$siteContent = $currentSite;
// Liste des inscrits dans le cours sélectionné. // Liste des inscrits dans le cours sélectionné.
@ -461,7 +461,7 @@ class course extends common
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']), $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
$pageId, $pageId,
helper::dateUTF8('%d %B %Y - %H:%M', $maxTime), helper::dateUTF8('%d %B %Y - %H:%M', $maxTime),
round(($viewPages * 100)/ $sumPages, 1) . ' %', round(($viewPages * 100) / $sumPages, 1) . ' %',
template::button('userDelete' . $userId, [ template::button('userDelete' . $userId, [
'class' => 'userDelete buttonRed', 'class' => 'userDelete buttonRed',
'href' => helper::baseUrl() . 'course/userDelete/' . $courseId . '/' . $userId, 'href' => helper::baseUrl() . 'course/userDelete/' . $courseId . '/' . $userId,
@ -658,10 +658,17 @@ class course extends common
$_SESSION['ZWII_SITE_CONTENT'] = $courseId; $_SESSION['ZWII_SITE_CONTENT'] = $courseId;
break; break;
case self::COURSE_ENROLMENT_SELF_KEY: case self::COURSE_ENROLMENT_SELF_KEY:
if ($this->getInput('courseSwapEnrolmentKey') === $this->getData(['course', $courseId, 'enrolmentKey'])) { if ($this->getInput('courseSwapEnrolmentKey', null, true) === $this->getData(['course', $courseId, 'enrolmentKey'])) {
$this->courseEnrolUser($courseId, $userId); $this->courseEnrolUser($courseId, $userId);
// Stocker la sélection // Stocker la sélection
$_SESSION['ZWII_SITE_CONTENT'] = $courseId; $_SESSION['ZWII_SITE_CONTENT'] = $courseId;
} else {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl(),
'state' => false,
'notification' => 'La clé est incorrecte'
]);
} }
break; break;
} }
@ -784,7 +791,8 @@ class course extends common
} }
} }
private function countPages($array) { private function countPages($array)
{
$count = 0; $count = 0;
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
$count++; // Incrémente le compteur pour chaque clé associative trouvée $count++; // Incrémente le compteur pour chaque clé associative trouvée