summaryrefslogtreecommitdiff
path: root/program/steps/settings
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2013-07-25 17:39:35 +0200
committerThomas Bruederli <thomas@roundcube.net>2013-09-04 09:32:00 +0200
commit0b1de8a487034724e8acbdccf8a7b506d1ecaeed (patch)
tree7c896d632582140adcd8a46e0b66eb72a30a4ef7 /program/steps/settings
parentb6be23ac4bb9ebe8fd90f347e3f209c2e0e5f24e (diff)
Add new feature to save and recall text snippets (aka canned responses) when composing messages
Diffstat (limited to 'program/steps/settings')
-rw-r--r--program/steps/settings/responses.inc53
1 files changed, 53 insertions, 0 deletions
diff --git a/program/steps/settings/responses.inc b/program/steps/settings/responses.inc
new file mode 100644
index 000000000..5a7db5687
--- /dev/null
+++ b/program/steps/settings/responses.inc
@@ -0,0 +1,53 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/responses.inc |
+ | |
+ | This file is part of the Roundcube Webmail client |
+ | Copyright (C) 2013, The Roundcube Dev Team |
+ | |
+ | Licensed under the GNU General Public License version 3 or |
+ | any later version with exceptions for skins & plugins. |
+ | See the README file for a full license statement. |
+ | |
+ | PURPOSE: |
+ | Manage and save canned response texts |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+*/
+
+
+if (!empty($_POST['_insert'])) {
+ $name = get_input_value('_name', RCUBE_INPUT_POST);
+ $text = trim(get_input_value('_text', RCUBE_INPUT_POST));
+
+ if (!empty($name) && !empty($text)) {
+ $dupes = 0;
+ $responses = $RCMAIL->config->get('compose_responses', array());
+ foreach ($responses as $resp) {
+ if (strcasecmp($name, preg_replace('/\s\(\d+\)$/', '', $resp['name'])) == 0)
+ $dupes++;
+ }
+ if ($dupes) { // require a unique name
+ $name .= ' (' . ++$dupes . ')';
+ }
+
+ $response = array('name' => $name, 'text' => $text, 'format' => 'text', 'key' => substr(md5($name), 0, 16));
+ $responses[] = $response;
+
+ if ($RCMAIL->user->save_prefs(array('compose_responses' => $responses))) {
+ $RCMAIL->output->command('add_response_item', $response);
+ $RCMAIL->output->command('display_message', rcube_label('successfullysaved'), 'confirmation');
+ }
+ else {
+ $RCMAIL->output->command('display_message', rcube_label('errorsaving'), 'error');
+ }
+ }
+}
+
+// send response
+$RCMAIL->output->send();
+