summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG4
-rw-r--r--program/js/app.js11
-rw-r--r--program/steps/mail/folders.inc9
-rw-r--r--program/steps/mail/func.inc1
4 files changed, 21 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a385121e7..b0ec287e3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,10 @@
CHANGELOG RoundCube Webmail
---------------------------
+2008/06/24 (alec)
+----------
+- Allow trash/junk subfolders to be purged (#1485085)
+
2008/06/20 (alec)
----------
- Added Azerbaijani translation
diff --git a/program/js/app.js b/program/js/app.js
index abd5ca748..74e027403 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -203,7 +203,10 @@ function rcube_webmail()
if (this.env.messagecount)
this.enable_command('select-all', 'select-none', 'expunge', true);
- if (this.env.messagecount && (this.env.mailbox==this.env.trash_mailbox || this.env.mailbox==this.env.junk_mailbox))
+ if (this.env.messagecount
+ && (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox
+ || this.env.mailbox.match('^' + RegExp.escape(this.env.trash_mailbox) + RegExp.escape(this.env.delimiter))
+ || this.env.mailbox.match('^' + RegExp.escape(this.env.junk_mailbox) + RegExp.escape(this.env.delimiter))))
this.enable_command('purge', true);
this.set_page_buttons();
@@ -3559,7 +3562,11 @@ function rcube_webmail()
case 'check-recent':
case 'getunread':
this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0));
- this.enable_command('purge', (this.env.messagecount && (this.env.mailbox==this.env.trash_mailbox || this.env.mailbox==this.env.junk_mailbox)));
+ var mailboxtest = (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox
+ || this.env.mailbox.match('^' + RegExp.escape(this.env.trash_mailbox) + RegExp.escape(this.env.delimiter))
+ || this.env.mailbox.match('^' + RegExp.escape(this.env.junk_mailbox) + RegExp.escape(this.env.delimiter))) ? true : false;
+
+ this.enable_command('purge', (this.env.messagecount && mailboxtest));
break;
diff --git a/program/steps/mail/folders.inc b/program/steps/mail/folders.inc
index 69f3c0e4c..7fd1f62cc 100644
--- a/program/steps/mail/folders.inc
+++ b/program/steps/mail/folders.inc
@@ -39,8 +39,13 @@ if ($RCMAIL->action=='expunge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_
// clear mailbox
else if ($RCMAIL->action=='purge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST)))
{
- // we should only be purging trash and junk
- if($mbox == $CONFIG['trash_mbox'] || $mbox == $CONFIG['junk_mbox'])
+ $delimiter = $IMAP->get_hierarchy_delimiter();
+ $trash_regexp = '/^' . preg_quote($CONFIG['trash_mbox'] . $delimiter, '/') . '/';
+ $junk_regexp = '/^' . preg_quote($CONFIG['junk_mbox'] . $delimiter, '/') . '/';
+
+ // we should only be purging trash and junk (or their subfolders)
+ if ($mbox == $CONFIG['trash_mbox'] || $mbox == $CONFIG['junk_mbox']
+ || preg_match($trash_regexp, $mbox) || preg_match($junk_regexp, $mbox))
{
$success = $IMAP->clear_mailbox($mbox);
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index bb5ece5c1..7fbda27b4 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -57,6 +57,7 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
// set current mailbox in client environment
$OUTPUT->set_env('mailbox', $IMAP->get_mailbox_name());
$OUTPUT->set_env('quota', $IMAP->get_capability('quota'));
+$OUTPUT->set_env('delimiter', $IMAP->get_hierarchy_delimiter());
if ($CONFIG['trash_mbox'])
$OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']);