From 254d5ef32b7ec45a48abd43f19c84168dabe13d1 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 20 May 2011 06:38:44 -0400
Subject: [PATCH] - Improve performence of folder manager operations by moving subscriptions table operations (like adding/updateing/moving folders) into client-side - no need to invoke LIST, do sorting in browser - This change should also handle better situations when working with replicated IMAP backend (e.g.Cyrus Murder)

---
 program/steps/settings/func.inc |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index b204d9b..a44d6c8 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -747,7 +747,7 @@
 }
 
 
-function rcube_folder_options($mailbox)
+function rcmail_folder_options($mailbox)
 {
     global $RCMAIL;
 
@@ -785,6 +785,27 @@
     return $options;    
 }
 
+// Updates (or creates) folder row in the subscriptions table
+function rcmail_update_folder_row($name, $oldname=null)
+{
+    global $IMAP, $CONFIG, $OUTPUT;
+
+    $delimiter    = $IMAP->get_hierarchy_delimiter();
+    $name_utf8    = rcube_charset_convert($name, 'UTF7-IMAP');
+    $protected    = ($CONFIG['protect_default_folders'] == true && in_array($name, $CONFIG['default_imap_folders']));
+
+    $foldersplit  = explode($delimiter, $IMAP->mod_mailbox($name));
+    $level        = count($foldersplit) - 1;
+    $display_name = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level)
+        . Q($protected ? rcmail_localize_foldername($name) : rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'));
+
+    if ($oldname === null)
+        $OUTPUT->command('add_folder_row', $name_utf8, $display_name, $protected, true);
+    else
+        $OUTPUT->command('replace_folder_row', rcube_charset_convert($oldname, 'UTF7-IMAP'),
+            $name_utf8, $display_name, $protected);
+}
+
 
 // register UI objects
 $OUTPUT->add_handlers(array(

--
Gitblit v1.9.1