|
|
|
@ -110,19 +110,20 @@ class archive extends rcube_plugin
|
|
|
|
|
*/
|
|
|
|
|
function move_messages()
|
|
|
|
|
{
|
|
|
|
|
$rcmail = rcmail::get_instance();
|
|
|
|
|
$this->add_texts('localization');
|
|
|
|
|
|
|
|
|
|
$rcmail = rcmail::get_instance();
|
|
|
|
|
$storage = $rcmail->get_storage();
|
|
|
|
|
$storage->set_folder(($current_mbox = rcube_utils::get_input_value('_mbox', RCUBE_INPUT_POST)));
|
|
|
|
|
|
|
|
|
|
$delimiter = $storage->get_hierarchy_delimiter();
|
|
|
|
|
$archive_folder = $rcmail->config->get('archive_mbox');
|
|
|
|
|
$archive_type = $rcmail->config->get('archive_type', '');
|
|
|
|
|
|
|
|
|
|
$result = array('reload' => false, 'update' => false, 'errors' => array());
|
|
|
|
|
$storage->set_folder(($current_mbox = rcube_utils::get_input_value('_mbox', RCUBE_INPUT_POST)));
|
|
|
|
|
|
|
|
|
|
$result = array('reload' => false, 'update' => false, 'errors' => array());
|
|
|
|
|
$uids = explode(',', rcube_utils::get_input_value('_uid', RCUBE_INPUT_POST));
|
|
|
|
|
$folders = array();
|
|
|
|
|
|
|
|
|
|
foreach ($uids as $uid) {
|
|
|
|
|
if (!$archive_folder || !($message = $rcmail->storage->get_message($uid))) {
|
|
|
|
|
continue;
|
|
|
|
@ -167,10 +168,22 @@ class archive extends rcube_plugin
|
|
|
|
|
$folder = $archive_folder . ($subfolder ? $delimiter . $subfolder : '');
|
|
|
|
|
|
|
|
|
|
// create archive subfolder if it doesn't yet exist
|
|
|
|
|
if (!$storage->folder_exists($folder, false)) {
|
|
|
|
|
if ($storage->create_folder($folder, true))
|
|
|
|
|
// we'll create all folders in the path
|
|
|
|
|
if (!in_array($folder, $folders)) {
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$folders[] = $folder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// move message to target folder
|
|
|
|
|
if ($storage->move_message(array($uid), $folder)) {
|
|
|
|
|