Add FIXME
[squirrelmail.git] / src / search.php
index 54abb0f97ed4ada74ec0479e7b506ec255e3a840..0aeceddc4a89602e2711f9fc0719d0a211a0102e 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-2007 The SquirrelMail Project Team
+ * @copyright &copy; 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,8 +31,7 @@ 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');
-//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/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');
@@ -891,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);
 }
 
 /**
@@ -1313,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 ;)
 
 
@@ -1366,16 +1374,20 @@ if (isset($aMailbox['FORWARD_SESSION'])) {
             $compose_height = '550';
         }
         // do not use &amp;, 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;
     }
@@ -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');
-?>