X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fmailbox_display.php;h=29a3b340e178cf25fdcf279eb6956b2e2d02eb55;hp=0f50c06eddd0d933b75718a806c9b324d075e4a2;hb=426815a31523da074c7ee9d31be791f2f67a7d7a;hpb=4127171c46d6990dfdc6fd4a4cda39299ff1fbfd diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 0f50c06e..29a3b340 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -6,7 +6,7 @@ * This contains functions that display mailbox information, such as the * table row that has sender, date, subject, etc... * - * @copyright © 1999-2006 The SquirrelMail Project Team + * @copyright © 1999-2007 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail @@ -427,7 +427,7 @@ function fetchMessageHeaders($imapConnection, &$aMailbox) { function prepareMessageList(&$aMailbox, $aProps) { /* Globalize link attributes so plugins can share in modifying them */ - global $link, $title, $target, $onclick, $link_extra; + global $link, $title, $target, $onclick, $link_extra, $preselected; /* retrieve the properties */ $my_email_address = (isset($aProps['email'])) ? $aProps['email'] : false; @@ -569,7 +569,7 @@ function prepareMessageList(&$aMailbox, $aProps) { $sTrunc = truncateWithEntities($sTmp, $aColumnDesc[$k]['truncate']); if ($sTrunc != $sTmp) { if (!$title) { - $title = htmlspecialchars($sTmp); + $title = $sTmp; } else if ($title_maybe) { $title = $title .', '.$title_maybe; $title = substr($title,0,-2); // strip ', '; @@ -606,7 +606,8 @@ function prepareMessageList(&$aMailbox, $aProps) { // $onclick, $link_extra, $title, and so forth) // plugins are responsible for sharing nicely (such as for // setting the target, etc) - do_hook('subject_link', $temp=array(&$iPageOffset, &$sSearch, &$aSearch)); + $temp = array(&$iPageOffset, &$sSearch, &$aSearch, $aMsg); + do_hook('subject_link', $temp); } $value = (trim($value)) ? $value : _("(no subject)"); /* add thread indentation */ @@ -627,7 +628,7 @@ function prepareMessageList(&$aMailbox, $aProps) { 'draft' => false); if(!is_array($value)) $value = array(); - foreach ($value as $sFlag => $value) { + foreach ($value as $sFlag => $v) { switch ($sFlag) { case '\\seen' : $aFlagColumn['seen'] = true; break; case '\\deleted' : $aFlagColumn['deleted'] = true; break; @@ -646,7 +647,7 @@ function prepareMessageList(&$aMailbox, $aProps) { $value = (is_array($value) && $value[0] == 'multipart' && $value[1] == 'mixed') ? true : false; break; case SQM_COL_CHECK: - $value = $checkall; + $value = ($checkall || in_array($iUid, $preselected)); break; default : break; } @@ -987,11 +988,11 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { $thread_name = _("Thread View"); $newsort = $aMailbox['SORT'] + SQSORT_THREAD; } - $thread_link_str = '[' . $thread_name - . ']'; + $thread_link_uri = $baseurl . '&srt=' . $newsort + . '&startMessage=1'; } else { - $thread_link_str =''; + $thread_link_uri =''; + $thread_name = ''; } $sort = $aMailbox['SORT']; @@ -1151,9 +1152,11 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { $aTemplate['trash_folder'] = $trash_folder; $aTemplate['sent_folder'] = $sent_folder; $aTemplate['draft_folder'] = $draft_folder; - $aTemplate['thread_link_str'] = $thread_link_str; + $aTemplate['thread_link_uri'] = $thread_link_uri; + $aTemplate['thread_name'] = $thread_name; $aTemplate['php_self'] = str_replace('&','&',$php_self); $aTemplate['mailbox'] = $sMailbox; +//FIXME: javascript_on is always assigned to the template object in places like init.php; is there some reason to reassign it here? is there some chance that it was changed? if not, please remove this line! $aTemplate['javascript_on'] = (isset($aProps['config']['javascript_on'])) ? $aProps['config']['javascript_on'] : false; $aTemplate['enablesort'] = (isset($aProps['config']['enablesort'])) ? $aProps['config']['enablesort'] : false; $aTemplate['icon_theme'] = (isset($aProps['config']['icon_theme'])) ? $aProps['config']['icon_theme'] : false; @@ -1297,29 +1300,32 @@ function handleAsSent($mailbox) { * use it i.e. in read_body.php for del move next and update the cache * * @param resource $imapConnection imap connection - * @param array $aMailbox (reference) cached mailbox - * @param string $sButton fake a submit button - * @param array $aUid fake the $msg array + * @param array $aMailbox (reference) cached mailbox + * @param string $sButton fake a submit button + * @param array $aUid fake the $msg array + * @param string $targetMailbox fake the target mailbox for move operations + * @param boolean $bypass_trash fake the bypass trash checkbox for delete operations * @return string $sError error string in case of an error * @since 1.5.1 * @author Marc Groot Koerkamp */ -function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = array()) { +function handleMessageListForm($imapConnection, &$aMailbox, $sButton='', + $aUid = array(), $targetMailbox='', $bypass_trash=NULL) { /* incoming formdata */ - $sButton = (sqgetGlobalVar('moveButton', $sTmp, SQ_POST)) ? 'move' : $sButton; - $sButton = (sqgetGlobalVar('copyButton', $sTmp, SQ_POST)) ? 'copy' : $sButton; - $sButton = (sqgetGlobalVar('expungeButton', $sTmp, SQ_POST)) ? 'expunge' : $sButton; - $sButton = (sqgetGlobalVar('forward', $sTmp, SQ_POST)) ? 'forward' : $sButton; - $sButton = (sqgetGlobalVar('delete', $sTmp, SQ_POST)) ? 'setDeleted' : $sButton; - $sButton = (sqgetGlobalVar('undeleteButton', $sTmp, SQ_POST)) ? 'unsetDeleted' : $sButton; - $sButton = (sqgetGlobalVar('markRead', $sTmp, SQ_POST)) ? 'setSeen' : $sButton; - $sButton = (sqgetGlobalVar('markUnread', $sTmp, SQ_POST)) ? 'unsetSeen' : $sButton; - $sButton = (sqgetGlobalVar('markFlagged', $sTmp, SQ_POST)) ? 'setFlagged' : $sButton; - $sButton = (sqgetGlobalVar('markUnflagged', $sTmp, SQ_POST)) ? 'unsetFlagged' : $sButton; - sqgetGlobalVar('targetMailbox', $targetMailbox, SQ_POST); - sqgetGlobalVar('bypass_trash', $bypass_trash, SQ_POST); - sqgetGlobalVar('msg', $msg, SQ_POST); - if (sqgetGlobalVar('account', $iAccount, SQ_POST) === false) { + $sButton = (sqgetGlobalVar('moveButton', $sTmp, SQ_FORM)) ? 'move' : $sButton; + $sButton = (sqgetGlobalVar('copyButton', $sTmp, SQ_FORM)) ? 'copy' : $sButton; + $sButton = (sqgetGlobalVar('expungeButton', $sTmp, SQ_FORM)) ? 'expunge' : $sButton; + $sButton = (sqgetGlobalVar('forward', $sTmp, SQ_FORM)) ? 'forward' : $sButton; + $sButton = (sqgetGlobalVar('delete', $sTmp, SQ_FORM)) ? 'setDeleted' : $sButton; + $sButton = (sqgetGlobalVar('undeleteButton', $sTmp, SQ_FORM)) ? 'unsetDeleted' : $sButton; + $sButton = (sqgetGlobalVar('markRead', $sTmp, SQ_FORM)) ? 'setSeen' : $sButton; + $sButton = (sqgetGlobalVar('markUnread', $sTmp, SQ_FORM)) ? 'unsetSeen' : $sButton; + $sButton = (sqgetGlobalVar('markFlagged', $sTmp, SQ_FORM)) ? 'setFlagged' : $sButton; + $sButton = (sqgetGlobalVar('markUnflagged', $sTmp, SQ_FORM)) ? 'unsetFlagged' : $sButton; + if (empty($targetMailbox)) sqgetGlobalVar('targetMailbox', $targetMailbox, SQ_FORM); + if (is_null($bypass_trash)) sqgetGlobalVar('bypass_trash', $bypass_trash, SQ_FORM); + sqgetGlobalVar('msg', $msg, SQ_FORM); + if (sqgetGlobalVar('account', $iAccount, SQ_FORM) === false) { $iAccount = 0; } $sError = ''; @@ -1379,9 +1385,9 @@ function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = ar break; } /** - * Updates messages is an array containing the result of the untagged + * $aUpdatedMsgs is an array containing the result of the untagged * fetch responses send by the imap server due to a flag change. That - * response is parsed in a array with msg arrays by the parseFetch function + * response is parsed in an array with msg arrays by the parseFetch function */ if ($aUpdatedMsgs) { // Update the message headers cache @@ -1395,6 +1401,31 @@ function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = ar if (isset($aMailbox['MSG_HEADERS'][$iUid])) { $aMailbox['MSG_HEADERS'][$iUid]['FLAGS'] = $aMsg['FLAGS']; } + /** + * Also update flags in message object + */ +//FIXME: WHY are we keeping flags in TWO places?!? This is error-prone and some core code uses the is_xxxx message object values while other code uses the flags array above. That's a mess. + if (isset($aMailbox['MSG_HEADERS'][$iUid]['MESSAGE_OBJECT'])) { + $message = $aMailbox['MSG_HEADERS'][$iUid]['MESSAGE_OBJECT']; + $message->is_seen = false; + $message->is_answered = false; + $message->is_deleted = false; + $message->is_flagged = false; + $message->is_mdnsent = false; + foreach ($aMsg['FLAGS'] as $flag => $value) { + if (strtolower($flag) == '\\seen' && $value) + $message->is_seen = true; + else if (strtolower($flag) == '\\answered' && $value) + $message->is_answered = true; + else if (strtolower($flag) == '\\deleted' && $value) + $message->is_deleted = true; + else if (strtolower($flag) == '\\flagged' && $value) + $message->is_flagged = true; + else if (strtolower($flag) == '$mdnsent' && $value) + $message->is_mdnsent = true; + } + $aMailbox['MSG_HEADERS'][$iUid]['MESSAGE_OBJECT'] = $message; + } /** * Count the messages with the \Delete flag set so we can determine * if the number of expunged messages equals the number of flagged @@ -1476,9 +1507,6 @@ function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = ar * @author Marc Groot Koerkamp */ function attachSelectedMessages($imapConnection,$aMsgHeaders) { - global $username, $attachment_dir, - $data_dir; - sqgetGlobalVar('composesession', $composesession, SQ_SESSION); sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION); @@ -1495,8 +1523,6 @@ function attachSelectedMessages($imapConnection,$aMsgHeaders) { sqsession_register($composesession,'composesession'); } - $hashed_attachment_dir = getHashedDir($username, $attachment_dir); - $composeMessage = new Message(); $rfc822_header = new Rfc822Header(); $composeMessage->rfc822_header = $rfc822_header; @@ -1516,14 +1542,14 @@ function attachSelectedMessages($imapConnection,$aMsgHeaders) { $body = implode('', $body_a); $body .= "\r\n"; - $localfilename = GenerateRandomString(32, 'FILE', 7); - $full_localfilename = "$hashed_attachment_dir/$localfilename"; - - $fp = fopen( $full_localfilename, 'wb'); + global $username, $attachment_dir; + $filename = sq_get_attach_tempfile(); + $fullpath = getHashedDir($username, $attachment_dir) . '/' . $filename; + $fp = fopen($fullpath, 'wb'); fwrite ($fp, $body); fclose($fp); - $composeMessage->initAttachment('message/rfc822',$subject.'.msg', - $full_localfilename); + + $composeMessage->initAttachment('message/rfc822', $subject . '.eml', $filename); } } @@ -1531,3 +1557,4 @@ function attachSelectedMessages($imapConnection,$aMsgHeaders) { sqsession_register($compose_messages,'compose_messages'); return $composesession; } +