فهرست منبع

replacing obsolate function calls with current ones

tokul 19 سال پیش
والد
کامیت
a5b0361c80
1فایلهای تغییر یافته به همراه11 افزوده شده و 6 حذف شده
  1. 11 6
      functions/tree.php

+ 11 - 6
functions/tree.php

@@ -12,6 +12,9 @@
  * @package squirrelmail
  * @package squirrelmail
  */
  */
 
 
+/** @ignore */
+if (! defined('SM_PATH')) define('SM_PATH','../');
+
 /** Clearly, this needs the IMAP functions.. */
 /** Clearly, this needs the IMAP functions.. */
 require_once(SM_PATH . 'functions/imap.php');
 require_once(SM_PATH . 'functions/imap.php');
 
 
@@ -154,24 +157,26 @@ function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tre
     $subFolderName = substr($tree[$index]['value'], $position);
     $subFolderName = substr($tree[$index]['value'], $position);
 
 
     if ($tree[$index]['doIHaveChildren']) {
     if ($tree[$index]['doIHaveChildren']) {
-        sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
+        // create new trash subfolder only if it does not exist.
+        if (!sqimap_mailbox_exists($imap_stream, $trash_folder . $delimiter . $subFolderName))
+            sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
+
         $mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
         $mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
         $messageCount = $mbx_response['EXISTS'];
         $messageCount = $mbx_response['EXISTS'];
         if ($messageCount > 0) {
         if ($messageCount > 0) {
-            // FIXME: broken call
-            sqimap_messages_copy($imap_stream, 1, '*', $trash_folder . $delimiter . $subFolderName);
+            sqimap_msgs_list_copy($imap_stream, '1:*', $trash_folder . $delimiter . $subFolderName);
         }
         }
         // after copy close the mailbox to get in unselected state
         // after copy close the mailbox to get in unselected state
         sqimap_run_command($imap_stream,'CLOSE',false,$response,$message);
         sqimap_run_command($imap_stream,'CLOSE',false,$response,$message);
         for ($j = 0;$j < count($tree[$index]['subNodes']); $j++)
         for ($j = 0;$j < count($tree[$index]['subNodes']); $j++)
             walkTreeInPostOrderCreatingFoldersUnderTrash($tree[$index]['subNodes'][$j], $imap_stream, $tree, $topFolderName);
             walkTreeInPostOrderCreatingFoldersUnderTrash($tree[$index]['subNodes'][$j], $imap_stream, $tree, $topFolderName);
     } else {
     } else {
-        sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, '');
+        if (!sqimap_mailbox_exists($imap_stream, $trash_folder . $delimiter . $subFolderName))
+            sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, '');
         $mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
         $mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
         $messageCount = $mbx_response['EXISTS'];
         $messageCount = $mbx_response['EXISTS'];
         if ($messageCount > 0) {
         if ($messageCount > 0) {
-            // FIXME: broken call
-            sqimap_messages_copy($imap_stream, 1, '*', $trash_folder . $delimiter . $subFolderName);
+            sqimap_msgs_list_copy($imap_stream, '1:*', $trash_folder . $delimiter . $subFolderName);
         }
         }
         // after copy close the mailbox to get in unselected state
         // after copy close the mailbox to get in unselected state
         sqimap_run_command($imap_stream,'CLOSE',false,$response,$message);
         sqimap_run_command($imap_stream,'CLOSE',false,$response,$message);