--- moodle/course/index.php 2012-08-02 20:04:31.000000000 -0400 +++ moodle2/course/index.php 2012-09-17 10:17:16.626160254 -0400 @@ -35,6 +35,8 @@ $moveto = optional_param('moveto',-1,PARAM_INT); $moveup = optional_param('moveup',0,PARAM_INT); $movedown = optional_param('movedown',0,PARAM_INT); +$hidecourses = optional_param('hidecourses',0,PARAM_INT); +$showcourses = optional_param('showcourses',0,PARAM_INT); $site = get_site(); @@ -209,6 +211,19 @@ } } +/// Hide or show direct children courses in a category +if ($hidecourses and confirm_sesskey()) { + if ($tempcat = $DB->get_record('course_categories', array('id'=>$hidecourses))) { + require_capability('moodle/category:manage', get_category_or_system_context($tempcat->parent)); + category_hide_courses($tempcat); + } +} else if ($showcourses and confirm_sesskey()) { + if ($tempcat = $DB->get_record('course_categories', array('id'=>$showcourses))) { + require_capability('moodle/category:manage', get_category_or_system_context($tempcat->parent)); + category_show_courses($tempcat); + } +} + /// Move a category up or down if ((!empty($moveup) or !empty($movedown)) and confirm_sesskey()) { fix_course_sortorder(); @@ -299,6 +314,8 @@ $str->edit = get_string('editthiscategory'); $str->hide = get_string('hide'); $str->show = get_string('show'); + $str->hidecourses = get_string('hidecourses'); + $str->showcourses = get_string('showcourses'); $str->cohorts = get_string('cohorts', 'cohort'); $str->spacer = $OUTPUT->spacer().' '; } @@ -338,6 +355,12 @@ ' src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$str->show.'" /> '; } + echo ' '; + + echo ' '; + if (has_capability('moodle/cohort:manage', $category->context) or has_capability('moodle/cohort:view', $category->context)) { echo ' '; --- moodle/course/lib.php 2012-08-23 20:04:54.000000000 -0400 +++ moodle2/course/lib.php 2012-10-15 09:17:29.613391966 -0400 @@ -851,6 +851,7 @@ } foreach ($courses as $course) { $fullname = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); +$fullname = get_course_display_name_for_list($course); echo $OUTPUT->box_start('coursebox'); $attributes = array('title' => s($fullname)); if (empty($course->visible)) { @@ -3617,6 +3618,30 @@ } /** + * Show direct children courses of category + * @param stdClass $category + * @return void + */ +function category_show_courses($category) { + global $DB; + + $DB->set_field('course', 'visible', 1, array('category'=>$category->id)); + $DB->set_field('course', 'visibleold', 1, array('category'=>$category->id)); +} + +/** + * Hide direct children courses of category + * @param stdClass $category + * @return void + */ +function category_hide_courses($category) { + global $DB; + + $DB->set_field('course', 'visible', 0, array('category'=>$category->id)); + $DB->set_field('course', 'visibleold', 0, array('category'=>$category->id)); +} + +/** * Efficiently moves a category - NOTE that this can have * a huge impact access-control-wise... */ --- moodle/lang/en/moodle.php 2012-09-07 20:04:41.000000000 -0400 +++ moodle2/lang/en/moodle.php 2012-09-17 10:14:02.486379278 -0400 @@ -829,6 +829,7 @@ $string['hiddensectionsinvisible'] = 'Hidden sections are completely invisible'; $string['hide'] = 'Hide'; $string['hideadvancedsettings'] = 'Hide advanced settings'; +$string['hidecourses'] = 'Hide all children courses'; $string['hidepicture'] = 'Hide picture'; $string['hidesection'] = 'Hide section {$a}'; $string['hidesettings'] = 'Hide settings'; @@ -1540,6 +1541,7 @@ $string['showblockcourse'] = 'Show list of courses containing block'; $string['showcomments'] = 'Show/hide comments'; $string['showcommentsnonjs'] = 'Show comments'; +$string['showcourses'] = 'Show all children courses'; $string['showdescription'] = 'Display description on course page'; $string['showdescription_help'] = 'If enabled, the introduction / description above will be displayed on the course page just below the link to the activity / resource.'; $string['showgrades'] = 'Show gradebook to students';