From f3b659935f3386c077746cd7a84770532ed0ec50 Mon Sep 17 00:00:00 2001 From: thomascube Date: Sun, 23 Oct 2005 14:39:09 +0000 Subject: Added patches for default language and sorting function --- program/steps/mail/func.inc | 37 ++++++++++++++++++++++++++++++++++--- program/steps/mail/list.inc | 33 ++++++++++++++++++++++++++++++++- program/steps/mail/sendmail.inc | 4 ++-- 3 files changed, 68 insertions(+), 6 deletions(-) (limited to 'program/steps/mail') 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 = '%s'; + // 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 .= "\n \n"; + $javascript = ''; foreach ($a_show_cols as $col) - $out .= '' . rep_specialchars_output(rcube_label($col)) . "\n"; + { + // get column name + $col_name = rep_specialchars_output(rcube_label($col)); + + // make sort links + $sort = ''; + if ($col != 'size') + { + // asc link + $asc = '_ASC'; + $sort .= '' + . ''; + // desc link + $desc = '_DESC'; + $sort .= ' ' + . ''; + } + + // put it all together + $out .= '' . "$col_name  $sort\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 .= ''.($attrib['attachmenticon'] ? sprintf($image_tag, $skin_path, $attrib['attachmenticon'], '') : '')."\n"; $out .= "\n\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); -- cgit v1.2.3