From 3a13707a0a4428c04a62595de8f1e27cad52f50c Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Mon, 13 Apr 2015 14:41:24 +0800 Subject: [PATCH] MDL-49819 navigation: Admin section in user profile update. The Admin section will now only show when the admin or someone with similar capabilities views the user profile. The edit profile link has also been moved. Part of MDL-45774. --- lib/myprofilelib.php | 9 +++++---- user/classes/output/myprofile/category.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/myprofilelib.php b/lib/myprofilelib.php index 8c12a467e2d..c0c5c2efc3a 100644 --- a/lib/myprofilelib.php +++ b/lib/myprofilelib.php @@ -72,7 +72,7 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, if (($iscurrentuser || is_siteadmin($USER) || !is_siteadmin($user)) && has_capability('moodle/user:update', $systemcontext)) { $url = new moodle_url('/user/editadvanced.php', array('id' => $user->id, 'course' => $courseid)); - $node = new core_user\output\myprofile\node('administration', 'editprofile', get_string('editmyprofile'), null, $url); + $node = new core_user\output\myprofile\node('contact', 'editprofile', get_string('editmyprofile'), null, $url); $tree->add_node($node); } else if ((has_capability('moodle/user:editprofile', $usercontext) && !is_siteadmin($user)) || ($iscurrentuser && has_capability('moodle/user:editownprofile', $systemcontext))) { @@ -89,14 +89,15 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $url = new moodle_url('/user/edit.php', array('userid' => $user->id, 'course' => $course->id)); } } - $node = new core_user\output\myprofile\node('administration', 'editprofile', + $node = new core_user\output\myprofile\node('contact', 'editprofile', get_string('editmyprofile'), null, $url); $tree->add_node($node); } } } - // Preference page. - if ($iscurrentuser || is_siteadmin()) { + + // Preference page. Only visible by administrators. + if (is_siteadmin()) { $url = new moodle_url('/user/preferences.php', array('userid' => $user->id)); $title = $iscurrentuser ? get_string('mypreferences') : get_string('userspreferences', 'moodle', fullname($user)); $node = new core_user\output\myprofile\node('administration', 'preferences', $title, null, $url); diff --git a/user/classes/output/myprofile/category.php b/user/classes/output/myprofile/category.php index 840d4dc1f5e..4fec047e9e3 100644 --- a/user/classes/output/myprofile/category.php +++ b/user/classes/output/myprofile/category.php @@ -113,7 +113,7 @@ class category implements \renderable { foreach ($this->nodes as $node) { $after = $node->after; $content = $node->content; - if ($after == null && !empty($content)) { + if (($after == null && !empty($content)) || $node->name === 'editprofile') { // Can go anywhere in the cat. Also show content nodes first. $tempnodes = array_merge($tempnodes, array($node->name => $node), $this->find_nodes_after($node)); } -- 2.43.0