]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11543 Temporary solution originally proposed by Martin
authornicolasconnault <nicolasconnault>
Tue, 9 Oct 2007 12:53:24 +0000 (12:53 +0000)
committernicolasconnault <nicolasconnault>
Tue, 9 Oct 2007 12:53:24 +0000 (12:53 +0000)
course/category.php
course/index.php
lang/en_utf8/moodle.php

index ffa1d8332e863c831b438b48c92677c374aa57fe..842b58bd55a70339124db93928151df429970b9d 100644 (file)
         $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()) {
         }
     }
 
-/// 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 '<div class="buttons">'; 
+        print_single_button('editcategory.php', $options, get_string('addsubcategory'), 'get');
+        echo '<br /></div>';
     }
 
 /// Print out all the courses
index 5d698b4f594af12e86962914a298c3cd84957d75..e695380f46fbfcba53c0871fe668d0559b77dbf7 100644 (file)
     $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) {
 /// 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');
     echo '</table>';
 
     echo '<div class="buttons">';
-    /// 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)) {
         }
     }
 
+    // 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 '<td class="icons">';    /// Print little icons
 
+        if (has_capability('moodle/category:update', $category->context)) {
+            echo '<a title="'.$str->edit.'" href="editcategory.php?id='.$category->id.'&amp;sesskey='.sesskey().'"><img'.
+                 ' src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'.$str->edit.'" /></a> ';
+        }
+
         if (has_capability('moodle/category:delete', $category->context)) {
             echo '<a title="'.$str->delete.'" href="index.php?delete='.$category->id.'&amp;sesskey='.sesskey().'"><img'.
                  ' src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'.$str->delete.'" /></a> ';
index 96dc187269d6b631c3144547fd14bb624f9b1485..da5da52c7514e1be3d394a0ed6423c17249f8594 100644 (file)
@@ -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. <br />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
+?>