MDL-23532 enrol - abstracted user enrolment action icons to the enrolment plugin class

This commit is contained in:
Sam Hemelryk 2011-04-07 12:20:38 +08:00
parent 410135aa10
commit 291215f441
4 changed files with 129 additions and 28 deletions

View file

@ -1531,4 +1531,26 @@ abstract class enrol_plugin {
public function get_manual_enrol_button(course_enrolment_manager $manager) {
return false;
}
}
/**
* Gets an array of the user enrolment actions
*
* @param course_enrolment_manager $manager
* @param stdClass $ue
* @return array An array of user_enrolment_actions
*/
public function get_user_enrolment_actions(course_enrolment_manager $manager, $ue) {
$actions = array();
$context = $manager->get_context();
$instance = $ue->enrolmentinstance;
if ($this->allow_unenrol($instance) && has_capability("enrol/".$instance->enrol.":unenrol", $context)) {
$url = new moodle_url($manager->get_moodlepage()->url, array('action' => 'unenrol', 'ue' => $ue->id));
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
}
if ($this->allow_manage($instance) && has_capability("enrol/".$instance->enrol.":manage", $context)) {
$url = new moodle_url($manager->get_moodlepage()->url, array('action' => 'edit', 'ue' => $ue->id));
$actions[] = new user_enrolment_action(new pix_icon('t/edit', ''), get_string('edit'), $url, array('class'=>'editenrollink', 'rel'=>$ue->id));
}
return $actions;
}
}