Permalink
Browse files

Merge branch 'MDL-8307-master' of git://github.com/FMCorz/moodle

  • Loading branch information...
2 parents 8e35be4 + d347f30 commit dafc3b7a85a49eca5dd936354f320e8c642f1bd6 @stronk7 stronk7 committed Sep 19, 2012
Showing with 6 additions and 5 deletions.
  1. +3 −3 course/lib.php
  2. +3 −2 course/pending.php
View
@@ -4144,7 +4144,7 @@ public static function create($data) {
global $USER, $DB, $CFG;
$data->requester = $USER->id;
- // Setting the default category is none set.
+ // Setting the default category if none set.
if (empty($data->category) || empty($CFG->requestcategoryselection)) {
$data->category = $CFG->defaultrequestcategory;
}
@@ -4306,10 +4306,10 @@ public function approve() {
unset($data->reason);
unset($data->requester);
- // If the current user does not have the rights to change the category, or if the
+ // If the category is not set, if the current user does not have the rights to change the category, or if the
// category does not exist, we set the default category to the course to be approved.
// The system level is used because the capability moodle/site:approvecourse is based on a system level.
- if (!has_capability('moodle/course:changecategory', context_system::instance()) ||
+ if (empty($data->category) || !has_capability('moodle/course:changecategory', context_system::instance()) ||
(!$category = get_course_category($data->category))) {
$category = get_course_category($CFG->defaultrequestcategory);
}
View
@@ -111,11 +111,12 @@
$course->check_shortname_collision();
// Retreiving category name.
- // If the user does not have the capability to change the category, we fallback on the default one.
+ // If the category was not set (can happen after upgrade) or if the user does not have the capability
+ // to change the category, we fallback on the default one.
// Else, the category proposed is fetched, but we fallback on the default one if we can't find it.
// It is just a matter of displaying the right information because the logic when approving the category
// proceeds the same way. The system context level is used as moodle/site:approvecourse uses it.
- if (!has_capability('moodle/course:changecategory', context_system::instance()) ||
+ if (empty($course->category) || !has_capability('moodle/course:changecategory', context_system::instance()) ||
(!$category = get_course_category($course->category))) {
$category = get_course_category($CFG->defaultrequestcategory);
}

0 comments on commit dafc3b7

Please sign in to comment.