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 --- CHANGELOG | 6 +++++ config/main.inc.php.dist | 2 +- index.php | 4 +-- program/include/main.inc | 15 ++++++----- program/js/app.js | 13 ++++++++-- program/lib/imap.inc | 8 +++++- program/localization/index.inc | 2 +- program/steps/mail/func.inc | 37 +++++++++++++++++++++++++--- program/steps/mail/list.inc | 33 ++++++++++++++++++++++++- program/steps/mail/sendmail.inc | 4 +-- skins/default/images/buttons/down_arrow.png | Bin 0 -> 285 bytes skins/default/images/buttons/up_arrow.png | Bin 0 -> 279 bytes 12 files changed, 105 insertions(+), 19 deletions(-) create mode 100755 skins/default/images/buttons/down_arrow.png create mode 100755 skins/default/images/buttons/up_arrow.png diff --git a/CHANGELOG b/CHANGELOG index 0e42c40be..7683bd9f0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -60,3 +60,9 @@ CHANGELOG RoundCube Webmail - Display folder names with special chars correctly (Bug #1330157) +2005/10/22 +---------- +- Get IMAP server capabilities in array +- Check for NAMESPACE capability before sending command +- Set default user language from config 'locale_string' +- Added sorting patch (not finished yet) diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index c8d1ad076..5031db47f 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -75,7 +75,7 @@ $rcmail_config['session_lifetime'] = 10; $rcmail_config['ip_check'] = TRUE; // not shure what this was good for :-) -$rcmail_config['locale_string'] = 'de_DE'; +$rcmail_config['locale_string'] = 'en'; // use this format for short date display $rcmail_config['date_short'] = 'D H:i'; diff --git a/index.php b/index.php index a32fcea5d..d5b2db0e3 100644 --- a/index.php +++ b/index.php @@ -45,13 +45,13 @@ $INSTALL_PATH = './'; $OUTPUT_TYPE = 'html'; $JS_OBJECT_NAME = 'rcmail'; -$CURRENT_PATH=dirname($_SERVER['SCRIPT_FILENAME']); +$CURRENT_PATH = dirname($_SERVER['SCRIPT_FILENAME']); if ($CURRENT_PATH!='') $CURRENT_PATH.='/'; // set environment first -ini_set('include_path', $INSTALL_PATH.PATH_SEPARATOR.$CURRENT_PATH.'program'.PATH_SEPARATOR.$CURRENT_PATH.'program/lib'.PATH_SEPARATOR.ini_get('include_path')); +ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.$INSTALL_PATH.PATH_SEPARATOR.$CURRENT_PATH.'program'.PATH_SEPARATOR.$CURRENT_PATH.'program/lib'); ini_set('session.name', 'sessid'); ini_set('session.use_cookies', 1); ini_set('error_reporting', E_ALL&~E_NOTICE); 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 @@ -'; + // 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); diff --git a/skins/default/images/buttons/down_arrow.png b/skins/default/images/buttons/down_arrow.png new file mode 100755 index 000000000..d4f9e2d98 Binary files /dev/null and b/skins/default/images/buttons/down_arrow.png differ diff --git a/skins/default/images/buttons/up_arrow.png b/skins/default/images/buttons/up_arrow.png new file mode 100755 index 000000000..aca1b5443 Binary files /dev/null and b/skins/default/images/buttons/up_arrow.png differ -- cgit v1.2.3