Thomas Bruederli
2014-06-04 3412e50b54e3daac8745234e21ab6e72be0ed165
program/steps/settings/save_folder.inc
@@ -1,6 +1,6 @@
<?php
/**
/*
 +-----------------------------------------------------------------------+
 | program/steps/settings/save_folder.inc                                |
 |                                                                       |
@@ -19,18 +19,17 @@
 +-----------------------------------------------------------------------+
*/
// WARNING: folder names in UI are encoded with RCMAIL_CHARSET
// WARNING: folder names in UI are encoded with RCUBE_CHARSET
// init IMAP connection
$STORAGE = $RCMAIL->get_storage();
$name = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST, true));
$old  = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
$path = rcube_utils::get_input_value('_parent', rcube_utils::INPUT_POST, true);
$name = trim(get_input_value('_name', RCUBE_INPUT_POST, true));
$old  = get_input_value('_mbox', RCUBE_INPUT_POST, true);
$path = get_input_value('_parent', RCUBE_INPUT_POST, true);
$name_imap = rcube_charset_convert($name, RCMAIL_CHARSET, 'UTF7-IMAP');
$old_imap  = rcube_charset_convert($old, RCMAIL_CHARSET, 'UTF7-IMAP');
$name_imap = rcube_charset::convert($name, RCUBE_CHARSET, 'UTF7-IMAP');
$old_imap  = rcube_charset::convert($old, RCUBE_CHARSET, 'UTF7-IMAP');
// $path is in UTF7-IMAP already
$delimiter = $STORAGE->get_hierarchy_delimiter();
@@ -40,16 +39,16 @@
if ($options['protected'] || $options['norename']) {
}
else if (!strlen($name)) {
    $error = rcube_label('cannotbeempty');
    $error = $RCMAIL->gettext('namecannotbeempty');
}
else if (mb_strlen($name) > 128) {
    $error = rcube_label('nametoolong');
    $error = $RCMAIL->gettext('nametoolong');
}
else {
    // these characters are problematic e.g. when used in LIST/LSUB
    foreach (array($delimiter, '%', '*') as $char) {
        if (strpos($name, $delimiter) !== false) {
            $error = rcube_label('forbiddencharacter') . " ($char)";
            $error = $RCMAIL->gettext('forbiddencharacter') . " ($char)";
            break;
        }
    }
@@ -76,7 +75,7 @@
    if ($parent_opts['namespace'] != 'personal'
        && (empty($parent_opts['rights']) || !preg_match('/[ck]/', implode($parent_opts['rights'])))
    ) {
        $error = rcube_label('parentnotwritable');
        $error = $RCMAIL->gettext('parentnotwritable');
    }
}
@@ -90,15 +89,14 @@
    $folder['options']  = $options;
    $folder['settings'] = array(
        // List view mode: 0-list, 1-threads
        'view_mode'   => (int) get_input_value('_viewmode', RCUBE_INPUT_POST),
        'sort_column' => get_input_value('_sortcol', RCUBE_INPUT_POST),
        'sort_order'  => get_input_value('_sortord', RCUBE_INPUT_POST),
        'view_mode'   => (int) rcube_utils::get_input_value('_viewmode', rcube_utils::INPUT_POST),
        'sort_column' => rcube_utils::get_input_value('_sortcol', rcube_utils::INPUT_POST),
        'sort_order'  => rcube_utils::get_input_value('_sortord', rcube_utils::INPUT_POST),
    );
}
// create a new mailbox
if (!$error && !strlen($old)) {
    $folder['subscribe'] = true;
    $plugin = $RCMAIL->plugins->exec_hook('folder_create', array('record' => $folder));
@@ -136,7 +134,6 @@
        $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false);
    }
}
// update a mailbox
else if (!$error) {
    $plugin = $RCMAIL->plugins->exec_hook('folder_update', array('record' => $folder));
@@ -192,6 +189,9 @@
            rcmail_update_folder_row($folder['name'], $folder['oldname'], $folder['subscribe'], $folder['class']);
            $OUTPUT->send('iframe');
        }
        else if (!empty($folder['class'])) {
            rcmail_update_folder_row($folder['name'], $folder['oldname'], $folder['subscribe'], $folder['class']);
        }
    }
    else {
        // show error message
@@ -199,4 +199,4 @@
    }
}
rcmail_overwrite_action('edit-folder');
$RCMAIL->overwrite_action('edit-folder');