From e7129e3c66d386fa56264916786f06e9264be620 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 4 Oct 2023 21:05:39 +0200 Subject: [PATCH] =?UTF-8?q?New=20suppression=20de=20cat=C3=A9gorie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/course/course.php | 59 ++++++++++++++++++- .../course/view/category/category.js.php | 25 ++++++++ core/module/course/view/category/category.php | 2 +- .../course/view/categoryAdd/categoryAdd.css | 18 ++++++ .../course/view/categoryAdd/categoryAdd.php | 29 +++++++++ core/module/course/view/index/index.php | 15 +++-- core/module/course/view/user/user.css | 18 ++++++ core/module/course/view/user/user.php | 0 8 files changed, 158 insertions(+), 8 deletions(-) create mode 100644 core/module/course/view/category/category.js.php create mode 100644 core/module/course/view/categoryAdd/categoryAdd.css create mode 100644 core/module/course/view/categoryAdd/categoryAdd.php create mode 100644 core/module/course/view/user/user.css create mode 100644 core/module/course/view/user/user.php diff --git a/core/module/course/course.php b/core/module/course/course.php index 8c02fba..33c403c 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -25,6 +25,8 @@ class course extends common 'delete' => self::GROUP_ADMIN, 'category' => self::GROUP_ADMIN, 'categoryAdd' => self::GROUP_ADMIN, + 'categoryDelete' => self::GROUP_ADMIN, + 'user' => self::GROUP_ADMIN, ]; public static $courseAccess = [ @@ -249,7 +251,7 @@ class course extends common } else { // Active l'accueil $_SESSION['ZWII_SITE_CONTENT'] = 'home'; - + // ET efface la structure if (is_dir(self::DATA_DIR . $courseId)) { $success = $this->deleteDir(self::DATA_DIR . $courseId); @@ -278,13 +280,13 @@ class course extends common self::$courseCategories[] = [ $categoryId, $categoryTitle, - template::button('courseEdit' . $categoryId, [ + template::button('categoryEdit' . $categoryId, [ 'href' => helper::baseUrl() . 'course/categoryEdit/' . $categoryId, 'value' => template::ico('pencil'), 'help' => 'Éditer' ]), template::button('courseDelete' . $categoryId, [ - 'class' => 'courseDelete buttonRed', + 'class' => 'categoryDelete buttonRed', 'href' => helper::baseUrl() . 'course/categoryDelete/' . $categoryId, 'value' => template::ico('trash'), 'help' => 'Supprimer' @@ -298,6 +300,57 @@ class course extends common ]); } + public function categoryAdd() + { + + // Soumission du formulaire + if ( + $this->getUser('permission', __CLASS__, __FUNCTION__) === true && + $this->isPost() + ) { + $categoryId = $this->getInput('categoryAddTitle', helper::FILTER_ID, true); + $this->setData([ + 'category', + $categoryId, + $this->getInput('categoryAddTitle', helper::FILTER_STRING_SHORT, true) + ]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'course/category', + 'notification' => helper::translate('Catégorie créée'), + 'state' => true + ]); + } + + // Valeurs en sortie + $this->addOutput([ + 'title' => helper::translate('Ajouter une catégorie'), + 'view' => 'categoryAdd' + ]); + } + + public function categoryDelete() + { + + $categories = helper::arrayColumn($this->getData(['course']), 'category', 'SORT_ASC'); + $courseId = $this->getUrl(2); + $message = helper::translate('Une catégorie affectée ne peut pas être effacée'); + $state = false; + if (in_array($courseId, $categories) === false) { + $this->deleteData(['category', $this->getUrl(2)]); + // Valeurs en sortie + $message = helper::translate('Catégorie effacée'); + $state = true; + } + + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'course/category', + 'notification' => $message, + 'state' => $state + ]); + } + /* * Traitement du changement de langue */ diff --git a/core/module/course/view/category/category.js.php b/core/module/course/view/category/category.js.php new file mode 100644 index 0000000..ab26456 --- /dev/null +++ b/core/module/course/view/category/category.js.php @@ -0,0 +1,25 @@ +/** + * This file is part of Zwii. + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2023, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.fr/ + */ + +$(document).ready(function () { + /** + * Confirmation de suppression + */ + $(".categoryDelete").on("click", function () { + var _this = $(this); + var message = ""; + return core.confirm(message, function () { + $(location).attr("href", _this.attr("href")); + }); + }); +}); \ No newline at end of file diff --git a/core/module/course/view/category/category.php b/core/module/course/view/category/category.php index 89ee26e..4d0cd9d 100644 --- a/core/module/course/view/category/category.php +++ b/core/module/course/view/category/category.php @@ -9,7 +9,7 @@
'buttonGreen', - 'href' => helper::baseUrl() . 'courseCategoryadd', + 'href' => helper::baseUrl() . 'course/categoryAdd', 'value' => template::ico('plus') ]); ?>
diff --git a/core/module/course/view/categoryAdd/categoryAdd.css b/core/module/course/view/categoryAdd/categoryAdd.css new file mode 100644 index 0000000..ec84629 --- /dev/null +++ b/core/module/course/view/categoryAdd/categoryAdd.css @@ -0,0 +1,18 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2023, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.fr/ + */ + + +/** NE PAS EFFACER +* admin.css +*/ \ No newline at end of file diff --git a/core/module/course/view/categoryAdd/categoryAdd.php b/core/module/course/view/categoryAdd/categoryAdd.php new file mode 100644 index 0000000..1405bcd --- /dev/null +++ b/core/module/course/view/categoryAdd/categoryAdd.php @@ -0,0 +1,29 @@ + +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . 'course/category', + 'value' => template::ico('left') + ]); ?> +
+
+ +
+
+
+
+
+

+ +

+
+
+ 'Nom de la catégorie' + ]); ?> +
+
+
+
+
\ No newline at end of file diff --git a/core/module/course/view/index/index.php b/core/module/course/view/index/index.php index a58a4b0..3caf7c7 100644 --- a/core/module/course/view/index/index.php +++ b/core/module/course/view/index/index.php @@ -1,20 +1,27 @@
- 'buttonGrey', 'href' => helper::baseUrl() . $this->getUrl(2), 'value' => template::ico('left') ]); ?>
-
- + helper::baseUrl() . 'course/user', + 'value' => template::ico('users'), + 'help' => 'Etudiants inscrits' + ]); ?> +
+
+ helper::baseUrl() . 'course/category', 'value' => template::ico('table'), 'help' => 'Catégories de cours' ]); ?>
- 'buttonGreen', 'href' => helper::baseUrl() . 'course/add', 'value' => template::ico('plus') diff --git a/core/module/course/view/user/user.css b/core/module/course/view/user/user.css new file mode 100644 index 0000000..ec84629 --- /dev/null +++ b/core/module/course/view/user/user.css @@ -0,0 +1,18 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2023, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.fr/ + */ + + +/** NE PAS EFFACER +* admin.css +*/ \ No newline at end of file diff --git a/core/module/course/view/user/user.php b/core/module/course/view/user/user.php new file mode 100644 index 0000000..e69de29