MDL-59369 enrol: Introduce data-action attribute for enrol action links
This commit is contained in:
@@ -236,7 +236,9 @@ class enrol_cohort_plugin extends enrol_plugin {
|
||||
$params['ue'] = $ue->id;
|
||||
if ($this->allow_unenrol_user($instance, $ue) && has_capability('enrol/cohort:unenrol', $context)) {
|
||||
$url = new moodle_url('/enrol/unenroluser.php', $params);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
|
||||
$actionparams = array('class' => 'unenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_UNENROL);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url,
|
||||
$actionparams);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,9 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
$params['ue'] = $ue->id;
|
||||
if ($this->allow_unenrol_user($instance, $ue) && has_capability('enrol/database:unenrol', $context)) {
|
||||
$url = new moodle_url('/enrol/unenroluser.php', $params);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
|
||||
$actionparams = array('class' => 'unenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_UNENROL);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url,
|
||||
$actionparams);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
@@ -132,11 +132,14 @@ class enrol_flatfile_plugin extends enrol_plugin {
|
||||
$params['ue'] = $ue->id;
|
||||
if ($this->allow_unenrol_user($instance, $ue) && has_capability("enrol/flatfile:unenrol", $context)) {
|
||||
$url = new moodle_url('/enrol/unenroluser.php', $params);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
|
||||
$actionparams = array('class' => 'unenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_UNENROL);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url,
|
||||
$actionparams);
|
||||
}
|
||||
if ($this->allow_manage($instance) && has_capability("enrol/flatfile: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));
|
||||
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/edit', ''), get_string('edit'), $url, $actionparams);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
+4
-3
@@ -392,13 +392,14 @@ class enrol_lti_plugin extends enrol_plugin {
|
||||
$params['ue'] = $ue->id;
|
||||
if ($this->allow_unenrol_user($instance, $ue) && has_capability("enrol/lti:unenrol", $context)) {
|
||||
$url = new moodle_url('/enrol/unenroluser.php', $params);
|
||||
$actionparams = array('class' => 'unenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_UNENROL);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url,
|
||||
array('class' => 'unenrollink', 'rel' => $ue->id));
|
||||
$actionparams);
|
||||
}
|
||||
if ($this->allow_manage($instance) && has_capability("enrol/lti: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));
|
||||
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/edit', ''), get_string('edit'), $url, $actionparams);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
@@ -376,11 +376,14 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
$params['ue'] = $ue->id;
|
||||
if ($this->allow_unenrol_user($instance, $ue) && has_capability("enrol/manual:unenrol", $context)) {
|
||||
$url = new moodle_url('/enrol/unenroluser.php', $params);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
|
||||
$actionparams = array('class' => 'unenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_UNENROL);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url,
|
||||
$actionparams);
|
||||
}
|
||||
if ($this->allow_manage($instance) && has_capability("enrol/manual: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));
|
||||
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/edit', ''), get_string('edit'), $url, $actionparams);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
+3
-1
@@ -110,7 +110,9 @@ class enrol_meta_plugin extends enrol_plugin {
|
||||
$params['ue'] = $ue->id;
|
||||
if ($this->allow_unenrol_user($instance, $ue) && has_capability('enrol/meta:unenrol', $context)) {
|
||||
$url = new moodle_url('/enrol/unenroluser.php', $params);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
|
||||
$actionparams = array('class' => 'unenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_UNENROL);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url,
|
||||
$actionparams);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
@@ -291,11 +291,14 @@ class enrol_paypal_plugin extends enrol_plugin {
|
||||
$params['ue'] = $ue->id;
|
||||
if ($this->allow_unenrol($instance) && has_capability("enrol/paypal:unenrol", $context)) {
|
||||
$url = new moodle_url('/enrol/unenroluser.php', $params);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
|
||||
$actionparams = array('class' => 'unenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_UNENROL);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url,
|
||||
$actionparams);
|
||||
}
|
||||
if ($this->allow_manage($instance) && has_capability("enrol/paypal: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));
|
||||
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/edit', ''), get_string('edit'), $url, $actionparams);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
+5
-2
@@ -536,11 +536,14 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
$params['ue'] = $ue->id;
|
||||
if ($this->allow_unenrol($instance) && has_capability("enrol/self:unenrol", $context)) {
|
||||
$url = new moodle_url('/enrol/unenroluser.php', $params);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
|
||||
$actionparams = array('class' => 'unenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_UNENROL);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url,
|
||||
$actionparams);
|
||||
}
|
||||
if ($this->allow_manage($instance) && has_capability("enrol/self: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));
|
||||
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/edit', ''), get_string('edit'), $url, $actionparams);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,12 @@ define('ENROL_SEND_EMAIL_FROM_KEY_HOLDER', 2);
|
||||
*/
|
||||
define('ENROL_SEND_EMAIL_FROM_NOREPLY', 3);
|
||||
|
||||
/** Edit enrolment action. */
|
||||
define('ENROL_ACTION_EDIT', 'editenrolment');
|
||||
|
||||
/** Unenrol action. */
|
||||
define('ENROL_ACTION_UNENROL', 'unenrol');
|
||||
|
||||
/**
|
||||
* Returns instances of enrol plugins
|
||||
* @param bool $enabled return enabled only
|
||||
|
||||
@@ -25,6 +25,13 @@ information provided here is intended especially for developers.
|
||||
every form. The method should accept a single parameter with the submitted value. It should return a string with the
|
||||
eventual validation error, or an empty value if the validation passes.
|
||||
* New user_picture attribute $includefullname to determine whether to include the user's full name with the user's picture.
|
||||
* Enrol plugins which provide enrolment actions can now declare the following "data-action" attributes in their implementation of
|
||||
enrol_plugin::get_user_enrolment_actions() whenever applicable:
|
||||
* "editenrolment" - For editing a user'e enrolment details. Defined by constant ENROL_ACTION_EDIT.
|
||||
* "unenrol" - For unenrolling a student. Defined by constant ENROL_ACTION_UNENROL.
|
||||
These attributes enable enrol actions to be rendered via modals. If not added, clicking on the enrolment action buttons will still
|
||||
redirect the user to the appropriate enrolment action page. Though optional, it is recommended to add these attributes for a
|
||||
better user experience when performing enrol actions.
|
||||
|
||||
=== 3.3.1 ===
|
||||
|
||||
|
||||
Reference in New Issue
Block a user