MDL-12873 - show an add course button when editing at the top level (which
authorpoltawski <poltawski>
Tue, 8 Jan 2008 12:00:11 +0000 (12:00 +0000)
committerpoltawski <poltawski>
Tue, 8 Jan 2008 12:00:11 +0000 (12:00 +0000)
is the default view when you click 'Add/Edit Courses')

merged from MOODLE_19_STABLE

course/index.php

index 5c8407ca2622ea87d7ad9e0374caf44f2164de4d..1301b09a95de85852f09f592a3a2db1b81b79fee 100644 (file)
 
     echo '<div class="buttons">';
     
-    // Print link to create a new course
-    if (has_capability('moodle/course:create', $context)) {
-        unset($options);
-        if (!empty($category->id)) {
+    if (!empty($category->id)) {
+        // Print link to create a new course in current category
+        if (has_capability('moodle/course:create', $context)) {
+            $options = array();
             $options['category'] = $category->id;
             print_single_button('edit.php', $options, get_string('addnewcourse'), 'get');
         }
+    }else{
+        if (has_capability('moodle/course:create', $sysctx)) {  
+            // print create course link to first category
+            $options = array();
+            $options = array('category' => get_field('course_categories', 'id', 'parent', '0'));
+            print_single_button('edit.php', $options, get_string('addnewcourse'), 'get');
+        }
     }
 
     // Print button for creating new categories