Skip to content

Commit

Permalink
MDL-48362 enrol: Fixes to cohort and manual enrol plugins
Browse files Browse the repository at this point in the history
These were regressions from the change to use the standard editing ui
for enrolment plugins.
  • Loading branch information
Damyon Wiese committed Mar 2, 2016
1 parent cc32a71 commit 72fcaae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions enrol/cohort/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public function add_instance($course, array $fields = null) {
* @return boolean
*/
public function update_instance($instance, $data) {
global $CFG;

// NOTE: no cohort changes here!!!
$context = context_course::instance($instance->courseid);
if ($data->roleid != $instance->roleid) {
Expand Down
12 changes: 10 additions & 2 deletions enrol/manual/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,18 @@ public function get_manual_enrol_link($instance) {
* @return boolean
*/
public function can_add_instance($courseid) {
global $DB;

$context = context_course::instance($courseid, MUST_EXIST);
if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/manual:config', $context)) {
return false;
}
// Multiple instances supported - multiple parent courses linked.

if ($DB->record_exists('enrol', array('courseid'=>$courseid, 'enrol'=>'manual'))) {
// Multiple instances not supported.
return false;
}

return true;
}

Expand All @@ -107,7 +114,8 @@ public function get_action_icons(stdClass $instance) {
$managelink = new moodle_url("/enrol/manual/manage.php", array('enrolid'=>$instance->id));
$icons[] = $OUTPUT->action_icon($managelink, new pix_icon('t/enrolusers', get_string('enrolusers', 'enrol_manual'), 'core', array('class'=>'iconsmall')));
}
$icons = $icons + parent::get_action_icons($instance);
$parenticons = parent::get_action_icons($instance);
$icons = array_merge($icons, $parenticons);

return $icons;
}
Expand Down

0 comments on commit 72fcaae

Please sign in to comment.