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 {
* @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 _
$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();
* 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;
$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) {
function highlightMessage($sCol, $sVal, $highlight_list, &$aFormat) {
-
-
if (!is_array($highlight_list) && count($highlight_list) == 0) {
return false;
}
}
}
if ($hlt_color) {
- // Bug in highlight color???
+ // Bug in highlight color???
if ($hlt_color{0} != '#') {
$hlt_color = '#'. $hlt_color;
}
}
}
$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 {
* @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 '<a href="javascript:void(0)" onclick="comp_in_new(\''.$base_uri.$url.'\')">'. $text.'</a>';
+ $compuri = $base_uri.$url;
+ return "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$compuri','$compose_width','$compose_height')\">$text</a>";
}
-
// otherwise, just open new window using regular HTML
return makeInternalLink($url, $text, '_blank');
-
}
/**
// 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);
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;
}
$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)