diff --git a/api/src/Accounts.php b/api/src/Accounts.php index f7cc06c5ae..2ec473a64c 100644 --- a/api/src/Accounts.php +++ b/api/src/Accounts.php @@ -612,6 +612,20 @@ class Accounts $account['account_firstname'] , $account['account_lastname'], $account_id); } + /** + * Return formatted username for Links, does NOT throw if $account_id is not int + * + * @param $account_id + */ + static function title($account_id) + { + if (empty($account_id) || !is_numeric($account_id) && !($id = self::getInstance()->name2id($account_id))) + { + return '#'.$account_id; + } + return self::username($id ?? $account_id); + } + /** * Format an email address according to the system standard * diff --git a/api/src/Link.php b/api/src/Link.php index 40a3bafeda..f86e96fd36 100644 --- a/api/src/Link.php +++ b/api/src/Link.php @@ -154,7 +154,7 @@ class Link extends Link\Storage 'name' => 'Accounts', 'icon' => 'addressbook/accounts', 'query' => 'EGroupware\\Api\\Accounts::link_query', - 'title' => 'EGroupware\\Api\\Accounts::username', + 'title' => 'EGroupware\\Api\\Accounts::title', 'view' => array('menuaction'=>'addressbook.addressbook_ui.view','ajax'=>'true'), 'view_id' => 'account_id' ), @@ -914,7 +914,12 @@ class Link extends Link\Storage } else { - $title = self::title($app,$id); // no titles method --> fallback to query each link separate + try { + $title = self::title($app, $id); // no titles method --> fallback to query each link separate + } + catch (\Throwable $e) { + $title = lang('Error').': '.$e->getMessage(); + } } } $titles[$id] = $title;