// default sorting column
$_prefs['sortby'] = array(
- 'value' => Horde_Imap_Client::SORT_ARRIVAL,
+ // Sort by sequence by default. It is the fastest sort as it is the only
+ // sort that can be done without parsing message headers. It sorts
+ // messages by the order they arrived within the mailbox.
+ 'value' => Horde_Imap_Client::SORT_SEQUENCE,
'locked' => false,
'shared' => false,
'type' => 'enum',
'enum' => array(
- Horde_Imap_Client::SORT_ARRIVAL => _("Arrival Time"),
- Horde_Imap_Client::SORT_DATE => _("Message Date"),
+ Horde_Imap_Client::SORT_SEQUENCE => _("NONE"),
+ IMP::IMAP_SORT_DATE => _("Date"),
Horde_Imap_Client::SORT_FROM => _("From Address"),
Horde_Imap_Client::SORT_TO => _("To Address"),
Horde_Imap_Client::SORT_SUBJECT => _("Subject"),
'shared' => false,
'type' => 'implicit');
+// default sorting criteria for the date column
+$_prefs['sortdate'] = array(
+ // Use internal IMAP date by default - this is generally the date that a
+ // message was first received on the IMAP server and is maintained even
+ // if the message moves between mailboxes.
+ 'value' => Horde_Imap_Client::SORT_ARRIVAL,
+ // Locked by default
+ 'locked' => true,
+ 'shared' => false,
+ 'type' => 'enum',
+ 'enum' => array(
+ Horde_Imap_Client::SORT_ARRIVAL => _("Arrival time on server"),
+ Horde_Imap_Client::SORT_DATE => _("Date in message headers")
+ ),
+ 'desc' => _("Criteria to use when sorting by date:")
+);
+
// mailbox constraints
$_prefs['max_msgs'] = array(
'value' => 30,
v5.0-git
--------
+[mms] Simplified date sorting display (Ticket #8936).
[mms] Properly redirect messages pursuant to RFC 5322 [3.6.6].
[mms] Add redirect message capability to DIMP.
[mms] Add ability to add attachments to composed messages for advanced mobile
setSortColumns: function(sortby)
{
- var tmp,
+ var hdr, tmp,
ptr = DIMP.conf.sort,
- togglesort = [],
m = $('msglistHeader');
if (Object.isUndefined(sortby)) {
m.down('.msgFrom').update(ptr.get('from').e).insert(ptr.get('to').e);
m.down('.msgSize').update(ptr.get('size').e);
+ m.down('.msgDate').update(ptr.get('date').e);
}
/* Toggle between From/To header. */
tmp = m.down('.msgSubject');
if (this.isSearch() ||
this.viewport.getMetaData('nothread')) {
- togglesort.push({ l: 'subject', t: tmp });
+ hdr = { l: 'subject', t: tmp };
} else if (sortby == ptr.get('thread').v) {
- togglesort.push({ l: 'thread', s: 'subject', t: tmp });
+ hdr = { l: 'thread', s: 'subject', t: tmp };
} else {
- togglesort.push({ l: 'subject', s: 'thread', t: tmp });
+ hdr = { l: 'subject', s: 'thread', t: tmp };
}
- /* Toggle between Date/Arrival header. */
- tmp = m.down('.msgDate');
- if (sortby == ptr.get('arrival').v) {
- togglesort.push({ l: 'arrival', s: 'date', t: tmp });
- } else {
- togglesort.push({ l: 'date', s: 'arrival', t: tmp });
+ hdr.t.update().update(ptr.get(hdr.l).e.removeClassName('smallSort').update(ptr.get(hdr.l).t));
+ if (hdr.s) {
+ hdr.t.insert(ptr.get(hdr.s).e.addClassName('smallSort').update('[' + ptr.get(hdr.s).t + ']'));
}
- togglesort.each(function(hdr) {
- hdr.t.update().update(ptr.get(hdr.l).e.removeClassName('smallSort').update(ptr.get(hdr.l).t));
- if (hdr.s) {
- hdr.t.insert(ptr.get(hdr.s).e.addClassName('smallSort').update('[' + ptr.get(hdr.s).t + ']'));
- }
- });
-
ptr.find(function(s) {
return (sortby == s.value.v)
? s.value.e.up().addClassName(this.viewport.getMetaData('sortdir') ? 'sortup' : 'sortdown')
$query = new Horde_Imap_Client_Search_Query();
$query->flag('\\seen', false);
- $ids = $GLOBALS['imp_search']->runSearchQuery($query, 'INBOX', Horde_Imap_Client::SORT_ARRIVAL, 1);
+ $ids = $GLOBALS['imp_search']->runSearchQuery($query, 'INBOX', Horde_Imap_Client::SORT_SEQUENCE, 1);
$html = '<table cellspacing="0" width="100%">';
if (empty($ids)) {
const PREF_NO_FOLDER = 'nofolder\0';
const PREF_VTRASH = 'vtrash\0';
+ /* Sorting constants. */
+ const IMAP_SORT_DATE = 100;
+
/* Storage place for an altered version of the current URL. */
static public $newUrl = null;
/**
* Return the sorting preference for the current mailbox.
*
- * @param string $mbox The mailbox to use (defaults to current mailbox
- * in the session).
+ * @param string $mbox The mailbox to use (defaults to current
+ * mailbox in the session).
+ * @param boolean $convert Convert 'by' to a Horde_Imap_Client constant?
*
* @return array An array with the following keys:
* <pre>
- * 'by' - (integer) Sort type (Horde_Imap_Client constant)
- * 'dir' - (integer) Sort direction
+ * 'by' - (integer) Sort type.
+ * 'dir' - (integer) Sort direction.
* </pre>
*/
- static public function getSort($mbox = null)
+ static public function getSort($mbox = null, $convert = false)
{
if (is_null($mbox)) {
$mbox = $GLOBALS['imp_mbox']['mailbox'];
'dir' => isset($entry['d']) ? $entry['d'] : $GLOBALS['prefs']->getValue('sortdir'),
);
- /* Restrict POP3 sorting to arrival only. Although possible to
+ /* Restrict POP3 sorting to sequence only. Although possible to
* abstract other sorting methods, all other methods require a
* download of all messages, which is too much overhead.*/
if ($_SESSION['imp']['protocol'] == 'pop') {
- $ob['by'] = Horde_Imap_Client::SORT_ARRIVAL;
+ $ob['by'] = Horde_Imap_Client::SORT_SEQUENCE;
return $ob;
}
/* Can't do threaded searches in search mailboxes. */
if (!self::threadSortAvailable($mbox) &&
($ob['by'] == Horde_Imap_Client::SORT_THREAD)) {
- $ob['by'] = Horde_Imap_Client::SORT_DATE;
+ $ob['by'] = IMP::IMAP_SORT_DATE;
}
if (self::isSpecialFolder($mbox)) {
$ob['by'] = Horde_Imap_Client::SORT_FROM;
}
+ if ($convert && ($ob['by'] == IMP::IMAP_SORT_DATE)) {
+ $ob['by'] = $GLOBALS['prefs']->getValue('sortdate');
+ }
+
return $ob;
}
*/
public function execute()
{
+ $this->_upgradeForwardPrefs();
$this->_upgradeSortPrefs();
$this->_upgradeVirtualFolders();
}
/**
- * Check for old, non-existent sort values. See Bug #7296.
+ * Upgrade to the new forward preferences.
*/
- protected function _upgradeSortPrefs()
+ protected function upgradeForwardPrefs()
{
- $sortby = $GLOBALS['prefs']->getValue('sortby');
- if ($sortby > 10) {
- $GLOBALS['prefs']->setValue('sortby', Horde_Imap_Client::SORT_ARRIVAL);
- }
-
- $update = false;
- $sortpref = @unserialize($GLOBALS['prefs']->getValue('sortpref'));
- foreach ($sortpref as $key => $val) {
- if ($val['b'] > 10) {
- $sortpref[$key]['b'] = Horde_Imap_Client::SORT_ARRIVAL;
- $update = true;
- }
- }
- if ($update) {
- $GLOBALS['prefs']->setValue('sortpref', serialize($sortpref));
- }
-
switch ($GLOBALS['prefs']->getValue('forward_default')) {
case 'forward_attachments':
$GLOBALS['prefs']->setValue('forward_default', 'both');
}
/**
+ * Check for old, non-existent sort values. See Bug #7296.
+ */
+ protected function _upgradeSortPrefs()
+ {
+ $update = false;
+ $sortpref = @unserialize($GLOBALS['prefs']->getValue('sortpref'));
+ foreach ($sortpref as $key => $val) {
+ $sb = $this->_newSortbyValue($val['b']);
+ if (!is_null($sb)) {
+ $sortpref[$key]['b'] = $sb;
+ $update = true;
+ }
+ }
+
+ if ($update) {
+ $GLOBALS['prefs']->setValue('sortpref', serialize($sortpref));
+ }
+
+ $sb = $this->_newSortbyValue($GLOBALS['prefs']->getValue('sortby'));
+ if (!is_null($sb)) {
+ $GLOBALS['prefs']->setValue('sortby', $sb);
+ }
+ }
+
+ /**
+ * Get the new sortby pref value.
+ *
+ * @param integer $sortby The old value.
+ *
+ * @return integer Null if no change or else the converted sort value.
+ */
+ protected function _newSortbyValue($sortby)
+ {
+ switch ($sortby) {
+ case 1: // SORTARRIVAL
+ /* Sortarrival was the same thing as sequence sort in IMP 4. */
+ return Horde_Imap_Client::SORT_SEQUENCE;
+
+ case 2: // SORTDATE
+ return IMP::IMAP_SORT_DATE;
+
+ case 161: // SORTTHREAD
+ return Horde_Imap_Client::SORT_THREAD;
+ }
+
+ return null;
+ }
+
+ /**
* Upgrade IMP 4 style virtual folders.
*/
protected function _upgradeVirtualFolders()
$GLOBALS['notification']->push(_("Mailbox listing failed") . ': ' . $e->getMessage(), 'horde.error');
}
} else {
- $sortpref = IMP::getSort($this->_mailbox);
+ $sortpref = IMP::getSort($this->_mailbox, true);
+ $sortpref['by'] = 1;
if ($sortpref['by'] == Horde_Imap_Client::SORT_THREAD) {
$this->_threadob = null;
case IMP::MAILBOX_START_FIRSTUNSEEN:
$sortpref = IMP::getSort($this->_mailbox);
- /* Optimization: if sorting by arrival then first unseen
+ /* Optimization: if sorting by sequence then first unseen
* information is returned via a SELECT/EXAMINE call. */
- if ($sortpref['by'] == Horde_Imap_Client::SORT_ARRIVAL) {
+ if ($sortpref['by'] == Horde_Imap_Client::SORT_SEQUENCE) {
try {
$res = $GLOBALS['imp_imap']->ob()->status($this->_mailbox, Horde_Imap_Client::STATUS_FIRSTUNSEEN);
if (!is_null($res['firstunseen'])) {
public function getCacheID()
{
if (!$this->_searchmbox) {
- $sortpref = IMP::getSort($this->_mailbox);
+ $sortpref = IMP::getSort($this->_mailbox, true);
try {
return $GLOBALS['imp_imap']->ob()->getCacheId($this->_mailbox, array($sortpref['by'], $sortpref['dir']));
} catch (Horde_Imap_Client_Exception $e) {}
}
/* How do we want to sort results? */
- $sortpref = IMP::getSort();
+ $sortpref = IMP::getSort(null, true);
if ($sortpref['by'] == Horde_Imap_Client::SORT_THREAD) {
- $sortpref['by'] = Horde_Imap_Client::SORT_DATE;
+ $sortpref['by'] = $GLOBALS['prefs']->getValue('sortdate');
}
foreach ($search['f'] as $val) {
/* Create header links. */
$hdr_list = array(
- 'hdr_arrival' => array('#', Horde_Imap_Client::SORT_ARRIVAL),
'hdr_from' => array(_("From"), Horde_Imap_Client::SORT_FROM),
'hdr_subject' => array(_("Subject"), Horde_Imap_Client::SORT_SUBJECT),
'hdr_thread' => array(_("Thread"), Horde_Imap_Client::SORT_THREAD)
$sortImg = ($sortpref['dir']) ? 'za.png' : 'az.png';
$sortText = ($sortpref['dir']) ? '\/' : '/\\';
$headers = array(
- Horde_Imap_Client::SORT_ARRIVAL => array(
- 'stext' => _("Sort by Arrival"),
- 'text' => _("Arrival"),
- 'width' => '14%'
- ),
- Horde_Imap_Client::SORT_DATE => array(
+ IMP::IMAP_SORT_DATE => array(
'stext' => _("Sort by Date"),
'text' => _("Dat_e"),
'width' => '14%'
unset($headers[Horde_Imap_Client::SORT_TO]);
}
- /* Determine which of Date/Arrival to emphasize. */
- if ($sortpref['by'] == Horde_Imap_Client::SORT_ARRIVAL) {
- $extra = Horde_Imap_Client::SORT_DATE;
- $standard = Horde_Imap_Client::SORT_ARRIVAL;
- } else {
- $extra = Horde_Imap_Client::SORT_ARRIVAL;
- $standard = Horde_Imap_Client::SORT_DATE;
- }
- $headers[$standard]['extra'] = '<span class="toggleSort">[' . Horde::widget($mailbox_imp_url->copy()->add(array('sortby' => $extra, 'actionID' => 'change_sort', 'mailbox_token' => $mailbox_token)), $headers[$extra]['stext'], 'widget', null, null, $headers[$extra]['text']) . ']</span>';
- unset($headers[$extra]);
-
/* Determine which of Subject/Thread to emphasize. */
if (!IMP::threadSortAvailable($imp_mbox['mailbox'])) {
unset($headers[Horde_Imap_Client::SORT_THREAD]);
if ($new_mail) {
$query->flag('\\seen', false);
}
-$ids = $imp_search->runSearchQuery($query, $mailbox, Horde_Imap_Client::SORT_DATE, 1);
+$ids = $imp_search->runSearchQuery($query, $mailbox, Horde_Imap_Client::SORT_ARRIVAL, 1);
if (!empty($ids)) {
$imp_ui = new IMP_Ui_Mailbox($imp_mbox['mailbox']);
),
'date' => array(
't' => _("Date"),
- 'v' => Horde_Imap_Client::SORT_DATE
- ),
- 'arrival' => array(
- 't' => _("Arrival"),
- 'v' => Horde_Imap_Client::SORT_ARRIVAL
+ 'v' => IMP::IMAP_SORT_DATE
),
'size' => array(
't' => _("Size"),
<if:checkbox>
<th></th>
</if:checkbox>
- <th><tag:hdr_arrival /></th>
+ <th></th>
<th><tag:hdr_from /></th>
<th><tag:hdr_subject /><if:hdr_subject_minor> <small>[<tag:hdr_subject_minor />]</small></if:hdr_subject_minor></th>
</tr>