+ $recent_prefkeys = array('search_where', 'search_folder', 'search_what', 'search_unop');
+ $saved_prefkeys = array('saved_where', 'saved_folder', 'saved_what', 'saved_unop');
+}
+
+/** How we did enter the form
+ * - unset : Enter key, or called from outside (eg read_body)
+ * - $search_button_text : Search button
+ * - 'Search_no_update' : Search but don't update recent
+ * - 'Search_last' : Same as no_update but reload and search last
+ * - 'Search_silent' : Same as no_update but only display results
+ * - $add_criteria_button_text : Add New Criteria button
+ * - $del_excluded_button_text : Remove Excluded Criteria button
+ * - $del_all_button_text : Remove All Criteria button
+ * - 'save_recent'
+ * - 'search_recent'
+ * - 'forget_recent'
+ * - 'edit_saved'
+ * - 'search_saved'
+ * - 'delete_saved'
+ * @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']);
+}
+
+/** Searched mailboxes
+ * @global array $mailbox_array
+ */
+/* 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);
+ }
+} else {
+ $mailbox_array = array();
+ $targetmailbox = array();
+}
+$aMailboxGlobalPref = array(
+ MBX_PREF_SORT => 0,
+ MBX_PREF_LIMIT => (int) $show_num,
+ MBX_PREF_AUTO_EXPUNGE => (bool) $auto_expunge,
+ MBX_PREF_INTERNALDATE => (bool) getPref($data_dir, $username, 'internal_date_sort')
+ // MBX_PREF_FUTURE => (var) $future
+ );
+
+/**
+ * system wide admin settings and incoming vars.
+ */
+$aConfig = array(
+// 'allow_thread_sort' => $allow_thread_sort,
+// 'allow_server_sort' => $allow_server_sort,
+ 'user' => $username,
+ 'setindex' => 1
+ );
+
+/** 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))
+ $biop_array = array($biop_array);
+} else {
+ $biop_array = array();
+}
+/** 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))
+ $unop_array = array($unop_array);
+} else {
+ $unop_array = array();
+}
+/** 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)) {
+ $where_array = array($where_array);
+ }
+} else {
+ $where_array = array();
+}
+/** 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)) {
+ $what_array = array($what_array);
+ }
+} else {
+ $what_array = array();
+}
+/** 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 {
+ $exclude_array = array();
+}
+/** 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 {
+ $sub_array = array();
+}
+/** 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']);
+}
+/** Change global sort
+ */
+if (sqgetGlobalVar('srt', $temp, SQ_GET)) {
+ $srt = (int) $temp;
+ asearch_edit_last(1);
+// asearch_push_recent($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array);
+}
+/* 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);
+}
+
+if ( sqgetGlobalVar('showall', $temp, SQ_GET) ) {
+ $showall = (int) $temp;
+ asearch_edit_last(1);
+// asearch_push_recent($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array);
+}
+
+if ( sqgetGlobalVar('account', $temp, SQ_GET) ) {
+ $iAccount = (int) $temp;
+} else {
+ $iAccount = 0;
+}
+
+/**
+ * Incoming submit buttons from the message list with search results
+ */
+if (sqgetGlobalVar('moveButton', $moveButton, SQ_POST) ||
+ sqgetGlobalVar('expungeButton', $expungeButton, SQ_POST) ||
+ sqgetGlobalVar('delete', $markDelete, SQ_POST) ||
+ sqgetGlobalVar('undeleteButton', $undeleteButton, SQ_POST) ||
+ sqgetGlobalVar('markRead', $markRead, SQ_POST) ||
+ sqgetGlobalVar('markUnread', $markUnread, SQ_POST) ||
+ sqgetGlobalVar('markFlagged', $markFlagged, SQ_POST) ||
+ sqgetGlobalVar('markUnflagged', $markUnflagged, SQ_POST) ||
+ sqgetGlobalVar('attache', $attache, SQ_POST)) {
+ asearch_edit_last(1);
+ $submit = '';
+ asearch_push_recent($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array);
+}
+
+
+
+/** Toggle show/hide saved searches
+ */
+if (sqgetGlobalVar('search_show_saved', $search_show_saved, SQ_GET)) {
+ setPref($data_dir, $username, 'search_show_saved', $search_show_saved & 1);
+}
+/** Toggle show/hide recent searches
+ */
+if (sqgetGlobalVar('search_show_recent', $search_show_recent, SQ_GET)) {
+ setPref($data_dir, $username, 'search_show_recent', $search_show_recent & 1);