diff options
author | thomascube <thomas@roundcube.net> | 2006-01-25 22:56:53 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2006-01-25 22:56:53 +0000 |
commit | 5e35126796f14e0910a007972779d96fd49e1789 (patch) | |
tree | 9d04098a0470504edbf12692247ba58545f1695e | |
parent | c9d09bbe43f268c11cadc9846652ff33521edf6c (diff) |
Added folder purge function and some checks
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | program/include/rcube_imap.inc | 14 | ||||
-rw-r--r-- | program/js/app.js | 44 | ||||
-rw-r--r-- | program/js/common.js | 6 | ||||
-rwxr-xr-x | program/lib/MDB2/Driver/Manager/fbsql.php | 1 | ||||
-rw-r--r-- | program/steps/addressbook/func.inc | 3 | ||||
-rw-r--r-- | program/steps/mail/check_recent.inc | 4 | ||||
-rw-r--r-- | program/steps/mail/folders.inc | 8 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 3 | ||||
-rw-r--r-- | skins/default/templates/mail.html | 1 |
10 files changed, 66 insertions, 20 deletions
@@ -244,7 +244,7 @@ if ($_task=='mail') if ($_action=='addcontact') include('program/steps/mail/addcontact.inc'); - if ($_action=='expunge') + if ($_action=='expunge' || $_action=='purge') include('program/steps/mail/folders.inc'); if ($_action=='check-recent') diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc index 7f91d3a65..fa13e02cf 100644 --- a/program/include/rcube_imap.inc +++ b/program/include/rcube_imap.inc @@ -986,8 +986,18 @@ class rcube_imap if ($msg_count>0) { - $this->clear_message_cache($mailbox.'.msg'); - return iil_C_ClearFolder($this->conn, $mailbox); + $cleared = iil_C_ClearFolder($this->conn, $mailbox); + + // make sure the message count cache is cleared as well + if ($cleared) + { + $this->clear_message_cache($mailbox.'.msg'); + $a_mailbox_cache = $this->get_cache('messagecount'); + unset($a_mailbox_cache[$mailbox]); + $this->update_cache('messagecount', $a_mailbox_cache); + } + + return $cleared; } else return 0; diff --git a/program/js/app.js b/program/js/app.js index 3c91490f6..e0e31ed09 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -145,6 +145,9 @@ function rcube_webmail() if (this.env.messagecount) this.enable_command('select-all', 'select-none', 'sort', 'expunge', true); + if (this.env.messagecount && this.env.mailbox==this.env.trash_mailbox) + this.enable_command('purge', true); + this.set_page_buttons(); // focus this window @@ -622,9 +625,10 @@ function rcube_webmail() this.expunge_mailbox(this.env.mailbox); break; - case 'clear-mailbox': - //if (this.env.messagecount) - //this.clear_mailbox(this.env.mailbox); + case 'purge': + case 'empty-mailbox': + if (this.env.messagecount) + this.purge_mailbox(this.env.mailbox); break; @@ -1435,6 +1439,28 @@ function rcube_webmail() }; + this.purge_mailbox = function(mbox) + { + var lock = false; + var add_url = ''; + + if (!confirm(this.get_label('purgefolderconfirm'))) + return false; + + // lock interface if it's the active mailbox + if (mbox == this.env.mailbox) + { + lock = true; + this.set_busy(true, 'loading'); + add_url = '&_reload=1'; + } + + // send request to server + var url = '_mbox='+escape(mbox); + this.http_request('purge', url+add_url, lock); + }; + + // move selected messages to the specified mailbox this.move_messages = function(mbox) { @@ -2068,6 +2094,7 @@ function rcube_webmail() return false; //if (this.env.framed && add_url=='') + // add_url = '&_framed=1'; if (action && (cid || action=='add')) @@ -2081,9 +2108,9 @@ function rcube_webmail() this.delete_contacts = function() { // exit if no mailbox specified or if selection is empty - if (!(this.selection.length || this.env.cid)) + if (!(this.selection.length || this.env.cid) || !confirm(this.get_label('deletecontactconfirm'))) return; - + var a_cids = new Array(); if (this.env.cid) @@ -2821,7 +2848,7 @@ function rcube_webmail() if (request_obj.__lock) this.set_busy(false); - console(request_obj.responseText); + console(request_obj.get_text()); // if we get javascript code from server -> execute it if (request_obj.get_text() && (ctype=='text/javascript' || ctype=='application/x-javascript')) @@ -2837,9 +2864,12 @@ function rcube_webmail() break; case 'list': + if (this.env.messagecount) + this.enable_command('purge', (this.env.mailbox==this.env.trash_mailbox)); + case 'expunge': this.enable_command('select-all', 'select-none', 'expunge', this.env.messagecount ? true : false); - break; + break; } request_obj.reset(); diff --git a/program/js/common.js b/program/js/common.js index 02f698b90..8378e2e57 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -6,11 +6,11 @@ | Copyright (C) 2005, RoundCube Dev, - Switzerland | | Licensed under the GNU GPL | | | - | Modified:2005/11/06 (roundcube) | - | | +-----------------------------------------------------------------------+ | Author: Thomas Bruederli <roundcube@gmail.com> | +-----------------------------------------------------------------------+ + + $Id$ */ @@ -271,7 +271,7 @@ function rcube_check_email(input, inline) { var reg_str = '([a-z0-9][-a-z0-9\.\+_]*)\@(([-a-z0-9][\.]?)*[a-z0-9]\.[a-z]{2,9})'; var reg1 = inline ? new RegExp(reg_str, 'i') : new RegExp('^'+reg_str+'$', 'i'); - var reg2 = /[\._\-\@]{2}/; + var reg2 = /[\._\-]{2}/; return reg1.test(input) && !reg2.test(input) ? true : false; } return false; diff --git a/program/lib/MDB2/Driver/Manager/fbsql.php b/program/lib/MDB2/Driver/Manager/fbsql.php index 60850bb5f..c1895ce4d 100755 --- a/program/lib/MDB2/Driver/Manager/fbsql.php +++ b/program/lib/MDB2/Driver/Manager/fbsql.php @@ -478,7 +478,6 @@ class MDB2_Driver_Manager_fbsql extends MDB2_Driver_Manager_Common * @return mixed data array on success, a MDB2 error on failure * @access public */ - */ function listTableIndexes($table) { $db =& $this->getDBInstance(); diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index f7993c9bc..6d3e95ea2 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -91,6 +91,9 @@ function rcmail_contacts_list($attrib) $OUTPUT->add_script($javascript); + // add some labels to client + rcube_add_label('deletecontactconfirm'); + return $out; } diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc index fbf8871f9..3d0ceb2a9 100644 --- a/program/steps/mail/check_recent.inc +++ b/program/steps/mail/check_recent.inc @@ -22,10 +22,10 @@ $REMOTE_REQUEST = TRUE; $mbox = $IMAP->get_mailbox_name(); -if ($recent_count = $IMAP->messagecount(NULL, 'RECENT')) +if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE)) { $count = $IMAP->messagecount(); - $unread_count = $IMAP->messagecount(NULL, 'UNSEEN'); + $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE); $commands = sprintf("this.set_unread_count('%s', %d, true);\n", addslashes($mbox), $unread_count); $commands .= sprintf("this.set_env('messagecount', %d);\n", $count); diff --git a/program/steps/mail/folders.inc b/program/steps/mail/folders.inc index e1730ef93..5a22b7e72 100644 --- a/program/steps/mail/folders.inc +++ b/program/steps/mail/folders.inc @@ -16,7 +16,6 @@ +-----------------------------------------------------------------------+ $Id$ - */ $REMOTE_REQUEST = TRUE; @@ -26,7 +25,7 @@ $mbox = $IMAP->get_mailbox_name(); // send EXPUNGE command if ($_action=='expunge') { - $success = $IMAP->expunge(); + $success = $IMAP->expunge($_GET['_mbox']); // reload message list if current mailbox if ($success && $_GET['_reload']) @@ -42,11 +41,12 @@ if ($_action=='expunge') // clear mailbox else if ($_action=='purge') { - $success = $IMAP->clear_mailbox(); + $success = $IMAP->clear_mailbox($_GET['_mbox']); if ($success && $_GET['_reload']) { - $commands = "this.set_env('messagecount', 0);\n"; + $commands = "this.clear_message_list();\n"; + $commands .= "this.set_env('messagecount', 0);\n"; $commands .= "this.set_env('pagecount', 0);\n"; $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text()); $commands .= sprintf("this.set_unread_count('%s', 0);\n", addslashes($mbox)); diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 4f84e2065..8e0178d7a 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -66,6 +66,9 @@ function rcmail_mailbox_list($attrib) global $IMAP, $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH; static $s_added_script = FALSE; static $a_mailboxes; + + // add some labels to client + rcube_add_label('purgefolderconfirm'); // $mboxlist_start = rcube_timer(); diff --git a/skins/default/templates/mail.html b/skins/default/templates/mail.html index 1af25ed88..0913018f2 100644 --- a/skins/default/templates/mail.html +++ b/skins/default/templates/mail.html @@ -31,6 +31,7 @@ <div id="mailboxcontrols"> <roundcube:label name="folder" />: <roundcube:button command="expunge" label="compact" classAct="active" /> +<roundcube:button command="purge" label="empty" classAct="active" /> </div> |