diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2012-03-31 12:25:48 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2012-03-31 12:25:48 +0000 |
| commit | e6d8f97bf2e0bbb4d95df0c4e030eb7ec6ef75a5 (patch) | |
| tree | 4f6fdadb51cbe1a2bb3b2b06c9bcabb0429d1a84 /roundcubemail/plugins/subscriptions_option/subscriptions_option.php | |
| parent | 868c169e2a64c1d19a9b6bbcd98f268808dfd173 (diff) | |
Move plugins repository into roundcubemail root folder; svn:externals are not defined anymore
git-svn-id: https://svn.roundcube.net/trunk@6034 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/plugins/subscriptions_option/subscriptions_option.php')
| -rw-r--r-- | roundcubemail/plugins/subscriptions_option/subscriptions_option.php | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/roundcubemail/plugins/subscriptions_option/subscriptions_option.php b/roundcubemail/plugins/subscriptions_option/subscriptions_option.php new file mode 100644 index 000000000..28f826263 --- /dev/null +++ b/roundcubemail/plugins/subscriptions_option/subscriptions_option.php @@ -0,0 +1,95 @@ +<?php + +/** + * Subscription Options + * + * A plugin which can enable or disable the use of imap subscriptions. + * It includes a toggle on the settings page under "Server Settings". + * The preference can also be locked + * + * Add it to the plugins list in config/main.inc.php to enable the user option + * The user option can be hidden and set globally by adding 'use_subscriptions' + * to the the 'dont_override' configure line: + * $rcmail_config['dont_override'] = array('use_subscriptions'); + * and then set the global preference + * $rcmail_config['use_subscriptions'] = true; // or false + * + * Roundcube caches folder lists. When a user changes this option or visits + * their folder list, this cache is refreshed. If the option is on the + * 'dont_override' list and the global option has changed, don't expect + * to see the change until the folder list cache is refreshed. + * + * @version @package_version@ + * @author Ziba Scott + */ +class subscriptions_option extends rcube_plugin +{ + public $task = 'mail|settings'; + + function init() + { + $this->add_texts('localization/', false); + $dont_override = rcmail::get_instance()->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') { + $use_subscriptions = rcmail::get_instance()->config->get('use_subscriptions'); + $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, 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'); + + $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']))) { + $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 ($storage->check_connection()) { + $args['folders'] = $storage->conn->listMailboxes($args['root'], $args['name']); + } + } + return $args; + } + + function folders_list($args) + { + $rcmail = rcmail::get_instance(); + if (!$rcmail->config->get('use_subscriptions', true)) { + $args['table']->remove_column('subscribed'); + } + return $args; + } +} |
