Skip to content

Commit

Permalink
MDL-72287 report: Add back link and headings in user profile pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihail Geshoski committed Dec 9, 2021
1 parent b9d1aaa commit d000b16
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 4 deletions.
5 changes: 4 additions & 1 deletion blog/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
}
$PAGE->set_context($context);

if (isset($userid) && $USER->id == $userid) {
if (isset($userid) && $USER->id == $userid && !$PAGE->has_secondary_navigation()) {
$blognode = $PAGE->navigation->find('siteblog', null);
if ($blognode) {
$blognode->make_inactive();
Expand Down Expand Up @@ -153,6 +153,9 @@
if ($courseid != SITEID) {
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);

if (!empty($user)) {
$headerinfo = array('heading' => fullname($user), 'user' => $user);
echo $OUTPUT->context_header($headerinfo, 2);
Expand Down
24 changes: 21 additions & 3 deletions course/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@
$coursecontext = context_course::instance($course->id);
$personalcontext = context_user::instance($user->id);

$PAGE->set_context($personalcontext);
if ($id == SITEID) {
$PAGE->set_context($personalcontext);
$PAGE->set_heading(fullname($user));
} else {
$PAGE->set_context($coursecontext);
$PAGE->set_secondary_active_tab('participants');
$PAGE->set_heading($course->fullname);
}

$PAGE->set_url('/course/user.php', array('id'=>$id, 'user'=>$user->id, 'mode'=>$mode));

Expand Down Expand Up @@ -125,7 +132,6 @@
$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 ($mode)");
$PAGE->set_heading(fullname($user));

switch ($mode) {
case "grade":
Expand Down Expand Up @@ -166,6 +172,19 @@
}
echo $OUTPUT->header();

if ($course->id !== SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $user->id, 'course' => $course->id]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
$userheading = array(
'heading' => fullname($user, has_capability('moodle/site:viewfullnames', $PAGE->context)),
'user' => $user,
'usercontext' => $personalcontext,
);
echo $OUTPUT->context_header($userheading, 2);

echo $OUTPUT->heading(get_string('grades', 'moodle'), 2, 'main mt-4 mb-4');
}

if (empty($CFG->grade_profilereport) or !file_exists($CFG->dirroot.'/grade/report/'.$CFG->grade_profilereport.'/lib.php')) {
$CFG->grade_profilereport = 'user';
}
Expand All @@ -179,7 +198,6 @@
}
break;

break;
default:
// It's unlikely to reach this piece of code, as the mode is never empty and it sets mode as grade in most of the cases.
// Display the page header to avoid breaking the navigation. A course/user.php review will be done in MDL-49939.
Expand Down
2 changes: 2 additions & 0 deletions mod/forum/lang/en/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
$string['discussionstartedby'] = 'Discussion started by {$a}';
$string['discussionsstartedbyrecent'] = 'Discussions recently started by {$a}';
$string['discussionsstartedbyuserincourse'] = 'Discussions started by {$a->fullname} in {$a->coursename}';
$string['discussionsstartedincourse'] = 'Discussions started in {$a}';
$string['discussionunpin'] = 'Unpin';
$string['discussionunsubscribed'] = 'You are now unsubscribed from this discussion.';
$string['discussthistopic'] = 'Discuss this topic';
Expand Down Expand Up @@ -525,6 +526,7 @@
$string['postsfrom'] = 'Posts from';
$string['postsmadebyuser'] = 'Posts made by {$a}';
$string['postsmadebyuserincourse'] = 'Posts made by {$a->fullname} in {$a->coursename}';
$string['postsmadeincourse'] = 'Posts made in {$a}';
$string['poststo'] = 'Posts to';
$string['posttoforum'] = 'Post to forum';
$string['postupdated'] = 'Your post was updated';
Expand Down
15 changes: 15 additions & 0 deletions mod/forum/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,18 @@
// Display a page letting the user know that there's nothing to display;
$PAGE->set_title($pagetitle);
if ($isspecificcourse) {
$PAGE->set_secondary_active_tab('participants');
$PAGE->set_heading($pageheading);
} else if ($canviewuser) {
$PAGE->set_heading(fullname($user));
} else {
$PAGE->set_heading($SITE->fullname);
}
echo $OUTPUT->header();
if (isset($courseid) && $courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
}
if (!$isspecificcourse) {
echo $OUTPUT->heading($pagetitle);
} else {
Expand Down Expand Up @@ -309,9 +314,15 @@
$navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid, 'mode' => 'discussions')));
}
$PAGE->set_secondary_active_tab('participants');
}

echo $OUTPUT->header();

if (isset($courseid) && $courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
}
echo html_writer::start_tag('div', array('class' => 'user-content'));

if ($isspecificcourse) {
Expand All @@ -321,6 +332,10 @@
'usercontext' => $usercontext
);
echo $OUTPUT->context_header($userheading, 2);
$coursename = format_string($course->fullname, true, array('context' => $coursecontext));
$heading = $mode === 'posts' ? get_string('postsmadeincourse', 'mod_forum', $coursename) :
get_string('discussionsstartedincourse', 'mod_forum', $coursename);
echo $OUTPUT->heading($heading, 2, 'main mt-4 mb-4');
} else {
echo $OUTPUT->heading($inpageheading);
}
Expand Down
3 changes: 3 additions & 0 deletions notes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
echo $OUTPUT->header();

if ($course->id != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);

$headerinfo = array('heading' => fullname($user), 'user' => $user);
echo $OUTPUT->context_header($headerinfo, 2);
}
Expand Down
8 changes: 8 additions & 0 deletions report/log/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,20 @@

echo $OUTPUT->header();
if ($courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);

$userheading = array(
'heading' => fullname($user, has_capability('moodle/site:viewfullnames', $PAGE->context)),
'user' => $user,
'usercontext' => $personalcontext,
);
echo $OUTPUT->context_header($userheading, 2);
if ($mode === 'today') {
echo $OUTPUT->heading(get_string('todaylogs', 'moodle'), 2, 'main mt-4 mb-4');
} else {
echo $OUTPUT->heading(get_string('alllogs', 'moodle'), 2, 'main mt-4 mb-4');
}
}

// Time to filter records from.
Expand Down
7 changes: 7 additions & 0 deletions report/outline/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,19 @@

echo $OUTPUT->header();
if ($courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
echo $OUTPUT->context_header(
array(
'heading' => fullname($user),
'user' => $user,
'usercontext' => $personalcontext
), 2);
if ($mode === 'outline') {
echo $OUTPUT->heading(get_string('outlinereport', 'moodle'), 2, 'main mt-4 mb-4');
} else {
echo $OUTPUT->heading(get_string('completereport', 'moodle'), 2, 'main mt-4 mb-4');
}
}

$modinfo = get_fast_modinfo($course, $user->id);
Expand Down
4 changes: 4 additions & 0 deletions report/stats/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@
$PAGE->set_heading($pageheading);
echo $OUTPUT->header();
if ($courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);

echo $OUTPUT->context_header(
array(
'heading' => $userfullname,
'user' => $user,
'usercontext' => $personalcontext
), 2);
echo $OUTPUT->heading(get_string('statistics', 'moodle'), 2, 'main mt-4 mb-4');
}

// Trigger a user report viewed event.
Expand Down

0 comments on commit d000b16

Please sign in to comment.