From: kink Date: Wed, 23 Oct 2002 16:16:44 +0000 (+0000) Subject: Some reworking of folders.php and friends. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b7f83b61539e8952b9b337f167870aa99eb772f8;p=squirrelmail.git Some reworking of folders.php and friends. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3954 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/src/folders.php b/src/folders.php index d99e96be..a6c8f639 100644 --- a/src/folders.php +++ b/src/folders.php @@ -46,35 +46,47 @@ echo '
' . html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[4] ); -if ((isset($success) && $success) || - (isset($sent_create) && $sent_create == 'true') || - (isset($trash_create) && $trash_create == 'true')) { - if ($success == "subscribe") { - $td_str = "" . _("Subscribed successfully!") . "
"; - } else if ($success == "unsubscribe") { - $td_str = "" . _("Unsubscribed successfully!") . "
"; - } else if ($success == "delete") { - $td_str = "" . _("Deleted folder successfully!") . "
"; - } else if ($success == "create") { - $td_str = "" . _("Created folder successfully!") . "
"; - } else if ($success == "rename") { - $td_str = "" . _("Renamed successfully!") . "
"; - } else if ($success == "subscribe-doesnotexist") { - $td_str = "" . - _("Subscription Unsuccessful - Folder does not exist.") . - "
"; +if ( isset($success) && $success ) { + + $td_str = ''; + + switch ($success) + { + case 'subscribe': + $td_str .= _("Subscribed successfully!"); + break; + case 'unsubscribe': + $td_str .= _("Unsubscribed successfully!"); + break; + case 'delete': + $td_str .= _("Deleted folder successfully!"); + break; + case 'create': + $td_str .= _("Created folder successfully!"); + break; + case 'rename': + $td_str .= _("Renamed successfully!"); + break; + case 'subscribe-doesnotexist': + $td_str .= _("Subscription Unsuccessful - Folder does not exist."); + break; } + $td_str .= '
'; + + echo html_tag( 'table', html_tag( 'tr', html_tag( 'td', $td_str . - "" . _("refresh folder list") . "" , + '' . + _("refresh folder list") . '' , 'center' ) ) , - 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' ) . "
\n"; -} else { - echo "
"; + 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' ); } + +echo "\n
"; + $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection); @@ -89,7 +101,7 @@ echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspaci "
\n". "
\n". _("as a subfolder of"). - "
". + '
'. "\n"; if ($show_contain_subfolders_option) { - echo "
 "; - echo _("Let this folder contain subfolders"); - echo "
"; + echo '
 ' + . _("Let this folder contain subfolders") + . '
'; } echo "\n"; echo "
\n"; @@ -189,7 +201,7 @@ if ($count_special_folders < count($boxes)) { "\">\n". "\n"; } else { - echo _("No folders found") . "

"; + echo _("No folders found") . '

'; } $boxes_sub = $boxes; @@ -223,11 +235,11 @@ if ($count_special_folders < count($boxes)) { echo " \n"; } } - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n" + . '\n" + . "\n"; } else { echo _("No folders found") . "

"; } @@ -246,8 +258,8 @@ echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspaci html_tag( 'td', '', 'center', $color[0], 'width="50%"' ); if ($count_special_folders < count($boxes)) { - echo "
\n"; - echo "\n"; for ($i = 0; $i < count($boxes); $i++) { $use_folder = true; if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && @@ -260,13 +272,13 @@ if ($count_special_folders < count($boxes)) { echo "

\n"; - echo "\n"; - echo "
\n"; + echo "

\n" + . '\n" + . "\n"; } else { - echo _("No folders were found to unsubscribe from!") . ""; + echo _("No folders were found to unsubscribe from!") . ''; } $boxes_sub = $boxes; @@ -275,50 +287,49 @@ echo html_tag( 'td', '', 'center', $color[0], 'width="50%"' ); if(!$no_list_for_subscribe) { $boxes_all = sqimap_mailbox_list_all ($imapConnection); - $box = ""; - $box2 = ""; + $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"]) { + if ($boxes_all[$i]['unformatted'] == $boxes[$p]['unformatted']) { $use_folder = false; continue; - } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) { + } else if ($boxes_all[$i]['unformatted-dm'] == $folder_prefix) { $use_folder = false; } } if ($use_folder == true) { - $box[$q] = $boxes_all[$i]["unformatted-dm"]; - $box2[$q] = imap_utf7_decode_local($boxes_all[$i]["unformatted-disp"]); + $box[$q] = $boxes_all[$i]['unformatted-dm']; + $box2[$q] = imap_utf7_decode_local($boxes_all[$i]['unformatted-disp']); $q++; } } if ($box && $box2) { - echo "
\n"; - echo "'; for ($q = 0; $q < count($box); $q++) { echo "

"; - echo "\n"; - echo "

\n"; + echo '

' + . '\n" + . "
\n"; } else { - echo _("No folders were found to subscribe to!") . ""; + echo _("No folders were found to subscribe to!") . ''; } } else { /* don't perform the list action -- this is much faster */ - echo "
\n"; - echo _("Subscribe to:") . "
"; - echo ""; - echo "\n"; - echo "
\n"; + echo "
\n" + . _("Subscribe to:") . '
' + . '' + . '\n" + . "
\n"; } -do_hook("folders_bottom"); +do_hook('folders_bottom'); ?> - diff --git a/src/folders_create.php b/src/folders_create.php index d15927cb..604e6561 100644 --- a/src/folders_create.php +++ b/src/folders_create.php @@ -34,22 +34,20 @@ if (isset($_POST['contain_subs'])) { /* end of get globals */ -$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - $folder_name = trim($folder_name); -if (substr_count($folder_name, "\"") || substr_count($folder_name, "\\") || - substr_count($folder_name, "'") || substr_count($folder_name, "$delimiter") || - ($folder_name == '')) { +if (substr_count($folder_name, '"') || substr_count($folder_name, "\\") || + substr_count($folder_name, $delimiter) || ($folder_name == '')) { displayPageHeader($color, 'None'); - plain_error_message(_("Illegal folder name. Please select a different name.")."
"._("Click here to go back").".", $color); - sqimap_logout($imapConnection); + plain_error_message(_("Illegal folder name. Please select a different name."). + '
'._("Click here to go back").'.', $color); + exit; } if (isset($contain_subs) && $contain_subs ) { - $folder_name = "$folder_name$delimiter"; + $folder_name = $folder_name . $delimiter; } if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) { @@ -62,13 +60,17 @@ if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_ $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"); -sqimap_logout($imapConnection); + ?> diff --git a/src/folders_delete.php b/src/folders_delete.php index 93022b07..0f4ac3e9 100644 --- a/src/folders_delete.php +++ b/src/folders_delete.php @@ -6,7 +6,7 @@ * Copyright (c) 1999-2002 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * - * Deltes folders from the IMAP server. + * Deletes folders from the IMAP server. * Called from the folders.php * * $Id$ @@ -21,11 +21,12 @@ require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'functions/array.php'); require_once(SM_PATH . 'functions/tree.php'); require_once(SM_PATH . 'functions/display_messages.php'); +require_once(SM_PATH . 'functions/html.php'); /* -* Incoming values: -* $mailbox - selected mailbox from the form -*/ + * Incoming values: + * $mailbox - selected mailbox from the form + */ /* globals */ $username = $_SESSION['username']; @@ -39,14 +40,44 @@ $mailbox = $_POST['mailbox']; if ($mailbox == '') { displayPageHeader($color, 'None'); - echo ""; - plain_error_message(_("You have not selected a folder to delete. Please do so.")."
"._("Click here to go back").".", $color); + + plain_error_message(_("You have not selected a folder to delete. Please do so."). + '
'._("Click here to go back").'.', $color); + exit; +} + +if (isset($_POST['backingout'])) { + $location = get_location(); + header ("Location: $location/folders.php"); exit; } +if(!isset($_POST['confirmed'])) { + 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?"), $mailbox). + '

'. + + '\n" . + '\n". + '\n". + '


'; + + 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) @@ -57,50 +88,42 @@ else /** lets see if we CAN move folders to the trash.. otherwise, ** just delete them **/ -/* Courier IMAP doesn't like subfolders of Trash */ -if (strtolower($imap_server_type) == "courier") { - $can_move_to_trash = false; -} - -/* If global options say we can't move it into Trash */ -else if(isset($delete_folder) && $delete_folder == true) { - $can_move_to_trash = false; -} - -/* If it's already a subfolder of trash, we'll have to delete it */ -else if(eregi("^".$trash_folder.".+", $mailbox)) { - - $can_move_to_trash = false; - +/* 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 < count($boxes); $i++) { - if ($boxes[$i]["unformatted"] == $trash_folder) { + 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 < count($boxes);$i++) { - if (($boxes[$i]["unformatted-dm"] == $mailbox) && (strlen($boxes[$i]["unformatted-dm"]) == strlen($mailbox))) { - $foldersTree[0]["value"] = $mailbox; - $foldersTree[0]["doIHaveChildren"] = false; +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. */ -$j = 0; -for ($i = 0;$i < count($boxes);$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); +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); } } -/* simpleWalkTreePre(0, $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 **/ @@ -115,17 +138,5 @@ sqimap_logout($imap_stream); $location = get_location(); header ("Location: $location/folders.php?success=delete"); -/* -echo "


"; -echo _("Folder Deleted!"); -echo "

"; -echo _("The folder has been successfully deleted."); -echo "
"; -echo _("Click here"); -echo " "; -echo _("to continue."); -echo "
"; - -echo ""; -*/ + ?> diff --git a/src/folders_rename_do.php b/src/folders_rename_do.php index 8c596eaa..f625ac48 100644 --- a/src/folders_rename_do.php +++ b/src/folders_rename_do.php @@ -18,13 +18,13 @@ 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/display_messages.php'); /* globals */ $username = $_SESSION['username']; $key = $_COOKIE['key']; $delimiter = $_SESSION['delimiter']; $onetimepad = $_SESSION['onetimepad']; -$base_uri = $_SESSION['base_uri']; $orig = $_POST['orig']; $old_name = $_POST['old_name']; @@ -34,6 +34,16 @@ $new_name = $_POST['new_name']; $new_name = trim($new_name); +if (substr_count($new_name, '"') || substr_count($new_name, "\\") || + substr_count($new_name, $delimiter) || ($new_name == '')) { + displayPageHeader($color, 'None'); + + plain_error_message(_("Illegal folder name. Please select a different name."). + '
'._("Click here to go back").'.', $color); + + exit; +} + if ($old_name <> $new_name) { $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); @@ -50,7 +60,7 @@ if ($old_name <> $new_name) { $newone = $new_name; } - // Renaming a folder doesn't renames the folder but leaves you unsubscribed + // Renaming a folder doesn't rename the folder but leaves you unsubscribed // at least on Cyrus IMAP servers. if (isset($isfolder)) { $newone = $newone.$delimiter; @@ -62,5 +72,7 @@ if ($old_name <> $new_name) { sqimap_logout($imapConnection); } -header ('Location: ' . $base_uri . 'src/folders.php?success=rename'); + +header ('Location: ' . get_location() . '/folders.php?success=rename'); + ?> diff --git a/src/folders_rename_getname.php b/src/folders_rename_getname.php index 4b8dff0e..6e494aa7 100644 --- a/src/folders_rename_getname.php +++ b/src/folders_rename_getname.php @@ -17,7 +17,6 @@ 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/html.php'); require_once(SM_PATH . 'functions/display_messages.php'); @@ -34,14 +33,12 @@ $old = $_POST['old']; if ($old == '') { displayPageHeader($color, 'None'); - echo ""; - plain_error_message(_("You have not selected a folder to rename. Please do so.")."
"._("Click here to go back").".", $color); + + plain_error_message(_("You have not selected a folder to rename. Please do so."). + '
'._("Click here to go back").'.', $color); exit; } - -$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) { $isfolder = TRUE; $old = substr($old, 0, strlen($old) - 1); @@ -59,24 +56,21 @@ if (strpos($old, $delimiter)) { displayPageHeader($color, 'None'); echo '
' . - html_tag( 'table', '', 'center', '', 'width="95%" cols="1" border="0"' ) . + 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] ) . - "
\n". + ''. _("New name:"). "
$old_parent $delimiter
\n"; if ( $isfolder ) { - echo ""; + echo ''; } -printf("\n", $old); -printf("\n", $old_name); -echo "\n". - "

". - ""; +printf("\n", $old); +printf("\n", $old_name); +echo '\n". + '
'; -/** Log out this session **/ -sqimap_logout($imapConnection); ?> diff --git a/src/folders_subscribe.php b/src/folders_subscribe.php index d7487b51..154ea472 100644 --- a/src/folders_subscribe.php +++ b/src/folders_subscribe.php @@ -6,7 +6,7 @@ * Copyright (c) 1999-2002 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * - * Subscribe and unsubcribe form folders. + * Subscribe and unsubcribe from folders. * Called from folders.php * * $Id$ @@ -30,16 +30,16 @@ $mailbox = $_POST['mailbox']; /* end globals */ -$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - $location = get_location(); -if (!isset($mailbox) || !isset($mailbox[0]) || $mailbox[0] == "") { +if (!isset($mailbox) || !isset($mailbox[0]) || $mailbox[0] == '') { header("Location: $location/folders.php"); - sqimap_logout($imapConnection); + exit(0); } +$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); + if ($method == 'sub') { if($no_list_for_subscribe && $imap_server_type == 'cyrus') { /* Cyrus, atleast, does not typically allow subscription to @@ -51,38 +51,20 @@ if ($method == 'sub') { exit(0); } } - for ($i=0; $i < count($mailbox); $i++) { $mailbox[$i] = trim($mailbox[$i]); sqimap_subscribe ($imapConnection, $mailbox[$i]); - header("Location: $location/folders.php?success=subscribe"); } + $success = 'subscribe'; } else { for ($i=0; $i < count($mailbox); $i++) { $mailbox[$i] = trim($mailbox[$i]); sqimap_unsubscribe ($imapConnection, $mailbox[$i]); - header("Location: $location/folders.php?success=unsubscribe"); } + $success = 'unsubscribe'; } + sqimap_logout($imapConnection); +header("Location: $location/folders.php?success=$success"); -/* -displayPageHeader($color, 'None'); -echo "


"; -if ($method == "sub") { - echo _("Subscribed Successfully!"); - echo "

"; - echo _("You have been successfully subscribed."); -} else { - echo _("Unsubscribed Successfully!"); - echo "

"; - echo _("You have been successfully unsubscribed."); -} -echo "
"; -echo _("Click here"); -echo " "; -echo _("to continue."); -echo "
"; -echo ""; -*/ ?>