From 7057c3efa923c42c1cdd2e49ea6208c402ba2aee Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Wed, 30 Dec 2015 14:52:29 +0000 Subject: [PATCH] MDL-38020 participants: Use consistent link for editing enrollments Previously the role assignment url was used when a role was selected, but this page doesn't enrol users into the course (its the old 1.9 way before we had the enrollments table). --- user/index.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/user/index.php b/user/index.php index bb6e79501b0..9c93d117282 100644 --- a/user/index.php +++ b/user/index.php @@ -506,6 +506,11 @@ if (count($rolenames) > 1) { echo ''; } +$editlink = ''; +if ($course->id != SITEID && has_capability('moodle/course:enrolreview', $context)) { + $editlink = new moodle_url('/enrol/users.php', array('id' => $course->id)); +} + if ($roleid > 0) { $a = new stdClass(); $a->number = $totalcount; @@ -524,24 +529,22 @@ if ($roleid > 0) { $heading .= ": $a->number"; - if (user_can_assign($context, $roleid)) { - $headingurl = new moodle_url($CFG->wwwroot . '/' . $CFG->admin . '/roles/assign.php', - array('roleid' => $roleid, 'contextid' => $context->id)); - $heading .= $OUTPUT->action_icon($headingurl, new pix_icon('t/edit', get_string('edit'))); + if (!empty($editlink)) { + $editlink->param('role', $roleid); + $heading .= $OUTPUT->action_icon($editlink, new pix_icon('t/edit', get_string('edit'))); } echo $OUTPUT->heading($heading, 3); } else { - if ($course->id != SITEID && has_capability('moodle/course:enrolreview', $context)) { - $editlink = $OUTPUT->action_icon(new moodle_url('/enrol/users.php', array('id' => $course->id)), - new pix_icon('t/edit', get_string('edit'))); - } else { - $editlink = ''; - } if ($course->id == SITEID and $roleid < 0) { $strallparticipants = get_string('allsiteusers', 'role'); } else { $strallparticipants = get_string('allparticipants'); } + + if (!empty($editlink)) { + $editlink = $OUTPUT->action_icon($editlink, new pix_icon('t/edit', get_string('edit'))); + } + if ($matchcount < $totalcount) { echo $OUTPUT->heading($strallparticipants.get_string('labelsep', 'langconfig').$matchcount.'/'.$totalcount . $editlink, 3); } else {