summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2005-10-23 14:39:09 +0000
committerthomascube <thomas@roundcube.net>2005-10-23 14:39:09 +0000
commitf3b659935f3386c077746cd7a84770532ed0ec50 (patch)
treef396f50225366a1e3661580786cfde368454b10c /program
parentf619dedc5aa2020eeffa01e05feacedb043ccb66 (diff)
Added patches for default language and sorting function
Diffstat (limited to 'program')
-rw-r--r--program/include/main.inc15
-rw-r--r--program/js/app.js13
-rw-r--r--program/lib/imap.inc8
-rw-r--r--program/localization/index.inc2
-rw-r--r--program/steps/mail/func.inc37
-rw-r--r--program/steps/mail/list.inc33
-rw-r--r--program/steps/mail/sendmail.inc4
7 files changed, 96 insertions, 16 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 7955aa870..a7020c75f 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -76,7 +76,7 @@ function rcmail_startup($task='mail')
if (!$_SESSION['client_id'])
{
$_SESSION['client_id'] = $sess_id;
- $_SESSION['user_lang'] = 'en';
+ $_SESSION['user_lang'] = substr($CONFIG['locale_string'], 0, 2);
$_SESSION['auth_time'] = mktime();
$_SESSION['auth'] = rcmail_auth_hash($sess_id, $_SESSION['auth_time']);
unset($GLOBALS['_auth']);
@@ -293,10 +293,11 @@ function rcmail_login($user, $pass, $host=NULL)
array_merge($CONFIG, $user_prefs);
}
+
// set user specific language
if (strlen($sql_arr['language']))
$sess_user_lang = $_SESSION['user_lang'] = $sql_arr['language'];
-
+
// update user's record
$DB->query(sprintf("UPDATE %s
SET last_login=NOW()
@@ -317,6 +318,7 @@ function rcmail_login($user, $pass, $host=NULL)
$_SESSION['imap_port'] = $imap_port;
$_SESSION['imap_ssl'] = $imap_ssl;
$_SESSION['username'] = $user;
+ $_SESSION['user_lang'] = $sess_user_lang;
$_SESSION['password'] = encrypt_passwd($pass);
// force reloading complete list of subscribed mailboxes
@@ -333,13 +335,14 @@ function rcmail_login($user, $pass, $host=NULL)
function rcmail_create_user($user, $host)
{
global $DB, $CONFIG, $IMAP;
-
+
$DB->query(sprintf("INSERT INTO %s
- (created, last_login, username, mail_host)
- VALUES (NOW(), NOW(), '%s', '%s')",
+ (created, last_login, username, mail_host, language)
+ VALUES (NOW(), NOW(), '%s', '%s', '%s')",
get_table_name('users'),
addslashes($user),
- addslashes($host)));
+ addslashes($host),
+ $_SESSION['user_lang']));
if ($user_id = $DB->insert_id())
{
diff --git a/program/js/app.js b/program/js/app.js
index 1e70c42fd..2b9a50f96 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -127,7 +127,7 @@ function rcube_webmail()
this.enable_command('add-attachment', 'send-attachment', 'send', true);
if (this.env.messagecount)
- this.enable_command('select-all', 'select-none', true);
+ this.enable_command('select-all', 'select-none', 'sort', true);
this.set_page_buttons();
@@ -443,6 +443,11 @@ function rcube_webmail()
this.list_contacts();
break;
+ case 'sort':
+ // get the type of sorting
+ this.list_mailbox('', '', props);
+ break;
+
case 'nextpage':
this.list_page('next');
break;
@@ -1011,7 +1016,7 @@ function rcube_webmail()
// list messages of a specific mailbox
- this.list_mailbox = function(mbox, page)
+ this.list_mailbox = function(mbox, page, sort)
{
var add_url = '';
var target = window;
@@ -1019,6 +1024,10 @@ function rcube_webmail()
if (!mbox)
mbox = this.env.mailbox;
+ // add sort to url if set
+ if (sort)
+ add_url += '&_sort=' + sort;
+
// set page=1 if changeing to another mailbox
if (!page && mbox != this.env.mailbox)
{
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 3d37bed17..fc5ff09d7 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -52,6 +52,7 @@ class iilConnection{
var $recent;
var $rootdir;
var $delimiter;
+ var $capability = array();
}
class iilBasicHeader{
@@ -246,6 +247,9 @@ function iil_ParseNamespace2($str, &$i, $len=0, $l){
function iil_C_NameSpace(&$conn){
global $my_prefs;
+ if (!in_array('NAMESPACE', $conn->capability))
+ return false;
+
if ($my_prefs["rootdir"]) return true;
fputs($conn->fp, "ns1 NAMESPACE\r\n");
@@ -334,7 +338,7 @@ function iil_Connect($host, $user, $password){
$iil_error.="Socket connection established\r\n";
$line=iil_ReadLine($conn->fp, 300);
-
+
if (strcasecmp($auth_method, "check")==0){
//check for supported auth methods
@@ -349,6 +353,8 @@ function iil_Connect($host, $user, $password){
$a = explode(" ", $line);
if ($line[0]=="*"){
while ( list($k, $w) = each($a) ){
+ if ($w!='*' && $w!='CAPABILITY')
+ $conn->capability[] = $w;
if ((strcasecmp($w, "AUTH=CRAM_MD5")==0)||
(strcasecmp($w, "AUTH=CRAM-MD5")==0)){
$auth_method = "auth";
diff --git a/program/localization/index.inc b/program/localization/index.inc
index e50a2713c..66b945af9 100644
--- a/program/localization/index.inc
+++ b/program/localization/index.inc
@@ -1,4 +1,4 @@
-<?php
+<?php
/*
+-----------------------------------------------------------------------+
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);