From 2965a981b7ec22866fbdf2d567d87e2d068d3617 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Fri, 31 Jul 2015 16:04:08 -0400
Subject: [PATCH] Allow to search and import missing PGP pubkeys from keyservers using Publickey.js
---
plugins/subscriptions_option/subscriptions_option.php | 79 ++++++++++++++++++++++-----------------
1 files changed, 45 insertions(+), 34 deletions(-)
diff --git a/plugins/subscriptions_option/subscriptions_option.php b/plugins/subscriptions_option/subscriptions_option.php
index af0481c..5b926f2 100644
--- a/plugins/subscriptions_option/subscriptions_option.php
+++ b/plugins/subscriptions_option/subscriptions_option.php
@@ -7,77 +7,88 @@
* 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
+ * Add it to the plugins list in config.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
+ * to the 'dont_override' configure line:
+ * $config['dont_override'] = array('use_subscriptions');
+ * and then set the global preference
+ * $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 1.0
+ * @version @package_version@
* @author Ziba Scott
+ * @license GNU GPLv3+
*/
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('user_preferences', array($this, 'settings_table'));
- $this->add_hook('save_preferences', array($this, 'save_prefs'));
+ 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('list_mailboxes', array($this, 'list_mailboxes'));
- $this->add_hook('manage_folders', array($this, 'manage_folders'));
+ $this->add_hook('storage_folders', array($this, 'mailboxes_list'));
+ $this->add_hook('folders_list', array($this, 'folders_list'));
}
- function settings_table($args)
+ function settings_blocks($args)
{
if ($args['section'] == 'server') {
$use_subscriptions = rcmail::get_instance()->config->get('use_subscriptions');
$field_id = 'rcmfd_use_subscriptions';
- $use_subscriptions = 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['table']->add(null, $use_subscriptions->show($use_subscriptions?1:0));
+ $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){
- $rcmail = rcmail::get_instance();
- $use_subscriptions = $rcmail->config->get('use_subscriptions');
+ 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']))) {
- $rcmail->imap_init(true);
- $rcmail->imap->clear_cache('mailboxes');
+ $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 list_mailboxes($args){
- $rcmail = rcmail::get_instance();
- if (!$rcmail->config->get('use_subscriptions', true)) {
- $args['folders'] = iil_C_ListMailboxes($rcmail->imap->conn, $rcmail->imap->mod_mailbox($args['root']), $args['filter']);
}
return $args;
}
- function manage_folders($args){
+ function mailboxes_list($args)
+ {
$rcmail = rcmail::get_instance();
if (!$rcmail->config->get('use_subscriptions', true)) {
- $args['table']->remove_column('subscribed');
+ $args['folders'] = $rcmail->get_storage()->list_folders_direct();
+ }
+ 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('/<input [^>]+>/', '', $data['content']);
+ }
}
return $args;
}
--
Gitblit v1.9.1