From 4114dc932da496238dbdcf51e8494713615e2adf Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 27 Jan 2020 14:58:34 +0100 Subject: [PATCH] Fix bug where it wasn't possible to save flag actions (#7188) Display proper error when no flag is selected. --- CHANGELOG | 1 + plugins/managesieve/Changelog | 1 + .../lib/Roundcube/rcube_sieve_engine.php | 22 ++++++++----------- plugins/managesieve/localization/en_US.inc | 1 + skins/elastic/styles/widgets/forms.less | 1 + 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9bfb6d7e2..9509ba2ac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ CHANGELOG Roundcube Webmail - Enigma: Fix so using list checkbox selection does not load the key preview frame - Enigma: Fix generation of key pairs for identities with IDN domains (#7181) - Enigma: Display IDN domains of key users and identities in UTF8 +- Managesieve: Fix bug where it wasn't possible to save flag actions (#7188) - Markasjunk: Fix bug where marking as spam/ham didn't work on moving messages with drag-and-drop (#7137) - Password: Make chpass-wrapper.py Python 3 compatible (#7135) - Elastic: Fix disappearing sidebar in mail compose after clicking Mail button diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index 69a0fd88b..d39181cea 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -2,6 +2,7 @@ - Replace "Filter disabled" with "Filter enabled" (#7028) - Fix so modifier type select wasn't hidden after hiding modifier select on header change - Fix filter selection after removing a first filter (#7079) +- Fix bug where it wasn't possible to save flag actions (#7188) * version 9.3 [2019-04-21] ----------------------------------------------------------- diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php index 25056ff03..72afcd069 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php @@ -1084,16 +1084,12 @@ class rcube_sieve_engine case 'addflag': case 'setflag': case 'removeflag': - $_target = array(); - if (empty($flags[$idx])) { - $this->errors['actions'][$i]['target'] = $this->plugin->gettext('noflagset'); - } - else { - foreach ($flags[$idx] as $flag) { - $_target[] = $this->strip_value($flag); - } + $this->form['actions'][$i]['target'] = $this->strip_value($flags[$idx]); + + if (empty($this->form['actions'][$i]['target'])) { + $this->errors['actions'][$i]['flag'] = $this->plugin->gettext('noflagset'); } - $this->form['actions'][$i]['target'] = $_target; + break; case 'addheader': @@ -2316,7 +2312,7 @@ class rcube_sieve_engine } $flout .= $this->list_input($id, 'action_flags', $custom_flags, true, - $this->error_class($id, 'action', 'flags', 'action_flags')); + $this->error_class($id, 'action', 'flag', 'action_flags_flag'), null, false, "action_flags_flag{$id}"); $out .= html::div(array( 'id' => 'action_flags' . $id, @@ -2578,7 +2574,7 @@ class rcube_sieve_engine return $trim ? trim($str) : $str; } - protected function error_class($id, $type, $target, $elem_prefix='') + protected function error_class($id, $type, $target, $elem_prefix = '') { // TODO: tooltips if (($type == 'test' && ($str = $this->errors['tests'][$id][$target])) || @@ -2610,7 +2606,7 @@ class rcube_sieve_engine $this->rc->output->add_script($script, 'docready'); } - protected function list_input($id, $name, $value, $enabled, $class, $size = null, $hidden = false) + protected function list_input($id, $name, $value, $enabled, $class, $size = null, $hidden = false, $elem_id = null) { $value = (array) $value; $value = array_map(array('rcube', 'Q'), $value); @@ -2621,7 +2617,7 @@ class rcube_sieve_engine 'data-size' => $size, 'data-hidden' => $hidden ?: null, 'name' => '_' . $name . '[' . $id . ']', - 'id' => $name.$id, + 'id' => $elem_id ?: ($name.$id), 'disabled' => !$enabled, 'class' => $class, 'style' => 'display:none', diff --git a/plugins/managesieve/localization/en_US.inc b/plugins/managesieve/localization/en_US.inc index a5c6d2702..4758bec72 100644 --- a/plugins/managesieve/localization/en_US.inc +++ b/plugins/managesieve/localization/en_US.inc @@ -276,3 +276,4 @@ $messages['emptyvacationbody'] = 'Body of vacation message is required!'; $messages['duplicate.conflict.err'] = 'Both header and unique identifier are not allowed.'; $messages['disabledaction'] = 'Action not permitted.'; $messages['lastindexempty'] = 'Index is required when counting from end'; +$messages['noflagset'] = 'At least one flag must be selected.'; diff --git a/skins/elastic/styles/widgets/forms.less b/skins/elastic/styles/widgets/forms.less index 3b3892518..e8bebcf89 100644 --- a/skins/elastic/styles/widgets/forms.less +++ b/skins/elastic/styles/widgets/forms.less @@ -833,6 +833,7 @@ html.ms .propform { & > .invalid-feedback { display: inline-block; + line-height: 1.5; } } }