Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_storage_folder.php
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | class kolab_storage_folder extends kolab_storage_folder_api | ||||
* Default constructor | * Default constructor | ||||
* | * | ||||
* @param string The folder name/path | * @param string The folder name/path | ||||
* @param string Expected folder type | * @param string Expected folder type | ||||
*/ | */ | ||||
function __construct($name, $type = null, $type_annotation = null) | function __construct($name, $type = null, $type_annotation = null) | ||||
{ | { | ||||
parent::__construct($name); | parent::__construct($name); | ||||
$this->imap->set_options(array('skip_deleted' => true)); | |||||
$this->set_folder($name, $type, $type_annotation); | $this->set_folder($name, $type, $type_annotation); | ||||
} | } | ||||
/** | /** | ||||
* Set the IMAP folder this instance connects to | * Set the IMAP folder this instance connects to | ||||
* | * | ||||
* @param string The folder name/path | * @param string The folder name/path | ||||
* @param string Expected folder type | * @param string Expected folder type | ||||
▲ Show 20 Lines • Show All 382 Lines • ▼ Show 20 Lines | public function read_object($msguid, $type = null, $folder = null) | ||||
return false; | return false; | ||||
} | } | ||||
if (!$type) $type = $this->type; | if (!$type) $type = $this->type; | ||||
if (!$folder) $folder = $this->name; | if (!$folder) $folder = $this->name; | ||||
$this->imap->set_folder($folder); | $this->imap->set_folder($folder); | ||||
$this->cache->bypass(true); | $this->cache->imap_mode(true); | ||||
$message = new rcube_message($msguid); | $message = new rcube_message($msguid); | ||||
$this->cache->bypass(false); | $this->cache->imap_mode(false); | ||||
// Message doesn't exist? | // Message doesn't exist? | ||||
if (empty($message->headers)) { | if (empty($message->headers)) { | ||||
return false; | return false; | ||||
} | } | ||||
// extract the X-Kolab-Type header from the XML attachment part if missing | // extract the X-Kolab-Type header from the XML attachment part if missing | ||||
if (empty($message->headers->others['x-kolab-type'])) { | if (empty($message->headers->others['x-kolab-type'])) { | ||||
▲ Show 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | public function save(&$object, $type = null, $uid = null) | ||||
if ($result) { | if ($result) { | ||||
$old_uid = $object['_msguid']; | $old_uid = $object['_msguid']; | ||||
$object['_msguid'] = $result; | $object['_msguid'] = $result; | ||||
$object['_mailbox'] = $this->name; | $object['_mailbox'] = $this->name; | ||||
if ($old_uid) { | if ($old_uid) { | ||||
// delete old message | // delete old message | ||||
$this->cache->bypass(true); | $this->cache->imap_mode(true); | ||||
$this->imap->delete_message($old_uid, $object['_mailbox']); | $this->imap->delete_message($old_uid, $object['_mailbox']); | ||||
$this->cache->bypass(false); | $this->cache->imap_mode(false); | ||||
} | } | ||||
// insert/update message in cache | // insert/update message in cache | ||||
$this->cache->save($result, $object, $old_uid); | $this->cache->save($result, $object, $old_uid); | ||||
} | } | ||||
// remove temp file | // remove temp file | ||||
if ($body_file) { | if ($body_file) { | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | class kolab_storage_folder extends kolab_storage_folder_api | ||||
{ | { | ||||
if (!$this->valid) { | if (!$this->valid) { | ||||
return false; | return false; | ||||
} | } | ||||
$msguid = is_array($object) ? $object['_msguid'] : $this->cache->uid2msguid($object); | $msguid = is_array($object) ? $object['_msguid'] : $this->cache->uid2msguid($object); | ||||
$success = false; | $success = false; | ||||
$this->cache->bypass(true); | $this->cache->imap_mode(true); | ||||
if ($msguid && $expunge) { | if ($msguid && $expunge) { | ||||
$success = $this->imap->delete_message($msguid, $this->name); | $success = $this->imap->delete_message($msguid, $this->name); | ||||
} | } | ||||
else if ($msguid) { | else if ($msguid) { | ||||
$success = $this->imap->set_flag($msguid, 'DELETED', $this->name); | $success = $this->imap->set_flag($msguid, 'DELETED', $this->name); | ||||
} | } | ||||
$this->cache->bypass(false); | $this->cache->imap_mode(false); | ||||
if ($success) { | if ($success) { | ||||
$this->cache->set($msguid, false); | $this->cache->set($msguid, false); | ||||
} | } | ||||
return $success; | return $success; | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
public function delete_all() | public function delete_all() | ||||
{ | { | ||||
if (!$this->valid) { | if (!$this->valid) { | ||||
return false; | return false; | ||||
} | } | ||||
$this->cache->purge(); | $this->cache->purge(); | ||||
$this->cache->bypass(true); | $this->cache->imap_mode(true); | ||||
$result = $this->imap->clear_folder($this->name); | $result = $this->imap->clear_folder($this->name); | ||||
$this->cache->bypass(false); | $this->cache->imap_mode(false); | ||||
return $result; | return $result; | ||||
} | } | ||||
/** | /** | ||||
* Restore a previously deleted object | * Restore a previously deleted object | ||||
* | * | ||||
* @param string Object UID | * @param string Object UID | ||||
* @return mixed Message UID on success, false on error | * @return mixed Message UID on success, false on error | ||||
*/ | */ | ||||
public function undelete($uid) | public function undelete($uid) | ||||
{ | { | ||||
if (!$this->valid) { | if (!$this->valid) { | ||||
return false; | return false; | ||||
} | } | ||||
if ($msguid = $this->cache->uid2msguid($uid, true)) { | if ($msguid = $this->cache->uid2msguid($uid, true)) { | ||||
$this->cache->bypass(true); | $this->cache->imap_mode(true); | ||||
$result = $this->imap->set_flag($msguid, 'UNDELETED', $this->name); | $result = $this->imap->set_flag($msguid, 'UNDELETED', $this->name); | ||||
$this->cache->bypass(false); | $this->cache->imap_mode(false); | ||||
if ($result) { | if ($result) { | ||||
return $msguid; | return $msguid; | ||||
} | } | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
Show All 10 Lines | public function move($uid, $target_folder) | ||||
if (!$this->valid) { | if (!$this->valid) { | ||||
return false; | return false; | ||||
} | } | ||||
if (is_string($target_folder)) | if (is_string($target_folder)) | ||||
$target_folder = kolab_storage::get_folder($target_folder); | $target_folder = kolab_storage::get_folder($target_folder); | ||||
if ($msguid = $this->cache->uid2msguid($uid)) { | if ($msguid = $this->cache->uid2msguid($uid)) { | ||||
$this->cache->bypass(true); | $this->cache->imap_mode(true); | ||||
$result = $this->imap->move_message($msguid, $target_folder->name, $this->name); | $result = $this->imap->move_message($msguid, $target_folder->name, $this->name); | ||||
$this->cache->bypass(false); | $this->cache->imap_mode(false); | ||||
if ($result) { | if ($result) { | ||||
$new_uid = ($copyuid = $this->imap->conn->data['COPYUID']) ? $copyuid[1] : null; | $new_uid = ($copyuid = $this->imap->conn->data['COPYUID']) ? $copyuid[1] : null; | ||||
$this->cache->move($msguid, $uid, $target_folder, $new_uid); | $this->cache->move($msguid, $uid, $target_folder, $new_uid); | ||||
return true; | return true; | ||||
} | } | ||||
else { | else { | ||||
rcube::raise_error(array( | rcube::raise_error(array( | ||||
▲ Show 20 Lines • Show All 256 Lines • Show Last 20 Lines |