/**
* imap_mailbox.php
*
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This impliments all functions that manipulate mailboxes
function isBoxBelow( $box2, $box1 ) {
- global $delimiter, $folder_prefix, $imap_server_type;
-
- if ( $imap_server_type == 'uw' ) {
- $boxs = $box2;
- $i = strpos( $box1, $delimiter, strlen( $folder_prefix ) );
- if ( $i === false ) {
- $i = strlen( $box2 );
- }
- } else {
- $boxs = $box2 . $delimiter;
- /* Skip next second delimiter */
- $i = strpos( $box1, $delimiter );
- $i = strpos( $box1, $delimiter, $i + 1 );
- if ( $i === false ) {
- $i = strlen( $box2 );
- } else {
- $i++;
- }
- }
-
- return ( substr( $box1, 0, $i ) == substr( $boxs, 0, $i ) );
+global $delimiter, $folder_prefix, $imap_server_type;
+ if ( $imap_server_type == 'uw' ) {
+ $boxs = $box2;
+ $i = strpos( $box1, $delimiter, strlen( $folder_prefix ) );
+ if ( $i === false ) {
+ $i = strlen( $box2 );
+ }
+ } else {
+ if (substr($box2,0,strlen($box1)) == $box1) {
+ return true;
+ }
+ $boxs = $box2 . $delimiter;
+ /* Skip next second delimiter */
+ $i = strpos( $box1, $delimiter );
+ $i = strpos( $box1, $delimiter, $i + 1 );
+ if ( $i === false ) {
+ $i = strlen( $box2 );
+ } else {
+ $i++;
+ }
+ }
+ return ( substr( $box1, 0, $i ) == substr( $boxs, 0, $i ) );
}
/* Defines special mailboxes */
$move_to_trash, $move_to_sent, $save_as_draft;
$ret = ( (strtolower($box) == 'inbox') ||
- ( $move_to_trash && isBoxBelow( $box, $trash_folder ) ) ||
- ( $move_to_sent && isBoxBelow( $box, $sent_folder )) ||
+ ( $move_to_trash && $trash_folder && isBoxBelow( $box, $trash_folder )) ||
+ ( $move_to_sent && $sent_folder && isBoxBelow( $box, $sent_folder )) ||
($save_as_draft && $box == $draft_folder ) );
if ( !$ret ) {
$ret = do_hook_function( 'special_mailbox', $box );
}
-
return $ret;
}
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);
/* 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);
}
$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");
}
$postfix = '';
}
- $old_name = imap_utf7_encode_local($old_name);
- $new_name = imap_utf7_encode_local($new_name);
-
$boxesall = sqimap_mailbox_list($imap_stream);
$cmd = 'RENAME "' . $old_name . '" "' . $new_name . '"';
$data = sqimap_run_command($imap_stream, $cmd, true, $response, $message);
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));
+ do_hook_function('rename_or_delete_folder',$args = array($old_name, 'rename', $new_name));
$l = strlen( $old_name ) + 1;
$p = 'unformatted';
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 */
$g++;
}
if(is_array($boxes)) {
- $boxes = sort ($boxes);
+ sort ($boxes);
}
return $boxes;
return $mailboxes;
}
+
?>