diff --git a/plugins/kolab_delegation/kolab_delegation_engine.php b/plugins/kolab_delegation/kolab_delegation_engine.php index ca4d5b4b..be16cf69 100644 --- a/plugins/kolab_delegation/kolab_delegation_engine.php +++ b/plugins/kolab_delegation/kolab_delegation_engine.php @@ -743,6 +743,13 @@ class kolab_delegation_engine { $context = $this->delegator_context(); + // try to derive context from the given user email + if (!$context && !empty($args['emails'])) { + if (($user = preg_replace('/@.+$/', '', $args['emails'][0])) && isset($_SESSION['delegators'][$user])) { + $context = $user; + } + } + // return delegator's addresses if ($context) { $args['emails'] = $_SESSION['delegators'][$context]; diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php index 0384ba02..ec82fdfd 100644 --- a/plugins/libcalendaring/libcalendaring.php +++ b/plugins/libcalendaring/libcalendaring.php @@ -361,32 +361,37 @@ class libcalendaring extends rcube_plugin } /** - * Get a list of email addresses of the current user (from login and identities) + * Get a list of email addresses of the given user (from login and identities) + * + * @param string User Email (default to current user) + * @return array Email addresses related to the user */ - public function get_user_emails() + public function get_user_emails($user = null) { - static $emails; + static $_emails = array(); - // return cached result - if (is_array($emails)) { - return $emails; + if (empty($user)) { + $user = $this->rc->user->get_username(); } - $emails = array(); + // return cached result + if (is_array($_emails[$user])) { + return $_emails[$user]; + } + + $emails = array($user); $plugin = $this->rc->plugins->exec_hook('calendar_user_emails', array('emails' => $emails)); $emails = array_map('strtolower', $plugin['emails']); - if ($plugin['abort']) { - return $emails; + // add all emails from the current user's identities + if (!$plugin['abort'] && ($user == $this->rc->user->get_username())) { + foreach ($this->rc->user->list_emails() as $identity) { + $emails[] = strtolower($identity['email']); + } } - $emails[] = $this->rc->user->get_username(); - foreach ($this->rc->user->list_emails() as $identity) { - $emails[] = strtolower($identity['email']); - } - - $emails = array_unique($emails); - return $emails; + $_emails[$user] = array_unique($emails); + return $_emails[$user]; } /**