summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-11-10 11:23:41 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-11-10 11:23:41 (GMT)
commit76ee97d11c0c74ed84744335a489c31166e7b94e (patch)
treef119866be3f8372589d36ee87dd5f01424ce5d34
parent57064bb0f801a1be105f7bfeb66aa924bcbac54a (diff)
downloadkolab-syncroton-76ee97d11c0c74ed84744335a489c31166e7b94e.tar.gz
Code improvements, use get_part_body() instead of get_part_content()
-rw-r--r--lib/kolab_sync_data_email.php20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/kolab_sync_data_email.php b/lib/kolab_sync_data_email.php
index 1625cf6..eb1db8a 100644
--- a/lib/kolab_sync_data_email.php
+++ b/lib/kolab_sync_data_email.php
@@ -125,7 +125,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
$message = $this->getObject($serverId);
// error (message doesn't exist?)
- if (empty($message) || empty($message->headers)) {
+ if (empty($message)) {
throw new Syncroton_Exception_NotFound("Message $serverId not found");
}
@@ -744,7 +744,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
$msg = $this->parseMessageId($itemId);
$message = $this->getObject($itemId);
- if (!$message) {
+ if (empty($message)) {
throw new Syncroton_Exception_Status(Syncroton_Exception_Status::ITEM_NOT_FOUND);
}
@@ -1188,13 +1188,10 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
return null;
}
- // set current folder
- $this->storage->set_folder($message['foldername']);
-
// get message
- $message = new rcube_message($message['uid']);
+ $message = new rcube_message($message['uid'], $message['foldername']);
- return $message;
+ return $message && !empty($message->headers) ? $message : null;
}
/**
@@ -1210,12 +1207,11 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
throw new Syncroton_Exception_NotFound('Message not found');
}
- $part = $message->mime_parts[$part_id];
- $body = $message->get_part_content($part_id);
- $content_type = $part->mimetype;
+ $part = $message->mime_parts[$part_id];
+ $body = $message->get_part_body($part_id);
return new Syncroton_Model_FileReference(array(
- 'contentType' => $content_type,
+ 'contentType' => $part->mimetype,
'data' => $body,
));
}
@@ -1458,7 +1454,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
public static function charset_to_cp($charset)
{
// @TODO: ?????
- // The body is converted to utf-8 in get_part_content(), what about headers?
+ // The body is converted to utf-8 in get_part_body(), what about headers?
return 65001; // UTF-8
$aliases = array(