mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°2847 Handle no contact linked to user on usr menu icon hover
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -213,6 +213,7 @@ class NavigationMenu extends UIBlock
|
||||
*/
|
||||
protected function ComputeUserData()
|
||||
{
|
||||
//Todo : what do we show if no contact is linked to the user ?
|
||||
$aData = [
|
||||
'sOrganization' => UserRights::GetContactOrganizationFriendlyname(),
|
||||
'sFirstname' => UserRights::GetContactFirstname(),
|
||||
@@ -222,7 +223,8 @@ class NavigationMenu extends UIBlock
|
||||
|
||||
// Logon message
|
||||
$sLogonMessageDictCode = (UserRights::IsAdministrator()) ? 'UI:LoggedAsMessage+Admin' : 'UI:LoggedAsMessage';
|
||||
$aData['sLogonMessage'] = Dict::Format($sLogonMessageDictCode, UserRights::GetContactObject()->Get('friendlyname'));
|
||||
|
||||
$aData['sLogonMessage'] = Dict::Format($sLogonMessageDictCode, UserRights::GetContactFriendlyname());
|
||||
|
||||
$this->aUserData = $aData;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user