Merge branch 'wip-mdl-37062-m23' of git://github.com/rajeshtaneja/moodle into MOODLE_23_STABLE

This commit is contained in:
Eloy Lafuente (stronk7) 2013-01-15 20:06:26 +01:00
commit 09ebf8386a
2 changed files with 11 additions and 9 deletions

View file

@ -67,12 +67,11 @@ $straction = get_string('action');
$strfulllistofcourses = get_string('fulllistofcourses'); $strfulllistofcourses = get_string('fulllistofcourses');
/// Unless it's an editing admin, just print the regular listing of courses/categories // Unless it's an editing admin, just print the regular listing of courses/categories.
if (!$adminediting) { if (!$adminediting) {
$showaddcoursebutton = true;
/// Print form for creating new categories // Print form for creating new categories.
$countcategories = $DB->count_records('course_categories'); $countcategories = $DB->count_records('course_categories');
if ($countcategories > 1 || ($countcategories == 1 && $DB->count_records('course') > 200)) { if ($countcategories > 1 || ($countcategories == 1 && $DB->count_records('course') > 200)) {
$strcourses = get_string('courses'); $strcourses = get_string('courses');
$strcategories = get_string('categories'); $strcategories = get_string('categories');
@ -96,14 +95,13 @@ if (!$adminediting) {
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->skip_link_target(); echo $OUTPUT->skip_link_target();
echo $OUTPUT->box_start('courseboxes'); echo $OUTPUT->box_start('courseboxes');
print_courses(0); $showaddcoursebutton = print_courses(0);
echo $OUTPUT->box_end(); echo $OUTPUT->box_end();
} }
echo $OUTPUT->container_start('buttons'); echo $OUTPUT->container_start('buttons');
if (has_capability('moodle/course:create', $systemcontext)) { if (has_capability('moodle/course:create', $systemcontext) && $showaddcoursebutton) {
/// Print link to create a new course // Print link to create a new course, for the 1st available category.
/// Get the 1st available category
$options = array('category' => $CFG->defaultrequestcategory); $options = array('category' => $CFG->defaultrequestcategory);
echo $OUTPUT->single_button(new moodle_url('edit.php', $options), get_string('addnewcourse'), 'get'); echo $OUTPUT->single_button(new moodle_url('edit.php', $options), get_string('addnewcourse'), 'get');
} }

View file

@ -2457,7 +2457,9 @@ function update_category_button($categoryid = 0) {
} }
/** /**
* Category is 0 (for all courses) or an object * Print courses in category. If category is 0 then all courses are printed.
* @param int|stdClass $category category object or id.
* @return bool true if courses found and printed, else false.
*/ */
function print_courses($category) { function print_courses($category) {
global $CFG, $OUTPUT; global $CFG, $OUTPUT;
@ -2505,8 +2507,10 @@ function print_courses($category) {
echo html_writer::start_tag('div', array('class'=>'addcoursebutton')); echo html_writer::start_tag('div', array('class'=>'addcoursebutton'));
echo $OUTPUT->single_button(new moodle_url('/course/edit.php', $options), get_string("addnewcourse")); echo $OUTPUT->single_button(new moodle_url('/course/edit.php', $options), get_string("addnewcourse"));
echo html_writer::end_tag('div'); echo html_writer::end_tag('div');
return false;
} }
} }
return true;
} }
/** /**