Page MenuHomePhorge

D5457.1775283395.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D5457.1775283395.diff

diff --git a/lib/kolab_sync_storage_kolab4.php b/lib/kolab_sync_storage_kolab4.php
--- a/lib/kolab_sync_storage_kolab4.php
+++ b/lib/kolab_sync_storage_kolab4.php
@@ -121,6 +121,10 @@
$list[$folder_data['serverId']] = $folder_data;
}
+
+ if ($flat_mode) {
+ $list = $this->folders_list_flat_mail($list);
+ }
} elseif (in_array($type, [self::MODEL_CONTACTS, self::MODEL_CALENDAR, self::MODEL_TASKS])) {
if (!empty($this->folders)) {
foreach ($this->folders as $unique_key => $folder) {
@@ -145,15 +149,54 @@
}
}
}
- /*
- // TODO
- if ($flat_mode) {
- $list = $this->folders_list_flat($list, $type, $typedata);
- }
- */
+
return $list;
}
+ /**
+ * Converts list of mail folders to a "flat" list
+ */
+ protected function folders_list_flat_mail($folders)
+ {
+ $delim = $this->storage->get_hierarchy_delimiter();
+
+ // for mail folders we modify only folders with non-existing parents
+ foreach ($folders as $idx => $folder) {
+ if ($folder['parentId'] && !isset($folders[$folder['parentId']])) {
+ $items = explode($delim, $folder['imap_name']);
+ $parent = 0;
+ $parent_id = null;
+
+ // find existing parent
+ while (count($items) > 0) {
+ array_pop($items);
+ $parent_id = $this->folder_id(implode($delim, $items), 'mail');
+ if (isset($folders[$parent_id])) {
+ $parent = $parent_id;
+ break;
+ }
+ }
+
+ // Modify the folder name to include "path"
+ // FIXME: Imo, this is over-complicated. How about we just use the method from the "else" below?
+ if (!$parent) {
+ $display_name = kolab_storage::object_prettyname($folder['imap_name']);
+ $display_name = html_entity_decode($display_name, ENT_COMPAT, RCUBE_CHARSET);
+ } else {
+ $parent_name = isset($parent_id) ? $folders[$parent_id]['imap_name'] : '';
+ $display_name = substr($folder['imap_name'], strlen($parent_name) + 1);
+ $display_name = rcube_charset::convert($display_name, 'UTF7-IMAP');
+ $display_name = str_replace($delim, ' » ', $display_name);
+ }
+
+ $folders[$idx]['parentId'] = $parent;
+ $folders[$idx]['displayName'] = $display_name;
+ }
+ }
+
+ return $folders;
+ }
+
/**
* Creates folder and subscribes to the device
*

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 6:16 AM (17 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18826411
Default Alt Text
D5457.1775283395.diff (2 KB)

Event Timeline