From e539c60e9b2497b9aa46638b7262f6329b0a6748 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Wed, 6 May 2026 17:37:50 +1100 Subject: [PATCH] feat: use primary identity display name in switcher dropdown The account switcher dropdown previously showed the IMAP username (typically the email address) for the primary account. Now it falls back to the identity's display name when available, matching the behavior of secondary accounts which use their custom label. Priority order: global_alias session var > primary identity display name > IMAP username. --- ident_switch.php | 4 +++- lib/IdentSwitchChecker.php | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ident_switch.php b/ident_switch.php index 77302b0..a39b8e7 100644 --- a/ident_switch.php +++ b/ident_switch.php @@ -188,7 +188,9 @@ class ident_switch extends rcube_plugin $iid = intval($iid_s); } - $accNames = [$_SESSION['global_alias'] ?? $rc->user->data['username']]; + $primaryIdentity = $rc->user->get_identity(); + $primaryName = !empty($primaryIdentity['name']) ? $primaryIdentity['name'] : null; + $accNames = [$_SESSION['global_alias'] ?? $primaryName ?? $rc->user->data['username']]; $accValues = [-1]; $accSelected = -1; $iidMap = [0 => -1]; // primary account: iid 0 → select value -1 diff --git a/lib/IdentSwitchChecker.php b/lib/IdentSwitchChecker.php index fd3cbba..5f15712 100644 --- a/lib/IdentSwitchChecker.php +++ b/lib/IdentSwitchChecker.php @@ -177,6 +177,9 @@ class IdentSwitchChecker $host = 'tls://' . $host; } + $primaryIdentity = $rc->user->get_identity(); + $primaryName = !empty($primaryIdentity['name']) ? $primaryIdentity['name'] : null; + return [ 'iid' => 0, 'imap_host' => $host, @@ -185,7 +188,7 @@ class IdentSwitchChecker 'username' => $rc->user->data['username'], 'password' => $_SESSION['password' . $postfix], 'email' => $rc->user->data['username'], - 'label' => $_SESSION['global_alias'] ?? $rc->user->data['username'], + 'label' => $_SESSION['global_alias'] ?? $primaryName ?? $rc->user->data['username'], 'notify_basic' => null, 'notify_sound' => null, 'notify_desktop' => null,