diff options
Diffstat (limited to 'program/lib/Roundcube')
-rw-r--r-- | program/lib/Roundcube/rcube_user.php | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/program/lib/Roundcube/rcube_user.php b/program/lib/Roundcube/rcube_user.php index b2110df8b..68156b157 100644 --- a/program/lib/Roundcube/rcube_user.php +++ b/program/lib/Roundcube/rcube_user.php @@ -51,6 +51,14 @@ class rcube_user */ private $identities = array(); + /** + * Internal emails cache + * + * @var array + */ + private $emails; + + const SEARCH_ADDRESSBOOK = 1; const SEARCH_MAIL = 2; @@ -79,7 +87,6 @@ class rcube_user } } - /** * Build a user name string (as e-mail address) * @@ -118,7 +125,6 @@ class rcube_user return false; } - /** * Get the preferences saved for this user * @@ -154,7 +160,6 @@ class rcube_user return $prefs; } - /** * Write the given user prefs to the user's record * @@ -233,6 +238,31 @@ class rcube_user } /** + * Return a list of all user emails (from identities) + * + * @return array List of emails (identity_id, name, email) + */ + function list_emails() + { + if ($this->emails === null) { + $this->emails = array(); + + $sql_result = $this->db->query( + "SELECT `identity_id`, `name`, `email`" + ." FROM " . $this->db->table_name('identities', true) + ." WHERE `user_id` = ? AND `del` <> 1" + ." ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC", + $this->ID); + + while ($sql_arr = $this->db->fetch_assoc($sql_result)) { + $this->emails[] = $sql_arr; + } + } + + return $this->emails; + } + + /** * Get default identity of this user * * @param int $id Identity ID. If empty, the default identity is returned @@ -250,7 +280,6 @@ class rcube_user return $this->identities[$id]; } - /** * Return a list of all identities linked with this user * @@ -286,7 +315,6 @@ class rcube_user return $result; } - /** * Update a specific identity record * @@ -317,12 +345,13 @@ class rcube_user call_user_func_array(array($this->db, 'query'), array_merge(array($sql), $query_params)); + // clear the cache $this->identities = array(); + $this->emails = null; return $this->db->affected_rows(); } - /** * Create a new identity record linked with this user * @@ -351,12 +380,13 @@ class rcube_user call_user_func_array(array($this->db, 'query'), array_merge(array($sql), $insert_values)); + // clear the cache $this->identities = array(); + $this->emails = null; return $this->db->insert_id('identities'); } - /** * Mark the given identity as deleted * @@ -387,12 +417,13 @@ class rcube_user $this->ID, $iid); + // clear the cache $this->identities = array(); + $this->emails = null; return $this->db->affected_rows(); } - /** * Make this identity the default one for this user * @@ -412,7 +443,6 @@ class rcube_user } } - /** * Update user's last_login timestamp */ @@ -427,7 +457,6 @@ class rcube_user } } - /** * Clear the saved object state */ @@ -437,7 +466,6 @@ class rcube_user $this->data = null; } - /** * Find a user record matching the given name and host * @@ -473,7 +501,6 @@ class rcube_user return false; } - /** * Create a new user record and return a rcube_user instance * @@ -587,7 +614,6 @@ class rcube_user return $user_id ? $user_instance : false; } - /** * Resolve username using a virtuser plugins * @@ -603,7 +629,6 @@ class rcube_user return $plugin['user']; } - /** * Resolve e-mail address from virtuser plugins * @@ -622,7 +647,6 @@ class rcube_user return empty($plugin['email']) ? NULL : $plugin['email']; } - /** * Return a list of saved searches linked with this user * @@ -655,7 +679,6 @@ class rcube_user return $result; } - /** * Return saved search data. * @@ -690,7 +713,6 @@ class rcube_user return null; } - /** * Deletes given saved search record * @@ -712,7 +734,6 @@ class rcube_user return $this->db->affected_rows(); } - /** * Create a new saved search record linked with this user * |