diff --git a/db/access.php b/db/access.php index 364b4a4..8014a45 100644 --- a/db/access.php +++ b/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', diff --git a/lang/en/enrol_apply.php b/lang/en/enrol_apply.php index 8f2ba65..b464561 100644 --- a/lang/en/enrol_apply.php +++ b/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'; diff --git a/lib.php b/lib.php index 2ff23ab..c8ae0f1 100644 --- a/lib.php +++ b/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; }