Provide View Unsafe Images link on viewing a text/html attachment.
[squirrelmail.git] / src / read_body.php
index 2e1f99872bed384b661570278f8c4041d3d8f780..b04812b0b355c3b144a18601b6902dfda46332fe 100644 (file)
  */
 
 /**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
  */
-define('SM_PATH','../');
+require('../include/init.php');
 
 /* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-//require_once(SM_PATH . 'functions/global.php');
+
+
 require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/imap_asearch.php'); // => move to mailbox_display
 require_once(SM_PATH . 'functions/mime.php');
 require_once(SM_PATH . 'functions/date.php');
 require_once(SM_PATH . 'functions/url_parser.php');
-require_once(SM_PATH . 'functions/html.php');
-//require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/identity.php');
-include_once(SM_PATH . 'functions/arrays.php');
-include_once(SM_PATH . 'functions/mailbox_display.php');
+require_once(SM_PATH . 'functions/arrays.php');
+require_once(SM_PATH . 'functions/mailbox_display.php');
+require_once(SM_PATH . 'functions/forms.php');
+require_once(SM_PATH . 'functions/attachment_common.php');
 
 /**
  * Given an IMAP message id number, this will look it up in the cached
@@ -141,7 +141,7 @@ function view_as_html_link($mailbox, $passed_id, $passed_ent_id, $message) {
         }
     }
     if($has_html == true) {
-        $vars = array('passed_ent_id', 'show_more', 'show_more_cc', 'override_type0', 'override_type1', 'startMessage');
+        $vars = array('passed_ent_id', 'show_more', 'show_more_cc', 'override_type0', 'override_type1', 'startMessage','where', 'what');
 
         $new_link = $base_uri . 'src/read_body.php?passed_id=' . urlencode($passed_id) .
                     '&passed_ent_id=' . urlencode($passed_ent_id) .
@@ -294,8 +294,16 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
 
     if ($useSendmail) {
         require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
-        global $sendmail_path;
-        $deliver = new Deliver_SendMail();
+        global $sendmail_path, $sendmail_args;
+        // Check for outdated configuration
+        if (!isset($sendmail_args)) {
+            if ($sendmail_path=='/var/qmail/bin/qmail-inject') {
+                $sendmail_args = '';
+            } else {
+                $sendmail_args = '-i -t';
+            }
+        }
+        $deliver = new Deliver_SendMail(array('sendmail_args'=>$sendmail_args));
         $stream = $deliver->initStream($composeMessage,$sendmail_path);
     } else {
         require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php');
@@ -318,7 +326,6 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
                 _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' .
                 nl2br(htmlspecialchars($deliver->dlv_server_msg));
         }
-        require_once(SM_PATH . 'functions/display_messages.php');
         plain_error_message($msg, $color);
     } else {
         unset ($deliver);
@@ -433,7 +440,11 @@ function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message,
                     if (!(handleAsSent($mailbox) ||
                           $message->is_deleted ||
                           $passed_ent_id)) {
-                        $mdn_url = $PHP_SELF . '&sendreceipt=1';
+                        $mdn_url = $PHP_SELF;
+                        $mdn_url = set_url_var($PHP_SELF, 'mailbox', urlencode($mailbox));
+                        $mdn_url = set_url_var($PHP_SELF, 'passed_id', $passed_id);
+                        $mdn_url = set_url_var($PHP_SELF, 'passed_ent_id', $passed_ent_id);
+                        $mdn_url = set_url_var($PHP_SELF, 'sendreceipt', 1);
                         if ($FirstTimeSee && $javascript_on) {
                             $script  = '<script type="text/javascript">' . "\n";
                             $script .= '<!--'. "\n";
@@ -489,7 +500,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed
     global $base_uri, $draft_folder, $where, $what, $color, $sort,
            $startMessage, $PHP_SELF, $save_as_draft,
            $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox,
-           $username, $delete_prev_next_display,
+           $username, $delete_prev_next_display, $show_copy_buttons,
            $compose_new_win, $javascript_on, $compose_width, $compose_height;
 
     //FIXME cleanup argument list, use $aMailbox where possible
@@ -578,7 +589,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed
         // top display is enabled.
         if ( $delete_prev_next_display == 1 &&
                in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) {
-            $del_prev_link = _("Delete & Prev");
+            $del_prev_link = _("Delete &amp; Prev");
             if ($prev >= 0) {
                 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
                        '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
@@ -588,7 +599,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed
                 $del_prev_link = '<a href="'.$uri.'">'.$del_prev_link.'</a>';
             }
 
-            $del_next_link = _("Delete & Next");
+            $del_next_link = _("Delete &amp; Next");
             if ($next >= 0) {
                 $uri = $base_uri . 'src/read_body.php?passed_id='.$next.
                        '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
@@ -709,7 +720,14 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed
         }
         $menu_row .= '</select> ';
 
-        $menu_row .= getButton('submit', 'moveButton',_("Move")) . "\n" . '</form>';
+        $menu_row .= getButton('submit', 'moveButton',_("Move")) . "\n";
+
+        // Add msg copy button
+        if ($show_copy_buttons) {
+            $menu_row .= getButton('submit', 'copyButton', _("Copy"));
+        }
+
+        $menu_row .= '</form>';
     }
     $menu_row .= '</td></tr>';
 
@@ -761,7 +779,7 @@ function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
 
     /* Output the download and/or unsafe images link/-s, if any. */
     if ($download_and_unsafe_link) {
-       echo $download_and_unsafe_link;
+        echo $download_and_unsafe_link;
     }
 
     do_hook("read_body_header_right");
@@ -798,11 +816,7 @@ function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
 
 /* get the globals we may need */
 
-sqgetGlobalVar('key',       $key,           SQ_COOKIE);
-sqgetGlobalVar('username',  $username,      SQ_SESSION);
-sqgetGlobalVar('onetimepad',$onetimepad,    SQ_SESSION);
 sqgetGlobalVar('delimiter', $delimiter,     SQ_SESSION);
-sqgetGlobalVar('base_uri',  $base_uri,      SQ_SESSION);
 sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION);
 if (!sqgetGlobalVar('messages', $messages, SQ_SESSION) ) {
     $messages = array();
@@ -878,7 +892,7 @@ sqgetGlobalVar('mailbox_cache',$mailbox_cache,SQ_SESSION);
 /* end of get globals */
 global $sqimap_capabilities, $lastTargetMailbox;
 
-$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+$imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
 $aMailbox = sqm_api_mailbox_select($imapConnection, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array());
 
 
@@ -1029,6 +1043,13 @@ for ($i = 0; $i < $cnt; $i++) {
    }
 }
 
+/**
+ * Write mailbox with updated seen flag information back to cache.
+ */
+$mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox;
+sqsession_register($mailbox_cache,'mailbox_cache');
+$_SESSION['mailbox_cache'] = $mailbox_cache;
+
 displayPageHeader($color, $mailbox,'','');
 formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message,false);
 formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
@@ -1095,11 +1116,5 @@ formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message, false, FALSE);
 
 do_hook('read_body_bottom');
 sqimap_logout($imapConnection);
-
-/**
- * Write mailbox with updated seen flag information back to cache.
- */
-$mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox;
-sqsession_register($mailbox_cache,'mailbox_cache');
 $oTemplate->display('footer.tpl');
 ?>