From 86830be66ef61f9f0a3271914441180d3146bc6e Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Tue, 9 Oct 2007 12:53:24 +0000 Subject: [PATCH] MDL-11543 Temporary solution originally proposed by Martin --- course/category.php | 25 +++++++---------------- course/index.php | 45 ++++++++++++++++++----------------------- lang/en_utf8/moodle.php | 5 ++++- 3 files changed, 31 insertions(+), 44 deletions(-) diff --git a/course/category.php b/course/category.php index ffa1d8332e..842b58bd55 100644 --- a/course/category.php +++ b/course/category.php @@ -51,20 +51,6 @@ $creatorediting = false; } - $mform = new sub_category_add_form(); - if (has_capability('moodle/category:create', $context)) { - if ($form = $mform->get_data()) { - $subcategory = new stdClass; - $subcategory->name = $form->addcategory; - $subcategory->description = $form->description; - $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()) { @@ -274,11 +260,14 @@ } } -/// print option to add a subcategory + // Print button for creating new categories if (has_capability('moodle/category:create', $context) && $creatorediting) { - $cat->id = $id; - $mform->set_data($cat); - $mform->display(); + unset($options); + $options['categoryadd'] = 1; + $options['id'] = $id; + echo '
'; + print_single_button('editcategory.php', $options, get_string('addsubcategory'), 'get'); + echo '
'; } /// Print out all the courses diff --git a/course/index.php b/course/index.php index 5d698b4f59..e695380f46 100644 --- a/course/index.php +++ b/course/index.php @@ -45,24 +45,6 @@ $straction = get_string('action'); -/// If data for a new category was submitted, then add it - $mform = new category_add_form(); - if ($form = $mform->get_data() and has_capability('moodle/category:create', $context)) { - if (!empty($form->addcategory)) { - unset($newcategory); - $newcategory->name = stripslashes_safe($form->addcategory); - $newcategory->description = $form->description; - $newcategory->sortorder = 999; - if (!$newcategory->id = insert_record('course_categories', $newcategory)) { - notify("Could not insert the new category '" . format_string($newcategory->name) . "'"); - } else { - $newcategory->context = get_context_instance(CONTEXT_COURSECAT, $newcategory->id); - mark_context_dirty($newcategory->context->path); - notify(get_string('categoryadded', '', format_string($newcategory->name))); - } - } - } - /// Unless it's an editing admin, just print the regular listing of courses/categories if (!$adminediting) { @@ -281,12 +263,6 @@ /// Should be a no-op 99% of the cases fix_course_sortorder(); -/// Print form for creating new categories - - if (has_capability('moodle/category:create', get_context_instance(CONTEXT_SYSTEM))) { - $mform->display(); - } - /// Print out the categories with all the knobs $strcategories = get_string('categories'); @@ -312,7 +288,8 @@ echo ''; echo '
'; - /// Print link to create a new course + + // Print link to create a new course if (has_capability('moodle/course:create', $context)) { unset($options); if (!empty($category->id)) { @@ -321,6 +298,18 @@ } } + // Print button for creating new categories + if (has_capability('moodle/category:create', $context)) { + unset($options); + if (!empty($category->id)) { + $options['id'] = $category->id; + } else { + $options['id'] = 0; + } + $options['categoryadd'] = 1; + print_single_button('editcategory.php', $options, get_string('addnewcategory'), 'get'); + } + if (has_capability('moodle/site:approvecourse', $sysctx) and !empty($CFG->enablecourserequests)) { print_single_button('pending.php',NULL, get_string('coursespending'), 'get'); } @@ -339,6 +328,7 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $ static $str = ''; if (empty($str)) { + $str->edit = get_string('edit'); $str->delete = get_string('delete'); $str->moveup = get_string('moveup'); $str->movedown = get_string('movedown'); @@ -367,6 +357,11 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $ echo ''; /// Print little icons + if (has_capability('moodle/category:update', $category->context)) { + echo ' '; + } + if (has_capability('moodle/category:delete', $category->context)) { echo ' '; diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php index 96dc187269..da5da52c75 100644 --- a/lang/en_utf8/moodle.php +++ b/lang/en_utf8/moodle.php @@ -189,6 +189,7 @@ $string['categoryadded'] = 'The category \'$a\' was added'; $string['categorydeleted'] = 'The category \'$a\' was deleted'; $string['categoryduplicate'] = 'A category named \'$a\' already exists!'; $string['categoryname'] = 'Category name'; +$string['categoryupdated'] = 'The category \'$a\' was updated'; $string['changedpassword'] = 'Changed password'; $string['changepassword'] = 'Change password'; $string['changessaved'] = 'Changes saved'; @@ -403,6 +404,7 @@ $string['edhelpfontfamily'] = 'The font-family property is a list of font family $string['edhelpfontlist'] = 'Define the fonts used on editors dropdown menu.'; $string['edhelpfontsize'] = 'The default font-size sets the size of a font.
Valid values are for example: medium, large, smaller, larger, 10pt, 11px.'; $string['edit'] = 'Edit $a'; +$string['editcategorysettings'] = 'Edit category settings'; $string['editcoursesettings'] = 'Edit course settings'; $string['editfiles'] = 'Edit files'; $string['editgroupprofile'] = 'Edit group profile'; @@ -1101,6 +1103,7 @@ $string['outline'] = 'Outline'; $string['outlinereport'] = 'Outline report'; $string['page'] = 'Page'; $string['pageheaderconfigablock'] = 'Configuring a block in %%fullname%%'; +$string['parentcategory'] = 'Parent category'; $string['parentcoursenotfound'] = 'Parent course not found!'; $string['parentcoursenotmetacourse'] = 'Parent course not metacourse!'; $string['parentfolder'] = 'Parent folder'; @@ -1598,4 +1601,4 @@ $string['zippingbackup'] = 'Zipping backup'; $string['authenticationplugins'] = 'Authentication Plugins'; $string['chooseauthmethod'] = 'Choose authentication plugin'; -?> \ No newline at end of file +?> -- 2.39.5