Fix mistake - was using echo instead of adding to output string
[squirrelmail.git] / src / search.php
index 7e037d223a019898a7ca92f5ee249c599a410dc8..54abb0f97ed4ada74ec0479e7b506ec255e3a840 100644 (file)
@@ -8,7 +8,7 @@
  * Subfolder search idea from Patch #806075 by Thomas Pohl xraven at users.sourceforge.net. Thanks Thomas!
  *
  * @author Alex Lemaresquier - Brainstorm <alex at brainstorm.fr>
- * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @copyright &copy; 1999-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -28,9 +28,11 @@ 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()
+//FIXME - comment on next line seems to indicate this require is for the since removed getButton() function...  the next line is thus being commented out... if this proves to be correct, please remove this and the next line completely
+//require_once(SM_PATH . 'functions/mailbox_display.php'); //getButton()
 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 +623,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 '<input '.$disabled.$js.
-            'type="'.$type.
-            '" name="'.$name.
-            '" value="'.$value .
-            '" style="padding: 0px; margin: 0px" />';
-}
-
 /**
  * Print a whole query array, recent or saved
  *
@@ -991,6 +973,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 +981,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 +1020,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 +1031,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 +1042,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 +1054,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 +1066,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 +1075,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 +1083,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 +1094,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);
 }
@@ -1376,7 +1375,7 @@ if (isset($aMailbox['FORWARD_SESSION'])) {
         session_write_close();
         // we have to redirect to the compose page
         $location = SM_PATH . 'src/compose.php?mailbox='. urlencode($mailbox).
-                    '&amp;session='.$aMailbox['FORWARD_SESSION'];
+                    '&session='.$aMailbox['FORWARD_SESSION'];
         header("Location: $location");
         exit;
     }
@@ -1390,7 +1389,7 @@ if (isset($note)) {
     $oTemplate->display('note.tpl');
 }
 
-do_hook('search_before_form');
+do_hook('search_before_form', $null);
 
 if (!$search_silent) {
     asearch_print_saved($boxes);
@@ -1428,7 +1427,7 @@ if (!$search_silent) {
     }
 }
 
-do_hook('search_after_form');
+do_hook('search_after_form', $null);
 
 if ($submit == $search_button_text) {
     $msgsfound = false;
@@ -1606,7 +1605,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);
@@ -1630,9 +1630,9 @@ if ($submit == $search_button_text) {
     }
 }
 
-do_hook('search_bottom');
+do_hook('search_bottom', $null);
 sqimap_logout($imapConnection);
 
 $oTemplate->display('footer.tpl');
 sqsession_register($mailbox_cache,'mailbox_cache');
-?>
\ No newline at end of file
+?>