From: stekkel Date: Sat, 16 Apr 2005 11:12:22 +0000 (+0000) Subject: strings: adapt makeComposeLink to the new js X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=d0b119a5463cbdf99e4cef5079e840706995cb79 strings: adapt makeComposeLink to the new js mailbox_display, retrieve aFetchHeaders. read_body, behave well when the cache is invalidated git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9311 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index eca9bc2b..60a8fed7 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -205,6 +205,11 @@ function sqm_api_mailbox_select($imapConnection,$account,$mailbox,$aConfig,$aPro array(SQM_COL_FLAGS,SQM_COL_FROM, SQM_COL_SUBJ, SQM_COL_FLAGS); } + /** + * Restore the headers we fetch the last time. Saves intitialisation stuff in read_body. + */ + $aMailbox['FETCHHEADERS'] = (isset($aCachedMailbox['FETCHHEADERS'])) ? $aCachedMailbox['FETCHHEADERS'] : null; + if (!isset($aProps[MBX_PREF_AUTO_EXPUNGE]) && isset($aCachedMailbox['AUTO_EXPUNGE'])) { $aMailbox['AUTO_EXPUNGE'] = $aCachedMailbox['AUTO_EXPUNGE']; } else { @@ -255,7 +260,7 @@ function sqm_api_mailbox_select($imapConnection,$account,$mailbox,$aConfig,$aPro * @return error $error error number * @author Marc Groot Koerkamp */ -function fetchMessageHeaders($imapConnection, &$aMailbox, $aFetchHeaders) { +function fetchMessageHeaders($imapConnection, &$aMailbox) { /* FIX ME, this function is kind of big, maybe we can split it up in a couple of functions. Make sure the functions are private and starts with _ @@ -280,12 +285,13 @@ function fetchMessageHeaders($imapConnection, &$aMailbox, $aFetchHeaders) { $start_msg = 1; } } - //sm_print_r($aMailbox); + if (is_array($aMailbox['UIDSET'])) { $aUid =& $aMailbox['UIDSET'][$iSetIndx]; } else { $aUid = false; } + $aFetchHeaders = $aMailbox['FETCHHEADERS']; $iError = 0; $aFetchItems = $aHeaderItems = array(); @@ -310,7 +316,6 @@ function fetchMessageHeaders($imapConnection, &$aMailbox, $aFetchHeaders) { * A uidset with sorted uid's is available. We can use the cache */ if (isset($aUid) && $aUid ) { - // limit the cache to SQM_MAX_PAGES_IN_CACHE if (!$aMailbox['SHOWALL'][$iSetIndx] && isset($aMailbox['MSG_HEADERS'])) { $iMaxMsgs = $iLimit * SQM_MAX_PAGES_IN_CACHE; @@ -517,7 +522,7 @@ function prepareMessageList(&$aMailbox, $aProps) { $value = ($sTmp) ? htmlspecialchars($sTmp) : $sUnknown; break; case SQM_COL_SUBJ: - // subject is mime encoded, decode it. + // subject is mime encoded, decode it. // value is sanitized in decoding function. $value=decodeHeader($value); if ($highlight_list && !$bHighLight) { @@ -599,8 +604,6 @@ function prepareMessageList(&$aMailbox, $aProps) { function highlightMessage($sCol, $sVal, $highlight_list, &$aFormat) { - - if (!is_array($highlight_list) && count($highlight_list) == 0) { return false; } @@ -629,7 +632,7 @@ function highlightMessage($sCol, $sVal, $highlight_list, &$aFormat) { } } if ($hlt_color) { - // Bug in highlight color??? + // Bug in highlight color??? if ($hlt_color{0} != '#') { $hlt_color = '#'. $hlt_color; } @@ -837,11 +840,11 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { } } $aFetchColumns = array_keys($aFetchColumns); - // store the columns to fetch to the session so we can pick them up in read_body + // store the columns to fetch so we can pick them up in read_body // where we validate the cache. - /////// sqsession_register($aFetchColumns,'aFetchColumns'); + $aMailbox['FETCHHEADERS'] = $aFetchColumns; - $iError = fetchMessageHeaders($imapConnection, $aMailbox, $aFetchColumns); + $iError = fetchMessageHeaders($imapConnection, $aMailbox); if ($iError) { return array(); } else { diff --git a/functions/strings.php b/functions/strings.php index ea629125..970ee5fb 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -817,35 +817,31 @@ function TrimArray(&$array) { * @param string text the link text, default "Compose" * @return string a link to the compose page */ -function makeComposeLink($url, $text = null, $target='') -{ - global $compose_new_win,$javascript_on; +function makeComposeLink($url, $text = null, $target='') { + global $compose_new_win,$javascript_on, $compose_width, $compose_height; if(!$text) { $text = _("Compose"); } - // if not using "compose in new window", make // regular link and be done with it if($compose_new_win != '1') { return makeInternalLink($url, $text, $target); } - // build the compose in new window link... // if javascript is on, use onclick event to handle it if($javascript_on) { sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); - return ''. $text.''; + $compuri = $base_uri.$url; + return "$text"; } - // otherwise, just open new window using regular HTML return makeInternalLink($url, $text, '_blank'); - } /** diff --git a/src/read_body.php b/src/read_body.php index ead59e36..b336e23e 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -522,12 +522,6 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed // Prev/Next links for regular messages } else if ( true ) { //!(isset($where) && isset($what)) ) { - /** - * Check if cache is still valid - */ - if (!is_array($aMailbox['UIDSET'][$what])) { - fetchMessageHeaders($imapConnection, $aMailbox); - } $prev = findPreviousMessage($aMailbox['UIDSET'][$what], $passed_id); $next = findNextMessage($aMailbox['UIDSET'][$what],$passed_id); @@ -781,6 +775,10 @@ sqgetGlobalVar('sendreceipt', $sendreceipt, SQ_GET); if (!sqgetGlobalVar('where', $where, SQ_GET) ) { $where = 'right_main.php'; } +/* + * Used as entry key to the list of uid's cached in the mailbox cache + * we use the cached uid's to get the next and prev message. + */ if (!sqgetGlobalVar('what', $what, SQ_GET) ){ $what = 0; } @@ -830,17 +828,21 @@ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0 $aMailbox = sqm_api_mailbox_select($imapConnection, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array()); /** - * Check if cache is still valid - */ -$iSetIndex = $aMailbox['SETINDEX']; -$aMailbox['CURRENT_MSG'][$iSetIndex] = $passed_id; -//$aMailbox['OFFSET'] = $startMessage -1; - -sqgetGlobalVar('aFetchColumns',$aFetchColumns,SQ_SESSION); + * Check if cache is still valid, $what contains the key + * which gives us acces to the array with uid's. At this moment + * 0 is used for a normal message list and search uses 1 as key. This can be + * changed / extended in the future. + * If on a select of a mailbox we detect that the cache should be invalidated due to + * the delete of messages or due to new messages we empty the list with uid's and + * that's what we detect below. + */ if (!is_array($aMailbox['UIDSET'][$what])) { - fetchMessageHeaders($imapConnection, $aMailbox, $aFetchColumns); + fetchMessageHeaders($imapConnection, $aMailbox); } +$iSetIndex = $aMailbox['SETINDEX']; +$aMailbox['CURRENT_MSG'][$iSetIndex] = $passed_id; + /** * Update the seen state * and ignore in_array('\\seen',$aMailbox['PERMANENTFLAGS'],true)