From 92df79b37b04984ced4963e8b90a23878a69d72d Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 8 Jun 2016 19:27:03 +0200 Subject: [PATCH] Fix subscription checkbox state on error in folder subscribe/unsubscribe action (#5243) --- CHANGELOG | 1 + program/js/app.js | 8 ++++++++ program/steps/settings/folders.inc | 12 +++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8b1a7fd0c59..a4a6bec80ac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ CHANGELOG Roundcube Webmail - Fix handling of --delete argument in moduserprefs.sh script (#5296) - Workaround PHP issue by calling closelog() on script shutdown when using log_driver=syslog (#5289) - Fix so upgrade script makes sure program/lib directory does not contain old libraries (#5287) +- Fix subscription checkbox state on error in folder subscribe/unsubscribe action (#5243) RELEASE 1.2.0 ------------- diff --git a/program/js/app.js b/program/js/app.js index 90984cc1e2d..71246d12bcc 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -6856,6 +6856,14 @@ function rcube_webmail() $('input[name="_subscribed[]"]:first', row).prop('disabled', true); }; + // resets state of subscription checkbox (e.g. on error) + this.reset_subscription = function(folder, state) + { + var row = this.subscription_list.get_item(folder, true); + if (row) + $('input[name="_subscribed[]"]:first', row).prop('checked', state); + }; + this.folder_size = function(folder) { var lock = this.set_busy(true, 'loading'); diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc index c4d9124cbbf..fbe2701fd93 100644 --- a/program/steps/settings/folders.inc +++ b/program/steps/settings/folders.inc @@ -50,8 +50,10 @@ if ($RCMAIL->action == 'subscribe') { $OUTPUT->show_message('foldersubscribed', 'confirmation'); } - else + else { $RCMAIL->display_server_error('errorsaving'); + $OUTPUT->command('reset_subscription', $mbox, false); + } } } // unsubscribe mailbox @@ -60,10 +62,14 @@ else if ($RCMAIL->action == 'unsubscribe') { if (strlen($mbox)) { $result = $STORAGE->unsubscribe(array($mbox)); - if ($result) + + if ($result) { $OUTPUT->show_message('folderunsubscribed', 'confirmation'); - else + } + else { $RCMAIL->display_server_error('errorsaving'); + $OUTPUT->command('reset_subscription', $mbox, true); + } } } // delete an existing mailbox