$aMailbox['UIDSET'][$iSetIndx] = false;
$aMailbox['ID'] = false;
$aMailbox['SETINDEX'] = $iSetIndx;
+ $aMailbox['MSG_HEADERS'] = false;
if ($aCachedMailbox) {
/**
'answered'=>false,
'flagged' => false,
'draft' => false);
-
- if(!is_array($value)) $value = array();
+
+ if(!is_array($value)) $value = array();
foreach ($value as $sFlag => $value) {
switch ($sFlag) {
case '\\seen' : $aFlagColumn['seen'] = true; break;
return $sSortField;
}
+function calcFetchColumns(&$aMailbox, &$aProps) {
+
+ $highlight_list = (isset($aProps['config']['highlight_list'])) ? $aProps['config']['highlight_list'] : false;
+ $aColumnsDesc = (isset($aProps['columns'])) ? $aProps['columns'] : false;
+
+ $aFetchColumns = $aColumnsDesc;
+ if (isset($aFetchColumns[SQM_COL_CHECK])) {
+ unset($aFetchColumns[SQM_COL_CHECK]);
+ }
+
+ /*
+ * Before we fetch the message headers, check if we need to fetch extra columns
+ * to make the message highlighting work
+ */
+ if (is_array($highlight_list) && count($highlight_list)) {
+ $aHighlightColumns = array();
+ foreach ($highlight_list as $highlight_list_part) {
+ if (trim($highlight_list_part['value'])) {
+ $match_type = strtoupper($highlight_list_part['match_type']);
+ switch ($match_type) {
+ case 'TO_CC':
+ $aHighlightColumns[SQM_COL_TO] = true;
+ $aHighlightColumns[SQM_COL_CC] = true;
+ break;
+ case 'TO': $aHighlightColumns[SQM_COL_TO] = true; break;
+ case 'CC': $aHighlightColumns[SQM_COL_CC] = true; break;
+ case 'FROM': $aHighlightColumns[SQM_COL_FROM] = true; break;
+ case 'SUBJECT':$aHighlightColumns[SQM_COL_SUBJ] = true; break;
+ }
+ }
+ }
+ $aExtraColumns = array();
+ foreach ($aHighlightColumns as $k => $v) {
+ if (!isset($aFetchColumns[$k])) {
+ $aExtraColumns[] = $k;
+ $aFetchColumns[$k] = true;
+ }
+ }
+ if (count($aExtraColumns)) {
+ $aProps['extra_columns'] = $aExtraColumns;
+ }
+ }
+ $aMailbox['FETCHHEADERS'] = array_keys($aFetchColumns);
+ ;
+}
/**
} else {
++$iFormId;
}
- /*
- * Remove the checkbox column because we cannot fetch it from the imap server
- */
- $aFetchColumns = $aColumnsDesc;
- if (isset($aFetchColumns[SQM_COL_CHECK])) {
- unset($aFetchColumns[SQM_COL_CHECK]);
- }
-
- /*
- * Before we fetch the message headers, check if we need to fetch extra columns
- * to make the message highlighting work
- */
- if (is_array($highlight_list) && count($highlight_list)) {
- $aHighlightColumns = array();
- foreach ($highlight_list as $highlight_list_part) {
- if (trim($highlight_list_part['value'])) {
- $match_type = strtoupper($highlight_list_part['match_type']);
- switch ($match_type) {
- case 'TO_CC':
- $aHighlightColumns[SQM_COL_TO] = true;
- $aHighlightColumns[SQM_COL_CC] = true;
- break;
- case 'TO': $aHighlightColumns[SQM_COL_TO] = true; break;
- case 'CC': $aHighlightColumns[SQM_COL_CC] = true; break;
- case 'FROM': $aHighlightColumns[SQM_COL_FROM] = true; break;
- case 'SUBJECT':$aHighlightColumns[SQM_COL_SUBJ] = true; break;
- }
- }
- }
- $aExtraColumns = array();
- foreach ($aHighlightColumns as $k => $v) {
- if (!isset($aFetchColumns[$k])) {
- $aExtraColumns[] = $k;
- $aFetchColumns[$k] = true;
- }
- }
- if (count($aExtraColumns)) {
- $aProps['extra_columns'] = $aExtraColumns;
- }
- }
- $aFetchColumns = array_keys($aFetchColumns);
// store the columns to fetch so we can pick them up in read_body
// where we validate the cache.
- $aMailbox['FETCHHEADERS'] = $aFetchColumns;
+ calcFetchColumns($aMailbox ,$aProps);
$iError = fetchMessageHeaders($imapConnection, $aMailbox);
if ($iError) {
require_once(SM_PATH . 'functions/global.php');
require_once(SM_PATH . 'functions/identity.php');
include_once(SM_PATH . 'functions/arrays.php');
-require_once(SM_PATH . 'functions/mailbox_display.php');
+include_once(SM_PATH . 'functions/mailbox_display.php');
/**
* Given an IMAP message id number, this will look it up in the cached
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
$aMailbox = sqm_api_mailbox_select($imapConnection, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array());
+
+/**
+ Start code to set the columns to fetch in case of hitting the next/prev link
+ The reason for this is the fact that the cache can be invalidated which means that the headers
+ to fetch aren't there anymore. Before they got calculated when the messagelist was shown.
+
+ Todo, better central handling of setting the mailbox options so we do not need to do the stuff below
+*/
+
+/**
+ * Replace From => To in case it concerns a draft or sent folder
+ */
+if (($mailbox == $sent_folder || $mailbox == $draft_folder) &&
+ !in_array(SQM_COL_TO,$index_order)) {
+ $aNewOrder = array(); // nice var name ;)
+ foreach($index_order as $iCol) {
+ if ($iCol == SQM_COL_FROM) {
+ $iCol = SQM_COL_TO;
+ }
+ $aNewOrder[] = $iCol;
+ }
+ $aColumns = $aNewOrder;
+} else {
+ $aColumns = $index_order;
+}
+
+$aProps = array(
+ 'columns' => $aColumns, // columns bound settings
+ 'config' => array(
+ 'highlight_list' => $message_highlight_list, // row highlighting rules
+ 'trash_folder' => $trash_folder,
+ 'sent_folder' => $sent_folder,
+ 'draft_folder' => $draft_folder));
+
+calcFetchColumns($aMailbox,$aProps);
+
/**
- * 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.
- */
+ End code to set the columns to fetch in case of hitting the next/prev link
+*/
+
+
+
+/**
+ * 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);
}