- adjusted to API changes

release-0.6
alecpl 16 years ago
parent 9510f89b62
commit 6a7f39da53

@ -11,7 +11,7 @@
* The user option can be hidden and set globally by adding 'use_subscriptions' * The user option can be hidden and set globally by adding 'use_subscriptions'
* to the the 'dont_override' configure line: * to the the 'dont_override' configure line:
* $rcmail_config['dont_override'] = array('use_subscriptions'); * $rcmail_config['dont_override'] = array('use_subscriptions');
* and then set the global preference" * and then set the global preference
* $rcmail_config['use_subscriptions'] = true; // or false * $rcmail_config['use_subscriptions'] = true; // or false
* *
* Roundcube caches folder lists. When a user changes this option or visits * Roundcube caches folder lists. When a user changes this option or visits
@ -24,49 +24,56 @@
*/ */
class subscriptions_option extends rcube_plugin class subscriptions_option extends rcube_plugin
{ {
public $task = 'mail|settings';
function init() function init()
{ {
$this->add_texts('localization/', false); $this->add_texts('localization/', false);
$dont_override = rcmail::get_instance()->config->get('dont_override', array()); $dont_override = rcmail::get_instance()->config->get('dont_override', array());
if (!in_array('use_subscriptions', $dont_override)){ if (!in_array('use_subscriptions', $dont_override)) {
$this->add_hook('user_preferences', array($this, 'settings_table')); $this->add_hook('user_preferences', array($this, 'settings_blocks'));
$this->add_hook('save_preferences', array($this, 'save_prefs')); $this->add_hook('save_preferences', array($this, 'save_prefs'));
} }
$this->add_hook('list_mailboxes', array($this, 'list_mailboxes')); $this->add_hook('list_mailboxes', array($this, 'list_mailboxes'));
$this->add_hook('manage_folders', array($this, 'manage_folders')); $this->add_hook('manage_folders', array($this, 'manage_folders'));
} }
function settings_table($args) function settings_blocks($args)
{ {
if ($args['section'] == 'server') { if ($args['section'] == 'server') {
$use_subscriptions = rcmail::get_instance()->config->get('use_subscriptions'); $use_subscriptions = rcmail::get_instance()->config->get('use_subscriptions');
$field_id = 'rcmfd_use_subscriptions'; $field_id = 'rcmfd_use_subscriptions';
$checkbox = new html_checkbox(array('name' => '_use_subscriptions', 'id' => $field_id, 'value' => 1)); $checkbox = new html_checkbox(array('name' => '_use_subscriptions', 'id' => $field_id, 'value' => 1));
$args['table']->add('title', html::label($field_id, Q($this->gettext('useimapsubscriptions')))); $args['blocks']['main']['options'][] = array(
$args['table']->add(null, $checkbox->show($use_subscriptions?1:0)); 'title' => html::label($field_id, Q($this->gettext('useimapsubscriptions'))),
'content' => $checkbox->show($use_subscriptions?1:0),
);
} }
return $args; return $args;
} }
function save_prefs($args){ function save_prefs($args)
$rcmail = rcmail::get_instance(); {
$use_subscriptions = $rcmail->config->get('use_subscriptions'); if ($args['section'] == 'server') {
$rcmail = rcmail::get_instance();
$use_subscriptions = $rcmail->config->get('use_subscriptions');
$args['prefs']['use_subscriptions'] = isset($_POST['_use_subscriptions']) ? true : false; $args['prefs']['use_subscriptions'] = isset($_POST['_use_subscriptions']) ? true : false;
// if the use_subscriptions preference changes, flush the folder cache
if (($use_subscriptions && !isset($_POST['_use_subscriptions'])) ||
(!$use_subscriptions && isset($_POST['_use_subscriptions']))) {
$rcmail->imap_init(true);
$rcmail->imap->clear_cache('mailboxes');
}
// if the use_subscriptions preference changes, flush the folder cache
if (($use_subscriptions && !isset($_POST['_use_subscriptions'])) ||
(!$use_subscriptions && isset($_POST['_use_subscriptions']))) {
$rcmail->imap_init(true);
$rcmail->imap->clear_cache('mailboxes');
}
}
return $args; return $args;
} }
function list_mailboxes($args){ function list_mailboxes($args)
{
$rcmail = rcmail::get_instance(); $rcmail = rcmail::get_instance();
if (!$rcmail->config->get('use_subscriptions', true)) { if (!$rcmail->config->get('use_subscriptions', true)) {
$args['folders'] = iil_C_ListMailboxes($rcmail->imap->conn, $rcmail->imap->mod_mailbox($args['root']), $args['filter']); $args['folders'] = iil_C_ListMailboxes($rcmail->imap->conn, $rcmail->imap->mod_mailbox($args['root']), $args['filter']);
@ -74,7 +81,8 @@ class subscriptions_option extends rcube_plugin
return $args; return $args;
} }
function manage_folders($args){ function manage_folders($args)
{
$rcmail = rcmail::get_instance(); $rcmail = rcmail::get_instance();
if (!$rcmail->config->get('use_subscriptions', true)) { if (!$rcmail->config->get('use_subscriptions', true)) {
$args['table']->remove_column('subscribed'); $args['table']->remove_column('subscribed');

Loading…
Cancel
Save