From c8c1e0ef3b229a82e74c70aeacc29f2ba021afbe Mon Sep 17 00:00:00 2001 From: svncommit Date: Tue, 27 Jun 2006 21:56:44 +0000 Subject: Renameable folders, mail-checking changes, other fixes (richs) --- program/include/main.inc | 22 ++++--- program/include/rcube_imap.inc | 25 +++++++- program/js/app.js | 96 ++++++++++++++++++++++++++++--- program/localization/cn/labels.inc | 1 + program/localization/cn/messages.inc | 2 + program/localization/de_CH/labels.inc | 1 + program/localization/de_CH/messages.inc | 2 + program/localization/de_DE/labels.inc | 1 + program/localization/de_DE/messages.inc | 2 + program/localization/el/labels.inc | 1 + program/localization/el/messages.inc | 2 + program/localization/en_GB/labels.inc | 1 + program/localization/en_GB/messages.inc | 2 + program/localization/en_US/labels.inc | 3 + program/localization/en_US/messages.inc | 2 + program/localization/es/labels.inc | 1 + program/localization/es/messages.inc | 2 + program/localization/fr/labels.inc | 1 + program/localization/fr/messages.inc | 2 + program/localization/it/labels.inc | 1 + program/localization/it/messages.inc | 2 + program/localization/ja/labels.inc | 1 + program/localization/ja/messages.inc | 2 + program/localization/pt_BR/labels.inc | 1 + program/localization/pt_BR/messages.inc | 2 + program/localization/pt_PT/labels.inc | 1 + program/localization/pt_PT/messages.inc | 2 + program/localization/ru/labels.inc | 1 + program/localization/ru/messages.inc | 2 + program/steps/mail/check_recent.inc | 52 ++++++++++------- program/steps/mail/func.inc | 4 +- program/steps/settings/manage_folders.inc | 68 +++++++++++++++++++++- 32 files changed, 264 insertions(+), 44 deletions(-) (limited to 'program') diff --git a/program/include/main.inc b/program/include/main.inc index 0a158dcb6..cc019af67 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -289,11 +289,11 @@ function get_sequence_name($sequence) // check the given string and returns language properties function rcube_language_prop($lang, $prop='lang') { - global $INSTLL_PATH; + global $INSTALL_PATH; static $rcube_languages, $rcube_language_aliases, $rcube_charsets; if (empty($rcube_languages)) - @include($INSTLL_PATH.'program/localization/index.inc'); + @include($INSTALL_PATH.'program/localization/index.inc'); // check if we have an alias for that language if (!isset($rcube_languages[$lang]) && isset($rcube_language_aliases[$lang])) @@ -357,7 +357,7 @@ function load_gui() $OUTPUT->set_charset($CONFIG['charset']); // add some basic label to client - rcube_add_label('loading'); + rcube_add_label('loading','checkingmail'); } @@ -764,13 +764,13 @@ function rcube_list_languages() if (!sizeof($sa_languages)) { - @include($INSTLL_PATH.'program/localization/index.inc'); + @include($INSTALL_PATH.'program/localization/index.inc'); - if ($dh = @opendir($INSTLL_PATH.'program/localization')) + if ($dh = @opendir($INSTALL_PATH.'program/localization')) { while (($name = readdir($dh)) !== false) { - if ($name{0}=='.' || !is_dir($INSTLL_PATH.'program/localization/'.$name)) + if ($name{0}=='.' || !is_dir($INSTALL_PATH.'program/localization/'.$name)) continue; if ($label = $rcube_languages[$name]) @@ -1192,6 +1192,7 @@ function rcube_xml_command($command, $str_attrib, $a_attrib=NULL) 'identityform' => 'rcube_identity_form', 'foldersubscription' => 'rcube_subscription_form', 'createfolder' => 'rcube_create_folder_form', + 'renamefolder' => 'rcube_rename_folder_form', 'composebody' => 'rcmail_compose_body' ); @@ -1317,7 +1318,7 @@ function rcube_button($attrib) $attrib['id'], $attrib['type'], $attrib['imageact'] ? $skin_path.$attrib['imageact'] : $attrib['classact'], - $attirb['imagesel'] ? $skin_path.$attirb['imagesel'] : $attrib['classsel'], + $attrib['imagesel'] ? $skin_path.$attrib['imagesel'] : $attrib['classsel'], $attrib['imageover'] ? $skin_path.$attrib['imageover'] : '')); // make valid href to task buttons @@ -1338,6 +1339,11 @@ function rcube_button($attrib) $attrib['onmouseout'] = sprintf("return %s.button_out('%s','%s')", $JS_OBJECT_NAME, $command, $attrib['id']); } + if ($command && $attrib['imagesel']) + { + $attrib['onmousedown'] = sprintf("return %s.button_sel('%s','%s')", $JS_OBJECT_NAME, $command, $attrib['id']); + $attrib['onmouseup'] = sprintf("return %s.button_out('%s','%s')", $JS_OBJECT_NAME, $command, $attrib['id']); + } $out = ''; @@ -1350,7 +1356,7 @@ function rcube_button($attrib) if ($attrib['label']) $btn_content .= ' '.$attrib['label']; - $link_attrib = array('href', 'onclick', 'onmouseover', 'onmouseout', 'title'); + $link_attrib = array('href', 'onclick', 'onmouseover', 'onmouseout', 'onmousedown', 'onmouseup', 'title'); } else if ($attrib['type']=='link') { diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc index dccd64fc9..7ad4ad082 100644 --- a/program/include/rcube_imap.inc +++ b/program/include/rcube_imap.inc @@ -1262,9 +1262,30 @@ class rcube_imap // set a new name to an existing mailbox - function rename_mailbox($mbox_name, $new_name) + function rename_mailbox($mbox_name, $new_name, $subscribe=TRUE) { - // not implemented yet + $result = FALSE; + + // replace backslashes + $name = preg_replace('/[\\\]+/', '-', $new_name); + + $name_enc = UTF7EncodeString($new_name); + + // reduce mailbox name to 100 chars + $name_enc = substr($name_enc, 0, 100); + + $abs_name = $this->_mod_mailbox($name_enc); + $a_mailbox_cache = $this->get_cache('mailboxes'); + + if (strlen($abs_name) && (!is_array($a_mailbox_cache) || !in_array($abs_name, $a_mailbox_cache))) + $result = iil_C_RenameFolder($this->conn, $mbox_name, $abs_name); + + // update mailboxlist cache + if ($result && $subscribe) + $this->unsubscribe($mbox_name); + $this->subscribe($name_enc); + + return $result ? $name : FALSE; } diff --git a/program/js/app.js b/program/js/app.js index c0dac3fed..c61c20a63 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -123,7 +123,7 @@ function rcube_webmail() } // enable mail commands - this.enable_command('list', 'compose', 'add-contact', 'search', 'reset-search', true); + this.enable_command('list', 'checkmail', 'compose', 'add-contact', 'search', 'reset-search', true); if (this.env.action=='show') { @@ -211,7 +211,7 @@ function rcube_webmail() this.enable_command('save', true); if (this.env.action=='folders') - this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'delete-folder', true); + this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'rename-folder', 'delete-folder', true); var identities_list = this.gui_objects.identitieslist; if (identities_list) @@ -613,12 +613,18 @@ function rcube_webmail() { if (this.env.search_request<0 || (this.env.search_request && props != this.env.mailbox)) this.reset_qsearch(); + + // Reset message list header, unless returning from compose/read/etc + if (this.env.mailbox != props && this.message_rows) + this.clear_message_list_header(); + this.list_mailbox(props); } else if (this.task=='addressbook') this.list_contacts(); break; + case 'sort': // get the type of sorting var a_sort = props.split('_'); @@ -842,6 +848,9 @@ function rcube_webmail() //location.href = this.env.comm_path+'&_action=show&_uid='+this.env.prev_uid+'&_mbox='+this.env.mailbox; break; + case 'checkmail': + this.check_for_recent(); + break; case 'compose': var url = this.env.comm_path+'&_action=compose'; @@ -1034,6 +1043,10 @@ function rcube_webmail() this.create_folder(props); break; + case 'rename-folder': + this.rename_folder(props); + break; + case 'delete-folder': if (confirm(this.get_label('deletefolderconfirm'))) this.delete_folder(props); @@ -1554,6 +1567,7 @@ function rcube_webmail() this.clear_message_list = function() { var table = this.gui_objects.messagelist; + var tbody = document.createElement('TBODY'); table.insertBefore(tbody, table.tBodies[0]); table.removeChild(table.tBodies[1]); @@ -1563,6 +1577,18 @@ function rcube_webmail() }; + this.clear_message_list_header = function() + { + var table = this.gui_objects.messagelist; + + var colgroup = document.createElement('COLGROUP'); + table.removeChild(table.colgroup); + table.insertBefore(colgroup, table.thead); + + var thead = document.createElement('THEAD'); + table.removeChild(table.thead); + table.insertBefore(thead, table.tBodies[0]); + }; this.expunge_mailbox = function(mbox) { @@ -2584,6 +2610,21 @@ function rcube_webmail() form.elements['_folder_name'].focus(); }; + this.rename_folder = function(props) + { + var form; + if ((form = this.gui_objects.editform) && form.elements['_folder_oldname'] && form.elements['_folder_newname']) + { + oldname = form.elements['_folder_oldname'].value; + newname = form.elements['_folder_newname'].value; + } + + if (oldname && newname) + this.http_request('rename-folder', '_folder_oldname='+escape(oldname)+'&_folder_newname='+escape(newname)); + else if (form.elements['_folder_newname']) + form.elements['_folder_newname'].focus(); + }; + this.delete_folder = function(folder) { @@ -2603,6 +2644,20 @@ function rcube_webmail() var row; if (id && (row = document.getElementById(id))) row.style.display = 'none'; + + // remove folder from rename-folder list + var form; + if ((form = this.gui_objects.editform) && form.elements['_folder_oldname']) + { + for (var i=0;i | +-----------------------------------------------------------------------+ - $Id$ + $Id: check_recent.inc 233 2006-06-26 17:31:20Z richs $ */ $REMOTE_REQUEST = TRUE; -$mbox_name = $IMAP->get_mailbox_name(); -if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE)) +$a_mailboxes = $IMAP->list_mailboxes(); + +foreach ($a_mailboxes as $mbox_name) { - $count = $IMAP->messagecount(); - $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE); - - $commands = sprintf("this.set_unread_count('%s', %d, true);\n", addslashes($mbox_name), $unread_count); - $commands .= sprintf("this.set_env('messagecount', %d);\n", $count); - $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text()); - $commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota()); - - // add new message headers to list - $a_headers = array(); - for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++) - $a_headers[] = $IMAP->get_headers($id, NULL, FALSE); - - $commands .= rcmail_js_message_list($a_headers, TRUE); + if ($mbox_name == $IMAP->get_mailbox_name()) + { + if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE)) + { + $count = $IMAP->messagecount(); + $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE); + + $commands .= sprintf("this.set_unread_count('%s', %d, true);\n", addslashes($mbox_name), $unread_count); + $commands .= sprintf("this.set_env('messagecount', %d);\n", $count); + $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text()); + $commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota()); + + // add new message headers to list + $a_headers = array(); + for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++) + $a_headers[] = $IMAP->get_headers($id, NULL, FALSE); + + $commands .= rcmail_js_message_list($a_headers, TRUE); + } + } + else + { + if ($IMAP->messagecount($mbox_name, 'RECENT')) + $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $IMAP->messagecount($mbox_name, 'UNSEEN')); + } } -if (strtoupper($mbox_name)!='INBOX' && $IMAP->messagecount('INBOX', 'RECENT')) - $commands = sprintf("this.set_unread_count('INBOX', %d);\n", $IMAP->messagecount('INBOX', 'UNSEEN')); - - rcube_remote_response($commands); ?> diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 8eff11c06..eac4e3747 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -304,10 +304,10 @@ function rcmail_message_list($attrib) // define list of cols to be displayed $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); - $a_sort_cols = array('subject', 'date', 'from', 'to'); + $a_sort_cols = array('subject', 'date', 'from', 'to', 'size'); // show 'to' instead of from in sent messages - if (strtolower($IMAP->get_mailbox_name())=='sent' && ($f = array_search('from', $a_show_cols)) + if (($IMAP->get_mailbox_name()==$CONFIG['sent_mbox'] || $IMAP->get_mailbox_name()==$CONFIG['drafts_mbox']) && ($f = array_search('from', $a_show_cols)) && !array_search('to', $a_show_cols)) $a_show_cols[$f] = 'to'; diff --git a/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc index 86b9bb7fe..dd321f0d8 100644 --- a/program/steps/settings/manage_folders.inc +++ b/program/steps/settings/manage_folders.inc @@ -19,7 +19,7 @@ */ -// init IAMP connection +// init IMAP connection rcmail_imap_init(TRUE); @@ -63,6 +63,27 @@ else if ($_action=='create-folder') show_message('errorsaving', 'error'); } +// rename a mailbox +else if ($_action=='rename-folder') + { + if (!empty($_GET['_folder_oldname']) && !empty($_GET['_folder_newname'])) + $rename = $IMAP->rename_mailbox(get_input_value('_folder_oldname', RCUBE_INPUT_GET), trim(get_input_value('_folder_newname', RCUBE_INPUT_GET)), TRUE); + + if ($rename && $REMOTE_REQUEST) + { + $commands = sprintf("this.add_folder_row('%s');", rep_specialchars_output($rename, 'js')); + $commands .= sprintf("this.remove_folder_row('%s')", rep_specialchars_output($_GET['_folder_oldname'], 'js')); + rcube_remote_response($commands); + } + else if (!$rename && $REMOTE_REQUEST) + { + $commands = show_message('errorsaving', 'error'); + rcube_remote_response($commands); + } + else if (!$rename) + show_message('errorsaving', 'error'); + } + // delete an existing IMAP mailbox else if ($_action=='delete-folder') { @@ -120,6 +141,9 @@ function rcube_subscription_form($attrib) // create list of available folders foreach ($a_unsubscribed as $i => $folder) { + if ($CONFIG['protect_default_folders'] == TRUE && in_array($folder,$CONFIG['default_imap_folders'])) + continue; + $zebra_class = $i%2 ? 'even' : 'odd'; $folder_js = rep_specialchars_output($folder, 'js'); $a_js_folders['rcmrow'.($i+1)] = $folder_js; @@ -176,10 +200,50 @@ function rcube_create_folder_form($attrib) return $out; } +function rcube_rename_folder_form($attrib) + { + global $CONFIG, $IMAP, $JS_OBJECT_NAME; + + list($form_start, $form_end) = get_form_tags($attrib, 'rename-folder'); + unset($attrib['form']); + + // return the complete edit form as table + $out = "$form_start\n"; + + $a_unsubscribed = $IMAP->list_unsubscribed(); + $select_folder = new select(array('name' => '_folder_oldname', 'id' => 'rcmfd_oldfolder')); + + foreach ($a_unsubscribed as $i => $folder) + { + if ($CONFIG['protect_default_folders'] == TRUE && in_array($folder,$CONFIG['default_imap_folders'])) + continue; + + $select_folder->add($folder); + } + + $out .= $select_folder->show(); + + $out .= " to "; + $inputtwo = new textfield(array('name' => '_folder_newname')); + $out .= $inputtwo->show(); + + if (get_boolean($attrib['button'])) + { + $button = new input_field(array('type' => 'button', + 'value' => rcube_label('rename'), + 'onclick' => "$JS_OBJECT_NAME.command('rename-folder',this.form)")); + $out .= $button->show(); + } + + $out .= "\n$form_end"; + + return $out; + } + // add some labels to client rcube_add_label('deletefolderconfirm'); parse_template('managefolders'); -?> \ No newline at end of file +?> -- cgit v1.2.3