From 1cd36267a19a2b0accda66827dbdc05ec5ec77be Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 01 Aug 2011 03:58:30 -0400
Subject: [PATCH] - Improved detection of folder rename possibility and its handling

---
 program/steps/settings/edit_folder.inc |   40 +++++++++++++++++++---------------------
 program/include/rcube_imap.php         |    7 +++++--
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index f809288..3ba0589 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -3535,6 +3535,7 @@
         $options['rights']    = $acl && !$options['is_root'] ? (array)$this->my_rights($mailbox) : array();
         $options['special']   = in_array($mailbox, $this->default_folders);
 
+        // Set 'noselect' and 'norename' flags
         if (is_array($options['options'])) {
             foreach ($options['options'] as $opt) {
                 $opt = strtolower($opt);
@@ -3548,12 +3549,14 @@
         }
 
         if (!empty($options['rights'])) {
-            $options['norename'] = !in_array('x', $options['rights']) &&
-                (!in_array('c', $options['rights']) || !in_array('d', $options['rights']));
+            $options['norename'] = !in_array('x', $options['rights']);
             if (!$options['noselect']) {
                 $options['noselect'] = !in_array('r', $options['rights']);
             }
         }
+        else {
+            $options['norename'] = $options['is_root'] || $options['namespace'] != 'personal';
+        }
 
         return $options;
     }
diff --git a/program/steps/settings/edit_folder.inc b/program/steps/settings/edit_folder.inc
index c7f61fe..710c3ff 100644
--- a/program/steps/settings/edit_folder.inc
+++ b/program/steps/settings/edit_folder.inc
@@ -106,28 +106,26 @@
         ),
     );
 
-    if (strlen($path) || !strlen($mbox)) {
-        if (!empty($options) && ($options['norename'] || $options['namespace'] != 'personal')) {
-            // prevent user from moving folder
-            $hidden_path = new html_hiddenfield(array('name' => '_parent', 'value' => $path));
-            $form['props']['fieldsets']['location']['content']['name']['value'] .= $hidden_path->show();
-        }
-        else {
-            $selected = isset($_POST['_parent']) ? $_POST['_parent'] : $path_id;
-            $select = rcmail_mailbox_select(array(
-                'name'        => '_parent',
-                'noselection' => '---',
-                'realnames'   => false,
-                'maxlength'   => 150,
-                'unsubscribed' => true,
-                'exceptions' => array($mbox_imap),
-            ));
+    if (!empty($options) && ($options['norename'] || $options['protected'])) {
+        // prevent user from moving folder
+        $hidden_path = new html_hiddenfield(array('name' => '_parent', 'value' => $path));
+        $form['props']['fieldsets']['location']['content']['name']['value'] .= $hidden_path->show();
+    }
+    else {
+        $selected = isset($_POST['_parent']) ? $_POST['_parent'] : $path_id;
+        $select = rcmail_mailbox_select(array(
+            'name'        => '_parent',
+            'noselection' => '---',
+            'realnames'   => false,
+            'maxlength'   => 150,
+            'unsubscribed' => true,
+            'exceptions' => array($mbox_imap),
+        ));
 
-            $form['props']['fieldsets']['location']['content']['path'] = array(
-                'label' => rcube_label('parentfolder'),
-                'value' => $select->show($selected),
-            );
-        }
+        $form['props']['fieldsets']['location']['content']['path'] = array(
+            'label' => rcube_label('parentfolder'),
+            'value' => $select->show($selected),
+        );
     }
 
     // Settings

--
Gitblit v1.9.1