diff options
author | Aleksander Machniak <alec@alec.pl> | 2014-04-01 19:27:07 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2014-04-01 19:27:07 +0200 |
commit | dc0b500e78aae13349b848303302a213ed3a1e65 (patch) | |
tree | 29ab0e108edad0456cbbdc3fddfd08fbf8ab7e72 /program/steps/settings | |
parent | 0ee63280982734599f83fdc84ccc309fbf3db2c2 (diff) |
Removed redundant default_folders config option (#1489737)
Implemented IMAP SPECIAL-USE extension support [RFC6154] (#1487830)
Diffstat (limited to 'program/steps/settings')
-rw-r--r-- | program/steps/settings/folders.inc | 23 | ||||
-rw-r--r-- | program/steps/settings/func.inc | 19 | ||||
-rw-r--r-- | program/steps/settings/save_prefs.inc | 28 |
3 files changed, 31 insertions, 39 deletions
diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc index b09ea03ce..1bcfb4cfc 100644 --- a/program/steps/settings/folders.inc +++ b/program/steps/settings/folders.inc @@ -45,7 +45,7 @@ if ($RCMAIL->action == 'subscribe') { if ($result) { // Handle subscription of protected folder (#1487656) if ($RCMAIL->config->get('protect_default_folders') - && in_array($mbox, (array)$RCMAIL->config->get('default_folders')) + && $STORAGE->is_special_folder($mbox) ) { $OUTPUT->command('disable_subscription', $mbox); } @@ -221,16 +221,15 @@ function rcube_subscription_form($attrib) // get folders from server $STORAGE->clear_cache('mailboxes', true); - $a_unsubscribed = $STORAGE->list_folders(); - $a_subscribed = $STORAGE->list_folders_subscribed('', '*', null, null, true); // unsorted - $delimiter = $STORAGE->get_hierarchy_delimiter(); - $namespace = $STORAGE->get_namespace(); - $a_js_folders = array(); - $seen = array(); - $list_folders = array(); - - $default_folders = (array) $RCMAIL->config->get('default_folders'); + $a_unsubscribed = $STORAGE->list_folders(); + $a_subscribed = $STORAGE->list_folders_subscribed('', '*', null, null, true); // unsorted + $delimiter = $STORAGE->get_hierarchy_delimiter(); + $namespace = $STORAGE->get_namespace(); + $special_folders = array_flip(array_merge(array('inbox' => 'INBOX'), $STORAGE->get_special_folders())); $protect_default = $RCMAIL->config->get('protect_default_folders'); + $a_js_folders = array(); + $seen = array(); + $list_folders = array(); // pre-process folders list foreach ($a_unsubscribed as $i => $folder) { @@ -291,7 +290,7 @@ function rcube_subscription_form($attrib) $idx = $i + 1; $sub_key = array_search($folder['id'], $a_subscribed); $subscribed = $sub_key !== false; - $protected = $protect_default && in_array($folder['id'], $default_folders); + $protected = $protect_default && isset($special_folders[$folder['id']]); $noselect = false; $classes = array($i%2 ? 'even' : 'odd'); @@ -368,7 +367,7 @@ function rcube_subscription_form($attrib) $OUTPUT->add_gui_object('subscriptionlist', $attrib['id']); $OUTPUT->set_env('subscriptionrows', $a_js_folders); - $OUTPUT->set_env('defaultfolders', $default_folders); + $OUTPUT->set_env('defaultfolders', array_keys($special_folders)); $OUTPUT->set_env('delimiter', $delimiter); return $form_start . $table->show($attrib) . $form_end; diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 307be8c8e..47efa5a70 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -1035,7 +1035,8 @@ function rcmail_user_prefs($current = null) } // Configure special folders - if (!isset($no_override['default_folders']) && $current) { + $set = array('drafts_mbox', 'sent_mbox', 'junk_mbox', 'trash_mbox'); + if ($current && count(array_intersect($no_override, $set)) < 4) { $select = $RCMAIL->folder_selector(array( 'noselection' => '---', 'realnames' => true, @@ -1043,10 +1044,10 @@ function rcmail_user_prefs($current = null) 'folder_filter' => 'mail', 'folder_rights' => 'w', )); - } - // #1486114, #1488279, #1489219 - $onchange = "if ($(this).val() == 'INBOX') $(this).val('')"; + // #1486114, #1488279, #1489219 + $onchange = "if ($(this).val() == 'INBOX') $(this).val('')"; + } if (!isset($no_override['drafts_mbox'])) { if (!$current) { @@ -1287,13 +1288,11 @@ function rcmail_update_folder_row($name, $oldname=null, $subscribe=false, $class { global $RCMAIL, $OUTPUT; - $default_folders = (array) $RCMAIL->config->get('default_folders'); $protect_folders = $RCMAIL->config->get('protect_default_folders'); - - $storage = $RCMAIL->get_storage(); - $delimiter = $storage->get_hierarchy_delimiter(); - $name_utf8 = rcube_charset::convert($name, 'UTF7-IMAP'); - $protected = $protect_folders && in_array($name, $default_folders); + $storage = $RCMAIL->get_storage(); + $delimiter = $storage->get_hierarchy_delimiter(); + $name_utf8 = rcube_charset::convert($name, 'UTF7-IMAP'); + $protected = $protect_folders && $storage->is_special_folder($name); $foldersplit = explode($delimiter, $storage->mod_folder($name)); $level = count($foldersplit) - 1; diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index f71eee39a..7a17f21f4 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -121,12 +121,12 @@ case 'server': case 'folders': $a_user_prefs = array( 'show_real_foldernames' => isset($_POST['_show_real_foldernames']) ? true : false, - 'drafts_mbox' => rcube_utils::get_input_value('_drafts_mbox', rcube_utils::INPUT_POST, true), - 'sent_mbox' => rcube_utils::get_input_value('_sent_mbox', rcube_utils::INPUT_POST, true), - 'junk_mbox' => rcube_utils::get_input_value('_junk_mbox', rcube_utils::INPUT_POST, true), - 'trash_mbox' => rcube_utils::get_input_value('_trash_mbox', rcube_utils::INPUT_POST, true), ); + foreach (rcube_storage::$folder_types as $type) { + $a_user_prefs[$type . '_mbox'] = rcube_utils::get_input_value('_' . $type . '_mbox', rcube_utils::INPUT_POST, true); + }; + break; } @@ -191,21 +191,15 @@ case 'addressbook': break; case 'folders': - // special handling for 'default_folders' - if (in_array('default_folders', (array)$CONFIG['dont_override'])) { - foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) { - $a_user_prefs[$p] = $CONFIG[$p]; - } - } - else { - $a_user_prefs['default_folders'] = array('INBOX'); - foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) { - if ($a_user_prefs[$p]) { - $a_user_prefs['default_folders'][] = $a_user_prefs[$p]; - } - } + $storage = $RCMAIL->get_storage(); + $specials = array(); + + foreach (rcube_storage::$folder_types as $type) { + $specials[$type] = $a_user_prefs[$type . '_mbox']; } + $storage->set_special_folders($specials); + break; } |