summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/settings/edit_folder.inc6
-rw-r--r--program/steps/settings/folders.inc44
-rw-r--r--program/steps/settings/func.inc23
-rw-r--r--program/steps/settings/save_folder.inc8
4 files changed, 32 insertions, 49 deletions
diff --git a/program/steps/settings/edit_folder.inc b/program/steps/settings/edit_folder.inc
index bc4310310..0bc7ab657 100644
--- a/program/steps/settings/edit_folder.inc
+++ b/program/steps/settings/edit_folder.inc
@@ -24,7 +24,7 @@
// init IMAP connection
$RCMAIL->imap_connect();
-function rcube_folder_form($attrib)
+function rcmail_folder_form($attrib)
{
global $RCMAIL;
@@ -41,7 +41,7 @@ function rcube_folder_form($attrib)
// Get mailbox parameters
if (strlen($mbox)) {
- $options = rcube_folder_options($mbox_imap);
+ $options = rcmail_folder_options($mbox_imap);
$namespace = $RCMAIL->imap->get_namespace();
$path = explode($delimiter, $mbox_imap);
@@ -319,7 +319,7 @@ function rcmail_localize_folderpath($path)
// register UI objects
$OUTPUT->add_handlers(array(
- 'folderdetails' => 'rcube_folder_form',
+ 'folderdetails' => 'rcmail_folder_form',
));
$OUTPUT->add_label('nonamewarning');
diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc
index bc95c7506..a9068099b 100644
--- a/program/steps/settings/folders.inc
+++ b/program/steps/settings/folders.inc
@@ -76,24 +76,12 @@ else if ($RCMAIL->action == 'delete-folder')
$mbox_utf8 = get_input_value('_mbox', RCUBE_INPUT_POST, true);
$mbox = rcube_charset_convert($mbox_utf8, RCMAIL_CHARSET, 'UTF7-IMAP');
- // get folder's children or all folders if the name contains special characters
- $delimiter = $IMAP->get_hierarchy_delimiter();
- if ((strpos($mbox, '%') === false) && (strpos($mbox, '*') === false))
- $a_mboxes = $IMAP->list_unsubscribed('', $mbox.$delimiter.'*');
- else
- $a_mboxes = $IMAP->list_unsubscribed();
-
if (strlen($mbox))
$deleted = $IMAP->delete_mailbox($mbox);
if ($OUTPUT->ajax_call && $deleted) {
// Remove folder and subfolders rows
- $OUTPUT->command('remove_folder_row', $mbox_utf8);
- foreach ($a_mboxes as $folder) {
- if (preg_match('/^'. preg_quote($mbox.$delimiter, '/') .'/', $folder)) {
- $OUTPUT->command('remove_folder_row', rcube_charset_convert($folder, 'UTF7-IMAP'));
- }
- }
+ $OUTPUT->command('remove_folder_row', $mbox_utf8, true);
$OUTPUT->show_message('folderdeleted', 'confirmation');
// Clear content frame
$OUTPUT->command('subscription_select');
@@ -118,34 +106,7 @@ else if ($RCMAIL->action == 'rename-folder')
}
if ($rename && $OUTPUT->ajax_call) {
- $folderlist = $IMAP->list_unsubscribed();
- $delimiter = $IMAP->get_hierarchy_delimiter();
-
- $regexp = '/^' . preg_quote($name . $delimiter, '/') . '/';
-
- // subfolders
- for ($x=sizeof($folderlist)-1; $x>=0; $x--) {
- if (preg_match($regexp, $folderlist[$x])) {
- $oldfolder = $oldname . $delimiter . preg_replace($regexp, '', $folderlist[$x]);
- $foldersplit = explode($delimiter, $IMAP->mod_mailbox($folderlist[$x]));
- $level = count($foldersplit) - 1;
- $display_rename = str_repeat('    ', $level)
- . rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP');
- $before = isset($folderlist[$x+1]) ? rcube_charset_convert($folderlist[$x+1], 'UTF7-IMAP') : false;
-
- $OUTPUT->command('replace_folder_row', rcube_charset_convert($oldfolder, 'UTF7-IMAP'),
- rcube_charset_convert($folderlist[$x], 'UTF7-IMAP'), $display_rename, $before);
- }
- }
-
- $index = array_search($name, $folderlist);
- $name = $IMAP->mod_mailbox($name);
- $foldersplit = explode($delimiter, $name);
- $level = count($foldersplit) - 1;
- $display_rename = str_repeat('    ', $level) . rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP');
- $before = $index !== false && isset($folderlist[$index+1]) ? rcube_charset_convert($folderlist[$index+1], 'UTF7-IMAP') : false;
-
- $OUTPUT->command('replace_folder_row', $oldname_utf8, $name_utf8, $display_rename, $before);
+ rcmail_update_folder_row($name, $oldname);
}
else if (!$rename) {
rcmail_display_server_error('errorsaving');
@@ -375,6 +336,7 @@ function rcmail_rename_folder($oldname, $newname)
return false;
}
+
$OUTPUT->set_pagetitle(rcube_label('folders'));
$OUTPUT->include_script('list.js');
$OUTPUT->set_env('quota', $IMAP->get_capability('QUOTA'));
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index b204d9bc9..a44d6c8ff 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -747,7 +747,7 @@ function rcmail_get_skins()
}
-function rcube_folder_options($mailbox)
+function rcmail_folder_options($mailbox)
{
global $RCMAIL;
@@ -785,6 +785,27 @@ function rcube_folder_options($mailbox)
return $options;
}
+// Updates (or creates) folder row in the subscriptions table
+function rcmail_update_folder_row($name, $oldname=null)
+{
+ global $IMAP, $CONFIG, $OUTPUT;
+
+ $delimiter = $IMAP->get_hierarchy_delimiter();
+ $name_utf8 = rcube_charset_convert($name, 'UTF7-IMAP');
+ $protected = ($CONFIG['protect_default_folders'] == true && in_array($name, $CONFIG['default_imap_folders']));
+
+ $foldersplit = explode($delimiter, $IMAP->mod_mailbox($name));
+ $level = count($foldersplit) - 1;
+ $display_name = str_repeat('    ', $level)
+ . Q($protected ? rcmail_localize_foldername($name) : rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'));
+
+ if ($oldname === null)
+ $OUTPUT->command('add_folder_row', $name_utf8, $display_name, $protected, true);
+ else
+ $OUTPUT->command('replace_folder_row', rcube_charset_convert($oldname, 'UTF7-IMAP'),
+ $name_utf8, $display_name, $protected);
+}
+
// register UI objects
$OUTPUT->add_handlers(array(
diff --git a/program/steps/settings/save_folder.inc b/program/steps/settings/save_folder.inc
index c1120961b..a4e752c90 100644
--- a/program/steps/settings/save_folder.inc
+++ b/program/steps/settings/save_folder.inc
@@ -34,7 +34,7 @@ $old_imap = rcube_charset_convert($old, RCMAIL_CHARSET, 'UTF7-IMAP');
// $path is in UTF7-IMAP already
$delimiter = $IMAP->get_hierarchy_delimiter();
-$options = strlen($old_imap) ? rcube_folder_options($old_imap) : array();
+$options = strlen($old_imap) ? rcmail_folder_options($old_imap) : array();
// Folder name checks
if ($options['protected'] || $options['norename']) {
@@ -105,9 +105,9 @@ if (!$error && !strlen($old)) {
$RCMAIL->user->save_prefs(array('message_threading' => $a_threaded));
}
-
+
+ rcmail_update_folder_row($folder['name']);
$OUTPUT->show_message('foldercreated', 'confirmation');
- $OUTPUT->command('reload', 250);
$OUTPUT->send('iframe');
}
else {
@@ -163,7 +163,7 @@ else if (!$error) {
$OUTPUT->show_message('folderupdated', 'confirmation');
if ($rename) {
- $OUTPUT->command('reload', 250);
+ rcmail_update_folder_row($folder['name'], $folder['oldname']);
$OUTPUT->send('iframe');
}
}