if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
$PAGE->navigation->extend_for_user($user);
- $PAGE->set_context(context_course::instance($course->id));
+ $PAGE->set_context(context_user::instance($user->id));
} else {
$PAGE->set_context($context);
}
$title = get_string('mybackpack', 'badges');
$PAGE->set_title($title);
-$PAGE->set_heading($title);
+$PAGE->set_heading(fullname($USER));
$PAGE->set_pagelayout('mydashboard');
$backpack = $DB->get_record('badge_backpack', array('userid' => $USER->id));
}
echo $OUTPUT->header();
+echo $OUTPUT->heading($title);
$form->display();
echo $OUTPUT->footer();
$title = get_string('mybadges', 'badges');
$PAGE->set_title($title);
-$PAGE->set_heading($title);
+$PAGE->set_heading(fullname($USER));
$PAGE->set_pagelayout('mydashboard');
// Include JS files for backpack support.
$url = new moodle_url('/badges/preferences.php');
require_login();
-$PAGE->set_context(context_system::instance());
+$PAGE->set_context(context_user::instance($USER->id));
$PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
$title = "$strbadges: $strpreferences";
$PAGE->set_title($title);
-$PAGE->set_heading($title);
+$PAGE->set_heading(fullname($USER));
echo $OUTPUT->header();
echo $OUTPUT->heading("$strbadges: $strpreferences", 2);
$id = null;
}
-// Blogs are always in system context.
$sitecontext = context_system::instance();
-$PAGE->set_context($sitecontext);
+$usercontext = context_user::instance($USER->id);
+$PAGE->set_context($usercontext);
require_login($courseid);
}
} else if ($action == 'add') {
$PAGE->set_title("$SITE->shortname: $strblogs: " . get_string('addnewentry', 'blog'));
- $PAGE->set_heading($SITE->shortname);
+ $PAGE->set_heading(fullname($USER));
} else if ($action == 'edit') {
$PAGE->set_title("$SITE->shortname: $strblogs: " . get_string('editentry', 'blog'));
- $PAGE->set_heading($SITE->shortname);
+ $PAGE->set_heading(fullname($USER));
}
if (!empty($entry->id)) {
$url->param('id', $id);
}
$PAGE->set_url($url);
-$PAGE->set_context($context);
+$PAGE->set_context(context_user::instance($USER->id));
$PAGE->set_pagelayout('admin');
$returnurl = new moodle_url('/blog/external_blogs.php');
redirect($returnurl);
}
-$PAGE->set_heading("$SITE->shortname: $strblogs: $strexternalblogs", $SITE->fullname);
+$PAGE->set_heading(fullname($USER));
$PAGE->set_title("$SITE->shortname: $strblogs: $strexternalblogs");
echo $OUTPUT->header();
require_login();
$context = context_system::instance();
-$PAGE->set_context($context);
+$PAGE->set_context(context_user::instance($USER->id));
$PAGE->set_url(new moodle_url('/blog/external_blogs.php'));
require_capability('moodle/blog:manageexternal', $context);
$blogs = $DB->get_records('blog_external', array('userid' => $USER->id));
-$PAGE->set_heading("$SITE->shortname: $strblogs: $strexternalblogs", $SITE->fullname);
+$PAGE->set_heading(fullname($USER));
$PAGE->set_title("$SITE->shortname: $strblogs: $strexternalblogs");
$PAGE->set_pagelayout('standard');
}
}
+if (isset($userid)) {
+ $context = context_user::instance($userid);
+} else {
+ $context = context_system::instance();
+}
+$PAGE->set_context($context);
+
$sitecontext = context_system::instance();
-// Blogs are always in system context.
-$PAGE->set_context($sitecontext);
// Check basic permissions.
if ($CFG->bloglevel == BLOG_GLOBAL_LEVEL) {
blog_rss_add_http_header($rsscontext, $rsstitle, $filtertype, $thingid, $tagid);
}
}
+if (isset($userid)) {
+ $PAGE->set_heading(fullname($user));
+}
echo $OUTPUT->header();
-
echo $OUTPUT->heading($blogheaders['heading'], 2);
$bloglisting = new blog_listing($blogheaders['filters']);
$PAGE->set_pagelayout('admin');
$sitecontext = context_system::instance();
-$PAGE->set_context($sitecontext);
+$usercontext = context_user::instance($USER->id);
+$PAGE->set_context($usercontext);
require_login($courseid);
if (empty($CFG->enableblogs)) {
$title = "$site->shortname: $strblogs : $strpreferences";
$PAGE->set_title($title);
-$PAGE->set_heading($title);
+$PAGE->set_heading(fullname($USER));
echo $OUTPUT->header();
$context = context_course::instance($course->id);
$systemcontext = context_system::instance();
$personalcontext = null;
-$PAGE->set_context($context);
// If we are accessing the page from a site context then ignore this check.
if ($courseid != SITEID) {
$personalcontext = context_user::instance($userid);
}
+if (isset($personalcontext)) {
+ $PAGE->set_context($personalcontext);
+} else {
+ $PAGE->set_context($context);
+}
+
$access = false;
if (has_capability('moodle/grade:viewall', $systemcontext)) {
// Ok - can view all course grades.
// Display a standard page.
if ($courseid == SITEID) {
$PAGE->set_pagelayout('standard');
- $header = get_string('mygrades', 'grades'). ' - '.fullname($report->user);
+ $header = get_string('mygrades', 'grades') . ' - ' . fullname($report->user);
$PAGE->set_title($header);
- $PAGE->set_heading($header);
+ $PAGE->set_heading(fullname($report->user));
if ($USER->id != $report->user->id) {
$PAGE->navigation->extend_for_user($report->user);
$fullname = fullname($USER, true);
$PAGE->set_title($strpasswordchanged);
- $PAGE->set_heading($COURSE->fullname);
+ $PAGE->set_heading(fullname($USER));
echo $OUTPUT->header();
notice($strpasswordchanged, new moodle_url($PAGE->url, array('return'=>1)));
$fullname = fullname($USER, true);
$PAGE->set_title($strchangepassword);
-$PAGE->set_heading($COURSE->fullname);
+$PAGE->set_heading($fullname);
echo $OUTPUT->header();
if (get_user_preferences('auth_forcepasswordchange')) {
/// Display page header
$strmessaging = get_string('messaging', 'message');
$PAGE->set_title($strmessaging);
-$PAGE->set_heading($strmessaging);
+$PAGE->set_heading(fullname($USER));
// Grab the renderer
$renderer = $PAGE->get_renderer('core', 'message');
$PAGE->set_pagelayout('incourse');
} else {
$PAGE->set_pagelayout('standard');
- $PAGE->set_context(context_user::instance($user1->id));
}
+// Page context should always be set to user.
+$PAGE->set_context(context_user::instance($user1->id));
if (!empty($user1->id) && $user1->id != $USER->id) {
$PAGE->navigation->extend_for_user($user1);
}
$user2fullname = fullname($user2);
$PAGE->set_title("$strmessages: $user2fullname");
- $PAGE->set_heading("$strmessages: $user2fullname");
} else {
$PAGE->set_title("{$SITE->shortname}: $strmessages");
- $PAGE->set_heading("{$SITE->shortname}: $strmessages");
}
+$PAGE->set_heading(fullname($USER));
//now the page contents
echo $OUTPUT->header();
{
case CONTEXT_COURSE:
case CONTEXT_SYSTEM:
+ case CONTEXT_USER:
// OK, expected context level.
break;
default:
// Unexpected contextlevel.
- throw new \coding_exception('Context level must be either CONTEXT_SYSTEM or CONTEXT_COURSE.');
+ throw new \coding_exception('Context level must be either CONTEXT_SYSTEM, CONTEXT_COURSE or CONTEXT_USER.');
}
}
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'Context level must be either CONTEXT_SYSTEM or CONTEXT_COURSE.');
+ $this->setExpectedException('coding_exception',
+ 'Context level must be either CONTEXT_SYSTEM, CONTEXT_COURSE or CONTEXT_USER.');
\mod_forum\event\user_report_viewed::create($params);
}
// We are going to search for all of the users posts in all courses!
// a general require login here as we arn't actually within any course.
require_login();
- $PAGE->set_context(context_system::instance());
+ $PAGE->set_context(context_user::instance($user->id));
// Now we need to get all of the courses to search.
// All courses where the user has posted within a forum will be returned.
$courses = forum_get_courses_user_posted_in($user, $discussionsonly);
}
-
$params = array(
'context' => $PAGE->context,
'relateduserid' => $user->id,
// Display a page letting the user know that there's nothing to display;
$PAGE->set_title($pagetitle);
- $PAGE->set_heading($pageheading);
+ if ($isspecificcourse) {
+ $PAGE->set_heading($pageheading);
+ } else {
+ $PAGE->set_heading(fullname($user));
+ }
echo $OUTPUT->header();
echo $OUTPUT->heading($pagetitle);
echo $OUTPUT->notification($notification);
}
$PAGE->set_title($pagetitle);
-$PAGE->set_heading($pagetitle);
+$PAGE->set_heading($pageheading);
+
$PAGE->navigation->extend_for_user($user);
$PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
$userid = $USER->id; // Owner of the page
$context = context_user::instance($USER->id);
$PAGE->set_blocks_editing_capability('moodle/my:manageblocks');
- $header = "$SITE->shortname: $strmymoodle";
+ $header = fullname($USER);
}
// Get the My Moodle page info. Should always return something unless the database is broken.
print_error('mymoodlesetup');
}
-if (!$currentpage->userid) {
- $context = context_system::instance(); // So we even see non-sticky blocks
-}
-
// Start setting up the page
$params = array();
$PAGE->set_context($context);
}
} else if ($edit !== null) { // Editing state was specified
$USER->editing = $edit; // Change editing state
- if (!$currentpage->userid && $edit) {
- // If we are viewing a system page as ordinary user, and the user turns
- // editing on, copy the system pages as new user pages, and get the
- // new page record
- if (!$currentpage = my_copy_page($USER->id, MY_PAGE_PRIVATE)) {
- print_error('mymoodlesetup');
- }
- $context = context_user::instance($USER->id);
- $PAGE->set_context($context);
- $PAGE->set_subpage($currentpage->id);
- }
} else { // Editing state is in session
if ($currentpage->userid) { // It's a page we can edit, so load from session
if (!empty($USER->editing)) {
} else {
$edit = 0;
}
- } else { // It's a system page and they are not allowed to edit system pages
+ } else {
+ // For the page to display properly with the user context header the page blocks need to
+ // be copied over to the user context.
+ if (!$currentpage = my_copy_page($USER->id, MY_PAGE_PRIVATE)) {
+ print_error('mymoodlesetup');
+ }
+ $context = context_user::instance($USER->id);
+ $PAGE->set_context($context);
+ $PAGE->set_subpage($currentpage->id);
+ // It's a system page and they are not allowed to edit system pages
$USER->editing = $edit = 0; // Disable editing completely, just to be safe
}
}
$USER->editing = $edit = 0;
}
-// HACK WARNING! This loads up all this page's blocks in the system context
-if ($currentpage->userid == 0) {
- $CFG->blockmanagerclass = 'my_syspage_block_manager';
-}
-
-
echo $OUTPUT->header();
echo $OUTPUT->custom_block_region('content');
$PAGE->set_pagelayout('incourse');
$PAGE->set_title($course->shortname . ': ' . $strnotes);
-$PAGE->set_heading($course->fullname);
+$PAGE->set_heading(fullname($USER));
echo $OUTPUT->header();
if ($userid) {
$coursecontext = context_course::instance($course->id);
$personalcontext = context_user::instance($user->id);
+if ($courseid == SITEID) {
+ $PAGE->set_context($personalcontext);
+}
+
if ($USER->id != $user->id and has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)
and !is_enrolled($coursecontext, $USER) and is_enrolled($coursecontext, $user)) {
//TODO: do not require parents to be enrolled in courses - this is a hack!
$PAGE->navigation->extend_for_user($user);
$PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
$PAGE->set_title("$course->shortname: $stractivityreport");
-$PAGE->set_heading($course->fullname);
+if ($courseid == SITEID) {
+ $PAGE->set_heading(fullname($user));
+} else {
+ $PAGE->set_heading($course->fullname);
+}
// Trigger a user logs viewed event.
$event = \report_log\event\user_report_viewed::create(array('context' => $coursecontext, 'relateduserid' => $userid,
$coursecontext = context_course::instance($course->id);
$personalcontext = context_user::instance($user->id);
+if ($courseid == SITEID) {
+ $PAGE->set_context($personalcontext);
+}
+
if ($USER->id != $user->id and has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)
and !is_enrolled($coursecontext, $USER) and is_enrolled($coursecontext, $user)) {
//TODO: do not require parents to be enrolled in courses - this is a hack!
$PAGE->navigation->extend_for_user($user);
$PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
$PAGE->set_title("$course->shortname: $stractivityreport");
-$PAGE->set_heading($course->fullname);
+if ($courseid == SITEID) {
+ $PAGE->set_heading(fullname($user));
+} else {
+ $PAGE->set_heading($course->fullname);
+}
// Trigger a report viewed event.
$event = \report_outline\event\report_viewed::create(array('context' => context_course::instance($course->id),
$PAGE->set_url('/report/usersessions/user.php');
$PAGE->set_context($context);
$PAGE->set_title(get_string('navigationlink', 'report_usersessions'));
+$PAGE->set_heading(fullname($USER));
$PAGE->set_pagelayout('admin');
if ($delete and confirm_sesskey()) {
$userfullname = fullname($user, true);
$PAGE->set_title("$course->shortname: $streditmyprofile");
-$PAGE->set_heading($course->fullname);
+$PAGE->set_heading($userfullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($userfullname);
if ($user->id == -1) {
echo $OUTPUT->header();
} else {
- $PAGE->set_heading($SITE->fullname);
- echo $OUTPUT->header();
$userfullname = fullname($user, true);
+ $PAGE->set_heading($userfullname);
+ echo $OUTPUT->header();
echo $OUTPUT->heading($userfullname);
}
} else if (!empty($USER->newadminuser)) {
$userfullname = fullname($user, true);
$PAGE->set_title("$course->shortname: $streditmyprofile");
- $PAGE->set_heading($course->fullname);
+ $PAGE->set_heading($userfullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($userfullname);
$PAGE->set_url('/user/files.php');
$PAGE->set_context($context);
$PAGE->set_title($title);
-$PAGE->set_heading($title);
+$PAGE->set_heading(fullname($USER));
$PAGE->set_pagelayout('mydashboard');
$PAGE->set_pagetype('user-files');
$PAGE->set_url('/user/preferences.php', array('userid' => $userid));
$PAGE->set_pagelayout('admin');
$PAGE->set_pagetype('user-preferences');
+$PAGE->set_title(fullname($user));
+$PAGE->set_heading(fullname($user));
if (!$currentuser) {
- $PAGE->set_title(fullname($user));
- $PAGE->set_heading(fullname($user));
-
$PAGE->navigation->extend_for_user($user);
$settings = $PAGE->settingsnav->get('userviewingsettings' . $user->id);
} else {
- $PAGE->set_title(get_string('preferences'));
- $PAGE->set_heading(get_string('preferences'));
-
$settings = $PAGE->settingsnav->get('usercurrentsettings');
}
$struser = get_string('user');
$PAGE->set_context(context_system::instance());
$PAGE->set_title("$SITE->shortname: $struser"); // Do not leak the name.
- $PAGE->set_heading("$SITE->shortname: $struser");
+ $PAGE->set_heading($struser);
$PAGE->set_url('/user/profile.php', array('id' => $userid));
$PAGE->navbar->add($struser);
echo $OUTPUT->header();
print_error('mymoodlesetup');
}
-if (!$currentpage->userid) {
- $context = context_system::instance(); // A trick so that we even see non-sticky blocks.
-}
-
$PAGE->set_context($context);
$PAGE->set_pagelayout('mypublic');
$PAGE->set_pagetype('user-profile');
$PAGE->blocks->add_region('content');
$PAGE->set_subpage($currentpage->id);
$PAGE->set_title(fullname($user).": $strpublicprofile");
-$PAGE->set_heading(fullname($user).": $strpublicprofile");
+$PAGE->set_heading(fullname($user));
if (!$currentuser) {
$PAGE->navigation->extend_for_user($user);
}
} else if ($edit !== null) { // Editing state was specified.
$USER->editing = $edit; // Change editing state.
- if (!$currentpage->userid && $edit) {
- // If we are viewing a system page as ordinary user, and the user turns
- // editing on, copy the system pages as new user pages, and get the
- // new page record.
- if (!$currentpage = my_copy_page($userid, MY_PAGE_PUBLIC, 'user-profile')) {
- print_error('mymoodlesetup');
- }
- $PAGE->set_context($usercontext);
- $PAGE->set_subpage($currentpage->id);
- }
} else { // Editing state is in session.
if ($currentpage->userid) { // It's a page we can edit, so load from session.
if (!empty($USER->editing)) {
} else {
$edit = 0;
}
- } else { // It's a system page and they are not allowed to edit system pages.
+ } else {
+ // For the page to display properly with the user context header the page blocks need to
+ // be copied over to the user context.
+ if (!$currentpage = my_copy_page($userid, MY_PAGE_PUBLIC, 'user-profile')) {
+ print_error('mymoodlesetup');
+ }
+ $PAGE->set_context($usercontext);
+ $PAGE->set_subpage($currentpage->id);
+ // It's a system page and they are not allowed to edit system pages.
$USER->editing = $edit = 0; // Disable editing completely, just to be safe.
}
}
$USER->editing = $edit = 0;
}
-// HACK WARNING! This loads up all this page's blocks in the system context.
-if ($currentpage->userid == 0) {
- $CFG->blockmanagerclass = 'my_syspage_block_manager';
-}
-
// Trigger a user profile viewed event.
profile_view($user, $usercontext);