Small performance fix - cache identities list in-memory

This commit is contained in:
Aleksander Machniak 2012-12-17 19:03:47 +01:00
parent 0745ebf406
commit acd574b650

View file

@ -515,6 +515,21 @@ class kolab_delegation_engine
return $parsed ? $this->parse_ldap_record($this->cache['user']) : $this->cache['user']; return $parsed ? $this->parse_ldap_record($this->cache['user']) : $this->cache['user'];
} }
/**
* Returns current user identities
*
* @return array List of identities
*/
public function user_identities()
{
// cache result in-memory, we need it more than once
if ($this->identities === null) {
$this->identities = $this->rc->user->list_identities();
}
return $this->identities;
}
/** /**
* Update LDAP record of current user * Update LDAP record of current user
* *
@ -559,7 +574,7 @@ class kolab_delegation_engine
$other_ns = $storage->get_namespace('other'); $other_ns = $storage->get_namespace('other');
$folders = $storage->list_folders(); $folders = $storage->list_folders();
$use_subs = $this->rc->config->get('kolab_use_subscriptions'); $use_subs = $this->rc->config->get('kolab_use_subscriptions');
$identities = $this->rc->user->list_identities(); $identities = $this->user_identities();
$emails = array(); $emails = array();
$uids = array(); $uids = array();
@ -693,7 +708,7 @@ class kolab_delegation_engine
return; return;
} }
$identities = $this->rc->user->list_identities(); $identities = $this->user_identities();
$emails = $_SESSION['delegators'][$context]; $emails = $_SESSION['delegators'][$context];
foreach ($identities as $ident) { foreach ($identities as $ident) {
@ -723,10 +738,10 @@ class kolab_delegation_engine
} }
// return only user addresses (exclude all delegators addresses) // return only user addresses (exclude all delegators addresses)
else if (!empty($_SESSION['delegators'])) { else if (!empty($_SESSION['delegators'])) {
$identities = $this->rc->user->list_identities(); $identities = $this->user_identities();
$emails[] = $this->rc->user->get_username(); $emails[] = $this->rc->user->get_username();
foreach ($this->rc->user->list_identities() as $identity) { foreach ($identities as $identity) {
$emails[] = $identity['email']; $emails[] = $identity['email'];
} }