Skip to content

Commit

Permalink
MDL-45760 make sure to check permission before setting header
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy authored and danpoltawski committed Jul 7, 2014
1 parent 88ec9f3 commit 9dbf62d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
9 changes: 5 additions & 4 deletions notes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
$filtertype = optional_param('filtertype', '', PARAM_ALPHA);
$filterselect = optional_param('filterselect', 0, PARAM_INT);

if (empty($CFG->enablenotes)) {
print_error('notesdisabled', 'notes');
}

$url = new moodle_url('/notes/index.php');
if ($courseid != SITEID) {
$url->param('course', $courseid);
Expand Down Expand Up @@ -67,6 +71,7 @@
} else {
$coursecontext = context_course::instance($course->id); // Course context
}
require_capability('moodle/notes:view', $coursecontext);
$systemcontext = context_system::instance(); // SYSTEM context

// Trigger event.
Expand All @@ -76,10 +81,6 @@
));
$event->trigger();

if (empty($CFG->enablenotes)) {
print_error('notesdisabled', 'notes');
}

$strnotes = get_string('notes', 'notes');
if ($userid) {
$PAGE->set_context(context_user::instance($user->id));
Expand Down
20 changes: 10 additions & 10 deletions user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,6 @@
$systemcontext = context_system::instance();
$personalcontext = context_user::instance($user->id);

$PAGE->set_pagelayout('admin');
$PAGE->set_context($personalcontext);
if ($USER->id != $user->id) {
$PAGE->navigation->extend_for_user($user);
} else {
if ($node = $PAGE->navigation->find('myprofile', navigation_node::TYPE_ROOTNODE)) {
$node->force_open();
}
}

// Check access control.
if ($user->id == $USER->id) {
// Editing own profile - require_login() MUST NOT be used here, it would result in infinite loop!
Expand Down Expand Up @@ -140,6 +130,16 @@
die;
}

$PAGE->set_pagelayout('admin');
$PAGE->set_context($personalcontext);
if ($USER->id != $user->id) {
$PAGE->navigation->extend_for_user($user);
} else {
if ($node = $PAGE->navigation->find('myprofile', navigation_node::TYPE_ROOTNODE)) {
$node->force_open();
}
}

// Process email change cancellation.
if ($cancelemailchange) {
cancel_email_update($user->id);
Expand Down

0 comments on commit 9dbf62d

Please sign in to comment.