mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 14:02:32 +02:00
MDL-22897 fixed problem when no category sync roles defined
This commit is contained in:
parent
abbdb60539
commit
ff3af0a542
@ -152,6 +152,16 @@ function enrol_category_sync_course($course) {
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$roles = get_roles_with_capability('enrol/category:synchronised', CAP_ALLOW, $syscontext);
|
||||
|
||||
if (!$roles) {
|
||||
//nothing to sync, so remove the instance completely if exists
|
||||
if ($instances = $DB->get_records('enrol', array('courseid'=>$course->id, 'enrol'=>'category'))) {
|
||||
foreach ($instances as $instance) {
|
||||
$plugin->delete_instance($instance);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// first find out if any parent category context contains interesting role assignments
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$contextids = get_parent_contexts($coursecontext);
|
||||
|
Loading…
x
Reference in New Issue
Block a user