summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap_generic.php
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-10-26 11:35:00 +0000
committeralecpl <alec@alec.pl>2011-10-26 11:35:00 +0000
commit8a6503a23c48470f4bc98a21bde61490e0836bda (patch)
tree0fa0eb3e525bfa264443d16b79dc441487cc95f3 /program/include/rcube_imap_generic.php
parent2db2ef3ec95f81a04acd5c143a39f0d8c06c4cae (diff)
- Fix getting message part data from structure, fixes r5363
Diffstat (limited to 'program/include/rcube_imap_generic.php')
-rw-r--r--program/include/rcube_imap_generic.php70
1 files changed, 35 insertions, 35 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index ecd2949d7..5c7a41c73 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -3176,47 +3176,48 @@ class rcube_imap_generic
return false;
}
- static function getStructurePartType($structure, $part)
+ /**
+ * Returns data of a message part according to specified structure.
+ *
+ * @param array $structure Message structure (getStructure() result)
+ * @param string $part Message part identifier
+ *
+ * @return array Part data as hash array (type, encoding, charset, size)
+ */
+ static function getStructurePartData($structure, $part)
{
$part_a = self::getStructurePartArray($structure, $part);
- if (!empty($part_a)) {
- if (is_array($part_a[0]))
- return 'multipart';
- else if ($part_a[0])
- return $part_a[0];
- }
+ $data = array();
- return 'other';
- }
+ if (empty($part_a)) {
+ return $data;
+ }
- static function getStructurePartEncoding($structure, $part)
- {
- $part_a = self::getStructurePartArray($structure, $part);
- if ($part_a) {
- if (!is_array($part_a[0]))
- return $part_a[5];
- }
+ // content-type
+ if (is_array($part_a[0])) {
+ $data['type'] = 'multipart';
+ }
+ else {
+ $data['type'] = strtolower($part_a[0]);
- return '';
- }
+ // encoding
+ $data['encoding'] = strtolower($part_a[5]);
- static function getStructurePartCharset($structure, $part)
- {
- $part_a = self::getStructurePartArray($structure, $part);
- if ($part_a) {
- if (is_array($part_a[0]))
- return '';
- else {
- if (is_array($part_a[2])) {
- $name = '';
- while (list($key, $val) = each($part_a[2]))
- if (strcasecmp($val, 'charset') == 0)
- return $part_a[2][$key+1];
- }
- }
- }
+ // charset
+ if (is_array($part_a[2])) {
+ while (list($key, $val) = each($part_a[2])) {
+ if (strcasecmp($val, 'charset') == 0) {
+ $data['charset'] = $part_a[2][$key+1];
+ break;
+ }
+ }
+ }
+ }
- return '';
+ // size
+ $data['size'] = intval($part_a[6]);
+
+ return $data;
}
static function getStructurePartArray($a, $part)
@@ -3249,7 +3250,6 @@ class rcube_imap_generic
}
}
-
/**
* Creates next command identifier (tag)
*