From 3f4521bcf4b538b6ac54817cfad22b51e347546d Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Wed, 17 Jun 2015 03:03:03 -0400 Subject: [PATCH] Fix so plain text signature field uses monospace font (#1490435) --- program/steps/settings/edit_response.inc | 45 ++++++++++++++++++++++----------------------- 1 files changed, 22 insertions(+), 23 deletions(-) diff --git a/program/steps/settings/edit_response.inc b/program/steps/settings/edit_response.inc index 26f7e6e..03a6878 100644 --- a/program/steps/settings/edit_response.inc +++ b/program/steps/settings/edit_response.inc @@ -22,10 +22,8 @@ $responses = $RCMAIL->get_compose_responses(); // edit-response -if (($key = get_input_value('_key', RCUBE_INPUT_GPC))) { +if (($key = rcube_utils::get_input_value('_key', rcube_utils::INPUT_GPC))) { foreach ($responses as $i => $response) { - if (empty($response['key'])) - $response['key'] = substr(md5($response['name']), 0, 16); if ($response['key'] == $key) { $RESPONSE_RECORD = $response; $RESPONSE_RECORD['index'] = $i; @@ -35,12 +33,9 @@ } // save response -if ($RCMAIL->action == 'save-response' && isset($_POST['_name'])) { - $name = trim(get_input_value('_name', RCUBE_INPUT_POST)); - $text = trim(get_input_value('_text', RCUBE_INPUT_POST)); - - if (!empty($_REQUEST['_framed'])) - $RCMAIL->output->framed = 1; +if ($RCMAIL->action == 'save-response' && isset($_POST['_name']) && !$RESPONSE_RECORD['static']) { + $name = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST)); + $text = trim(rcube_utils::get_input_value('_text', rcube_utils::INPUT_POST, true)); if (!empty($name) && !empty($text)) { $dupes = 0; @@ -62,9 +57,11 @@ $responses[] = $response; } - if ($RCMAIL->user->save_prefs(array('compose_responses' => $responses))) { + $responses = array_filter($responses, function($item){ return empty($item['static']); }); + if ($RCMAIL->user->save_prefs(array('compose_responses' => array_values($responses)))) { $RCMAIL->output->show_message('successfullysaved', 'confirmation'); - $RCMAIL->output->command('update_response_row', $response, $key); + $RCMAIL->output->command('parent.update_response_row', $response, $key); + $RCMAIL->overwrite_action('edit-response'); $RESPONSE_RECORD = $response; } } @@ -73,12 +70,19 @@ } } +$OUTPUT->set_env('readonly', !empty($RESPONSE_RECORD['static'])); +$OUTPUT->add_handler('responseform', 'rcube_response_form'); +$OUTPUT->set_pagetitle($RCMAIL->gettext($RCMAIL->action == 'add-response' ? 'addresponse' : 'editresponse')); + +$OUTPUT->send('responseedit'); + function rcube_response_form($attrib) { - global $RCMAIL, $OUTPUT, $RESPONSE_RECORD; + global $RCMAIL, $RESPONSE_RECORD; // Set form tags and hidden fields + $disabled = !empty($RESPONSE_RECORD['static']); $key = $RESPONSE_RECORD['key']; list($form_start, $form_end) = get_form_tags($attrib, 'save-response', $key, array('name' => '_key', 'value' => $key)); unset($attrib['form'], $attrib['id']); @@ -87,22 +91,17 @@ $out = "$form_start\n"; $table = new html_table(array('cols' => 2)); - $label = rcube_label('responsename'); - $table->add('title', html::label('ffname', Q(rcube_label('responsename')))); - $table->add(null, rcube_output::get_edit_field('name', $RESPONSE_RECORD['name'], array('id' => 'ffname', 'size' => $attrib['size']), 'text')); + $table->add('title', html::label('ffname', rcube::Q($RCMAIL->gettext('responsename')))); + $table->add(null, rcube_output::get_edit_field('name', $RESPONSE_RECORD['name'], + array('id' => 'ffname', 'size' => $attrib['size'], 'disabled' => $disabled), 'text')); - $table->add('title', html::label('fftext', Q(rcube_label('responsetext')))); - $table->add(null, rcube_output::get_edit_field('text', $RESPONSE_RECORD['text'], array('id' => 'fftext', 'size' => $attrib['textareacols'], 'rows' => $attrib['textarearows']), 'textarea')); + $table->add('title', html::label('fftext', rcube::Q($RCMAIL->gettext('responsetext')))); + $table->add(null, rcube_output::get_edit_field('text', $RESPONSE_RECORD['text'], + array('id' => 'fftext', 'size' => $attrib['textareacols'], 'rows' => $attrib['textarearows'], 'disabled' => $disabled), 'textarea')); $out .= $table->show($attrib); $out .= $form_end; return $out; } - -$OUTPUT->add_handler('responseform', 'rcube_response_form'); -$OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-response' ? 'savenewresponse' : 'editresponse'))); - -$OUTPUT->send('responseedit'); - -- Gitblit v1.9.1