N°2847 Handle no contact linked to user on usr menu icon hover

This commit is contained in:
Stephen Abello
2020-08-04 14:44:42 +02:00
parent 2db7611368
commit 18b653f641
2 changed files with 24 additions and 1 deletions

View File

@@ -1168,6 +1168,27 @@ class UserRights
return $sFirstname;
}
/**
* Return the friendlyname of the current user's contact.
* If the user has no contact, null is returned.
*
* @return string|null
* @throws \Exception
* @since 2.8.0
*/
public static function GetContactFriendlyname()
{
$sFriendlyname = null;
$oContact = static::GetContactObject();
if(!is_null($oContact) && MetaModel::IsValidAttCode(get_class($oContact), 'friendlyname'))
{
$sFriendlyname = $oContact->Get('friendlyname');
}
return $sFriendlyname;
}
/**
* @return \DBObject|null
*/