diff options
author | Thomas Bruederli <bruederli@kolabsys.com> | 2015-01-21 15:58:09 (GMT) |
---|---|---|
committer | Thomas Bruederli <bruederli@kolabsys.com> | 2015-01-21 15:58:09 (GMT) |
commit | d9f69d35c7ebbdd0544351db5cbed810ce431072 (patch) | |
tree | a2ecc29647ae598f48508ea04c08762609e824da /plugins/libcalendaring | |
parent | d6789046c6bb5575c13616003ffa4734a75f860b (diff) | |
download | roundcubemail-plugins-kolab-d9f69d35c7ebbdd0544351db5cbed810ce431072.tar.gz |
Allow to provide the context for getting user emails (augmented by kolab_delegation)
Diffstat (limited to 'plugins/libcalendaring')
-rw-r--r-- | plugins/libcalendaring/libcalendaring.php | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php index 0384ba0..ec82fdf 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(); + + if (empty($user)) { + $user = $this->rc->user->get_username(); + } // return cached result - if (is_array($emails)) { - return $emails; + if (is_array($_emails[$user])) { + return $_emails[$user]; } - $emails = array(); + $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; - } - - $emails[] = $this->rc->user->get_username(); - foreach ($this->rc->user->list_emails() as $identity) { - $emails[] = strtolower($identity['email']); + // 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 = array_unique($emails); - return $emails; + $_emails[$user] = array_unique($emails); + return $_emails[$user]; } /** |