X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fimap_mailbox.php;h=46873d12d74693a789a386dfcaea6d3296a39667;hb=0c46707d33b0e134bc2edba3362b043b56e9b5e1;hp=90ef906d6e925f843296bd36a87b8d01fee43658;hpb=a8725d932a7c1c27f4fd88cc337d851171aece3f;p=squirrelmail.git diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 90ef906d..46873d12 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -13,6 +13,35 @@ global $boxesnew; +function find_mailbox_name ($mailbox) { + if (ereg(" *\"([^\r\n\"]*)\"[ \r\n]*$", $mailbox, $regs)) + return $regs[1]; + ereg(" *([^ \r\n\"]*)[ \r\n]*$",$mailbox,$regs); + return $regs[1]; + +} + +/** + * If $haystack is a full mailbox name, and $needle is the mailbox + * separator character, returns the second last part of the full + * mailbox name (i.e. the mailbox's parent mailbox) + */ +function readMailboxParent($haystack, $needle) { + + if ($needle == '') { + $ret = ''; + } else { + $parts = explode($needle, $haystack); + $elem = array_pop($parts); + while ($elem == '' && count($parts)) { + $elem = array_pop($parts); + } + $ret = join($needle, $parts); + } + return( $ret ); +} + + function isBoxBelow( $box2, $box1 ) { global $delimiter, $folder_prefix, $imap_server_type; @@ -145,10 +174,12 @@ function sqimap_unsubscribe ($imap_stream, $mailbox) { /* Deletes the given folder */ function sqimap_mailbox_delete ($imap_stream, $mailbox) { + global $data_dir, $username; $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', '')); + removePref($data_dir, $username, "thread_$mailbox"); } /* Determines if the user is subscribed to the folder or not */ @@ -165,7 +196,7 @@ function sqimap_mailbox_is_subscribed($imap_stream, $folder) { /* Renames a mailbox */ function sqimap_mailbox_rename( $imap_stream, $old_name, $new_name ) { if ( $old_name != $new_name ) { - global $delimiter, $imap_server_type; + global $delimiter, $imap_server_type, $data_dir, $username; if ( substr( $old_name, -1 ) == $delimiter ) { $old_name = substr( $old_name, 0, strlen( $old_name ) - 1 ); $new_name = substr( $new_name, 0, strlen( $new_name ) - 1 ); @@ -177,7 +208,10 @@ function sqimap_mailbox_rename( $imap_stream, $old_name, $new_name ) { $cmd = 'RENAME "' . quoteIMAP($old_name) . '" "' . quoteIMAP($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); 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)); $l = strlen( $old_name ) + 1; $p = 'unformatted'; @@ -190,7 +224,10 @@ function sqimap_mailbox_rename( $imap_stream, $old_name, $new_name ) { $response, $message); } sqimap_unsubscribe($imap_stream, $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", $args = array($box[$p], 'rename', $new_sub)); } @@ -338,7 +375,7 @@ function user_strcasecmp($a, $b) { * See comment on sqimap_mailbox_parse() for info about the returned array. */ function sqimap_mailbox_list($imap_stream) { - global $boxesnew, $default_folder_prefix, $optional_delimiter; + global $boxesnew, $default_folder_prefix; if ( !isset( $boxesnew ) ) { @@ -467,9 +504,13 @@ function sqimap_mailbox_list($imap_stream) { $boxesnew[] = $box; $used[$k] = true; } - $spec_sub = $box['formatted']; - $spec_sub = str_replace(" ", "", $box['formatted']); - if (!$used[$k] && preg_match("/^$default_folder_prefix(Sent|Drafts|Trash).{1}$spec_sub$/", $box['unformatted']) ) { + $spec_sub = str_replace(' ', '', $box['formatted']); + + /* In case of problems with preg + here is a ereg version + if (!$used[$k] && ereg("^$default_folder_prefix(Sent|Drafts|Trash).{1}$spec_sub$", $box['unformatted']) ) { */ + + if (!$used[$k] && preg_match("?^$default_folder_prefix(Sent|Drafts|Trash).{1}$spec_sub$?", $box['unformatted']) ) { $boxesnew[] = $box; $used[$k] = true; }