Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_storage_cache.php
Show First 20 Lines • Show All 640 Lines • ▼ Show 20 Lines | public function select($query = array(), $uids = false, $fast = false) | ||||
$result[] = $sql_arr; | $result[] = $sql_arr; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// use IMAP | // use IMAP | ||||
else { | else { | ||||
$filter = $this->_query2assoc($query); | $filter = $this->_query2assoc($query); | ||||
if ($filter['uid']) { | |||||
// We already know what we want (Maybe we will not know if we switch this around to using event uids) | |||||
$index = [$filter['uid']]; | |||||
} else { | |||||
// Search for what we want | |||||
$this->imap_mode(true); | $this->imap_mode(true); | ||||
if ($filter['type']) { | if ($filter['type']) { | ||||
$search = 'UNDELETED HEADER X-Kolab-Type ' . kolab_format::KTYPE_PREFIX . $filter['type']; | $search = 'UNDELETED HEADER X-Kolab-Type ' . kolab_format::KTYPE_PREFIX . $filter['type']; | ||||
$index = $this->imap->search_once($this->folder->name, $search); | $index = $this->imap->search_once($this->folder->name, $search); | ||||
} | } | ||||
else { | else { | ||||
$index = $this->imap->index($this->folder->name, null, null, true, true); | $index = $this->imap->index($this->folder->name, null, null, true, true); | ||||
} | } | ||||
$this->imap_mode(false); | $this->imap_mode(false); | ||||
if ($index->is_error()) { | if ($index->is_error()) { | ||||
$this->check_error(); | $this->check_error(); | ||||
if ($uids) { | if ($uids) { | ||||
return null; | return null; | ||||
} | } | ||||
$result->set_error(true); | $result->set_error(true); | ||||
return $result; | return $result; | ||||
} | } | ||||
$index = $index->get(); | // Results come in the wrong order by default | ||||
$index = array_reverse($index->get()); | |||||
} | |||||
$result = $uids ? $index : $this->_fetch($index, $filter['type']); | $result = $uids ? $index : $this->_fetch($index, $filter['type']); | ||||
// TODO: post-filter result according to query | // TODO: post-filter result according to query | ||||
} | } | ||||
// We don't want to cache big results in-memory, however | // We don't want to cache big results in-memory, however | ||||
// if we select only one object here, there's a big chance we will need it later | // if we select only one object here, there's a big chance we will need it later | ||||
if (!$uids && count($result) == 1) { | if (!$uids && count($result) == 1) { | ||||
▲ Show 20 Lines • Show All 594 Lines • Show Last 20 Lines |