Index: account_update.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/account_update.php,v retrieving revision 1.36 diff -r1.36 account_update.php 58c58,93 < if ( $f_realname != user_get_name( $t_user_id ) ) { --- > if ( $f_realname != user_get_field( $t_user_id, 'realname' ) ) { > # checks for problems with realnames > $c_realname = db_prepare_string( $f_realname ); > $t_username = user_get_field( $t_user_id, 'username' ); > > # allow realname to match username > if ( $f_realname <> $t_username ) { > # check realname does not match an existing username > $t_user_table = config_get( 'mantis_user_table' ); > > $query = "SELECT username > FROM $t_user_table > WHERE username='$c_realname'"; > $result = db_query( $query, 1 ); > > if ( db_num_rows( $result ) > 0 ) { > trigger_error( ERROR_USER_REAL_MATCH_USER, ERROR ); > } > > # check to see if the realname is unique > $query = "SELECT id > FROM $t_user_table > WHERE realname='$c_realname'"; > $result = db_query( $query ); > $count = db_num_rows( $result ); > if ( $count > 0 ) { > # set flags for non-unique realnames > $t_count = db_num_rows( $result ); > echo lang_get( 'realname_duplicated' ) . '
'; > user_set_field( $t_user_id, 'duplicate_realname', 'Y' ); > for ( $i=0 ; $i < $count ; $i++ ) { > $t_id = db_result( $result, $i ); > user_set_field( $t_id, 'duplicate_realname', 'Y' ); > } > } > } Index: config_defaults_inc.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/config_defaults_inc.php,v retrieving revision 1.183 diff -r1.183 config_defaults_inc.php 349a350,352 > # -- show users with their real name or not > $g_show_realname = OFF; > Index: admin/upgrades/0_18_inc.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/admin/upgrades/0_18_inc.php,v retrieving revision 1.14 diff -r1.14 0_18_inc.php 264c264 < # Author: Marcello Scatà marcello@marcelloscata.com --- > # Author: Marcello Scat‡ marcello@marcelloscata.com 441a442,475 > $upgrades[] = new SQLUpgrade( > 'user-duplicate', > 'Add realname duplicate field to user table', > "ALTER TABLE $t_user_table ADD duplicate_realname CHAR( 1 ) DEFAULT ''" ); > > $upgrades[] = new FunctionUpgrade( > 'user-duplicate-fix', > 'set values for duplicate_realname', > 'upgrade_0_18_user_duplicate' ); > > function upgrade_0_18_user_duplicate() { > global $t_user_table; > > $query = "SELECT realname FROM $t_user_table > WHERE realname != '' > GROUP BY realname > HAVING count(realname) > 1"; > $result = db_query( $query ); > $t_count = db_num_rows( $result ); > for ( $i = 0 ; $i < $t_count ; $i++ ) { > $t_row = db_fetch_array( $result ); > $t_name = $t_row['realname']; > $query = "UPDATE $t_user_table > SET duplicate_realname = 'Y' > WHERE realname='$t_name'"; > db_query( $query ); > } > > return true; > } > > > > Index: core/constant_inc.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/constant_inc.php,v retrieving revision 1.24 diff -r1.24 constant_inc.php 206a207 > define( 'ERROR_USER_REAL_MATCH_USER', 807 ); Index: core/history_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/history_api.php,v retrieving revision 1.25 diff -r1.25 history_api.php 112,115c112,113 < $query = "SELECT b.*, u.username < FROM $t_mantis_bug_history_table b < LEFT JOIN $t_mantis_user_table u < ON b.user_id=u.id --- > $query = "SELECT * > FROM $t_mantis_bug_history_table 129,134c127,128 < # $v_username will be empty, if user no longer exists. < if ( is_blank( $v_username ) ) { < $raw_history[$i]['username'] = user_get_name( $v_user_id ); < } else { < $raw_history[$i]['username'] = $v_username; < } --- > # user_get_name handles deleted users, and username vs realname > $raw_history[$i]['username'] = user_get_name( $v_user_id ); Index: core/user_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/user_api.php,v retrieving revision 1.74 diff -r1.74 user_api.php 379,380c379 < user_clear_cache( $p_user_id ); < --- > #unset non-unique realname flags if necessary 382a382,398 > $c_realname = db_prepare_string( user_get_field( $p_user_id, 'realname' ) ); > $query = "SELECT id > FROM $t_user_table > WHERE realname='$c_realname'"; > $result = db_query( $query ); > $t_count = db_num_rows( $result ); > > if ( $t_count == 2 ) { > # unset flags if there are now only 2 unique names > for ( $i=0 ; $i < $t_count ; $i++ ) { > $t_user_id = db_result( $result, $i ); > user_set_field( $t_user_id, 'duplicate_realname', '' ); > } > } > > user_clear_cache( $p_user_id ); > 483c499,511 < return is_blank( $row['realname'] ) ? $row['username'] : $row['realname']; --- > if ( ON == config_get( 'show_realname' ) ) { > if ( is_blank( $row['realname'] ) ) { > return '(' . $row['username'] . ')'; > }else{ > if ( is_blank( $row['duplicate_realname'] ) ) { > return $row['realname']; > }else{ > return $row['realname'] . ' (' . $row['username'] . ')'; > } > } > }else{ > return $row['username']; > } Index: lang/strings_english.txt =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/lang/strings_english.txt,v retrieving revision 1.189 diff -r1.189 strings_english.txt 211a212 > $MANTIS_ERROR[ERROR_USER_REAL_MATCH_USER] = 'The "Real Name" chosen matches another user\'s login name. Please choose another.'; 385a387 > $s_realname_duplicated = 'Real name is in use by another user';