Commit 00a344a3 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow username to be turned off in display_name

parent c92a34be
......@@ -302,7 +302,7 @@ function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml='')
*
* @returns string name to display
*/
function display_name($user, $userto=null) {
function display_name($user, $userto=null, $nameonly=false) {
global $USER;
if (empty($userto)) {
......@@ -339,13 +339,13 @@ function display_name($user, $userto=null) {
// if they don't have a preferred name set, just return here
if (empty($user->preferredname)) {
if ($userto->admin || $userto->staff) {
if (($userto->admin || $userto->staff) && !$nameonly) {
return $user->firstname . ' ' . $user->lastname . ' (' . $user->username . ')';
}
return $user->firstname . ' ' . $user->lastname;
}
if ($userto->admin || $userto->staff) {
if (($userto->admin || $userto->staff) && !$nameonly) {
return $user->preferredname . ' (' . $user->firstname . ' ' . $user->lastname . ' - ' . $user->username . ')';
}
......@@ -355,7 +355,7 @@ function display_name($user, $userto=null) {
ON g1.group = g2.group
WHERE g1.member = ? AND g2.member = ? AND g2.tutor = ?';
if (record_exists_sql($sql, array($user->id, $userto->id, 1))) {
return $user->preferredname . ' (' . $user->firstname . ' ' . $user->lastname . ')';
return $user->preferredname . ($nameonly ? '' : ' (' . $user->firstname . ' ' . $user->lastname . ')');
}
return $user->preferredname;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment