diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2012-11-17 16:24:09 +0100 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2012-11-17 16:24:09 +0100 |
commit | 6ddb16d181e285d4f0ef0ef55bdd0ba787f1b583 (patch) | |
tree | 5f186f89d5d7f77592acf3aec676b48367a96d48 /program/include/rcube_user.php | |
parent | bc66f7d6d208ac99dcec57992c4eb955570d85bc (diff) | |
parent | 9ab34604d94270f6c1795c7dd7b615273d05db0c (diff) |
Merge branch 'master' of github.com:roundcube/roundcubemail
Diffstat (limited to 'program/include/rcube_user.php')
-rw-r--r-- | program/include/rcube_user.php | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php index b92187ad4..5a8e9005e 100644 --- a/program/include/rcube_user.php +++ b/program/include/rcube_user.php @@ -5,7 +5,7 @@ | program/include/rcube_user.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2010, The Roundcube Dev Team | + | Copyright (C) 2005-2012, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -17,6 +17,7 @@ | | +-----------------------------------------------------------------------+ | Author: Thomas Bruederli <roundcube@gmail.com> | + | Author: Aleksander Machniak <alec@alec.pl> | +-----------------------------------------------------------------------+ */ @@ -24,8 +25,8 @@ /** * Class representing a system user * - * @package Core - * @author Thomas Bruederli <roundcube@gmail.com> + * @package Framework + * @subpackage Core */ class rcube_user { @@ -47,6 +48,13 @@ class rcube_user */ private $rc; + /** + * Internal identities cache + * + * @var array + */ + private $identities = array(); + const SEARCH_ADDRESSBOOK = 1; const SEARCH_MAIL = 2; @@ -213,8 +221,14 @@ class rcube_user */ function get_identity($id = null) { - $result = $this->list_identities($id ? sprintf('AND identity_id = %d', $id) : ''); - return $result[0]; + $id = (int)$id; + // cache identities for better performance + if (!array_key_exists($id, $this->identities)) { + $result = $this->list_identities($id ? 'AND identity_id = ' . $id : ''); + $this->identities[$id] = $result[0]; + } + + return $this->identities[$id]; } @@ -273,6 +287,8 @@ class rcube_user call_user_func_array(array($this->db, 'query'), array_merge(array($sql), $query_params)); + $this->identities = array(); + return $this->db->affected_rows(); } @@ -305,6 +321,8 @@ class rcube_user call_user_func_array(array($this->db, 'query'), array_merge(array($sql), $insert_values)); + $this->identities = array(); + return $this->db->insert_id('identities'); } @@ -339,6 +357,8 @@ class rcube_user $this->ID, $iid); + $this->identities = array(); + return $this->db->affected_rows(); } @@ -359,6 +379,8 @@ class rcube_user " AND del <> 1", $this->ID, $iid); + + unset($this->identities[0]); } } |