Skip to content

Commit

Permalink
Merge pull request #36 from sudile/fix-capabilities
Browse files Browse the repository at this point in the history
Fix: use of capabilities from other enrolment plugins (manual, self) …
  • Loading branch information
Flottertotte committed Oct 13, 2015
2 parents e03c2c9 + 6551baa commit 5ace709
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$context = context_course::instance($course->id, MUST_EXIST);

require_login($course);
require_capability('enrol/self:config', $context);
require_capability('enrol/apply:config', $context);

$PAGE->set_url('/enrol/apply/edit.php', array('courseid'=>$course->id, 'id'=>$instanceid));
$PAGE->set_pagelayout('admin');
Expand Down
8 changes: 4 additions & 4 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function allow_unenrol(stdClass $instance) {
public function get_newinstance_link($courseid) {
$context = context_course::instance($courseid, MUST_EXIST);

if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/manual:config', $context)) {
if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/apply:config', $context)) {
return NULL;
}
// multiple instances supported - different roles with different password
Expand Down Expand Up @@ -158,17 +158,17 @@ public function get_action_icons(stdClass $instance) {

$icons = array();

if (has_capability('enrol/manual:config', $context)) {
if (has_capability('enrol/apply:config', $context)) {
$editlink = new moodle_url("/enrol/apply/edit.php", array('courseid'=>$instance->courseid, 'id'=>$instance->id));
$icons[] = $OUTPUT->action_icon($editlink, new pix_icon('t/edit', get_string('edit'), 'core', array('class' => 'iconsmall')));
}

if (has_capability('enrol/manual:manage', $context)) {
if (has_capability('enrol/apply:manage', $context)) {
$managelink = new moodle_url("/enrol/apply/apply.php", array('id'=>$_GET['id'],'enrolid'=>$instance->id));
$icons[] = $OUTPUT->action_icon($managelink, new pix_icon('i/users', get_string('confirmenrol', 'enrol_apply'), 'core', array('class'=>'iconsmall')));
}

if (has_capability("enrol/manual:enrol", $context)) {
if (has_capability("enrol/apply:enrol", $context)) {
$enrollink = new moodle_url("/enrol/apply/enroluser.php", array('enrolid'=>$instance->id));
$icons[] = $OUTPUT->action_icon($enrollink, new pix_icon('t/enrolusers', get_string('enrolusers', 'enrol_apply'), 'core', array('class'=>'iconsmall')));
}
Expand Down
4 changes: 2 additions & 2 deletions unenroluser.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

// Obviously
require_login($course);
// Make sure the user can unenrol self enrolled users.
require_capability("enrol/self:unenrol", context_course::instance($course->id));
// Make sure the user can unenrol users.
require_capability("enrol/apply:unenrol", context_course::instance($course->id));

// Get the enrolment manager for this course
$manager = new course_enrolment_manager($PAGE, $course, $filter);
Expand Down

0 comments on commit 5ace709

Please sign in to comment.