summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/mail/func.inc37
-rw-r--r--program/steps/mail/list.inc33
-rw-r--r--program/steps/mail/sendmail.inc4
3 files changed, 68 insertions, 6 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 059a8cfcb..0875c0477 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -238,8 +238,12 @@ function rcmail_message_list($attrib)
$skin_path = $CONFIG['skin_path'];
$image_tag = '<img src="%s%s" alt="%s" border="0" />';
+ // check to see if we have some settings for sorting
+ $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : 'date';
+ $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : 'DESC';
+
// get message headers
- $a_headers = $IMAP->list_headers();
+ $a_headers = $IMAP->list_headers('', '', $sort_col, $sort_order);
// add id to message list table if not specified
if (!strlen($attrib['id']))
@@ -261,8 +265,35 @@ function rcmail_message_list($attrib)
// add table title
$out .= "<thead><tr>\n<td class=\"icon\">&nbsp;</td>\n";
+ $javascript = '';
foreach ($a_show_cols as $col)
- $out .= '<td class="'.$col.'">' . rep_specialchars_output(rcube_label($col)) . "</td>\n";
+ {
+ // get column name
+ $col_name = rep_specialchars_output(rcube_label($col));
+
+ // make sort links
+ $sort = '';
+ if ($col != 'size')
+ {
+ // asc link
+ $asc = '_ASC';
+ $sort .= '<a href="#" id="sort_' . $col_name . $asc . '" onclick="return rcmail.command(\'sort\',\''
+ . $col_name . $asc . '\',this)" title="Sort by ' . $col_name . ' ascending">'
+ . '<img src="skins/default/images/buttons/up_arrow.png" width="11" height="11" border="0" alt="" /></a>';
+ // desc link
+ $desc = '_DESC';
+ $sort .= '&nbsp;<a href="#" id="sort_' . $col_name . $desc . '" onclick="return rcmail.command(\'sort\',\''
+ . $col_name . $desc . '\',this)" title="Sort by ' . $col_name . ' descending">'
+ . '<img src="skins/default/images/buttons/down_arrow.png" width="11" height="11" border="0" alt="" /></a>';
+ }
+
+ // put it all together
+ $out .= '<td class="'.$col.'">' . "$col_name&nbsp;&nbsp;$sort</td>\n";
+
+ // register sort buttons
+ $javascript .= "rcmail.register_button('sort', 'sort_{$col_name}_desc', 'link', 'active', '', '');\n";
+ $javascript .= "rcmail.register_button('sort', 'sort_{$col_name}_asc', 'link', 'active', '', '');\n";
+ }
$out .= '<td class="icon">'.($attrib['attachmenticon'] ? sprintf($image_tag, $skin_path, $attrib['attachmenticon'], '') : '')."</td>\n";
$out .= "</tr></thead>\n<tbody>\n";
@@ -339,7 +370,7 @@ function rcmail_message_list($attrib)
$message_count = $IMAP->messagecount();
// set client env
- $javascript = sprintf("%s.gui_object('messagelist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
+ $javascript .= sprintf("%s.gui_object('messagelist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
$javascript .= sprintf("%s.set_env('messagecount', %d);\n", $JS_OBJECT_NAME, $message_count);
$javascript .= sprintf("%s.set_env('current_page', %d);\n", $JS_OBJECT_NAME, $IMAP->list_page);
$javascript .= sprintf("%s.set_env('pagecount', %d);\n", $JS_OBJECT_NAME, ceil($message_count/$IMAP->page_size));
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index 1e9ce926b..5dd652d44 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -25,6 +25,37 @@ $OUTPUT_TYPE = 'js';
$unseen = $IMAP->messagecount($mbox, 'UNSEEN', !empty($_GET['_refresh']) ? TRUE : FALSE);
$count = $IMAP->messagecount();
+// is there a sort type for this request?
+if ($sort = isset($_GET['_sort']) ? $_GET['_sort'] : false)
+ {
+ // yes, so set the sort vars
+ list($sort_col, $sort_order) = explode('_', $sort);
+
+ // iloha mail sort func doesn't know about a 'Sender' col
+ $sort_col = $sort_col == 'Sender' ? 'From' : $sort_col;
+
+ // set session vars for sort (so next page and task switch know how to sort)
+ $_SESSION['sort_col'] = $sort_col;
+ $_SESSION['sort_order'] = $sort_order;
+ }
+else
+ {
+ // if switching folder, use default sorting
+ if ($_GET['_refresh'] == '1')
+ {
+ $sort_col = 'date';
+ $sort_order = 'desc';
+ unset($_SESSION['sort_col'], $_SESSION['sort_order']);
+ }
+ else
+ {
+ // use session settings if set, defaults if not
+ $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : 'date';
+ $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : 'desc';
+ }
+ }
+
+
// update message count display
$pages = ceil($count/$IMAP->page_size);
$commands = sprintf("this.set_env('messagecount', %d);\n", $count);
@@ -39,7 +70,7 @@ $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox), $u
// add message rows
if ($count)
{
- $a_headers = $IMAP->list_headers($mbox);
+ $a_headers = $IMAP->list_headers($mbox, null, $sort_col, $sort_order);
$commands .= rcmail_js_message_list($a_headers);
}
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 809aed534..bacb1b1e8 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -152,8 +152,8 @@ $message_param = array('text_encoding' => '7bit',
'html_encoding' => 'quoted-printable',
'head_encoding' => 'quoted-printable',
'head_charset' => 'ISO-8859-1',
- 'html_charset' => 'UTF-8',
- 'text_charset' => 'UTF-8');
+ 'html_charset' => 'ISO-8859-1',
+ 'text_charset' => 'ISO-8859-1');
// compose message body and get headers
$msg_body = $MAIL_MIME->get($message_param);