From 32aa007421fc0e1b8620d091a804d61d15c74ba6 Mon Sep 17 00:00:00 2001 From: kink Date: Sat, 26 Mar 2005 18:48:43 +0000 Subject: [PATCH] Completely cleanup the folders management (create/subscribe etc) code. - Remove the many small src/folders_*, concentrate their functionality in functions/folder_manip.php and call that from folders.php. - Saves duplicate code and an IMAP call here and there. - Improve the code itself, replace complex structures with simpler ones which acheive the same. - Improve UI by adding Cancel buttons where appropriate. - Some other small fixes. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9140 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 4 +- functions/folder_manip.php | 328 +++++++++++++++++++++++++++++++++ src/folders.php | 180 ++++++++++-------- src/folders_create.php | 79 -------- src/folders_delete.php | 144 --------------- src/folders_rename_do.php | 85 --------- src/folders_rename_getname.php | 84 --------- src/folders_subscribe.php | 73 -------- 8 files changed, 436 insertions(+), 541 deletions(-) create mode 100644 functions/folder_manip.php delete mode 100644 src/folders_create.php delete mode 100644 src/folders_delete.php delete mode 100644 src/folders_rename_do.php delete mode 100644 src/folders_rename_getname.php delete mode 100644 src/folders_subscribe.php diff --git a/ChangeLog b/ChangeLog index 36afc1b2..41e7b77e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -274,7 +274,9 @@ Version 1.5.1 -- CVS - Add ability to the Filters plugin to filter on Message Body, or both the Headers and the Message Body. - Update the message copy and move functions to allow for error handling. - - Fix the filter plugin from halting the login process when copying errors occur + - Fix the filter plugin from halting the login process when copying errors + occur. + - Clean up the folder management (create, rename, subscribe) code. Version 1.5.0 -------------------- diff --git a/functions/folder_manip.php b/functions/folder_manip.php new file mode 100644 index 00000000..46ba4b9d --- /dev/null +++ b/functions/folder_manip.php @@ -0,0 +1,328 @@ +'._("Click here to go back").'.', $color); + + sqimap_logout($imapConnection); + exit; + } +} + +/** + * Called from folders.php to create a new folder. + */ +function folders_create ($imapConnection, $delimiter, $folder_name, $subfolder, $contain_subs) +{ + folders_checkname($imapConnection, $folder_name, $delimiter); + + global $folder_prefix; + + $folder_name = imap_utf7_encode_local($folder_name); + + if ( ! empty($contain_subs) ) { + $folder_name = $folder_name . $delimiter; + } + + if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) { + $folder_prefix = $folder_prefix . $delimiter; + } + if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)) { + $subfolder_orig = $subfolder; + $subfolder = $folder_prefix . $subfolder; + } else { + $subfolder_orig = $subfolder; + } + + if (trim($subfolder_orig) == '') { + sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, ''); + } else { + sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, ''); + } + + return; +} + +/** + * Called from folders.php, given a folder name, ask the user what this + * folder should be renamed to. + */ +function folders_rename_getname ($imapConnection, $delimiter, $old) { + global $color; + + if ( $old == '' ) { + plain_error_message(_("You have not selected a folder to rename. Please do so."). + '
'._("Click here to go back").'.', $color); + sqimap_logout($imapConnection); + exit; + } + + if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) { + $isfolder = TRUE; + $old = substr($old, 0, strlen($old) - 1); + } else { + $isfolder = FALSE; + } + + $old = imap_utf7_decode_local($old); + + if (strpos($old, $delimiter)) { + $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old)); + $old_parent = substr($old, 0, strrpos($old, $delimiter)); + } else { + $old_name = $old; + $old_parent = ''; + } + + echo '
' . + html_tag( 'table', '', 'center', '', 'width="95%" border="0"' ) . + html_tag( 'tr', + html_tag( 'td', '' . _("Rename a folder") . '', 'center', $color[0] ) + ) . + html_tag( 'tr' ) . + html_tag( 'td', '', 'center', $color[4] ) . + addForm('folders.php'). + addHidden('smaction', 'rename'). + _("New name:"). + '
' . htmlspecialchars($old_parent) . ' ' . htmlspecialchars($delimiter) . '' . + addInput('new_name', $old_name, 25) . '

' . "\n"; + if ( $isfolder ) { + echo addHidden('isfolder', 'true'); + } + echo addHidden('orig', $old). + addHidden('old_name', $old_name). + '\n". + '\n". + '
'; + echo "\n\n"; + + sqimap_logout($imapConnection); + exit; +} + +/** + * Given an old and new folder name, renames the folder. + */ +function folders_rename_do($imapConnection, $delimiter, $orig, $old_name, $new_name) +{ + folders_checkname($imapConnection, $new_name, $delimiter); + + $orig = imap_utf7_encode_local($orig); + $old_name = imap_utf7_encode_local($old_name); + $new_name = imap_utf7_encode_local($new_name); + + if ($old_name != $new_name) { + + if (strpos($orig, $delimiter)) { + $old_dir = substr($orig, 0, strrpos($orig, $delimiter)); + } else { + $old_dir = ''; + } + + if ($old_dir != '') { + $newone = $old_dir . $delimiter . $new_name; + } else { + $newone = $new_name; + } + + // Renaming a folder doesn't rename the folder but leaves you unsubscribed + // at least on Cyrus IMAP servers. + if (isset($isfolder)) { + $newone = $newone.$delimiter; + $orig = $orig.$delimiter; + } + sqimap_mailbox_rename( $imapConnection, $orig, $newone ); + + } + + return; +} + +/** + * Presents a confirmation dialog to the user asking whether they're + * sure they want to delete this folder. + */ +function folders_delete_ask ($imapConnection, $folder_name) +{ + global $color; + + if ($folder_name == '') { + plain_error_message(_("You have not selected a folder to delete. Please do so."). + '
'._("Click here to go back").'.', $color); + exit; + } + + echo '
' . + html_tag( 'table', '', 'center', '', 'width="95%" border="0"' ) . + html_tag( 'tr', + html_tag( 'td', '' . _("Delete Folder") . '', 'center', $color[0] ) + ) . + html_tag( 'tr' ) . + html_tag( 'td', '', 'center', $color[4] ) . + sprintf(_("Are you sure you want to delete %s?"), + str_replace(array(' ','<','>'),array(' ','<','>'), + imap_utf7_decode_local($folder_name))). + addForm('folders.php', 'post')."

\n". + addHidden('smaction', 'delete'). + addHidden('folder_name', $folder_name). + addSubmit(_("Yes"), 'confirmed'). + addSubmit(_("No"), 'cancelbutton'). + '


'; + + echo "\n\n"; + + sqimap_logout($imapConnection); + exit; +} + +/** + * Given a folder, moves it to trash (and all subfolders of it too). + */ +function folders_delete_do ($imapConnection, $delimiter, $folder_name) +{ + require_once(SM_PATH . 'functions/tree.php'); + + $boxes = sqimap_mailbox_list ($imapConnection); + + global $delete_folder, $imap_server_type, $trash_folder, $move_to_trash; + + if (substr($folder_name, -1) == $delimiter) { + $folder_name_no_dm = substr($folder_name, 0, strlen($folder_name) - 1); + } else { + $folder_name_no_dm = $folder_name; + } + + /** lets see if we CAN move folders to the trash.. otherwise, + ** just delete them **/ + + /* Courier IMAP doesn't like subfolders of Trash + * If global options say we can't move it into Trash + * If it's already a subfolder of trash, we'll have to delete it */ + if (strtolower($imap_server_type) == 'courier' || + (isset($delete_folder) && $delete_folder) || + eregi('^'.$trash_folder.'.+', $folder_name) ) + { + $can_move_to_trash = FALSE; + } + /* Otherwise, check if trash folder exits and support sub-folders */ + else { + foreach($boxes as $box) { + if ($box['unformatted'] == $trash_folder) { + $can_move_to_trash = !in_array('noinferiors', $box['flags']); + } + } + } + + /** First create the top node in the tree **/ + foreach($boxes as $box) { + if (($box['unformatted-dm'] == $folder_name) && (strlen($box['unformatted-dm']) == strlen($folder_name))) { + $foldersTree[0]['value'] = $folder_name; + $foldersTree[0]['doIHaveChildren'] = false; + continue; + } + } + + /* Now create the nodes for subfolders of the parent folder + You can tell that it is a subfolder by tacking the mailbox delimiter + on the end of the $folder_name string, and compare to that. */ + foreach($boxes as $box) { + if (substr($box['unformatted'], 0, strlen($folder_name_no_dm . $delimiter)) == ($folder_name_no_dm . $delimiter)) { + addChildNodeToTree($box['unformatted'], $box['unformatted-dm'], $foldersTree); + } + } + + /** Lets start removing the folders and messages **/ + if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/ + walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imapConnection, $foldersTree, $folder_name); + walkTreeInPreOrderDeleteFolders(0, $imapConnection, $foldersTree); + } else { /** if they do NOT wish to move messages to the trash (or cannot)**/ + walkTreeInPreOrderDeleteFolders(0, $imapConnection, $foldersTree); + } + + return; +} + +/** + * Given an array of folder_names, subscribes to each of them. + */ +function folders_subscribe($imapConnection, $folder_names) +{ + global $color; + + if (count($folder_names) == 0 || $folder_names[0] == '') { + plain_error_message(_("You have not selected a folder to subscribe. Please do so."). + '
'._("Click here to go back").'.', $color); + sqimap_logout($imapConnection); + exit; + } + + global $no_list_for_subscribe, $imap_server_type; + + if($no_list_for_subscribe && $imap_server_type == 'cyrus') { + /* Cyrus, atleast, does not typically allow subscription to + * nonexistent folders (this is an optional part of IMAP), + * lets catch it here and report back cleanly. */ + if(!sqimap_mailbox_exists($imapConnection, $folder_names[0])) { + plain_error_message(_("Subscription Unsuccessful - Folder does not exist."). + '
'._("Click here to go back").'.', $color); + sqimap_logout($imapConnection); + exit; + + } + } + foreach ( $folder_names as $folder_name ) { + sqimap_subscribe ($imapConnection, $folder_name); + } + + return; +} + +/** + * Given a list of folder names, unsubscribes from each of them. + */ +function folders_unsubscribe($imapConnection, $folder_names) +{ + global $color; + + if (count($folder_names) == 0 || $folder_names[0] == '') { + plain_error_message(_("You have not selected a folder to unsubscribe. Please do so."). + '
'._("Click here to go back").'.', $color); + sqimap_logout($imapConnection); + exit; + } + + foreach ( $folder_names as $folder_name ) { + sqimap_unsubscribe ($imapConnection, $folder_name); + } + + return; +} + + +?> diff --git a/src/folders.php b/src/folders.php index 86a8a9da..f34dc044 100644 --- a/src/folders.php +++ b/src/folders.php @@ -23,6 +23,7 @@ define('SM_PATH','../'); /* SquirrelMail required files. */ require_once(SM_PATH . 'include/validate.php'); require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/folder_manip.php'); require_once(SM_PATH . 'functions/plugin.php'); require_once(SM_PATH . 'functions/html.php'); require_once(SM_PATH . 'functions/forms.php'); @@ -36,7 +37,7 @@ sqgetGlobalVar('key', $key, SQ_COOKIE); sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); -sqgetGlobalVar('success', $success, SQ_GET); +sqgetGlobalVar('smaction', $action, SQ_POST); /* end of get globals */ @@ -48,38 +49,61 @@ echo '
' . html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[4] ); -if ( isset($success) && $success ) { +$imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0); - $td_str = ''; +/* switch to the right function based on what the user selected */ +if ( sqgetGlobalVar('smaction', $action, SQ_POST) ) { - switch ($success) + switch ($action) { - case 'subscribe': - $td_str .= _("Subscribed successfully!"); + case 'create': + sqgetGlobalVar('folder_name', $folder_name, SQ_POST); + sqgetGlobalVar('subfolder', $subfolder, SQ_POST); + sqgetGlobalVar('contain_subs', $contain_subs, SQ_POST); + folders_create($imapConnection, $delimiter, $folder_name, $subfolder, $contain_subs); + $td_str = _("Created folder successfully."); break; - case 'unsubscribe': - $td_str .= _("Unsubscribed successfully!"); + case 'rename': + if ( sqgetGlobalVar('cancelbutton', $dummy, SQ_POST) ) { + break; + } + if ( ! sqgetGlobalVar('new_name', $new_name, SQ_POST) ) { + sqgetGlobalVar('old_name', $old_name, SQ_POST); + folders_rename_getname($imapConnection, $delimiter, $old_name); + } else { + sqgetGlobalVar('orig', $orig, SQ_POST); + sqgetGlobalVar('old_name', $old_name, SQ_POST); + folders_rename_do($imapConnection, $delimiter, $orig, $old_name, $new_name); + $td_str = _("Renamed successfully!"); + } break; case 'delete': - $td_str .= _("Deleted folder successfully!"); - break; - case 'create': - $td_str .= _("Created folder successfully!"); + if ( sqgetGlobalVar('cancelbutton', $dummy, SQ_POST) ) { + break; + } + sqgetGlobalVar('folder_name', $folder_name, SQ_POST); + if ( sqgetGlobalVar('confirmed', $dummy, SQ_POST) ) { + folders_delete_do($imapConnection, $delimiter, $folder_name); + $td_str = _("Deleted folder successfully."); + } else { + folders_delete_ask($imapConnection, $folder_name); + } break; - case 'rename': - $td_str .= _("Renamed successfully!"); + case 'subscribe': + sqgetGlobalVar('folder_names', $folder_names, SQ_POST); + folders_subscribe($imapConnection, $folder_names); + $td_str = _("Subscribed successfully."); break; - case 'subscribe-doesnotexist': - $td_str .= _("Subscription Unsuccessful - Folder does not exist."); + case 'unsubscribe': + sqgetGlobalVar('folder_names', $folder_names, SQ_POST); + folders_unsubscribe($imapConnection, $folder_names); + $td_str = _("Unsubscribed successfully."); break; - } - - $td_str .= '
'; - + } echo html_tag( 'table', html_tag( 'tr', - html_tag( 'td', $td_str . + html_tag( 'td', '' . $td_str . "
\n" . '' . _("refresh folder list") . '' , 'center' ) @@ -89,7 +113,6 @@ if ( isset($success) && $success ) { echo "\n
"; -$imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection,true); /** CREATING FOLDERS **/ @@ -99,7 +122,8 @@ echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspaci ) . html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[0] ) . - addForm('folders_create.php', 'post', 'cf'). + addForm('folders.php', 'post', 'cf'). + addHidden('smaction','create'). addInput('folder_name', '', 25). "
\n". _("as a subfolder of"). '
'. "\n" + echo addForm('folders.php') + . addHidden('smaction', 'rename') + . "\n" + echo addForm('folders.php') + . addHidden('smaction', 'delete') + . "\n"; - for ($i = 0; $i < count($boxes); $i++) { + echo addForm('folders.php') + . addHidden('smaction', 'unsubscribe') + . "

\n" @@ -282,61 +310,63 @@ if ($show_only_subscribed_folders) { } else { echo _("No folders were found to unsubscribe from!") . ''; } - $boxes_sub = $boxes; /** SUBSCRIBE TO FOLDERS **/ echo html_tag( 'td', '', 'center', $color[0], 'width="50%"' ); if(!$no_list_for_subscribe) { - $boxes_all = sqimap_mailbox_list_all ($imapConnection); - - $box = ''; - $box2 = ''; - for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { - $use_folder = true; - for ($p = 0; $p < count ($boxes); $p++) { - if ($boxes_all[$i]['unformatted'] == $boxes[$p]['unformatted']) { - $use_folder = false; - continue; - } else if ($boxes_all[$i]['unformatted-dm'] == $folder_prefix) { - $use_folder = false; + $boxes_all = sqimap_mailbox_list_all ($imapConnection); + + $subboxes = array(); + // here we filter out all boxes we're already subscribed to, + // so we keep only the unsubscribed ones. + foreach ($boxes_all as $box_a) { + + $use_folder = true; + foreach ( $boxes as $box ) { + if ($box_a['unformatted'] == $box['unformatted'] || + $box_a['unformatted-dm'] == $folder_prefix ) { + $use_folder = false; + } + } + + if ($use_folder == true) { + $box_enc = htmlspecialchars($box_a['unformatted-dm']); + $box_disp = htmlspecialchars(imap_utf7_decode_local($box_a['unformatted-disp'])); + $subboxes[$box_enc] = $box_disp; } } - if ($use_folder == true) { - $box[$q] = htmlspecialchars($boxes_all[$i]['unformatted-dm']); - $box2[$q] = htmlspecialchars(imap_utf7_decode_local($boxes_all[$i]['unformatted-disp'])); - $q++; - } - } - if ($box && $box2) { - echo addForm('folders_subscribe.php?method=sub') - . ''; + + foreach($subboxes as $subbox_enc => $subbox_disp) { + echo ' \n"; + } - for ($q = 0; $q < count($box); $q++) { - echo ' \n"; + echo '

' + . '\n" + . "
\n"; + } else { + echo _("No folders were found to subscribe to.") . ''; } - echo '


' - . '\n" - . "
\n"; - } else { - echo _("No folders were found to subscribe to!") . ''; - } } else { - /* don't perform the list action -- this is much faster */ - echo addForm('folders_subscribe.php?method=sub') + /* don't perform the list action -- this is much faster */ + echo addForm('folders.php') + . addHidden('smaction', 'subscribe') . _("Subscribe to:") . '
' - . '' + . '' . '\n" . "
\n"; } } do_hook('folders_bottom'); +sqimap_logout($imapConnection); ?> - diff --git a/src/folders_create.php b/src/folders_create.php deleted file mode 100644 index 8c68b9de..00000000 --- a/src/folders_create.php +++ /dev/null @@ -1,79 +0,0 @@ -'._("Click here to go back").'.', $color); - - exit; -} - -$folder_name = imap_utf7_encode_local($folder_name); - -if (isset($contain_subs) && $contain_subs ) { - $folder_name = $folder_name . $delimiter; -} - -if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) { - $folder_prefix = $folder_prefix . $delimiter; -} -if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){ - $subfolder_orig = $subfolder; - $subfolder = $folder_prefix . $subfolder; -} else { - $subfolder_orig = $subfolder; -} - -$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - -if (trim($subfolder_orig) == '') { - sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, ''); -} else { - sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, ''); -} - -sqimap_logout($imapConnection); - -$location = get_location(); -header ("Location: $location/folders.php?success=create"); - -?> \ No newline at end of file diff --git a/src/folders_delete.php b/src/folders_delete.php deleted file mode 100644 index c65fcabd..00000000 --- a/src/folders_delete.php +++ /dev/null @@ -1,144 +0,0 @@ -'._("Click here to go back").'.', $color); - exit; -} - -if ( sqgetGlobalVar('backingout', $tmp, SQ_POST) ) { - $location = get_location(); - header ("Location: $location/folders.php"); - exit; -} - -if( !sqgetGlobalVar('confirmed', $tmp, SQ_POST) ) { - displayPageHeader($color, 'None'); - - echo '
' . - html_tag( 'table', '', 'center', '', 'width="95%" border="0"' ) . - html_tag( 'tr', - html_tag( 'td', '' . _("Delete Folder") . '', 'center', $color[0] ) - ) . - html_tag( 'tr' ) . - html_tag( 'td', '', 'center', $color[4] ) . - sprintf(_("Are you sure you want to delete %s?"), str_replace(array(' ','<','>'),array(' ','<','>'),imap_utf7_decode_local($mailbox))). - addForm('folders_delete.php', 'post')."

\n". - addHidden('mailbox', $mailbox). - addSubmit(_("Yes"), 'confirmed'). - addSubmit(_("No"), 'backingout'). - '


'; - - exit; -} - -$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - -$boxes = sqimap_mailbox_list ($imap_stream); -$numboxes = count($boxes); - -global $delete_folder; - -if (substr($mailbox, -1) == $delimiter) - $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1); -else - $mailbox_no_dm = $mailbox; - -/** lets see if we CAN move folders to the trash.. otherwise, - ** just delete them **/ - -/* Courier IMAP doesn't like subfolders of Trash - * If global options say we can't move it into Trash - * If it's already a subfolder of trash, we'll have to delete it */ -if (strtolower($imap_server_type) == 'courier' || - (isset($delete_folder) && $delete_folder) || - eregi('^'.$trash_folder.'.+', $mailbox) ) -{ - $can_move_to_trash = FALSE; -} - -/* Otherwise, check if trash folder exits and support sub-folders */ -else { - for ($i = 0; $i < $numboxes; $i++) { - if ($boxes[$i]['unformatted'] == $trash_folder) { - $can_move_to_trash = !in_array('noinferiors', $boxes[$i]['flags']); - } - } -} - -/** First create the top node in the tree **/ -for ($i = 0; $i < $numboxes; $i++) { - if (($boxes[$i]['unformatted-dm'] == $mailbox) && (strlen($boxes[$i]['unformatted-dm']) == strlen($mailbox))) { - $foldersTree[0]['value'] = $mailbox; - $foldersTree[0]['doIHaveChildren'] = false; - continue; - } -} - -/* Now create the nodes for subfolders of the parent folder - You can tell that it is a subfolder by tacking the mailbox delimiter - on the end of the $mailbox string, and compare to that. */ -for ($i = 0; $i < $numboxes; $i++) { - if (substr($boxes[$i]['unformatted'], 0, strlen($mailbox_no_dm . $delimiter)) == ($mailbox_no_dm . $delimiter)) { - addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]['unformatted-dm'], $foldersTree); - } -} - -/** Lets start removing the folders and messages **/ -if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/ - walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $mailbox); - walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree); -} else { /** if they do NOT wish to move messages to the trash (or cannot)**/ - walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree); -} - -/** Log out this session **/ -sqimap_logout($imap_stream); - -$location = get_location(); -header ("Location: $location/folders.php?success=delete"); - -?> \ No newline at end of file diff --git a/src/folders_rename_do.php b/src/folders_rename_do.php deleted file mode 100644 index ff29eb11..00000000 --- a/src/folders_rename_do.php +++ /dev/null @@ -1,85 +0,0 @@ -'._("Click here to go back").'.', $color); - - exit; -} - -$orig = imap_utf7_encode_local($orig); -$old_name = imap_utf7_encode_local($old_name); -$new_name = imap_utf7_encode_local($new_name); - -if ($old_name <> $new_name) { - - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - - if (strpos($orig, $delimiter)) { - $old_dir = substr($orig, 0, strrpos($orig, $delimiter)); - } else { - $old_dir = ''; - } - - if ($old_dir != '') { - $newone = $old_dir . $delimiter . $new_name; - } else { - $newone = $new_name; - } - - // Renaming a folder doesn't rename the folder but leaves you unsubscribed - // at least on Cyrus IMAP servers. - if (isset($isfolder)) { - $newone = $newone.$delimiter; - $orig = $orig.$delimiter; - } - sqimap_mailbox_rename( $imapConnection, $orig, $newone ); - - // Log out this session - sqimap_logout($imapConnection); - -} - -header ('Location: ' . get_location() . '/folders.php?success=rename'); - -?> \ No newline at end of file diff --git a/src/folders_rename_getname.php b/src/folders_rename_getname.php deleted file mode 100644 index e8563ace..00000000 --- a/src/folders_rename_getname.php +++ /dev/null @@ -1,84 +0,0 @@ -'._("Click here to go back").'.', $color); - exit; -} - -if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) { - $isfolder = TRUE; - $old = substr($old, 0, strlen($old) - 1); -} else { - $isfolder = FALSE; -} - -$old = imap_utf7_decode_local($old); - -if (strpos($old, $delimiter)) { - $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old)); - $old_parent = substr($old, 0, strrpos($old, $delimiter)); -} else { - $old_name = $old; - $old_parent = ''; -} - - -displayPageHeader($color, 'None'); -echo '
' . - html_tag( 'table', '', 'center', '', 'width="95%" border="0"' ) . - html_tag( 'tr', - html_tag( 'td', '' . _("Rename a folder") . '', 'center', $color[0] ) - ) . - html_tag( 'tr' ) . - html_tag( 'td', '', 'center', $color[4] ) . - addForm('folders_rename_do.php'). - _("New name:"). - '
' . htmlspecialchars($old_parent) . ' ' . htmlspecialchars($delimiter) . '' . - addInput('new_name', $old_name, 25) . '
' . "\n"; -if ( $isfolder ) { - echo addHidden('isfolder', 'true'); -} -echo addHidden('orig', $old). - addHidden('old_name', $old_name). - '\n". - '
'; - -?> \ No newline at end of file diff --git a/src/folders_subscribe.php b/src/folders_subscribe.php deleted file mode 100644 index 61bfe84c..00000000 --- a/src/folders_subscribe.php +++ /dev/null @@ -1,73 +0,0 @@ - \ No newline at end of file -- 2.25.1