Unified get_objects/count/get_uids/select methods argument handling (#5209)

This commit is contained in:
Aleksander Machniak 2016-03-09 11:46:26 +01:00
parent 14fae65553
commit 9d5dd5bf16
3 changed files with 17 additions and 39 deletions

View file

@ -1123,7 +1123,7 @@ class rcube_kolab_contacts extends rcube_addressbook
{
if (!isset($this->distlists)) {
$this->distlists = $this->groupmembers = array();
foreach ($this->storagefolder->get_objects('distribution-list') as $record) {
foreach ($this->storagefolder->select('distribution-list') as $record) {
$record['ID'] = $this->uid2id($record['uid']);
foreach ((array)$record['member'] as $i => $member) {
$mid = $this->uid2id($member['uid'] ? $member['uid'] : 'mailto:' . $member['email']);

View file

@ -232,7 +232,7 @@ class kolab_storage
* Execute cross-folder searches with the given query.
*
* @param array Pseudo-SQL query as list of filter parameter triplets
* @param string Object type (contact,event,task,journal,file,note,configuration)
* @param string Folder type (contact,event,task,journal,file,note,configuration)
* @param int Expected number of records or limit (for performance reasons)
*
* @return array List of Kolab data objects (each represented as hash array)
@ -251,7 +251,7 @@ class kolab_storage
$folder->set_order_and_limit(null, $limit);
}
foreach ($folder->select($query, '*') as $object) {
foreach ($folder->select($query) as $object) {
$result[] = $object;
}
}

View file

@ -37,7 +37,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
public $valid = false;
protected $error = 0;
protected $resource_uri;
@ -54,7 +53,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
$this->set_folder($name, $type, $type_annotation);
}
/**
* Set the IMAP folder this instance connects to
*
@ -249,8 +247,9 @@ class kolab_storage_folder extends kolab_storage_folder_api
/**
* Get number of objects stored in this folder
*
* @param mixed Pseudo-SQL query as list of filter parameter triplets
* @param mixed Pseudo-SQL query as list of filter parameter triplets
* or string with object type (e.g. contact, event, todo, journal, note, configuration)
*
* @return integer The number of objects of the given type
* @see self::select()
*/
@ -266,34 +265,26 @@ class kolab_storage_folder extends kolab_storage_folder_api
return $this->cache->count($this->_prepare_query($query));
}
/**
* List all Kolab objects of the given type
* List Kolab objects matching the given query
*
* @param string $type Object type (e.g. contact, event, todo, journal, note, configuration)
* @return array List of Kolab data objects (each represented as hash array)
* @param mixed Pseudo-SQL query as list of filter parameter triplets
* or string with object type (e.g. contact, event, todo, journal, note, configuration)
*
* @return array List of Kolab data objects (each represented as hash array)
* @deprecated Use select()
*/
public function get_objects($type = null)
public function get_objects($query = array())
{
if (!$type) $type = $this->type;
if (!$this->valid) {
return array();
}
// synchronize caches
$this->cache->synchronize();
// fetch objects from cache
return $this->cache->select($this->_prepare_query($type));
return $this->select($query);
}
/**
* Select *some* Kolab objects matching the given query
* Select Kolab objects matching the given query
*
* @param mixed Pseudo-SQL query as list of filter parameter triplets
* or string with object type (e.g. contact, event, todo, journal, note, configuration)
*
* @param array Pseudo-SQL query as list of filter parameter triplets
* triplet: array('<colname>', '<comparator>', '<value>')
* @return array List of Kolab data objects (each represented as hash array)
*/
public function select($query = array())
@ -302,11 +293,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
return array();
}
// check query argument
if (empty($query)) {
return $this->get_objects();
}
// synchronize caches
$this->cache->synchronize();
@ -314,7 +300,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
return $this->cache->select($this->_prepare_query($query));
}
/**
* Getter for object UIDs only
*
@ -395,7 +380,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
return $this->cache->get_by_uid($uid);
}
/**
* Fetch a Kolab object attachment which is stored in a separate part
* of the mail MIME message that represents the Kolab record.
@ -443,7 +427,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
return null;
}
/**
* Fetch the mime message from the storage server and extract
* the Kolab groupware object from it
@ -831,7 +814,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
return $success;
}
/**
*
*/
@ -849,7 +831,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
return $result;
}
/**
* Restore a previously deleted object
*
@ -875,7 +856,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
return false;
}
/**
* Move a Kolab object message to another IMAP folder
*
@ -914,7 +894,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
return false;
}
/**
* Creates source of the configuration object message
*
@ -1095,7 +1074,6 @@ class kolab_storage_folder extends kolab_storage_folder_api
return $message;
}
/**
* Triggers any required updates after changes within the
* folder. This is currently only required for handling free/busy