mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-51712-master' of git://github.com/xow/moodle
This commit is contained in:
commit
96a6b6b20b
@ -39,7 +39,8 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user,
|
||||
|
||||
$usercontext = context_user::instance($user->id, MUST_EXIST);
|
||||
$systemcontext = context_system::instance();
|
||||
$context = !empty($course) ? context_course::instance($course->id) : $systemcontext;
|
||||
$courseorusercontext = !empty($course) ? context_course::instance($course->id) : $usercontext;
|
||||
$courseorsystemcontext = !empty($course) ? context_course::instance($course->id) : $systemcontext;
|
||||
$courseid = !empty($course) ? $course->id : SITEID;
|
||||
|
||||
$contactcategory = new core_user\output\myprofile\category('contact', get_string('userdetails'));
|
||||
@ -62,7 +63,7 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user,
|
||||
// Full profile node.
|
||||
if (!empty($course)) {
|
||||
if (empty($CFG->forceloginforprofiles) || $iscurrentuser ||
|
||||
has_capability('moodle/user:viewdetails', context_user::instance($user->id))
|
||||
has_capability('moodle/user:viewdetails', $usercontext)
|
||||
|| has_coursecontact_role($user->id)) {
|
||||
$url = new moodle_url('/user/profile.php', array('id' => $user->id));
|
||||
$node = new core_user\output\myprofile\node('miscellaneous', 'fullprofile', get_string('fullprofile'), null, $url);
|
||||
@ -113,7 +114,7 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user,
|
||||
// Login as ...
|
||||
if (!$user->deleted && !$iscurrentuser &&
|
||||
!\core\session\manager::is_loggedinas() && has_capability('moodle/user:loginas',
|
||||
$context) && !is_siteadmin($user->id)) {
|
||||
$courseorsystemcontext) && !is_siteadmin($user->id)) {
|
||||
$url = new moodle_url('/course/loginas.php',
|
||||
array('id' => $courseid, 'user' => $user->id, 'sesskey' => sesskey()));
|
||||
$node = new core_user\output\myprofile\node('administration', 'loginas', get_string('loginas'), null, $url);
|
||||
@ -121,12 +122,12 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user,
|
||||
}
|
||||
|
||||
// Contact details.
|
||||
if (has_capability('moodle/user:viewhiddendetails', $usercontext)) {
|
||||
if (has_capability('moodle/user:viewhiddendetails', $courseorusercontext)) {
|
||||
$hiddenfields = array();
|
||||
} else {
|
||||
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
|
||||
}
|
||||
if (has_capability('moodle/site:viewuseridentity', $context)) {
|
||||
if (has_capability('moodle/site:viewuseridentity', $courseorusercontext)) {
|
||||
$identityfields = array_flip(explode(',', $CFG->showuseridentity));
|
||||
} else {
|
||||
$identityfields = array();
|
||||
@ -152,7 +153,8 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user,
|
||||
|
||||
if (isset($identityfields['email']) and ($iscurrentuser
|
||||
or $user->maildisplay == 1
|
||||
or has_capability('moodle/course:useremail', $usercontext)
|
||||
or has_capability('moodle/course:useremail', $courseorusercontext)
|
||||
or has_capability('moodle/site:viewuseridentity', $courseorusercontext)
|
||||
or ($user->maildisplay == 2 and enrol_sharing_course($user, $USER)))) {
|
||||
$node = new core_user\output\myprofile\node('contact', 'email', get_string('email'), null, null,
|
||||
obfuscate_mailto($user->email, ''));
|
||||
@ -284,7 +286,7 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user,
|
||||
|
||||
// Show groups this user is in.
|
||||
if (!isset($hiddenfields['groups']) && !empty($course)) {
|
||||
$accessallgroups = has_capability('moodle/site:accessallgroups', $context);
|
||||
$accessallgroups = has_capability('moodle/site:accessallgroups', $courseorsystemcontext);
|
||||
if ($usergroups = groups_get_all_groups($course->id, $user->id)) {
|
||||
$groupstr = '';
|
||||
foreach ($usergroups as $group) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user