Skip to content

Commit

Permalink
MDL-23048 applying the same frontpage logic on all permissions pages
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 13, 2010
1 parent 946191f commit 8a27af4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
14 changes: 6 additions & 8 deletions admin/roles/check.php
Expand Up @@ -33,7 +33,10 @@

$url = new moodle_url('/admin/roles/check.php', array('contextid' => $contextid));

if (!$course) {
if ($course) {
$isfrontpage = ($course->id == SITEID);
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
Expand All @@ -54,7 +57,6 @@

$courseid = $course->id;
$contextname = print_context_name($context);
$isfrontpage = ($course->id == SITEID);

// Get the user_selector we will need.
// Teachers within a course just get to see the same list of people they can
Expand All @@ -79,12 +81,8 @@
admin_externalpage_setup('checkpermissions', '', array('contextid' => $contextid));
break;
case CONTEXT_USER:
if ($isfrontpage) {
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
} else {
$PAGE->set_heading($course->fullname);
}
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
$showroles = 1;
break;
case CONTEXT_COURSECAT:
Expand Down
14 changes: 6 additions & 8 deletions admin/roles/override.php
Expand Up @@ -34,7 +34,10 @@

$url = new moodle_url('/admin/roles/override.php', array('contextid' => $contextid, 'roleid' => $roleid));

if (!$course) {
if ($course) {
$isfrontpage = ($course->id == SITEID);
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
Expand All @@ -54,7 +57,6 @@
$PAGE->set_context($context);

$courseid = $course->id;
$isfrontpage = ($course->id == SITEID);

$returnurl = new moodle_url('/admin/roles/permissions.php', array('contextid' => $context->id));

Expand Down Expand Up @@ -85,12 +87,8 @@
print_error('cannotoverridebaserole', 'error');
break;
case CONTEXT_USER:
if ($isfrontpage) {
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
} else {
$PAGE->set_heading($course->fullname);
}
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
$showroles = 1;
break;
case CONTEXT_COURSECAT:
Expand Down
14 changes: 6 additions & 8 deletions admin/roles/permissions.php
Expand Up @@ -42,7 +42,10 @@

$url = new moodle_url('/admin/roles/permissions.php', array('contextid' => $contextid));

if (!$course) {
if ($course) {
$isfrontpage = ($course->id == SITEID);
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
Expand All @@ -59,7 +62,6 @@
$PAGE->set_url($url);
$PAGE->set_context($context);
$courseid = $course->id;
$isfrontpage = ($course->id == SITEID);


// These are needed early because of tabs.php
Expand All @@ -84,12 +86,8 @@
print_error('cannotoverridebaserole', 'error');
break;
case CONTEXT_USER:
if ($isfrontpage) {
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
} else {
$PAGE->set_heading($course->fullname);
}
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
$showroles = 1;
break;
case CONTEXT_COURSECAT:
Expand Down

0 comments on commit 8a27af4

Please sign in to comment.