diff options
Diffstat (limited to 'plugins/archive')
-rw-r--r-- | plugins/archive/archive.js | 2 | ||||
-rw-r--r-- | plugins/archive/archive.php | 133 | ||||
-rw-r--r-- | plugins/archive/composer.json | 2 | ||||
-rw-r--r-- | plugins/archive/package.xml | 4 |
4 files changed, 72 insertions, 69 deletions
diff --git a/plugins/archive/archive.js b/plugins/archive/archive.js index c0d074cf9..58e7d6217 100644 --- a/plugins/archive/archive.js +++ b/plugins/archive/archive.js @@ -1,6 +1,6 @@ /** * Archive plugin script - * @version 2.2 + * @version 2.3 */ function rcmail_archive(prop) diff --git a/plugins/archive/archive.php b/plugins/archive/archive.php index 8c0a89d96..72f7a7f2a 100644 --- a/plugins/archive/archive.php +++ b/plugins/archive/archive.php @@ -6,7 +6,7 @@ * Plugin that adds a new button to the mailbox toolbar * to move messages to a (user selectable) archive folder. * - * @version 2.2 + * @version 2.3 * @license GNU GPLv3+ * @author Andre Rodier, Thomas Bruederli, Aleksander Machniak */ @@ -111,8 +111,7 @@ class archive extends rcube_plugin $delimiter = $storage->get_hierarchy_delimiter(); $archive_folder = $rcmail->config->get('archive_mbox'); $archive_type = $rcmail->config->get('archive_type', ''); - - $storage->set_folder(($current_mbox = rcube_utils::get_input_value('_mbox', RCUBE_INPUT_POST))); + $current_mbox = rcube_utils::get_input_value('_mbox', RCUBE_INPUT_POST); $result = array('reload' => false, 'update' => false, 'errors' => array()); $folders = array(); @@ -121,84 +120,88 @@ class archive extends rcube_plugin if ($uids == '*') { $index = $storage->index(null, rcmail_sort_column(), rcmail_sort_order()); - $uids = $index->get(); + $messageset = array($current_mbox => $index->get()); } else { - $uids = explode(',', $uids); + $messageset = rcmail::get_uids(); } - foreach ($uids as $uid) { - if (!$archive_folder || !($message = $rcmail->storage->get_message($uid))) { - continue; - } - - $subfolder = null; - switch ($archive_type) { - case 'year': - $subfolder = $rcmail->format_date($message->timestamp, 'Y'); - break; + foreach ($messageset as $mbox => $uids) { + $storage->set_folder(($current_mbox = $mbox)); - case 'month': - $subfolder = $rcmail->format_date($message->timestamp, 'Y') . $delimiter . $rcmail->format_date($message->timestamp, 'm'); - break; + foreach ($uids as $uid) { + if (!$archive_folder || !($message = $rcmail->storage->get_message($uid))) { + continue; + } - case 'folder': - $subfolder = $current_mbox; - break; + $subfolder = null; + switch ($archive_type) { + case 'year': + $subfolder = $rcmail->format_date($message->timestamp, 'Y'); + break; - case 'sender': - $from = $message->get('from'); - if (preg_match('/[\b<](.+@.+)[\b>]/i', $from, $m)) { - $subfolder = $m[1]; - } - else { - $subfolder = $this->gettext('unkownsender'); - } + case 'month': + $subfolder = $rcmail->format_date($message->timestamp, 'Y') . $delimiter . $rcmail->format_date($message->timestamp, 'm'); + break; - // replace reserved characters in folder name - $repl = $delimiter == '-' ? '_' : '-'; - $replacements[$delimiter] = $repl; - $replacements['.'] = $repl; // some IMAP server do not allow . characters - $subfolder = strtr($subfolder, $replacements); - break; + case 'folder': + $subfolder = $current_mbox; + break; - default: - $subfolder = ''; - break; - } + case 'sender': + $from = $message->get('from'); + if (preg_match('/[\b<](.+@.+)[\b>]/i', $from, $m)) { + $subfolder = $m[1]; + } + else { + $subfolder = $this->gettext('unkownsender'); + } - // compose full folder path - $folder = $archive_folder . ($subfolder ? $delimiter . $subfolder : ''); + // replace reserved characters in folder name + $repl = $delimiter == '-' ? '_' : '-'; + $replacements[$delimiter] = $repl; + $replacements['.'] = $repl; // some IMAP server do not allow . characters + $subfolder = strtr($subfolder, $replacements); + break; - // create archive subfolder if it doesn't yet exist - // we'll create all folders in the path - if (!in_array($folder, $folders)) { - if (empty($list)) { - $list = $storage->list_folders('', $archive_folder . '*', 'mail', null, true); + default: + $subfolder = ''; + break; } - $path = explode($delimiter, $folder); - - for ($i=0; $i<count($path); $i++) { - $_folder = implode($delimiter, array_slice($path, 0, $i+1)); - if (!in_array($_folder, $list)) { - if ($storage->create_folder($_folder, true)) { - $result['reload'] = true; - $list[] = $_folder; + + // compose full folder path + $folder = $archive_folder . ($subfolder ? $delimiter . $subfolder : ''); + + // create archive subfolder if it doesn't yet exist + // we'll create all folders in the path + if (!in_array($folder, $folders)) { + if (empty($list)) { + $list = $storage->list_folders('', $archive_folder . '*', 'mail', null, true); + } + $path = explode($delimiter, $folder); + + for ($i=0; $i<count($path); $i++) { + $_folder = implode($delimiter, array_slice($path, 0, $i+1)); + if (!in_array($_folder, $list)) { + if ($storage->create_folder($_folder, true)) { + $result['reload'] = true; + $list[] = $_folder; + } } } - } - $folders[] = $folder; - } + $folders[] = $folder; + } - // move message to target folder - if ($storage->move_message(array($uid), $folder)) { - $result['update'] = true; - } - else { - $result['errors'][] = $uid; - } - } // end for + // move message to target folder + if ($storage->move_message(array($uid), $folder)) { + $result['update'] = true; + } + else { + $result['errors'][] = $uid; + } + } // end for + } // send response if ($result['errors']) { diff --git a/plugins/archive/composer.json b/plugins/archive/composer.json index 8a585ad09..1e3331b2c 100644 --- a/plugins/archive/composer.json +++ b/plugins/archive/composer.json @@ -3,7 +3,7 @@ "type": "roundcube-plugin", "description": "This adds a button to move the selected messages to an archive folder. The folder (and the optional structure of subfolders) can be selected in the settings panel.", "license": "GNU GPLv3+", - "version": "2.1", + "version": "2.3", "authors": [ { "name": "Thomas Bruederli", diff --git a/plugins/archive/package.xml b/plugins/archive/package.xml index ec3323e4b..4f5a87c7b 100644 --- a/plugins/archive/package.xml +++ b/plugins/archive/package.xml @@ -19,9 +19,9 @@ <email>alec@alec.pl</email> <active>yes</active> </lead> - <date>2013-10-30</date> + <date>2014-04-07</date> <version> - <release>2.1</release> + <release>2.3</release> <api>2.0</api> </version> <stability> |