From 9487c2ff3a9d36af3dc93bd231a6f85fe7a6f762 Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Thu, 25 Oct 2001 10:02:39 +0000 Subject: [PATCH] Focus plugin integrated into the core git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1612 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/page_header.php | 4 +- src/addrbook_search.php | 328 +++++++++++++++++++------------------- src/compose.php | 115 ++++++------- src/folders_create.php | 4 +- src/login.php | 4 +- src/redirect.php | 26 +-- 6 files changed, 239 insertions(+), 242 deletions(-) diff --git a/functions/page_header.php b/functions/page_header.php index 2bc87506..98332826 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -44,9 +44,7 @@ function displayPageHeader($color, $mailbox) { displayHtmlHeader (); - printf('', - $color[8], $color[4], $color[7], $color[7], $color[7]); - echo "\n\n"; + echo "\n\n"; /** Here is the header and wrapping table **/ $shortBoxName = readShortMailboxName($mailbox, "."); diff --git a/src/addrbook_search.php b/src/addrbook_search.php index c010b154..9557065c 100644 --- a/src/addrbook_search.php +++ b/src/addrbook_search.php @@ -35,9 +35,9 @@ function to_address($addr) { if(pwintype != "undefined" ) { if ( parent.opener.document.compose.send_to.value ) { prefix = ", "; - parent.opener.document.compose.send_to.value = + parent.opener.document.compose.send_to.value = parent.opener.document.compose.send_to.value + ", " + $addr; - + } else { parent.opener.document.compose.send_to.value = $addr; } @@ -53,8 +53,8 @@ function cc_address($addr) { if(pwintype != "undefined" ) { if ( parent.opener.document.compose.send_to_cc.value ) { prefix = ", "; - parent.opener.document.compose.send_to_cc.value = - parent.opener.document.compose.send_to_cc.value + ", " + $addr; + parent.opener.document.compose.send_to_cc.value = + parent.opener.document.compose.send_to_cc.value + ", " + $addr; } else { parent.opener.document.compose.send_to_cc.value = $addr; } @@ -64,14 +64,14 @@ function cc_address($addr) { function bcc_address($addr) { var prefix = ""; var pwintype = typeof parent.opener.document.compose; - + $addr = $addr.replace(/ {1,35}$/, ""); if(pwintype != "undefined" ) { if ( parent.opener.document.compose.send_to_bcc.value ) { prefix = ", "; - parent.opener.document.compose.send_to_bcc.value = - parent.opener.document.compose.send_to_bcc.value + ", " + $addr; + parent.opener.document.compose.send_to_bcc.value = + parent.opener.document.compose.send_to_bcc.value + ", " + $addr; } else { parent.opener.document.compose.send_to_bcc.value = $addr; } @@ -80,167 +80,165 @@ function bcc_address($addr) { // --> -'; - printf(" ". - " %s %s". - " %s", - _("Name"), _("E-mail"), _("Info")); - - if($includesource) - printf(" %s", _("Source")); - - print "\n"; - - while(list($undef, $row) = each($res)) { - printf("". - "To | ". - "Cc | ". - "Bcc". - " %s ". - " %s ". - " %s ", - ($line % 2) ? " bgcolor=\"$color[0]\"" : "", - $row["email"], $row["email"], $row["email"], - $row["name"], $row["email"], $row["email"], - $row["label"]); - - if($includesource) - printf(" %s", $row["source"]); - - print "\n"; - $line++; - } - print ''; - } - - /* ================= End of functions ================= */ - - require_once('../functions/array.php'); - require_once('../functions/strings.php'); - require_once('../functions/addressbook.php'); - - displayHtmlHeader(); - - // Initialize vars - if(!isset($query)) $query = ""; - if(!isset($show)) $show = ""; - - // Choose correct colors for top and bottom frame - if($show == 'form') { - echo "'; - } else { - echo "\n"; - } - - // Empty search - if(empty($query) && empty($show) && empty($listall)) { - printf("


%s

\n\n", - _("No persons matching your search was found")); + // List search results + function display_result($res, $includesource = true) { + global $color; + + if(sizeof($res) <= 0) return; + + insert_javascript(); + + $line = 0; + echo ''; + printf("\n"; + + while(list($undef, $row) = each($res)) { + printf("\n"; + $line++; + } + echo '
 ". + " %s %s". + " %s", + _("Name"), _("E-mail"), _("Info")); + + if($includesource) + printf(" %s", _("Source")); + + echo "
". + "To | ". + "Cc | ". + "Bcc". + " %s ". + " %s ". + " %s ", + ($line % 2) ? " bgcolor=\"$color[0]\"" : "", + $row["email"], $row["email"], $row["email"], + $row["name"], $row["email"], $row["email"], + $row["label"]); + + if($includesource) + printf(" %s", $row["source"]); + + echo "
'; + } + + /* ================= End of functions ================= */ + + require_once('../functions/array.php'); + require_once('../functions/strings.php'); + require_once('../functions/addressbook.php'); + + displayHtmlHeader(); + + // Initialize vars + if(!isset($query)) $query = ""; + if(!isset($show)) $show = ""; + + // Choose correct colors for top and bottom frame + if($show == 'form') { + echo "'; + } else { + echo "\n"; + } + + // Empty search + if(empty($query) && empty($show) && empty($listall)) { + printf("


%s

\n\n", + _("No persons matching your search was found")); exit; - } - - // Initialize addressbook - $abook = addressbook_init(); - - // Create search form - if($show == 'form') { - printf("
\n", - $PHP_SELF); - print(''); - print("
\n"); - printf(" %s\n", _("Search for")); - printf(" \n", - htmlspecialchars($query)); - - // List all backends to allow the user to choose where to search - if($abook->numbackends > 1) { - printf("%s \n"; - } else { - print "\n"; - } - - printf("", - _("Search")); - printf(" | \n", + } + + // Initialize addressbook + $abook = addressbook_init(); + + // Create search form + if($show == 'form') { + echo "\n"; + echo ''; + echo "
\n"; + printf(" %s\n", _("Search for")); + printf(" \n", + htmlspecialchars($query)); + + // List all backends to allow the user to choose where to search + if($abook->numbackends > 1) { + printf("%s \n"; + } else { + print "\n"; + } + + printf("", + _("Search")); + printf(" | \n", _("List all")); - print "\n"; - printf("\n", + print "\n"; + printf("\n", _("Close window")); - print "
\n"; - } else - - // Show personal addressbook - if($show == 'blank' || !empty($listall)) { - - if($backend != -1 || $show == 'blank') { - if($show == 'blank') - $backend = $abook->localbackend; - - //printf("

%s

\n", $abook->backends[$backend]->sname); - - $res = $abook->list_addr($backend); - - if(is_array($res)) { - display_result($res, false); - } else { - printf("

"._("Unable to list addresses from %s"). - "

\n", $abook->backends[$backend]->sname); - } - - } else { - $res = $abook->list_addr(); - display_result($res, true); - } - - } else - - // Do the search - if(!empty($query) && empty($listall)) { - - if($backend == -1) { - $res = $abook->s_search($query); - } else { - $res = $abook->s_search($query, $backend); - } - - if(!is_array($res)) { - printf("


%s:
%s

\n\n", - _("Your search failed with the following error(s)"), - $abook->error); - exit; - } - - if(sizeof($res) == 0) { - printf("


%s.

\n\n", - _("No persons matching your search was found")); - exit; - } - - display_result($res); - } -?> - - + print "
\n"; + } else + + // Show personal addressbook + if($show == 'blank' || !empty($listall)) { + + if($backend != -1 || $show == 'blank') { + if($show == 'blank') + $backend = $abook->localbackend; + + $res = $abook->list_addr($backend); + + if(is_array($res)) { + display_result($res, false); + } else { + printf("

"._("Unable to list addresses from %s"). + "

\n", $abook->backends[$backend]->sname); + } + + } else { + $res = $abook->list_addr(); + display_result($res, true); + } + + } else + + // Do the search + if(!empty($query) && empty($listall)) { + + if($backend == -1) { + $res = $abook->s_search($query); + } else { + $res = $abook->s_search($query, $backend); + } + + if(!is_array($res)) { + printf("


%s:
%s

\n\n", + _("Your search failed with the following error(s)"), + $abook->error); + exit; + } + + if(sizeof($res) == 0) { + printf("


%s.

\n\n", + _("No persons matching your search was found")); + exit; + } + + display_result($res); + } + + echo "\n"; + +?> \ No newline at end of file diff --git a/src/compose.php b/src/compose.php index 360cd594..ae21388e 100644 --- a/src/compose.php +++ b/src/compose.php @@ -1,5 +1,5 @@ header->type0 == "text" || $message->header->type1 == "message") { + if ($message->header->type0 == 'text' || $message->header->type1 == 'message') { if ($ent_num) $body = decodeBody(mime_fetch_body($imapConnection, $id, $ent_num), $message->header->encoding); else @@ -60,11 +60,11 @@ } else { $body = ""; } - + if ($message->header->type1 == "html") $body = strip_tags($body); - sqUnWordWrap($body); + sqUnWordWrap($body); $body_ary = explode("\n", $body); $i = count($body_ary) - 1; while ($i >= 0 && ereg("^[>\\s]*$", $body_ary[$i])) { @@ -91,9 +91,9 @@ if ($forward_id) { $bodyTop = "-------- " . _("Original Message") . " --------\n"; - $bodyTop .= _("Subject") . ": " . $orig_header->subject . "\n"; - $bodyTop .= _("From") . ": " . $orig_header->from . "\n"; - $bodyTop .= _("To") . ": " . $orig_header->to[0] . "\n"; + $bodyTop .= _("Subject") . ": " . $orig_header->subject . "\n"; + $bodyTop .= _("From") . ": " . $orig_header->from . "\n"; + $bodyTop .= _("To") . ": " . $orig_header->to[0] . "\n"; if (count($orig_header->to) > 1) { for ($x=1; $x < count($orig_header->to); $x++) { $bodyTop .= " " . $orig_header->to[$x] . "\n"; @@ -108,7 +108,7 @@ $orig_from = str_replace("'",'',$orig_from); $body = getReplyCitation($orig_from) . $body; } - + return; } @@ -122,16 +122,16 @@ $send_to_cc = ereg_replace(";", ",", $send_to_cc); $sendcc = explode(",", $send_to_cc); $send_to_cc = ""; - + for ($i = 0; $i < count($sendcc); $i++) { $sendcc[$i] = trim($sendcc[$i]); if ($sendcc[$i] == "") continue; - + $sendcc[$i] = sqimap_find_email($sendcc[$i]); $whofrom = sqimap_find_displayable_name($msg["HEADER"]["FROM"]); $whoreplyto = sqimap_find_email($msg["HEADER"]["REPLYTO"]); - + if ((strtolower(trim($sendcc[$i])) != strtolower(trim($whofrom))) && (strtolower(trim($sendcc[$i])) != strtolower(trim($whoreplyto))) && (trim($sendcc[$i]) != "")) { @@ -151,17 +151,17 @@ if (!$message) { sqimap_mailbox_select($imapConnection, $mailbox); - $message = sqimap_get_message($imapConnection, $forward_id, + $message = sqimap_get_message($imapConnection, $forward_id, $mailbox); } - + if (count($message->entities) == 0) { if ($message->header->entity_id != $ent_num) { $filename = decodeHeader($message->header->filename); - + if ($filename == "") $filename = "untitled-".$message->header->entity_id; - + $localfilename = GenerateRandomString(32, '', 7); while (file_exists($attachment_dir . $localfilename)) $localfilename = GenerateRandomString(32, '', 7); @@ -174,33 +174,33 @@ // Write Attachment to file $fp = fopen ($attachment_dir.$localfilename, 'w'); - fputs ($fp, decodeBody(mime_fetch_body($imapConnection, - $forward_id, $message->header->entity_id), + fputs ($fp, decodeBody(mime_fetch_body($imapConnection, + $forward_id, $message->header->entity_id), $message->header->encoding)); fclose ($fp); - + $attachments[] = $newAttachment; } } else { for ($i = 0; $i < count($message->entities); $i++) { getAttachments($message->entities[$i]); - } + } } return; - } + } function showInputForm () { global $send_to, $send_to_cc, $reply_subj, $forward_subj, $body, - $passed_body, $color, $use_signature, $signature, $prefix_sig, - $editor_size, $attachments, $subject, $newmail, - $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox, + $passed_body, $color, $use_signature, $signature, $prefix_sig, + $editor_size, $attachments, $subject, $newmail, + $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox, $from_htmladdr_search, $location_of_buttons, $attachment_dir, $username, $data_dir, $identity; $subject = decodeHeader($subject); $reply_subj = decodeHeader($reply_subj); $forward_subj = decodeHeader($forward_subj); - + if ($use_javascript_addr_book) { echo "\n\n"; - } else { + } else { echo " "; - } + } echo "\n \n"; - + do_hook("compose_button_row"); echo " \n"; @@ -393,7 +394,7 @@ // True if FAILURE function saveAttachedFiles() { global $HTTP_POST_FILES, $attachment_dir, $attachments; - + $localfilename = GenerateRandomString(32, '', 7); while (file_exists($attachment_dir . $localfilename)) $localfilename = GenerateRandomString(32, '', 7); @@ -403,10 +404,10 @@ return true; } } - + $newAttachment['localfilename'] = $localfilename; $newAttachment['remotefilename'] = $HTTP_POST_FILES['attachfile']['name']; - $newAttachment['type'] = + $newAttachment['type'] = strtolower($HTTP_POST_FILES['attachfile']['type']); if ($newAttachment['type'] == "") @@ -414,7 +415,7 @@ $attachments[] = $newAttachment; } - + if (!isset($mailbox) || $mailbox == "" || ($mailbox == "None")) $mailbox = "INBOX"; @@ -435,7 +436,7 @@ // We'll change them to \r\n later (in the sendMessage function) $body = str_replace("\r\n", "\n", $body); $body = str_replace("\r", "\n", $body); - + // Rewrap $body so that no line is bigger than $editor_size // This should only really kick in the sqWordWrap function // if the browser doesn't support "HARD" as the wrap type @@ -453,23 +454,23 @@ } } $body = $newBody; - + do_hook("compose_send"); - + if (! sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id)) { - showInputForm(); + showInputForm(); exit(); } Header("Location: right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=1"); } else { //$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); displayPageHeader($color, $mailbox); - + if (isset($AttachFailure)) plain_error_message(_("Could not move/copy file. File not attached"), $color); checkInput(true); - + showInputForm(); //sqimap_logout($imapConnection); } @@ -495,7 +496,7 @@ } } } - + showInputForm(); } else if (isset($html_addr_search)) { if (isset($HTTP_POST_FILES['attachfile']) && @@ -529,7 +530,7 @@ } else { // This handles the default case as well as the error case // (they had the same code) --> if (isset($smtpErrors)) - $imapConnection = sqimap_login($username, $key, $imapServerAddress, + $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); displayPageHeader($color, $mailbox); @@ -539,21 +540,21 @@ if (isset($forward_id) && $forward_id && isset($ent_num) && $ent_num) getAttachments(0); - + newMail(); showInputForm(); sqimap_logout($imapConnection); } - + function ClearAttachments() { global $attachments, $attachment_dir; - + foreach ($attachments as $info) { if (file_exists($attachment_dir . $info['localfilename'])) { unlink($attachment_dir . $info['localfilename']); } } - + $attachments = array(); } @@ -584,5 +585,5 @@ /* Build and return the citation string. */ return ($start . $orig_from . $end . "\n"); - } + } ?> \ No newline at end of file diff --git a/src/folders_create.php b/src/folders_create.php index 09536fab..1f25070b 100644 --- a/src/folders_create.php +++ b/src/folders_create.php @@ -5,7 +5,7 @@ ** Copyright (c) 1999-2000 The SquirrelMail development team ** Licensed under the GNU GPL. For full terms see the file COPYING. ** - ** Creates folders on the IMAP server. + ** Creates folders on the IMAP server. ** Called from folders.php ** ** $Id$ @@ -20,7 +20,7 @@ if (strpos($folder_name, "\"") || strpos($folder_name, "\\") || strpos($folder_name, "'") || strpos($folder_name, "$dm")) { - print ""; + echo ""; plain_error_message(_("Illegal folder name. Please select a different name.")."
"._("Click here to go back").".", $color); sqimap_logout($imapConnection); exit; diff --git a/src/login.php b/src/login.php index c4e1db80..716f0f0c 100644 --- a/src/login.php +++ b/src/login.php @@ -83,11 +83,11 @@ if ($theme_css != "") echo "\n"; - + echo ''; echo $org_name . ' - ' . _("Login"); echo "\n"; - echo "\n"; + echo "\n"; echo "
\n"; $username_form_name = 'login_username'; diff --git a/src/redirect.php b/src/redirect.php index 431ba259..269ea11c 100644 --- a/src/redirect.php +++ b/src/redirect.php @@ -32,12 +32,12 @@ session_unregister ('user_is_logged_in'); session_register ('base_uri'); - if (! isset($squirrelmail_language)) + if (! isset($squirrelmail_language)) $squirrelmail_language = ''; set_up_language($squirrelmail_language, true); - + if(!isset($login_username)) { - echo "\n"; + echo "\n"; echo "

"; echo "
"; echo ""._("You must be logged in to access this page.")."
"; @@ -68,16 +68,16 @@ $login_username = strtolower($login_username); $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); - if (!$imapConnection) { - echo "\n"; - echo "

"; - echo "
"; - echo ""._("There was an error contacting the mail server.")."
"; - echo _("Contact your administrator for help.")."\n"; - echo "
"; - echo "\n"; - exit; - } + if (!$imapConnection) { + echo "\n"; + echo "

"; + echo "
"; + echo ""._("There was an error contacting the mail server.")."
"; + echo _("Contact your administrator for help.")."\n"; + echo "
"; + echo "\n"; + exit; + } sqimap_logout($imapConnection); $username = $login_username; -- 2.25.1