From b6cd452bd31bfd4b6b94b23fe54b424fdf901e61 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Thu, 18 Aug 2011 14:34:56 -0400
Subject: [PATCH] Backport changes from r5084 to r5090 to release branch

---
 program/steps/settings/folders.inc        |   18 +++++----
 skins/default/templates/messageprint.html |    2 
 program/include/main.inc                  |   28 +++++++-------
 program/include/rcube_imap.php            |   22 +++++++++-
 plugins/acl/acl.php                       |    8 ++--
 plugins/acl/acl.js                        |    2 
 skins/default/templates/error.html        |    2 
 skins/default/iehacks.css                 |   25 +++++++++++-
 program/js/app.js                         |    2 
 9 files changed, 74 insertions(+), 35 deletions(-)

diff --git a/plugins/acl/acl.js b/plugins/acl/acl.js
index 3cca7bf..d786076 100644
--- a/plugins/acl/acl.js
+++ b/plugins/acl/acl.js
@@ -1,7 +1,7 @@
 /**
  * ACL plugin script
  *
- * @version 0.5
+ * @version 0.6
  * @author Aleksander Machniak <alec@alec.pl>
  */
 
diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php
index 33f84db..1b021d0 100644
--- a/plugins/acl/acl.php
+++ b/plugins/acl/acl.php
@@ -3,7 +3,7 @@
 /**
  * Folders Access Control Lists Management (RFC4314, RFC2086)
  *
- * @version 0.5
+ * @version 0.6
  * @author Aleksander Machniak <alec@alec.pl>
  *
  *
@@ -427,7 +427,7 @@
      */
     private function action_save()
     {
-        $mbox  = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true, 'UTF7-IMAP'));
+        $mbox  = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true)); // UTF7-IMAP
         $user  = trim(get_input_value('_user', RCUBE_INPUT_GPC));
         $acl   = trim(get_input_value('_acl', RCUBE_INPUT_GPC));
         $oldid = trim(get_input_value('_old', RCUBE_INPUT_GPC));
@@ -464,7 +464,7 @@
      */
     private function action_delete()
     {
-        $mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true, 'UTF7-IMAP'));
+        $mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true)); //UTF7-IMAP
         $user = trim(get_input_value('_user', RCUBE_INPUT_GPC));
 
         $user = explode(',', $user);
@@ -495,7 +495,7 @@
             return;
         }
 
-        $this->mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true, 'UTF7-IMAP'));
+        $this->mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true)); // UTF7-IMAP
         $advanced   = trim(get_input_value('_mode', RCUBE_INPUT_GPC));
         $advanced   = $advanced == 'advanced' ? true : false;
 
diff --git a/program/include/main.inc b/program/include/main.inc
index a3edbf7..82d3eb7 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1407,21 +1407,21 @@
   $out = '';
 
   foreach ($arrFolders as $key => $folder) {
-    if (!empty($exceptions) && in_array($folder['id'], $exceptions)) {
+    if (empty($exceptions) || !in_array($folder['id'], $exceptions)) {
+      if (!$realnames && ($folder_class = rcmail_folder_classname($folder['id'])))
+        $foldername = rcube_label($folder_class);
+      else {
+        $foldername = $folder['name'];
+
+        // shorten the folder name to a given length
+        if ($maxlength && $maxlength>1)
+          $foldername = abbreviate_string($foldername, $maxlength);
+      }
+
+      $select->add(str_repeat('&nbsp;', $nestLevel*4) . $foldername, $folder['id']);
+    }
+    else if ($nestLevel)
       continue;
-    }
-
-    if (!$realnames && ($folder_class = rcmail_folder_classname($folder['id'])))
-      $foldername = rcube_label($folder_class);
-    else {
-      $foldername = $folder['name'];
-
-      // shorten the folder name to a given length
-      if ($maxlength && $maxlength>1)
-        $foldername = abbreviate_string($foldername, $maxlength);
-    }
-
-    $select->add(str_repeat('&nbsp;', $nestLevel*4) . $foldername, $folder['id']);
 
     if (!empty($folder['folders']))
       $out .= rcmail_render_folder_tree_select($folder['folders'], $mbox_name, $maxlength,
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index e31fb88..0e28b08 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -3083,20 +3083,36 @@
                 $a_folders = $this->conn->listMailboxes($root, $name,
                     NULL, array('SUBSCRIBED'));
 
-                // remove non-existent folders
-                if (is_array($a_folders)) {
+                // unsubscribe non-existent folders, remove from the list
+                if (is_array($a_folders) && $name == '*') {
                     foreach ($a_folders as $idx => $folder) {
                         if ($this->conn->data['LIST'] && ($opts = $this->conn->data['LIST'][$folder])
                             && in_array('\\NonExistent', $opts)
                         ) {
+                            $this->conn->unsubscribe($folder);
                             unset($a_folders[$idx]);
-                        } 
+                        }
                     }
                 }
             }
             // retrieve list of folders from IMAP server using LSUB
             else {
                 $a_folders = $this->conn->listSubscribed($root, $name);
+
+                // unsubscribe non-existent folders, remove from the list
+                if (is_array($a_folders) && $name == '*') {
+                    foreach ($a_folders as $idx => $folder) {
+                        if ($this->conn->data['LIST'] && ($opts = $this->conn->data['LIST'][$folder])
+                            && in_array('\\Noselect', $opts)
+                        ) {
+                            // Some servers returns \Noselect for existing folders
+                            if (!$this->mailbox_exists($folder)) {
+                                $this->conn->unsubscribe($folder);
+                                unset($a_folders[$idx]);
+                            }
+                        }
+                    }
+                }
             }
         }
 
diff --git a/program/js/app.js b/program/js/app.js
index 717b21c..d15950d 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -4432,7 +4432,7 @@
   this.set_photo_actions = function(id)
   {
     var n, buttons = this.buttons['upload-photo'];
-    for (n=0; n < buttons && buttons.length; n++)
+    for (n=0; buttons && n < buttons.length; n++)
       $('#'+buttons[n].id).html(this.get_label(id == '-del-' ? 'addphoto' : 'replacephoto'));
 
     $('#ff_photo').val(id);
diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc
index eea5806..1d5df46 100644
--- a/program/steps/settings/folders.inc
+++ b/program/steps/settings/folders.inc
@@ -278,9 +278,6 @@
         $display_folder = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $folder['level'])
             . Q($protected ? rcmail_localize_foldername($folder['id']) : $folder['name']);
 
-        if ($sub_key !== false)
-            unset($a_subscribed[$sub_key]);
-
         if ($folder['virtual']) {
             $classes[] = 'virtual';
         }
@@ -317,6 +314,16 @@
                 }
             }
         }
+        // check if the folder is shared, then disable subscription option on it
+        if (!$disabled && $folder['virtual'] && !empty($namespace)) {
+            $tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']);
+            foreach ($tmp_ns as $item) {
+                if (strpos($folder['id'], $item[0]) === 0) {
+                    $disabled = true;
+                    break;
+                }
+            }
+        }
 
         $table->add_row(array('id' => 'rcmrow'.$idx, 'class' => join(' ', $classes),
             'foldername' => $folder['id']));
@@ -327,11 +334,6 @@
 
         $a_js_folders['rcmrow'.$idx] = array($folder_utf8,
             Q($display_folder), $protected || $folder['virtual']);
-    }
-
-    // Unsubscribe from non-existing folders
-    foreach ($a_subscribed as $folder) {
-        $IMAP->unsubscribe($folder);
     }
 
     $RCMAIL->plugins->exec_hook('folders_list', array('table' => $table));
diff --git a/skins/default/iehacks.css b/skins/default/iehacks.css
index 8931e2a..6ff1056 100644
--- a/skins/default/iehacks.css
+++ b/skins/default/iehacks.css
@@ -9,7 +9,23 @@
 
 body.iframe
 {
-  margin-top: 6px;
+  margin-top: 0px;
+}
+
+body.iframe div.boxcontent
+{
+  margin-top: 20px;
+  z-index: 2;
+}
+
+body.iframe div.boxtitle
+{
+  z-index: 100;
+}
+
+body.iframe #prefs-details
+{
+  padding-top: 1px;
 }
 
 #login-form form
@@ -64,6 +80,11 @@
 div.messageheaderbox
 {
   margin-top: 0px;
+}
+
+body.iframe div.messageheaderbox
+{
+  margin-top: 6px;
 }
 
 #abooktoolbar a.buttonPas
@@ -254,7 +275,7 @@
 
 #contact-details
 {
-  margin-top: 12px;
+  margin-top: 20px;
 }
 
 #contact-details form {
diff --git a/skins/default/templates/error.html b/skins/default/templates/error.html
index 36862ce..60af53b 100644
--- a/skins/default/templates/error.html
+++ b/skins/default/templates/error.html
@@ -6,7 +6,7 @@
 </head>
 <body>
 
-<div id="header"><img src="/images/roundcube_logo.png" alt="<roundcube:object name='productname' />" /></div>
+<div id="header"><roundcube:object name="logo" src="/images/roundcube_logo.png" id="logo" border="0" alt="Logo" /></div>
 
 <div style="width:400px; margin:60px auto;">
 $__page_content
diff --git a/skins/default/templates/messageprint.html b/skins/default/templates/messageprint.html
index ea7a320..3102239 100644
--- a/skins/default/templates/messageprint.html
+++ b/skins/default/templates/messageprint.html
@@ -7,7 +7,7 @@
 </head>
 <body>
 
-<div id="header"><img src="/images/roundcube_logo.png" alt="<roundcube:object name="productname" />" /></div>
+<div id="header"><roundcube:object name="logo" src="/images/roundcube_logo.png" id="logo" border="0" alt="Logo" /></div>
 
 <div id="printmessageframe">
 <roundcube:object name="messageHeaders" class="headers-table" cellspacing="0" cellpadding="2" />

--
Gitblit v1.9.1