Added what I've changed to devel CVS. (conf.pl rework, CRAM/DIGEST-MD5, config overri...
[squirrelmail.git] / functions / imap_mailbox.php
index f8402f8c7dd45ca6f69dc595a55acff89c99083e..0cae70822d952b131522e978cc4b2f8cb5550e50 100755 (executable)
@@ -10,8 +10,8 @@
  *
  * $Id$
  */
-require_once(SM_PATH . 'functions/imap_utf7_encode_local.php');
-require_once(SM_PATH . 'functions/imap_utf7_decode_local.php');
+require_once(SM_PATH . 'functions/imap_utf7_local.php');
+
 global $boxesnew;
 
 class mailboxes {
@@ -225,7 +225,7 @@ function sqimap_mailbox_create ($imap_stream, $mailbox, $type) {
     if (strtolower($type) == 'noselect') {
         $mailbox .= $delimiter;
     }
-    $mailbox  = imap_utf7_encode_local($mailbox);
+
     $read_ary = sqimap_run_command($imap_stream, "CREATE \"$mailbox\"",
                                    true, $response, $message);
     sqimap_subscribe ($imap_stream, $mailbox);
@@ -239,7 +239,6 @@ function sqimap_subscribe ($imap_stream, $mailbox) {
 
 /* Unsubscribes to an existing folder */
 function sqimap_unsubscribe ($imap_stream, $mailbox) {
-    global $imap_server_type;
     $read_ary = sqimap_run_command($imap_stream, "UNSUBSCRIBE \"$mailbox\"",
                                    true, $response, $message);
 }
@@ -250,7 +249,7 @@ function sqimap_mailbox_delete ($imap_stream, $mailbox) {
     $read_ary = sqimap_run_command($imap_stream, "DELETE \"$mailbox\"",
                                    true, $response, $message);
     sqimap_unsubscribe ($imap_stream, $mailbox);
-    do_hook_function("rename_or_delete_folder", $args = array($mailbox, 'delete', ''));
+    do_hook_function('rename_or_delete_folder', $args = array($mailbox, 'delete', ''));
     removePref($data_dir, $username, "thread_$mailbox");
 }
 
@@ -276,31 +275,33 @@ function sqimap_mailbox_rename( $imap_stream, $old_name, $new_name ) {
         } else {
             $postfix = '';
         }
+
         $boxesall = sqimap_mailbox_list($imap_stream);
-        $cmd = 'RENAME "' . quoteIMAP($old_name) . '" "' .  quoteIMAP($new_name) . '"';
+        $cmd = 'RENAME "' . $old_name . '" "' . $new_name . '"';
         $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message);
         sqimap_unsubscribe($imap_stream, $old_name.$postfix);
-        $oldpref = getPref($data_dir, $username, "thread_".$old_name.$postfix);
-        removePref($data_dir, $username, "thread_".$old_name.$postfix);
+        $oldpref = getPref($data_dir, $username, 'thread_'.$old_name.$postfix);
+        removePref($data_dir, $username, 'thread_'.$old_name.$postfix);
         sqimap_subscribe($imap_stream, $new_name.$postfix);
-        setPref($data_dir, $username, "thread_".$new_name.$postfix, $oldpref);
-        do_hook_function("rename_or_delete_folder",$args = array($old_name, 'rename', $new_name));
+        setPref($data_dir, $username, 'thread_'.$new_name.$postfix, $oldpref);
+        do_hook_function('rename_or_delete_folder',$args = array($old_name, 'rename', $new_name));
         $l = strlen( $old_name ) + 1;
         $p = 'unformatted';
+
         foreach ($boxesall as $box) {
             if (substr($box[$p], 0, $l) == $old_name . $delimiter) {
                 $new_sub = $new_name . $delimiter . substr($box[$p], $l);
                 if ($imap_server_type == 'cyrus') {
-                    $cmd = 'RENAME "' . quoteIMAP($box[$p]) . '" "' .  quoteIMAP($new_sub) . '"';
+                    $cmd = 'RENAME "' . $box[$p] . '" "' . $new_sub . '"';
                     $data = sqimap_run_command($imap_stream, $cmd, true,
                                                $response, $message);
                 }
                 sqimap_unsubscribe($imap_stream, $box[$p]);
-                $oldpref = getPref($data_dir, $username, "thread_".$box[$p]);
-                removePref($data_dir, $username, "thread_".$box[$p]);
+                $oldpref = getPref($data_dir, $username, 'thread_'.$box[$p]);
+                removePref($data_dir, $username, 'thread_'.$box[$p]);
                 sqimap_subscribe($imap_stream, $new_sub);
-                setPref($data_dir, $username, "thread_".$new_sub, $oldpref);
-                do_hook_function("rename_or_delete_folder",
+                setPref($data_dir, $username, 'thread_'.$new_sub, $oldpref);
+                do_hook_function('rename_or_delete_folder',
                                  $args = array($box[$p], 'rename', $new_sub));
             }
         }
@@ -325,9 +326,9 @@ function sqimap_mailbox_parse ($line, $line_lsub) {
     for ($g = 0, $cnt = count($line); $g < $cnt; $g++) {
         /* Store the raw IMAP reply */
         if (isset($line[$g])) {
-            $boxesall[$g]["raw"] = $line[$g];
+            $boxesall[$g]['raw'] = $line[$g];
         } else {
-            $boxesall[$g]["raw"] = '';
+            $boxesall[$g]['raw'] = '';
         }
 
         /* Count number of delimiters ($delimiter) in folder name */
@@ -736,7 +737,7 @@ function sqimap_mailbox_list_all($imap_stream) {
         $g++;
     }
     if(is_array($boxes)) {
-        $boxes = sort ($boxes);
+        sort ($boxes);
     }
 
     return $boxes;