config->get('dont_override', array()); if (!in_array('use_subscriptions', $dont_override)) { $this->add_hook('preferences_list', array($this, 'settings_blocks')); $this->add_hook('preferences_save', array($this, 'save_prefs')); } $this->add_hook('storage_folders', array($this, 'mailboxes_list')); $this->add_hook('folders_list', array($this, 'folders_list')); } function settings_blocks($args) { if ($args['section'] == 'server') { $this->add_texts('localization/', false); $use_subscriptions = rcmail::get_instance()->config->get('use_subscriptions', true); $field_id = 'rcmfd_use_subscriptions'; $checkbox = new html_checkbox(array('name' => '_use_subscriptions', 'id' => $field_id, 'value' => 1)); $args['blocks']['main']['options']['use_subscriptions'] = array( 'title' => html::label($field_id, rcube::Q($this->gettext('useimapsubscriptions'))), 'content' => $checkbox->show($use_subscriptions?1:0), ); } return $args; } function save_prefs($args) { if ($args['section'] == 'server') { $rcmail = rcmail::get_instance(); $use_subscriptions = $rcmail->config->get('use_subscriptions', true); $args['prefs']['use_subscriptions'] = isset($_POST['_use_subscriptions']); // if the use_subscriptions preference changes, flush the folder cache if (($use_subscriptions && !isset($_POST['_use_subscriptions'])) || (!$use_subscriptions && isset($_POST['_use_subscriptions']))) { $storage = $rcmail->get_storage(); $storage->clear_cache('mailboxes'); } } return $args; } function mailboxes_list($args) { $rcmail = rcmail::get_instance(); if (!$rcmail->config->get('use_subscriptions', true)) { $storage = $rcmail->get_storage(); if ($folders = $storage->list_folders_direct()) { $folders = array_filter($folders, function($folder) use ($storage) { $attrs = $storage->folder_attributes($folder); return !in_array_nocase('\\Noselect', $attrs); }); $args['folders'] = $folders; } } return $args; } function folders_list($args) { $rcmail = rcmail::get_instance(); if (!$rcmail->config->get('use_subscriptions', true)) { foreach ($args['list'] as $idx => $data) { $args['list'][$idx]['content'] = preg_replace('/]+>/', '', $data['content']); } } return $args; } }