From fbc146318d932ce748cfff593f921a30e492d4a4 Mon Sep 17 00:00:00 2001
From: Ziba Scott <ziba@umich.edu>
Date: Wed, 9 Jul 2008 13:49:27 -0400
Subject: [PATCH] Added the ability to not use IMAP subscriptions and added a "use_subscriptions" preference and a user interface to the preference.
---
config/main.inc.php.dist | 3 +++
program/include/rcube_imap.php | 7 ++++++-
program/localization/en_US/labels.inc | 1 +
program/steps/settings/func.inc | 11 +++++++++++
program/steps/settings/manage_folders.inc | 22 +++++++++++++---------
program/steps/settings/save_prefs.inc | 8 ++++++++
6 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index 7b15948..0d3b78f 100644
|
a
|
b
|
|
| 139 | 139 | // only list folders within this path |
| 140 | 140 | $rcmail_config['imap_root'] = ''; |
| 141 | 141 | |
| | 142 | // only list subscribed folders |
| | 143 | $rcmail_config['use_subscriptions'] = TRUE; |
| | 144 | |
| 142 | 145 | // store draft message is this mailbox |
| 143 | 146 | // leave blank if draft messages should not be stored |
| 144 | 147 | $rcmail_config['drafts_mbox'] = 'Drafts'; |
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index fcc5ac1..32d9f86 100644
|
a
|
b
|
|
| 420 | 420 | return $a_mboxes; |
| 421 | 421 | |
| 422 | 422 | // retrieve list of folders from IMAP server |
| 423 | | $a_folders = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox($root), $filter); |
| | 423 | if (rcmail::get_instance()->config->get('use_subscriptions', TRUE)) { |
| | 424 | $a_folders = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox($root), $filter); |
| | 425 | } |
| | 426 | else { |
| | 427 | $a_folders = iil_C_ListMailboxes($this->conn, $this->_mod_mailbox($root), $filter); |
| | 428 | } |
| 424 | 429 | |
| 425 | 430 | if (!is_array($a_folders) || !sizeof($a_folders)) |
| 426 | 431 | $a_folders = array(); |
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 4fb3df9..1520fda 100644
|
a
|
b
|
|
| 272 | 272 | $labels['never'] = 'never'; |
| 273 | 273 | $labels['messagesdisplaying'] = 'Messages displaying'; |
| 274 | 274 | $labels['messagescomposition'] = 'Messages composition'; |
| | 275 | $labels['usesubscriptions'] = 'Use IMAP subscriptions'; |
| 275 | 276 | |
| 276 | 277 | $labels['folder'] = 'Folder'; |
| 277 | 278 | $labels['folders'] = 'Folders'; |
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index 4921906..e5d0f0b 100644
|
a
|
b
|
|
| 302 | 302 | $input_expunge->show($config['logout_expunge']?1:0)); |
| 303 | 303 | } |
| 304 | 304 | |
| | 305 | // Using IMAP subscription information |
| | 306 | if (!isset($no_override['use_subscriptions'])) |
| | 307 | { |
| | 308 | $field_id = 'rcmfd_use_subscriptions'; |
| | 309 | $use_subscriptions = new html_checkbox(array('name' => '_use_subscriptions', 'id' => $field_id, 'value' => 1)); |
| | 310 | $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
| | 311 | $field_id, |
| | 312 | Q(rcube_label('usesubscriptions')), |
| | 313 | $use_subscriptions->show($config['use_subscriptions']?1:0)); |
| | 314 | } |
| | 315 | |
| 305 | 316 | $out .= "\n</table></fieldset>$form_end"; |
| 306 | 317 | |
| 307 | 318 | return $out; |
diff --git a/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc
index b725d8c..f8da5b7 100644
|
a
|
b
|
|
| 182 | 182 | |
| 183 | 183 | // add table header |
| 184 | 184 | $out .= "<thead><tr>\n"; |
| 185 | | $out .= sprintf('<td class="name">%s</td><td class="msgcount">%s</td><td class="subscribed">%s</td>'. |
| 186 | | '<td class="rename"> </td><td class="delete"> </td>', |
| 187 | | rcube_label('foldername'), rcube_label('messagecount'), rcube_label('subscribed')); |
| 188 | | |
| | 185 | $out .= sprintf('<td class="name">%s</td><td class="msgcount">%s</td>', |
| | 186 | rcube_label('foldername'), rcube_label('messagecount')); |
| | 187 | if ($CONFIG['use_subscriptions']){ |
| | 188 | $out .= sprintf('<td class="subscribed">%s</td>', rcube_label('subscribed')); |
| | 189 | } |
| | 190 | $out .= '<td class="rename"> </td><td class="delete"> </td>'; |
| 189 | 191 | $out .= "\n</tr></thead>\n<tbody>\n"; |
| 190 | 192 | |
| 191 | 193 | |
| … |
… |
|
| 229 | 231 | $zebra_class, |
| 230 | 232 | Q($folder_html), |
| 231 | 233 | $IMAP->messagecount($folder)); |
| 232 | | |
| 233 | | if ($protected) |
| 234 | | $out .= '<td class="subscribed"> '.($subscribed ? '•' : '-').'</td>'; |
| 235 | | else |
| 236 | | $out .= '<td class="subscribed">'.$checkbox_subscribe->show($subscribed?$folder_utf8:'', array('value' => $folder_utf8)).'</td>'; |
| | 234 | |
| | 235 | if ($CONFIG['use_subscriptions']){ |
| | 236 | if ($protected) |
| | 237 | $out .= '<td class="subscribed"> '.($subscribed ? '•' : '-').'</td>'; |
| | 238 | else |
| | 239 | $out .= '<td class="subscribed">'.$checkbox_subscribe->show($subscribed?$folder_utf8:'', array('value' => $folder_utf8)).'</td>'; |
| | 240 | } |
| 237 | 241 | |
| 238 | 242 | // add rename and delete buttons |
| 239 | 243 | if (!$protected) |
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index 750b33b..cb099b5 100644
|
a
|
b
|
|
| 36 | 36 | 'draft_autosave' => isset($_POST['_draft_autosave']) ? intval($_POST['_draft_autosave']) : 0, |
| 37 | 37 | 'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0, |
| 38 | 38 | 'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'], |
| | 39 | 'use_subscriptions' => isset($_POST['_use_subscriptions']) ? TRUE : FALSE, |
| 39 | 40 | ); |
| 40 | 41 | |
| | 42 | // if the use_subscriptions preference changes, flush the folder cache |
| | 43 | if (($CONFIG['use_subscriptions'] && !isset($_POST['_use_subscriptions'])) || |
| | 44 | (!$CONFIG['use_subscriptions'] && isset($_POST['_use_subscriptions']))) { |
| | 45 | $RCMAIL->imap_init(true); |
| | 46 | $IMAP->clear_cache('mailboxes'); |
| | 47 | } |
| | 48 | |
| 41 | 49 | // don't override these parameters |
| 42 | 50 | foreach ((array)$CONFIG['dont_override'] as $p) |
| 43 | 51 | $a_user_prefs[$p] = $CONFIG[$p]; |