]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13925
authorthepurpleblob <thepurpleblob>
Wed, 23 Jul 2008 14:36:10 +0000 (14:36 +0000)
committerthepurpleblob <thepurpleblob>
Wed, 23 Jul 2008 14:36:10 +0000 (14:36 +0000)
Was not handling adding subcategories properly. Thanks to Dennis Protzek for the patch.

Merged from STABLE_19

course/editcategory.php

index c3390eb1969f529af105b1836bf537c49ecd5c5e..3288f45857cf19519ce7e368ec695672c50380fb 100644 (file)
@@ -20,15 +20,20 @@ $categoryedit   = optional_param('categoryedit', -1, PARAM_BOOL);    // Enables
 $categoryadd    = optional_param('categoryadd', 0, PARAM_BOOL);  // Enables the Add Category form
 $categoryupdate = optional_param('categoryupdate', 0, PARAM_BOOL); // Enables the Edit Category form
 $resort         = optional_param('resort', 0, PARAM_BOOL);
+$parent         = optional_param('parent', 0, PARAM_INT );
 
 if (!$site = get_site()) {
     print_error("siteisnotdefined");
 }
 
-if ($categoryadd) { // Show Add category form: if $id is given, it is used as the parent category 
+if ($categoryadd and !$parent) { // Show Add category form: if $id is given, it is used as the parent category 
     $strtitle = get_string("addnewcategory");
     $context = get_context_instance(CONTEXT_SYSTEM);
     $category = null;
+} elseif ($categoryadd and $parent) {
+       $strtitle = get_string("addnewcategory");
+       $context = get_context_instance(CONTEXT_COURSECAT,$parent);
+       $category = null;
 } elseif (!is_null($id) && !$categoryadd) { // Show Edit category form: $id is given as the identifier of the category being edited
     $strtitle = get_string("editcategorysettings");
     $context = get_context_instance(CONTEXT_COURSECAT, $id);