Commit 2447fe3d authored by Tony Butler's avatar Tony Butler

Add site option to prevent display of usernames (Bug #1353516)

Change-Id: I0c2db9c1fefcea2dfd7e442729ee0d46e822a781
Signed-off-by: default avatarTony Butler <tonyjbutler@gmail.com>
parent bae6eff1
......@@ -140,6 +140,13 @@ $siteoptionform = array(
'defaultvalue' => get_config('userscanhiderealnames'),
'disabled' => in_array('userscanhiderealnames', $OVERRIDDEN),
),
'nousernames' => array(
'type' => 'checkbox',
'title' => get_string('nousernames', 'admin'),
'description' => get_string('nousernamesdescription', 'admin'),
'defaultvalue' => get_config('nousernames'),
'disabled' => in_array('nousernames', $OVERRIDDEN),
),
'searchusernames' => array(
'type' => 'checkbox',
'title' => get_string('searchusernames', 'admin'),
......@@ -773,7 +780,7 @@ function siteoptions_submit(Pieform $form, $values) {
'registerterms', 'licensemetadata', 'licenseallowcustom', 'allowmobileuploads', 'creategroups', 'createpublicgroups', 'allowgroupcategories', 'wysiwyg',
'staffreports', 'staffstats', 'userscandisabledevicedetection', 'watchlistnotification_delay',
'masqueradingreasonrequired', 'masqueradingnotified', 'searchuserspublic',
'eventloglevel', 'eventlogexpiry', 'sitefilesaccess', 'exporttoqueue', 'defaultmultipleblogs',
'eventloglevel', 'eventlogexpiry', 'sitefilesaccess', 'exporttoqueue', 'defaultmultipleblogs', 'nousernames',
);
$count = 0;
$where_sql = " WHERE admin = 0 AND id != 0";
......
......@@ -360,6 +360,8 @@ $string['institutionexpirynotification'] = 'Warning time for institution expiry'
$string['institutionexpirynotificationdescriptioninfo'] = 'A notification message will be sent to site and institution administrators that long before an institution expires.';
$string['language'] = 'Language';
$string['none'] = 'None';
$string['nousernames'] = 'Never display usernames';
$string['nousernamesdescription'] = 'If checked, ordinary users will not be able to see the username of any other user.';
$string['onlineuserssideblockmaxusers'] = 'Online users limit';
$string['onlineuserssideblockmaxusersdescription'] = 'The maximum number of users to display in the online users sidebar.';
$string['country'] = 'Country';
......
......@@ -1029,10 +1029,11 @@ function display_name($user, $userto=null, $nameonly=false, $realname=false, $us
return display_default_name($user);
}
$nousernames = get_config('nousernames');
$userto = get_user_for_display($userto);
$user = get_user_for_display($user);
$addusername = $username || !empty($userto->admin) || !empty($userto->staff);
$addusername = ($username && empty($nousernames)) || !empty($userto->admin) || !empty($userto->staff) || $userto === $user;
// if they don't have a preferred name set, just return here
if (empty($user->preferredname)) {
......@@ -1826,7 +1827,7 @@ function get_users_data($userids, $getviews=true) {
$userid = $USER->get('id');
$data = get_records_sql_assoc($sql, array_merge(array($userid, $userid, $userid, $userid), $userids));
$allowhidename = get_config('userscanhiderealnames');
$showusername = get_config('searchusernames');
$showusername = !get_config('nousernames');
$institutionstrings = get_institution_strings_for_users($userids);
foreach ($data as &$record) {
......
......@@ -165,7 +165,7 @@ class ElasticsearchType_usr extends ElasticsearchType
$record->mainfacetterm = self::$mainfacetterm;
$allowhidename = get_config('userscanhiderealnames');
$showusername = get_config('searchusernames');
$showusername = !get_config('nousernames');
$record->sort = strtolower(strip_tags(display_name($record, null, false, !$allowhidename || !$record->hidenamepref, $showusername)));
return $record;
......
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