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