summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap_generic.php
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-10-29 12:41:11 +0000
committeralecpl <alec@alec.pl>2010-10-29 12:41:11 +0000
commit93272ea91b3263acd883cac77986125e9a2ad8c6 (patch)
tree760662f717e8aaa9ec7b9d6668d9d3ec94f9c9e7 /program/include/rcube_imap_generic.php
parentc309cd8928af861637996f5c5490a2db0dc626dc (diff)
- Use consistent results from some functions, code cleanup
Diffstat (limited to 'program/include/rcube_imap_generic.php')
-rw-r--r--program/include/rcube_imap_generic.php73
1 files changed, 45 insertions, 28 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index e9a5a2d44..5d16dc0c1 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -1199,35 +1199,52 @@ class rcube_imap_generic
return implode(',', $result);
}
- function UID2ID($folder, $uid)
+ /**
+ * Returns message sequence identifier
+ *
+ * @param string $mailbox Mailbox name
+ * @param int $uid Message unique identifier (UID)
+ *
+ * @return int Message sequence identifier
+ * @access public
+ */
+ function UID2ID($mailbox, $uid)
{
if ($uid > 0) {
- $id_a = $this->search($folder, "UID $uid");
+ $id_a = $this->search($mailbox, "UID $uid");
if (is_array($id_a) && count($id_a) == 1) {
- return $id_a[0];
+ return (int) $id_a[0];
}
}
- return false;
+ return null;
}
- function ID2UID($folder, $id)
+ /**
+ * Returns message unique identifier (UID)
+ *
+ * @param string $mailbox Mailbox name
+ * @param int $uid Message sequence identifier
+ *
+ * @return int Message unique identifier
+ * @access public
+ */
+ function ID2UID($mailbox, $id)
{
- if (empty($id)) {
- return -1;
+ if (empty($id) || $id < 0) {
+ return null;
}
if (!$this->select($folder)) {
- return -1;
+ return null;
}
- $result = -1;
list($code, $response) = $this->execute('FETCH', array($id, '(UID)'));
if ($code == self::ERROR_OK && preg_match("/^\* $id FETCH \(UID (.*)\)/i", $response, $m)) {
- $result = $m[1];
+ return (int) $m[1];
}
- return $result;
+ return null;
}
function fetchUIDs($mailbox, $message_set=null)
@@ -1615,18 +1632,32 @@ class rcube_imap_generic
function copy($messages, $from, $to)
{
if (empty($from) || empty($to)) {
- return -1;
+ return false;
}
if (!$this->select($from)) {
- return -1;
+ return false;
}
$result = $this->execute('UID COPY', array(
$this->compressMessageSet($messages), $this->escape($to)),
self::COMMAND_NORESPONSE);
- return $result;
+ return ($result == self::ERROR_OK);
+ }
+
+ function move($messages, $from, $to)
+ {
+ if (!$from || !$to) {
+ return false;
+ }
+
+ $r = $this->copy($messages, $from, $to);
+
+ if ($r) {
+ return $this->delete($from, $messages);
+ }
+ return $r;
}
// Don't be tempted to change $str to pass by reference to speed this up - it will slow it down by about
@@ -1806,20 +1837,6 @@ class rcube_imap_generic
return false;
}
- function move($messages, $from, $to)
- {
- if (!$from || !$to) {
- return -1;
- }
-
- $r = $this->copy($messages, $from, $to);
-
- if ($r==0) {
- return $this->delete($from, $messages);
- }
- return $r;
- }
-
/**
* Returns list of mailboxes
*