commit | author | age
|
48e9c1
|
1 |
<?php |
T |
2 |
|
|
3 |
/** |
|
4 |
* Subscription Options |
|
5 |
* |
|
6 |
* A plugin which can enable or disable the use of imap subscriptions. |
|
7 |
* It includes a toggle on the settings page under "Server Settings". |
|
8 |
* The preference can also be locked |
|
9 |
* |
461a30
|
10 |
* Add it to the plugins list in config.inc.php to enable the user option |
48e9c1
|
11 |
* The user option can be hidden and set globally by adding 'use_subscriptions' |
654ac1
|
12 |
* to the 'dont_override' configure line: |
bcedf0
|
13 |
* $config['dont_override'] = array('use_subscriptions'); |
48e9c1
|
14 |
* and then set the global preference |
bcedf0
|
15 |
* $config['use_subscriptions'] = true; // or false |
48e9c1
|
16 |
* |
T |
17 |
* Roundcube caches folder lists. When a user changes this option or visits |
|
18 |
* their folder list, this cache is refreshed. If the option is on the |
|
19 |
* 'dont_override' list and the global option has changed, don't expect |
|
20 |
* to see the change until the folder list cache is refreshed. |
|
21 |
* |
|
22 |
* @version @package_version@ |
|
23 |
* @author Ziba Scott |
07c6c6
|
24 |
* @license GNU GPLv3+ |
48e9c1
|
25 |
*/ |
T |
26 |
class subscriptions_option extends rcube_plugin |
|
27 |
{ |
|
28 |
public $task = 'mail|settings'; |
|
29 |
|
|
30 |
function init() |
|
31 |
{ |
|
32 |
$this->add_texts('localization/', false); |
|
33 |
$dont_override = rcmail::get_instance()->config->get('dont_override', array()); |
|
34 |
if (!in_array('use_subscriptions', $dont_override)) { |
|
35 |
$this->add_hook('preferences_list', array($this, 'settings_blocks')); |
|
36 |
$this->add_hook('preferences_save', array($this, 'save_prefs')); |
|
37 |
} |
|
38 |
$this->add_hook('storage_folders', array($this, 'mailboxes_list')); |
|
39 |
$this->add_hook('folders_list', array($this, 'folders_list')); |
|
40 |
} |
|
41 |
|
|
42 |
function settings_blocks($args) |
|
43 |
{ |
|
44 |
if ($args['section'] == 'server') { |
|
45 |
$use_subscriptions = rcmail::get_instance()->config->get('use_subscriptions'); |
|
46 |
$field_id = 'rcmfd_use_subscriptions'; |
|
47 |
$checkbox = new html_checkbox(array('name' => '_use_subscriptions', 'id' => $field_id, 'value' => 1)); |
|
48 |
|
|
49 |
$args['blocks']['main']['options']['use_subscriptions'] = array( |
61be82
|
50 |
'title' => html::label($field_id, rcube::Q($this->gettext('useimapsubscriptions'))), |
48e9c1
|
51 |
'content' => $checkbox->show($use_subscriptions?1:0), |
T |
52 |
); |
|
53 |
} |
|
54 |
|
|
55 |
return $args; |
|
56 |
} |
|
57 |
|
|
58 |
function save_prefs($args) |
|
59 |
{ |
|
60 |
if ($args['section'] == 'server') { |
|
61 |
$rcmail = rcmail::get_instance(); |
|
62 |
$use_subscriptions = $rcmail->config->get('use_subscriptions'); |
|
63 |
|
9f1f75
|
64 |
$args['prefs']['use_subscriptions'] = isset($_POST['_use_subscriptions']); |
48e9c1
|
65 |
|
T |
66 |
// if the use_subscriptions preference changes, flush the folder cache |
|
67 |
if (($use_subscriptions && !isset($_POST['_use_subscriptions'])) || |
|
68 |
(!$use_subscriptions && isset($_POST['_use_subscriptions']))) { |
|
69 |
$storage = $rcmail->get_storage(); |
|
70 |
$storage->clear_cache('mailboxes'); |
|
71 |
} |
|
72 |
} |
|
73 |
return $args; |
|
74 |
} |
|
75 |
|
|
76 |
function mailboxes_list($args) |
|
77 |
{ |
3c5489
|
78 |
$rcmail = rcmail::get_instance(); |
48e9c1
|
79 |
if (!$rcmail->config->get('use_subscriptions', true)) { |
3c5489
|
80 |
$args['folders'] = $rcmail->get_storage()->list_folders_direct(); |
48e9c1
|
81 |
} |
T |
82 |
return $args; |
|
83 |
} |
|
84 |
|
|
85 |
function folders_list($args) |
|
86 |
{ |
|
87 |
$rcmail = rcmail::get_instance(); |
|
88 |
if (!$rcmail->config->get('use_subscriptions', true)) { |
c6447e
|
89 |
foreach ($args['list'] as $idx => $data) { |
AM |
90 |
$args['list'][$idx]['content'] = preg_replace('/<input [^>]+>/', '', $data['content']); |
|
91 |
} |
48e9c1
|
92 |
} |
T |
93 |
return $args; |
|
94 |
} |
|
95 |
} |