From 6f83b034e099532913db7820fca304fc3a626e55 Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Wed, 25 Jul 2007 14:02:27 +0000 Subject: [PATCH] MDL-10604: Add ability to add sub categories directly from category screens. Merged from STABLE_18 --- course/category.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/course/category.php b/course/category.php index 45da9e964..07a0d3d9b 100644 --- a/course/category.php +++ b/course/category.php @@ -18,6 +18,7 @@ $rename = optional_param('rename', '', PARAM_NOTAGS); $resort = optional_param('resort', 0, PARAM_BOOL); $categorytheme= optional_param('categorytheme', false, PARAM_CLEAN); + $addsubcategory=optional_param('addsubcategory', '', PARAM_NOTAGS); if (!$site = get_site()) { error("Site isn't defined!"); @@ -51,6 +52,18 @@ } + if (has_capability('moodle/category:create', $context)) { + if (!empty($addsubcategory) and confirm_sesskey()) { + $subcategory = new stdClass; + $subcategory->name = $addsubcategory; + $subcategory->sortorder = 999; + $subcategory->parent = $id; + if (!insert_record('course_categories', $subcategory )) { + notify( "Could not insert the new subcategory '$addsubcategory' " ); + } + } + } + if (has_capability('moodle/category:update', $context)) { /// Rename the category if requested if (!empty($rename) and confirm_sesskey()) { @@ -250,6 +263,21 @@ } } +/// print option to add a subcategory + if (has_capability('moodle/category:create', $context)) { + $straddsubcategory = get_string('addsubcategory'); + echo '
'; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + // echo ''; + echo '
'; + echo '
'; + echo '
'; + } /// Print out all the courses unset($course); // To avoid unwanted language effects later -- 2.11.4.GIT