Skip to content

Commit

Permalink
Merge branch 'MDL-59756-master-2' of git://github.com/junpataleta/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Aug 15, 2017
2 parents 245227f + 654f52d commit 19e8e56
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 44 deletions.
12 changes: 6 additions & 6 deletions enrol/flatfile/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ public function get_user_enrolment_actions(course_enrolment_manager $manager, $u
$instance = $ue->enrolmentinstance;
$params = $manager->get_moodlepage()->url->params();
$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);
$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')),
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);
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
$actions[] = new user_enrolment_action(new pix_icon('t/edit', get_string('editenrolment', 'enrol')),
get_string('editenrolment', 'enrol'), $url, $actionparams);
}
if ($this->allow_unenrol_user($instance, $ue) && has_capability("enrol/flatfile: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')),
get_string('unenrol', 'enrol'), $url, $actionparams);
}
return $actions;
}

Expand Down
12 changes: 6 additions & 6 deletions enrol/lti/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,18 +390,18 @@ public function get_user_enrolment_actions(course_enrolment_manager $manager, $u
$instance = $ue->enrolmentinstance;
$params = $manager->get_moodlepage()->url->params();
$params['ue'] = $ue->id;
if ($this->allow_manage($instance) && has_capability("enrol/lti:manage", $context)) {
$url = new moodle_url('/enrol/editenrolment.php', $params);
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
$actions[] = new user_enrolment_action(new pix_icon('t/edit', get_string('editenrolment', 'enrol')),
get_string('editenrolment', 'enrol'), $url, $actionparams);
}
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')),
get_string('unenrol', 'enrol'), $url, $actionparams);
}
if ($this->allow_manage($instance) && has_capability("enrol/lti:manage", $context)) {
$url = new moodle_url('/enrol/editenrolment.php', $params);
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
$actions[] = new user_enrolment_action(new pix_icon('t/edit', get_string('editenrolment', 'enrol')),
get_string('editenrolment', 'enrol'), $url, $actionparam);
}
return $actions;
}

Expand Down
12 changes: 6 additions & 6 deletions enrol/manual/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,18 @@ public function get_user_enrolment_actions(course_enrolment_manager $manager, $u
$instance = $ue->enrolmentinstance;
$params = $manager->get_moodlepage()->url->params();
$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);
$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')),
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);
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
$actions[] = new user_enrolment_action(new pix_icon('t/edit', get_string('editenrolment', 'enrol')),
get_string('editenrolment', 'enrol'), $url, $actionparams);
}
if ($this->allow_unenrol_user($instance, $ue) && has_capability("enrol/manual: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')),
get_string('unenrol', 'enrol'), $url, $actionparams);
}
return $actions;
}

Expand Down
12 changes: 6 additions & 6 deletions enrol/paypal/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,18 +289,18 @@ public function get_user_enrolment_actions(course_enrolment_manager $manager, $u
$instance = $ue->enrolmentinstance;
$params = $manager->get_moodlepage()->url->params();
$params['ue'] = $ue->id;
if ($this->allow_unenrol($instance) && has_capability("enrol/paypal: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')),
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);
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
$actions[] = new user_enrolment_action(new pix_icon('t/edit', get_string('editenrolment', 'enrol')),
get_string('editenrolment', 'enrol'), $url, $actionparams);
}
if ($this->allow_unenrol($instance) && has_capability("enrol/paypal: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')),
get_string('unenrol', 'enrol'), $url, $actionparams);
}
return $actions;
}

Expand Down
12 changes: 6 additions & 6 deletions enrol/self/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,18 @@ public function get_user_enrolment_actions(course_enrolment_manager $manager, $u
$instance = $ue->enrolmentinstance;
$params = $manager->get_moodlepage()->url->params();
$params['ue'] = $ue->id;
if ($this->allow_unenrol($instance) && has_capability("enrol/self: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')),
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);
$actionparams = array('class' => 'editenrollink', 'rel' => $ue->id, 'data-action' => ENROL_ACTION_EDIT);
$actions[] = new user_enrolment_action(new pix_icon('t/edit', get_string('editenrolment', 'enrol')),
get_string('editenrolment', 'enrol'), $url, $actionparams);
}
if ($this->allow_unenrol($instance) && has_capability("enrol/self: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')),
get_string('unenrol', 'enrol'), $url, $actionparams);
}
return $actions;
}

Expand Down
2 changes: 1 addition & 1 deletion user/amd/build/status_field.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 29 additions & 4 deletions user/amd/src/status_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,37 @@ define(['core/templates',
"timeend": parentContainer.data('timeend')
};

var modalTitlePromise = Str.get_string('enroldetails', 'enrol');
// Get default string for the modal and modal type.
var strings = [
{
key: 'enroldetails',
component: 'enrol'
}
];

// Find the edit enrolment link.
var editEnrolLink = detailsButton.next(SELECTORS.EDIT_ENROLMENT);
if (editEnrolLink.length) {
// If there's an edit enrolment link for this user, clone it into the context for the modal.
context.editenrollink = $('<div>').append(editEnrolLink.clone()).html();
}

var modalStringsPromise = Str.get_strings(strings);
var modalPromise = ModalFactory.create({large: true, type: ModalFactory.types.CANCEL});
$.when(modalTitlePromise, modalPromise).done(function(modalTitle, modal) {
$.when(modalStringsPromise, modalPromise).done(function(strings, modal) {
var modalBodyPromise = Template.render('core_user/status_details', context);
modal.setTitle(modalTitle);
modal.setTitle(strings[0]);
modal.setBody(modalBodyPromise);

if (editEnrolLink.length) {
modal.getRoot().on('click', SELECTORS.EDIT_ENROLMENT, function(e) {
e.preventDefault();
modal.hide();
// Trigger click event for the edit enrolment link to show the edit enrolment modal.
$(editEnrolLink).trigger('click');
});
}

modal.show();

// Handle hidden event.
Expand Down Expand Up @@ -320,4 +345,4 @@ define(['core/templates',
(new StatusFieldActions(config));
}
};
});
});
2 changes: 1 addition & 1 deletion user/templates/status_details.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
{{#str}}enrolmentmethod, enrol{{/str}}
</th>
<td class="user-enrol-instance">
{{enrolinstancename}}
{{enrolinstancename}} {{{editenrollink}}}
</td>
</tr>
<tr>
Expand Down
Loading

0 comments on commit 19e8e56

Please sign in to comment.