From 19869073e3e60903ee90c5e5d9404058c29679fb Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Sun, 10 Jul 2011 14:11:25 -0400 Subject: [PATCH] - Plugin API: added folder_delete and folder_rename hooks --- CHANGELOG | 1 + program/steps/settings/folders.inc | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8748ecc..342e7eb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Plugin API: added folder_delete and folder_rename hooks - Added possibility to undo last contact delete operation - Fix sorting of contact groups after group create (#1487747) - Add optional textual upload progress indicator (#1486039) diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc index 239413f..cc149bc 100644 --- a/program/steps/settings/folders.inc +++ b/program/steps/settings/folders.inc @@ -76,8 +76,16 @@ $mbox_utf8 = get_input_value('_mbox', RCUBE_INPUT_POST, true); $mbox = rcube_charset_convert($mbox_utf8, RCMAIL_CHARSET, 'UTF7-IMAP'); - if (strlen($mbox)) - $deleted = $IMAP->delete_mailbox($mbox); + if (strlen($mbox)) { + $plugin = $RCMAIL->plugins->exec_hook('folder_delete', array('name' => $mbox)); + + if (!$plugin['abort']) { + $deleted = $IMAP->delete_mailbox($plugin['name']); + } + else { + $deleted = $plugin['result']; + } + } if ($OUTPUT->ajax_call && $deleted) { // Remove folder and subfolders rows @@ -340,10 +348,19 @@ global $RCMAIL; $delimiter = $RCMAIL->imap->get_hierarchy_delimiter(); - $rename = $RCMAIL->imap->rename_mailbox($oldname, $newname); + + $plugin = $RCMAIL->plugins->exec_hook('folder_rename', array( + 'oldname' => $oldname, 'newname' => $newname)); + + if (!$plugin['abort']) { + $renamed = $RCMAIL->imap->rename_mailbox($oldname, $newname); + } + else { + $renamed = $plugin['result']; + } // update per-folder options for modified folder and its subfolders - if ($rename !== false) { + if ($renamed) { $a_threaded = (array) $RCMAIL->config->get('message_threading', array()); $oldprefix = '/^' . preg_quote($oldname . $delimiter, '/') . '/'; -- Gitblit v1.9.1