Browse Source

Merge pull request #36 from sudile/fix-capabilities

Fix: use of capabilities from other enrolment plugins (manual, self) …
SABERES_37_STABLE v2.9-a
Flotter Totte 9 years ago
parent
commit
5ace70974e
  1. 2
      edit.php
  2. 8
      lib.php
  3. 4
      unenroluser.php

2
edit.php

@ -20,7 +20,7 @@ $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
$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');

8
lib.php

@ -32,7 +32,7 @@ class enrol_apply_plugin extends enrol_plugin {
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
@ -158,17 +158,17 @@ class enrol_apply_plugin extends enrol_plugin {
$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')));
}

4
unenroluser.php

@ -50,8 +50,8 @@ if ($course->id == SITEID) {
// 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);

Loading…
Cancel
Save