From ced34cb15e095836767971aa4d27b141fb1d7ec9 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sat, 18 Oct 2014 08:47:54 -0400 Subject: [PATCH] Merge pull request #230 from bytesatwork-xx/master --- program/steps/settings/responses.inc | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/program/steps/settings/responses.inc b/program/steps/settings/responses.inc index fcc9c9a..117e17f 100644 --- a/program/steps/settings/responses.inc +++ b/program/steps/settings/responses.inc @@ -22,7 +22,7 @@ if (!empty($_POST['_insert'])) { $name = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST)); - $text = trim(rcube_utils::get_input_value('_text', rcube_utils::INPUT_POST)); + $text = trim(rcube_utils::get_input_value('_text', rcube_utils::INPUT_POST, true)); if (!empty($name) && !empty($text)) { $dupes = 0; @@ -51,8 +51,8 @@ $RCMAIL->output->send(); } -if ($RCMAIL->action == 'delete-response') { - if ($key = rcube_utils::get_input_value('_key', rcube_utils::INPUT_GPC)) { +if ($RCMAIL->action == 'delete-response' && $RCMAIL->output->ajax_call) { + if ($key = rcube_utils::get_input_value('_key', rcube_utils::INPUT_POST)) { $responses = $RCMAIL->get_compose_responses(false, true); foreach ($responses as $i => $response) { if (empty($response['key'])) @@ -70,9 +70,7 @@ $RCMAIL->output->command('remove_response', $key); } - if ($RCMAIL->output->ajax_call) { - $RCMAIL->output->send(); - } + $RCMAIL->output->send(); } @@ -95,7 +93,7 @@ { global $RCMAIL, $OUTPUT; - $attrib += array('id' => 'rcmresponseslist', 'tagname' => 'table', 'cols' => 1); + $attrib += array('id' => 'rcmresponseslist', 'tagname' => 'table'); $plugin = $RCMAIL->plugins->exec_hook('responses_list', array( 'list' => $RCMAIL->get_compose_responses(true), @@ -104,10 +102,16 @@ $out = $RCMAIL->table_output($attrib, $plugin['list'], $plugin['cols'], 'key'); + $readonly_responses = array(); + foreach ($plugin['list'] as $item) { + if (!empty($item['static'])) { + $readonly_responses[] = $item['key']; + } + } + // set client env $OUTPUT->add_gui_object('responseslist', $attrib['id']); - $OUTPUT->set_env('readonly_responses', array_values(array_map(function($rec){ return $rec['key']; }, - array_filter($plugin['list'], function($item){ return !empty($item['static']); })))); + $OUTPUT->set_env('readonly_responses', $readonly_responses); return $out; } -- Gitblit v1.9.1