Skip to content

Commit

Permalink
Re-use user exists check when rendering avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
vboctor committed Apr 22, 2016
1 parent 341e1ba commit 4853bd1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/classes/Avatar.class.php
Expand Up @@ -61,7 +61,8 @@ public static function get( $p_user_id, $p_size = 80 ) {
$t_avatar = null;

if ( $t_enabled ) {
if ( user_exists( $p_user_id ) &&
$t_user_exists = user_exists( $p_user_id );
if ( $t_user_exists &&
access_has_project_level( config_get( 'show_avatar_threshold' ), null, $p_user_id ) ) {
$t_avatar = event_signal(
'EVENT_USER_AVATAR',
Expand All @@ -72,7 +73,7 @@ public static function get( $p_user_id, $p_size = 80 ) {
$t_avatar = new Avatar();
}

$t_avatar->normalize( $p_user_id );
$t_avatar->normalize( $p_user_id, $t_user_exists );
}

return $t_avatar;
Expand All @@ -85,18 +86,17 @@ public static function get( $p_user_id, $p_size = 80 ) {
* core.
*
* @param integer $p_user_id The user id.
* @param bool $p_user_exists Whether the user exists.
*
* @return void
*/
private function normalize( $p_user_id ) {
$t_user_exists = user_exists( $p_user_id );

private function normalize( $p_user_id, $p_user_exists ) {
if( $this->image === null) {
$this->image = config_get_global( 'path' ) . 'images/avatar.png';
}

if( $this->link === null ) {
if ( $t_user_exists ) {
if ( $p_user_exists ) {
$this->link = config_get_global( 'path' ) .
'view_user_page.php?id=' . $p_user_id;
} else {
Expand All @@ -105,7 +105,7 @@ private function normalize( $p_user_id ) {
}

if( $this->text === null ) {
$this->text = $t_user_exists ? user_get_name( $p_user_id ) : '';
$this->text = $p_user_exists ? user_get_name( $p_user_id ) : '';
}
}
}
Expand Down

0 comments on commit 4853bd1

Please sign in to comment.