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,