X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Ffolder_manip.php;h=49a3a3d3331893efd5eb7cd8ec92fe40325708a5;hp=4b4708fdd5665d99f3f0fe146de05b0b674d6a85;hb=8bbbc757da66a7d226c0723ba7b47cb711b728e0;hpb=a74103ddb7785467df4aff77fbb9a59a8b294bb8 diff --git a/functions/folder_manip.php b/functions/folder_manip.php index 4b4708fd..49a3a3d3 100644 --- a/functions/folder_manip.php +++ b/functions/folder_manip.php @@ -3,16 +3,15 @@ /** * folder_manip.php * - * Copyright (c) 1999-2005 The SquirrelMail Project Team - * Licensed under the GNU GPL. For full terms see the file COPYING. - * * Functions for IMAP folder manipulation: * (un)subscribe, create, rename, delete. * + * @author Thijs Kinkhorst + * @copyright © 1999-2007 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail * @see folders.php - * @author Thijs Kinkhorst - kink@squirrelmail.org */ @@ -25,22 +24,29 @@ function folders_checkname($imapConnection, $folder_name, $delimiter) { if (substr_count($folder_name, '"') || substr_count($folder_name, "\\") || substr_count($folder_name, $delimiter) || ($folder_name == '')) { - - global $color; + + global $color, $oTemplate; error_box(_("Illegal folder name.") . "
\n" . - sprintf(_("The name may not contain any of the following: %s"), '" \\ '.$delimiter.'') - . "
\n" . - _("Please select a different name."). - '
'. - _("Click here to go back") . '.', $color); + sprintf(_("The name may not contain any of the following: %s"), '" \\ '.$delimiter.'') + . "
\n" . + _("Please select a different name."). + '
'. + _("Click here to go back") . '.'); sqimap_logout($imapConnection); + $oTemplate->display('footer.tpl'); exit; } } /** * Called from folders.php to create a new folder. + * @param stream $imapConnection imap connection resource + * @param string $delimiter delimiter + * @param string $folder_name new folder name + * @param string $subfolder folder that stores new folder + * @param string $contain_subs if not empty, creates folder that can store subfolders + * @since 1.5.1 */ function folders_create ($imapConnection, $delimiter, $folder_name, $subfolder, $contain_subs) { @@ -49,9 +55,11 @@ function folders_create ($imapConnection, $delimiter, $folder_name, $subfolder, global $folder_prefix; $folder_name = imap_utf7_encode_local($folder_name); - + if ( ! empty($contain_subs) ) { - $folder_name = $folder_name . $delimiter; + $folder_type = 'noselect'; + } else { + $folder_type = ''; } if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) { @@ -65,9 +73,9 @@ function folders_create ($imapConnection, $delimiter, $folder_name, $subfolder, } if (trim($subfolder_orig) == '') { - sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, ''); + sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, $folder_type); } else { - sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, ''); + sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, $folder_type); } return; @@ -78,12 +86,13 @@ function folders_create ($imapConnection, $delimiter, $folder_name, $subfolder, * folder should be renamed to. */ function folders_rename_getname ($imapConnection, $delimiter, $old) { - global $color,$default_folder_prefix; + global $color, $default_folder_prefix, $oTemplate; 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); + sqimap_logout($imapConnection); + $oTemplate->display('footer.tpl'); exit; } @@ -97,7 +106,7 @@ function folders_rename_getname ($imapConnection, $delimiter, $old) { $old = imap_utf7_decode_local($old); if (strpos($old, $delimiter)) { - $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old)); + $old_name = substr($old, strrpos($old, $delimiter)+1); // hide default prefix (INBOX., mail/ or other) $quoted_prefix=preg_quote($default_folder_prefix,'/'); $prefix_length=(preg_match("/^$quoted_prefix/",$old) ? strlen($default_folder_prefix) : 0); @@ -111,30 +120,18 @@ function folders_rename_getname ($imapConnection, $delimiter, $old) { $old_name = $old; $old_parent = ''; } + + sqimap_logout($imapConnection); - 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) . '' . - 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\n\n"; + $oTemplate->assign('dialog_type', 'rename'); + $oTemplate->assign('parent_folder', htmlspecialchars($old_parent)); + $oTemplate->assign('current_full_name', htmlspecialchars($old)); + $oTemplate->assign('current_folder_name', htmlspecialchars($old_name)); + $oTemplate->assign('is_folder', $isfolder); - sqimap_logout($imapConnection); + $oTemplate->display('folder_manip_dialog.tpl'); + $oTemplate->display('footer.tpl'); + exit; } @@ -148,7 +145,7 @@ function folders_rename_do($imapConnection, $delimiter, $orig, $old_name, $new_n $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)) { @@ -182,11 +179,13 @@ function folders_rename_do($imapConnection, $delimiter, $orig, $old_name, $new_n */ function folders_delete_ask ($imapConnection, $folder_name) { - global $color,$default_folder_prefix; + global $color, $default_folder_prefix, $oTemplate; if ($folder_name == '') { plain_error_message(_("You have not selected a folder to delete. Please do so."). '
'._("Click here to go back").'.', $color); + sqimap_logout($imapConnection); + $oTemplate->display('footer.tpl'); exit; } @@ -196,25 +195,15 @@ function folders_delete_ask ($imapConnection, $folder_name) $prefix_length = (preg_match("/^$quoted_prefix/",$visible_folder_name) ? strlen($default_folder_prefix) : 0); $visible_folder_name = substr($visible_folder_name,$prefix_length); - 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(' ','<','>'),$visible_folder_name)). - addForm('folders.php', 'post')."

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


'; - - echo "\n\n\n\n"; - - sqimap_logout($imapConnection); + sqimap_logout($imapConnection); + + $oTemplate->assign('dialog_type', 'delete'); + $oTemplate->assign('folder_name', htmlspecialchars($folder_name)); + $oTemplate->assign('visible_folder_name', htmlspecialchars($visible_folder_name)); + + $oTemplate->display('folder_manip_dialog.tpl'); + $oTemplate->display('footer.tpl'); + exit; } @@ -223,8 +212,8 @@ function folders_delete_ask ($imapConnection, $folder_name) */ function folders_delete_do ($imapConnection, $delimiter, $folder_name) { - require_once(SM_PATH . 'functions/tree.php'); - + include(SM_PATH . 'functions/tree.php'); + $boxes = sqimap_mailbox_list ($imapConnection); global $delete_folder, $imap_server_type, $trash_folder, $move_to_trash; @@ -237,18 +226,10 @@ function folders_delete_do ($imapConnection, $delimiter, $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) ) - { + if ($delete_folder || eregi('^'.$trash_folder.'.+', $folder_name) ) { $can_move_to_trash = FALSE; - } + } else { /* 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']); @@ -290,12 +271,13 @@ function folders_delete_do ($imapConnection, $delimiter, $folder_name) */ function folders_subscribe($imapConnection, $folder_names) { - global $color; + global $color, $oTemplate; 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); + $oTemplate->display('footer.tpl'); exit; } @@ -310,7 +292,7 @@ function folders_subscribe($imapConnection, $folder_names) '
'._("Click here to go back").'.', $color); sqimap_logout($imapConnection); exit; - + } } foreach ( $folder_names as $folder_name ) { @@ -325,12 +307,13 @@ function folders_subscribe($imapConnection, $folder_names) */ function folders_unsubscribe($imapConnection, $folder_names) { - global $color; + global $color, $oTemplate; 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); + $oTemplate->display('footer.tpl'); exit; } @@ -340,6 +323,3 @@ function folders_unsubscribe($imapConnection, $folder_names) return; } - - -?>