From 851f6421d68dcf6b1fd87209fa2e04a21e98b554 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Thu, 19 Oct 2023 22:48:57 +0200 Subject: [PATCH] =?UTF-8?q?manque=20la=20fonction=20de=20d=C3=A9sincriptio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/workshop/view/config/config.php | 107 ++++++++++++++++++++----- module/workshop/view/index/index.php | 21 +++-- module/workshop/workshop.php | 89 +++++++++++++++++--- 3 files changed, 179 insertions(+), 38 deletions(-) diff --git a/module/workshop/view/config/config.php b/module/workshop/view/config/config.php index 3768742..bb43d4d 100644 --- a/module/workshop/view/config/config.php +++ b/module/workshop/view/config/config.php @@ -12,21 +12,101 @@
-
+
+ 'Catégorie à afficher', + 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'category']) + ]); ?> +
+
+
+
+
+

+ +

+
+
+ 'Ouvert', + 'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'accessopen']) + ]); ?> +
+
+ 'Période', + 'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'accessdate']) + ]); ?> +
+ +
+ 'Fermé', + 'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'accessclose']) + ]); ?> +
+
+
+
+

+ +

+
+
+
+
+ 'Anonyme', + 'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'enrolguest']) + ]); ?> +
+
+ 'Membre', + 'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'enrolself']) + ]); ?> +
+ +
+ 'Membre avec clé', + 'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'enrolselfkey']) + ]); ?> +
+
+
+
+ 'Lien vers le cours', + 'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'url']) + ]); ?> +
+
+ 'Désinscription', + 'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'unsuscribe']) + ]); ?> +
+
+
+
+
+
+

- $this->getData(['module', $this->getUrl(0), 'config', 'title']) ]); ?>
- $this->getData(['module', $this->getUrl(0), 'config', 'author']) ]); ?>
@@ -64,29 +144,14 @@ ]); ?>
-
-
- 'Texte du lien vers le cours', - 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'caption']) - ]); ?> -
-
-
+

- +

-
-
- 'Catégorie à afficher', - 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'category']) - ]); ?> -
-
+
- getData(['module', $this->getUrl(0), 'config', 'enrolment']) === true): ?> + getData(['module', $this->getUrl(0), 'config', 'enrolment']) === true ): ?>

- +

- + +
+ +
+ + getData(['enrolment', $courseId, $this->getUser('id')])): ?> + + getData(['module', $this->getUrl(0), 'caption', 'unsuscribe']); ?> + + +
+
getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?>
diff --git a/module/workshop/workshop.php b/module/workshop/workshop.php index dc8d282..8830b00 100644 --- a/module/workshop/workshop.php +++ b/module/workshop/workshop.php @@ -36,26 +36,44 @@ class workshop extends common 2 => 'Six cours par ligne', ]; + public static $coursesAccess = []; - public static $coursesAccess = [ - self::COURSE_ACCESS_OPEN => 'ouvert', - self::COURSE_ACCESS_DATE => 'période d\'ouverture', - self::COURSE_ACCESS_CLOSE => 'fermé', - ]; + public static $coursesEnrolment = []; - public static $coursesEnrolment = [ - self::COURSE_ENROLMENT_GUEST => 'anonyme, sans inscription', - self::COURSE_ENROLMENT_SELF => 'réservée aux membres inscrits', - self::COURSE_ENROLMENT_SELF_KEY => 'réservé aux membres et avec une clé d\'inscription ', - //self::COURSE_ENROLMENT_MANUAL => 'Manuelle' - ]; + public static $default = [ + "config" => array( + "category" => "general", + "title" => true, + "author" => true, + "description" => true, + "access" => true, + "openingdate" => true, + "closingdate" => true, + "enrolment" => true, + "layout" => 6, + "template" => true + ), + "caption" => array( + "accessopen" => "ouvert", + "accessdate" => "période d'ouverture", + "accessclose" => "fermé", + "enrolguest" => "anonyme", + "enrolself" => "membres", + "enrolselfkey" => "membres avec clé", + "url" => "Accéder au cours", + "unsuscribe" => "Me désinscrire" + ) + ]; - public static $coursesDetails = []; /** * Configuration */ public function config() { + + // Contrôle de la configuration par défaut + $this->update(); + // Soumission du formulaire if ( $this->getUser('permission', __CLASS__, __FUNCTION__) === true && @@ -79,6 +97,21 @@ class workshop extends common 'template' => $this->getInput('coursesConfigTemplate', helper::FILTER_BOOLEAN), ] ]); + $this->setData([ + 'module', + $this->getUrl(0), + 'caption', + [ + 'accessopen' => $this->getInput('coursesCaptionAccessOpen', helper::FILTER_STRING_SHORT), + 'accessdate' => $this->getInput('coursesCaptionAccessDate', helper::FILTER_STRING_SHORT), + 'accessclose' => $this->getInput('coursesCaptionAccessClose', helper::FILTER_STRING_SHORT), + 'enrolguest' => $this->getInput('coursesCaptionGuest', helper::FILTER_STRING_SHORT), + 'enrolself' => $this->getInput('coursesCaptionSelf', helper::FILTER_STRING_SHORT), + 'enrolselfkey' => $this->getInput('coursesCaptionSelfKey', helper::FILTER_STRING_SHORT), + 'url' => $this->getInput('coursesCaptionUrl', helper::FILTER_STRING_SHORT), + 'unsuscribe' => $this->getInput('coursesCaptionUnsuscribe', helper::FILTER_STRING_SHORT), + ] + ]); // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(), @@ -97,6 +130,17 @@ class workshop extends common } public function index() { + // Contrôle de la configuration par défaut + $this->update(); + + // Mise à jour des étiquettes + self::$coursesAccess[self::COURSE_ACCESS_OPEN] = $this->getData(['module', $this->getUrl(0), 'caption', 'accessopen']); + self::$coursesAccess[self::COURSE_ACCESS_DATE] = $this->getData(['module', $this->getUrl(0), 'caption', 'accessdate']); + self::$coursesAccess[self::COURSE_ACCESS_CLOSE] = $this->getData(['module', $this->getUrl(0), 'caption', 'accessclose']); + self::$coursesEnrolment[self::COURSE_ENROLMENT_GUEST] = $this->getData(['module', $this->getUrl(0), 'caption', 'enrolguest']); + self::$coursesEnrolment[self::COURSE_ENROLMENT_SELF] = $this->getData(['module', $this->getUrl(0), 'caption', 'enrolself']); + self::$coursesEnrolment[self::COURSE_ENROLMENT_SELF_KEY] = $this->getData(['module', $this->getUrl(0), 'caption', 'enrolselfkey']); + // Valeurs en sortie $this->addOutput([ 'showBarEditButton' => true, @@ -112,4 +156,25 @@ class workshop extends common 'view' => 'index', ]); } + + // Initialise avec des valeurs par défaut + private function update() + { + $check = false; + foreach (self::$default['config'] as $key => $value) { + if (is_null($this->getData(['module', $this->getUrl(0), 'config', $key]))) { + $this->setData(['module', $this->getUrl(0), 'config', $key, $value]); + $check = true; + } + } + foreach (self::$default['caption'] as $key => $value) { + if (is_null($this->getData(['module', $this->getUrl(0), 'caption', $key]))) { + $this->setData(['module', $this->getUrl(0), 'caption', $key, $value]); + $check = true; + } + } + if ($check) { + header('refresh:0'); + } + } } \ No newline at end of file