Browse Source

Implements enrolments management

By implementing `enrol_plugin::allow_manage()` an user with `enrol/apply:manage` capability can change an enrolment status, starttime and endtime.
SABERES_37_STABLE
Arnaud Trouvé 7 years ago
parent
commit
c9aa09387c
  1. 10
      db/access.php
  2. 1
      lang/en/enrol_apply.php
  3. 8
      lib.php

10
db/access.php

@ -49,6 +49,16 @@ $capabilities = array(
)
),
/* Manage enrolments of users. */
'enrol/apply:manage' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'manager' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
)
),
/* Unenrol a user */
'enrol/apply:unenrol' => array(
'captype' => 'write',

1
lang/en/enrol_apply.php

@ -81,6 +81,7 @@ $string['status'] = 'Allow Course enrol confirmation';
$string['confirmenrol'] = 'Manage application';
$string['apply:config'] = 'Configure apply enrol instances';
$string['apply:manage'] = 'Manage user enrolments';
$string['apply:manageapplications'] = 'Manage apply enrolment';
$string['apply:unenrol'] = 'Cancel users from the course';
$string['apply:unenrolself'] = 'Cancel self from the course';

8
lib.php

@ -59,6 +59,10 @@ class enrol_apply_plugin extends enrol_plugin {
}
return parent::allow_unenrol_user($instance, $ue);
}
public function allow_manage(stdClass $instance) {
// Users with manage cap may tweak period and status.
return true;
}
/**
* Returns link to page which may be used to add new instance of enrolment plugin in course.
* Multiple instances supported.
@ -213,6 +217,10 @@ class enrol_apply_plugin extends enrol_plugin {
$url,
array('class' => 'unenrollink', 'rel' => $ue->id));
}
if ($this->allow_manage($instance) && has_capability("enrol/apply:manage", $context)) {
$url = new moodle_url('/enrol/editenrolment.php', $params);
$actions[] = new user_enrolment_action(new pix_icon('t/edit', ''), get_string('edit'), $url, array('class'=>'editenrollink', 'rel'=>$ue->id));
}
return $actions;
}

Loading…
Cancel
Save