From a025d33ab8b1fb7a1b0805223a6a5c89b6369b21 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Tue, 17 Oct 2023 11:21:35 +0200 Subject: [PATCH] =?UTF-8?q?fix=20bloquage=20cl=C3=A9=20incorrecte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/course/course.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/module/course/course.php b/core/module/course/course.php index 7c0ceb0..6499f89 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -415,7 +415,7 @@ class course extends common $this->initDB('page', $courseId); $sumPages = $this->countPages($this->getHierarchy(null, false)); // Supprimer les barres - $sumPages = $sumPages - count($this->getHierarchy(null, false, true)); + $sumPages = $sumPages - count($this->getHierarchy(null, false, true)); self::$siteContent = $currentSite; // 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']), $pageId, helper::dateUTF8('%d %B %Y - %H:%M', $maxTime), - round(($viewPages * 100)/ $sumPages, 1) . ' %', + round(($viewPages * 100) / $sumPages, 1) . ' %', template::button('userDelete' . $userId, [ 'class' => 'userDelete buttonRed', 'href' => helper::baseUrl() . 'course/userDelete/' . $courseId . '/' . $userId, @@ -658,10 +658,17 @@ class course extends common $_SESSION['ZWII_SITE_CONTENT'] = $courseId; break; 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); // Stocker la sélection $_SESSION['ZWII_SITE_CONTENT'] = $courseId; + } else { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl(), + 'state' => false, + 'notification' => 'La clé est incorrecte' + ]); } break; } @@ -784,7 +791,8 @@ class course extends common } } - private function countPages($array) { + private function countPages($array) + { $count = 0; foreach ($array as $key => $value) { $count++; // Incrémente le compteur pour chaque clé associative trouvée