X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fsearch.php;h=0aeceddc4a89602e2711f9fc0719d0a211a0102e;hp=5622b460a7856703266479cb3556e10a062e7635;hb=712a518f5a94d77054bca499038699990fd4a5a2;hpb=6e515418431c0a99f10705da21366fe7093f95b6 diff --git a/src/search.php b/src/search.php index 5622b460..0aeceddc 100644 --- a/src/search.php +++ b/src/search.php @@ -8,7 +8,7 @@ * Subfolder search idea from Patch #806075 by Thomas Pohl xraven at users.sourceforge.net. Thanks Thomas! * * @author Alex Lemaresquier - Brainstorm - * @copyright © 1999-2006 The SquirrelMail Project Team + * @copyright © 1999-2009 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail @@ -17,6 +17,9 @@ * @todo explain why references are used in function calls */ +/** This is the search page */ +define('PAGE_NAME', 'search'); + /** * Include the SquirrelMail initialization file. */ @@ -28,9 +31,10 @@ require_once(SM_PATH . 'functions/imap_asearch.php'); require_once(SM_PATH . 'functions/imap_messages.php'); require_once(SM_PATH . 'functions/imap_general.php'); require_once(SM_PATH . 'functions/mime.php'); -require_once(SM_PATH . 'functions/mailbox_display.php'); //getButton() +require_once(SM_PATH . 'functions/mailbox_display.php'); //sqm_api_mailbox_select require_once(SM_PATH . 'functions/forms.php'); require_once(SM_PATH . 'functions/date.php'); +require_once(SM_PATH . 'functions/compose.php'); /** Prefs array ordinals. Must match $recent_prefkeys and $saved_prefkeys */ @@ -621,26 +625,6 @@ function asearch_get_query_display(&$color, &$mailbox_array, &$biop_array, &$uno return $query_display; } -/** - * Creates button - * - * @deprecated see form functions available in 1.5.1 and 1.4.3. - * @param string $type - * @param string $name - * @param string $value - * @param string $js - * @param bool $enabled - */ -function getButton($type, $name, $value, $js = '', $enabled = TRUE) { - $disabled = ( $enabled ? '' : 'disabled ' ); - $js = ( $js ? $js.' ' : '' ); - return ''; -} - /** * Print a whole query array, recent or saved * @@ -909,8 +893,14 @@ function sqimap_asearch_get_selectable_unformatted_mailboxes(&$boxes) /* get globals we will need */ sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); -if ( sqgetGlobalVar('checkall', $temp, SQ_GET) ) { - $checkall = (int) $temp; +if (!sqgetGlobalVar('checkall',$checkall,SQ_GET)) { + $checkall = false; +} + +if (!sqgetGlobalVar('preselected', $preselected, SQ_GET) || !is_array($preselected)) { + $preselected = array(); +} else { + $preselected = array_keys($preselected); } /** @@ -991,6 +981,7 @@ if ($search_advanced) { * @global string $submit */ $searchpressed = false; +//FIXME: Why is there so much access to $_GET in this file? What's wrong with sqGetGlobalVar? if (isset($_GET['submit'])) { $submit = strip_tags($_GET['submit']); } @@ -998,9 +989,17 @@ if (isset($_GET['submit'])) { /** Searched mailboxes * @global array $mailbox_array */ -if (isset($_GET['mailbox'])) { - $mailbox_array = $_GET['mailbox']; - $targetmailbox = $_GET['mailbox']; +/* when using compact paginator, mailbox might be indicated in $startMessage, so look for it now ($startMessage is then processed farther below) */ +$mailbox = ''; +$startMessage = ''; +if (sqGetGlobalVarMultiple('startMessage', $temp, 'paginator_submit', SQ_FORM)) { + if (strstr($temp, '_')) list($startMessage, $mailbox) = explode('_', $temp); + else $startMessage = $temp; +} +if (empty($mailbox)) sqGetGlobalVar('mailbox', $mailbox, SQ_GET, ''); +if (!empty($mailbox)) { + $mailbox_array = $mailbox; + $targetmailbox = $mailbox; if (!is_array($mailbox_array)) { $mailbox_array = array($mailbox_array); } @@ -1029,6 +1028,7 @@ $aConfig = array( /** Binary operators * @global array $biop_array */ +//FIXME: Why is there so much access to $_GET in this file? What's wrong with sqGetGlobalVar? if (isset($_GET['biop'])) { $biop_array = $_GET['biop']; if (!is_array($biop_array)) @@ -1039,6 +1039,7 @@ if (isset($_GET['biop'])) { /** Unary operators * @global array $unop_array */ +//FIXME: Why is there so much access to $_GET in this file? What's wrong with sqGetGlobalVar? if (isset($_GET['unop'])) { $unop_array = $_GET['unop']; if (!is_array($unop_array)) @@ -1049,6 +1050,7 @@ if (isset($_GET['unop'])) { /** Where to search * @global array $where_array */ +//FIXME: Why is there so much access to $_GET in this file? What's wrong with sqGetGlobalVar? if (isset($_GET['where'])) { $where_array = $_GET['where']; if (!is_array($where_array)) { @@ -1060,6 +1062,7 @@ if (isset($_GET['where'])) { /** What to search * @global array $what_array */ +//FIXME: Why is there so much access to $_GET in this file? What's wrong with sqGetGlobalVar? if (isset($_GET['what'])) { $what_array = $_GET['what']; if (!is_array($what_array)) { @@ -1071,6 +1074,7 @@ if (isset($_GET['what'])) { /** Whether to exclude this criteria from search * @global array $exclude_array */ +//FIXME: Why is there so much access to $_GET in this file? What's wrong with sqGetGlobalVar? if (isset($_GET['exclude'])) { $exclude_array = $_GET['exclude']; } else { @@ -1079,6 +1083,7 @@ if (isset($_GET['exclude'])) { /** Search within subfolders * @global array $sub_array */ +//FIXME: Why is there so much access to $_GET in this file? What's wrong with sqGetGlobalVar? if (isset($_GET['sub'])) { $sub_array = $_GET['sub']; } else { @@ -1086,6 +1091,7 @@ if (isset($_GET['sub'])) { } /** Row number used by recent and saved stuff */ +//FIXME: Why is there so much access to $_GET in this file? What's wrong with sqGetGlobalVar? if (isset($_GET['rownum'])) { $submit_rownum = strip_tags($_GET['rownum']); } @@ -1096,8 +1102,9 @@ if (sqgetGlobalVar('srt', $temp, SQ_GET)) { asearch_edit_last(1); // asearch_push_recent($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array); } -if (sqgetGlobalVar('startMessage', $temp, SQ_GET)) { - $startMessage = (int) $temp; +/* already retrieved startMessage above */ +if (!empty($startMessage)) { + $startMessage = (int) $startMessage; asearch_edit_last(1); // asearch_push_recent($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array); } @@ -1314,7 +1321,7 @@ $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, $boxes = sqimap_mailbox_list($imapConnection); /* ensure we have a valid default mailbox name */ $mailbox = asearch_nz($mailbox_array[0]); -if (($mailbox == '') || ($mailbox == 'None')) //Workaround for sm quirk IMHO (what if I really have a mailbox called None?) +if ($mailbox == '') $mailbox = $boxes[0]['unformatted']; //Usually INBOX ;) @@ -1367,16 +1374,20 @@ if (isset($aMailbox['FORWARD_SESSION'])) { $compose_height = '550'; } // do not use &, it will break the query string and $session will not be detected!!! - $comp_uri = SM_PATH . 'src/compose.php?mailbox='. urlencode($mailbox). - '&session='.$aMailbox['FORWARD_SESSION']; + $comp_uri = $base_uri . 'src/compose.php?mailbox='. urlencode($mailbox) + . '&session='.$aMailbox['FORWARD_SESSION']['SESSION_NUMBER'] + . '&smaction=forward_as_attachment' + . '&fwduid=' . implode('_', $aMailbox['FORWARD_SESSION']['UIDS']); displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri', $compose_width, $compose_height);", false); } else { // save mailboxstate sqsession_register($aMailbox,'aLastSelectedMailbox'); session_write_close(); // we have to redirect to the compose page - $location = SM_PATH . 'src/compose.php?mailbox='. urlencode($mailbox). - '&session='.$aMailbox['FORWARD_SESSION']; + $location = $base_uri . 'src/compose.php?mailbox='. urlencode($mailbox) + . '&session='.$aMailbox['FORWARD_SESSION']['SESSION_NUMBER'] + . '&smaction=forward_as_attachment' + . '&fwduid=' . implode('_', $aMailbox['FORWARD_SESSION']['UIDS']); header("Location: $location"); exit; } @@ -1606,7 +1617,8 @@ if ($submit == $search_button_text) { $oTemplate->assign('page_selector', $page_selector); $oTemplate->assign('page_selector_max', $page_selector_max); $oTemplate->assign('compact_paginator', $compact_paginator); - $oTemplate->assign('javascript_on', $javascript_on); + $oTemplate->assign('javascript_on', checkForJavascript()); + $oTemplate->assign('base_uri', sqm_baseuri()); $oTemplate->assign('enablesort', (isset($aProps['config']['enablesort'])) ? $aProps['config']['enablesort'] : false); $oTemplate->assign('icon_theme_path', $icon_theme_path); $oTemplate->assign('use_icons', (isset($use_icons)) ? $use_icons : false); @@ -1614,6 +1626,15 @@ if ($submit == $search_button_text) { $oTemplate->assign('alt_index_colors', isset($alt_index_colors) ? $alt_index_colors: false); $oTemplate->assign('color', $color); $oTemplate->assign('align', $align); + $oTemplate->assign('checkall', $checkall); + $oTemplate->assign('preselected', $preselected); + + global $show_personal_names; + $oTemplate->assign('show_personal_names', $show_personal_names); + + global $accesskey_mailbox_toggle_selected, $accesskey_mailbox_thread; + $oTemplate->assign('accesskey_mailbox_toggle_selected', $accesskey_mailbox_toggle_selected); + $oTemplate->assign('accesskey_mailbox_thread', $accesskey_mailbox_thread); $oTemplate->display('message_list.tpl'); } @@ -1635,4 +1656,3 @@ sqimap_logout($imapConnection); $oTemplate->display('footer.tpl'); sqsession_register($mailbox_cache,'mailbox_cache'); -?>