Skip to content

Commit

Permalink
Merge pull request #82 from andil-elearning/allow_manage
Browse files Browse the repository at this point in the history
Implements enrolments management
  • Loading branch information
Flottertotte authored Feb 24, 2018
2 parents b587e30 + c9aa093 commit 580ad76
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
)
),

/* 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',
Expand Down
1 change: 1 addition & 0 deletions lang/en/enrol_apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
$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';
Expand Down
8 changes: 8 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public function allow_unenrol_user(stdClass $instance, stdClass $ue) {
}
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.
Expand Down Expand Up @@ -213,6 +217,10 @@ public function get_user_enrolment_actions(course_enrolment_manager $manager, $u
$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;
}

Expand Down

0 comments on commit 580ad76

Please sign in to comment.