Skip to content

Commit

Permalink
Fix #0011399: Deprecate $g_show_realname and use $g_show_user_realnam…
Browse files Browse the repository at this point in the history
…e_threshold instead
  • Loading branch information
mantis committed Mar 1, 2013
1 parent 04d848b commit 5d6b1bb
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 15 deletions.
6 changes: 0 additions & 6 deletions config_defaults_inc.php
Expand Up @@ -860,12 +860,6 @@
*/
$MantisConfig->show_version_dates_threshold = NOBODY;

/**
* show users with their real name or not
* @global int $g_show_realname
*/
$MantisConfig->show_realname = OFF;

/**
* leave off for now
* @global int $g_differentiate_duplicates
Expand Down
2 changes: 1 addition & 1 deletion core/filter_api.php
Expand Up @@ -3445,7 +3445,7 @@ function print_filter_reporter_id() {
$t_username = user_get_field( $t_id, 'username' );
$t_realname = user_get_field( $t_id, 'realname' );
$t_display_name = string_attribute( $t_username );
if(( isset( $t_realname ) ) && ( $t_realname > '' ) && ( ON == config_get( 'show_realname' ) ) ) {
if( ( isset( $t_realname ) ) && ( $t_realname > '' ) && ( access_has_project_level( config_get( 'show_user_realname_threshold' ) ) ) ) {
$t_display_name = string_attribute( $t_realname );
}
echo '<option value="' . $t_id . '" selected="selected">' . $t_display_name . '</option>';
Expand Down
4 changes: 3 additions & 1 deletion core/obsolete.php
Expand Up @@ -197,4 +197,6 @@
config_obsolete( 'sort_icon_arr', 'theme');
config_obsolete( 'content_expire', '' );
config_obsolete( 'page_title', 'top_include_page' );
config_obsolete( 'icon_path', 'theme' );
config_obsolete( 'icon_path', 'theme' );

config_obsolete( 'show_realname', 'show_user_realname_threshold' );
2 changes: 1 addition & 1 deletion core/print_api.php
Expand Up @@ -281,7 +281,7 @@ function print_user_option_list( $p_user_id, $p_project_id = null, $p_access = A

$t_display = array();
$t_sort = array();
$t_show_realname = ( ON == config_get( 'show_realname' ) );
$t_show_realname = ( access_has_project_level( config_get( 'show_user_realname_threshold', null, null, $p_project_id ) ) );
$t_sort_by_last_name = ( ON == config_get( 'sort_by_last_name' ) );
foreach( $t_users as $t_user ) {
$t_user_name = string_attribute( $t_user['username'] );
Expand Down
6 changes: 3 additions & 3 deletions core/user_api.php
Expand Up @@ -475,7 +475,7 @@ function user_get_realname( $p_user_id ) {

/**
* return the username or a string "user<id>" if the user does not exist
* if show_realname is set and real name is not empty, return it instead
* if show_user_realname_threshold is set and real name is not empty, return it instead
*
* @param int $p_user_id User ID
* @return string
Expand All @@ -487,7 +487,7 @@ function user_get_name( $p_user_id ) {
return _( 'user' ) . (int) $p_user_id;
}

if( ON == config_get( 'show_realname' ) ) {
if( access_has_project_level( config_get( 'show_user_realname_threshold' ) ) ) {
if( is_blank( $t_user->realname ) ) {
return $t_user->username;
} else {
Expand Down Expand Up @@ -797,7 +797,7 @@ function user_get_unassigned_by_project_id( $p_project_id = null ) {
$t_display = array();
$t_sort = array();
$t_users = array();
$t_show_realname = ( ON == config_get( 'show_realname' ) );
$t_show_realname = ( access_has_project_level( config_get( 'show_user_realname_threshold', null, null, $p_project_id ), $p_project_id ) );
$t_sort_by_last_name = ( ON == config_get( 'sort_by_last_name' ) );

while( $t_row = db_fetch_array( $t_result ) ) {
Expand Down
2 changes: 1 addition & 1 deletion manage/proj_edit_page.php
Expand Up @@ -498,7 +498,7 @@
foreach ( $t_users as $t_user ) {
$t_user_name = string_attribute( $t_user['username'] );
$t_sort_name = mb_strtolower( $t_user_name );
if ( ( isset( $t_user['realname'] ) ) && ( $t_user['realname'] > "" ) && ( ON == config_get( 'show_realname' ) ) ){
if ( ( isset( $t_user['realname'] ) ) && ( $t_user['realname'] > "" ) && ( access_has_project_level( config_get( 'show_user_realname_threshold', null, null, $f_project_id ), $f_project_id ) ) {
$t_user_name = string_attribute( $t_user['realname'] ) . " (" . $t_user_name . ")";
if ( ON == config_get( 'sort_by_last_name') ) {
$t_sort_name_bits = explode( ' ', mb_strtolower( $t_user_name ), 2 );
Expand Down
2 changes: 1 addition & 1 deletion plugins/XmlImportExport/ImportXml/Issue.php
Expand Up @@ -305,7 +305,7 @@ private function get_user_id( $p_username, $p_squash_userid = 0 ) {
$t_user_id = user_get_id_by_name( $p_username );
if( $t_user_id === false ) {
// user not found by username -> check real name
// keep in mind that the setting config_get( 'show_realname' ) may differ between import and export system!
// keep in mind that the setting config_get( 'show_user_realname_threshold' ) may differ between import and export system!
$t_user_id = user_get_id_by_realname( $p_username );
if ( $t_user_id === false ) {
//not found
Expand Down
2 changes: 1 addition & 1 deletion project_page.php
Expand Up @@ -112,7 +112,7 @@
$t_access_level_for_dev_team = config_get( 'development_team_threshold' );

$t_users = project_get_all_user_rows( $f_project_id, $t_access_level_for_dev_team );
$t_show_real_names = config_get( 'show_realname' ) == ON;
$t_show_real_names = access_has_project_level( config_get( 'show_user_realname_threshold', null, null, $f_project_id ) );

if ( count( $t_users ) > 0 ) {
echo '<h2>', _( 'Development Team' ), '</h2>';
Expand Down

3 comments on commit 5d6b1bb

@dregad
Copy link
Member

@dregad dregad commented on 5d6b1bb Mar 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you should do that - please see my comment http://www.mantisbt.org/bugs/view.php?id=11399#c31588

@grangeway
Copy link
Contributor

@grangeway grangeway commented on 5d6b1bb Mar 2, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dregad
Copy link
Member

@dregad dregad commented on 5d6b1bb Mar 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then what about view_user_page.php ?

Take the example of mantisbt.org - we work with usernames everywhere, but as developer you're allowed to see users' realnames in view_user_page.php.

With your change, 2 options

  • threshold = DEVELOPER : developers and above see realnames everywhere in the application (not what we want)
  • threshold = ADMINISTRATOR (or even NOBODY) : nobody can see realnames, except users in their own profile, and administrators in the manage user pages (also not what we want).

In both cases we lose functionality.

Please sign in to comment.