1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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();
|