| | |
| | | <?php |
| | | |
| | | /* |
| | | /** |
| | | +-----------------------------------------------------------------------+ |
| | | | program/steps/settings/save_folder.inc | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2009, The Roundcube Dev Team | |
| | | | Licensed under the GNU GPL | |
| | | | Copyright (C) 2005-2012, The Roundcube Dev Team | |
| | | | | |
| | | | Licensed under the GNU General Public License version 3 or | |
| | | | any later version with exceptions for skins & plugins. | |
| | | | See the README file for a full license statement. | |
| | | | | |
| | | | PURPOSE: | |
| | | | Provide functionality to create/edit a folder | |
| | |
| | | +-----------------------------------------------------------------------+ |
| | | | Author: Aleksander Machniak <alec@alec.pl> | |
| | | +-----------------------------------------------------------------------+ |
| | | |
| | | $Id$ |
| | | |
| | | */ |
| | | |
| | | // WARNING: folder names in UI are encoded with RCMAIL_CHARSET |
| | | |
| | | // init IMAP connection |
| | | $RCMAIL->imap_connect(); |
| | | $STORAGE = $RCMAIL->get_storage(); |
| | | |
| | | |
| | | $name = trim(get_input_value('_name', RCUBE_INPUT_POST, true)); |
| | |
| | | $old_imap = rcube_charset_convert($old, RCMAIL_CHARSET, 'UTF7-IMAP'); |
| | | // $path is in UTF7-IMAP already |
| | | |
| | | $delimiter = $IMAP->get_hierarchy_delimiter(); |
| | | $delimiter = $STORAGE->get_hierarchy_delimiter(); |
| | | $options = strlen($old_imap) ? rcmail_folder_options($old_imap) : array(); |
| | | |
| | | // Folder name checks |
| | |
| | | } |
| | | } |
| | | |
| | | // Check access rights to the parent folder |
| | | if (!$error && strlen($path)) { |
| | | $parent_opts = $RCMAIL->imap->mailbox_info($path); |
| | | if ($parent_opts['namespace'] != 'personal' |
| | | && (empty($parent_opts['rights']) || !preg_match('/[ck]/', implode($parent_opts))) |
| | | ) { |
| | | $error = rcube_label('parentnotwritable'); |
| | | } |
| | | } |
| | | |
| | | if ($error) { |
| | | $OUTPUT->command('display_message', $error, 'error'); |
| | | } |
| | |
| | | $name_imap = $path . $delimiter . $name_imap; |
| | | } |
| | | else { |
| | | $name_imap = $RCMAIL->imap->mod_mailbox($name_imap, 'in'); |
| | | $name_imap = $STORAGE->mod_folder($name_imap, 'in'); |
| | | } |
| | | } |
| | | |
| | | // Check access rights to the parent folder |
| | | if (!$error && strlen($path) && (!strlen($old_imap) || $old_imap != $name_imap)) { |
| | | $parent_opts = $STORAGE->folder_info($path); |
| | | if ($parent_opts['namespace'] != 'personal' |
| | | && (empty($parent_opts['rights']) || !preg_match('/[ck]/', implode($parent_opts['rights']))) |
| | | ) { |
| | | $error = rcube_label('parentnotwritable'); |
| | | } |
| | | } |
| | | |
| | | if ($error) { |
| | | $OUTPUT->command('display_message', $error, 'error'); |
| | | } |
| | | else { |
| | | $folder['name'] = $name_imap; |
| | | $folder['oldname'] = $old_imap; |
| | | $folder['class'] = ''; |
| | |
| | | $folder = $plugin['record']; |
| | | |
| | | if (!$plugin['abort']) { |
| | | $created = $IMAP->create_mailbox($folder['name'], $folder['subscribe']); |
| | | $created = $STORAGE->create_folder($folder['name'], $folder['subscribe']); |
| | | } |
| | | else { |
| | | $created = $plugin['result']; |
| | |
| | | |
| | | if (!$plugin['abort']) { |
| | | if ($rename) { |
| | | $updated = $RCMAIL->imap->rename_mailbox($folder['oldname'], $folder['name']); |
| | | $updated = $STORAGE->rename_folder($folder['oldname'], $folder['name']); |
| | | } |
| | | else { |
| | | $updated = true; |
| | |
| | | } |
| | | else if (preg_match($oldprefix, $key)) { |
| | | unset($a_threaded[$key]); |
| | | $a_threaded[preg_replace($oldprefix, $folder['name'].$delimiter, $key)] = true; |
| | | $a_threaded[preg_replace($oldprefix, $folder['name'].$delimiter, $key)] = true; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | $OUTPUT->show_message('folderupdated', 'confirmation'); |
| | | |
| | | if ($rename) { |
| | | // #1488692: update session |
| | | if ($_SESSION['mbox'] === $folder['oldname']) { |
| | | $_SESSION['mbox'] = $folder['name']; |
| | | } |
| | | rcmail_update_folder_row($folder['name'], $folder['oldname'], $folder['subscribe'], $folder['class']); |
| | | $OUTPUT->send('iframe'); |
| | | } |