summaryrefslogtreecommitdiff
path: root/program/steps/settings/responses.inc
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2013-08-29 17:29:18 +0200
committerThomas Bruederli <thomas@roundcube.net>2013-09-04 09:32:01 +0200
commit0ce2126ac91f634b0bc5bf7f3567acd2f87f9972 (patch)
tree96a3b836868b034939442237667349c4613d51e2 /program/steps/settings/responses.inc
parent2d6242ffb25b199b569d956b65dec36170026d1e (diff)
New settings section to manage canned responses
Diffstat (limited to 'program/steps/settings/responses.inc')
-rw-r--r--program/steps/settings/responses.inc81
1 files changed, 77 insertions, 4 deletions
diff --git a/program/steps/settings/responses.inc b/program/steps/settings/responses.inc
index 5a7db5687..330b4fde4 100644
--- a/program/steps/settings/responses.inc
+++ b/program/steps/settings/responses.inc
@@ -21,12 +21,12 @@
if (!empty($_POST['_insert'])) {
- $name = get_input_value('_name', RCUBE_INPUT_POST);
+ $name = trim(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());
+ $responses = $RCMAIL->get_compose_responses();
foreach ($responses as $resp) {
if (strcasecmp($name, preg_replace('/\s\(\d+\)$/', '', $resp['name'])) == 0)
$dupes++;
@@ -46,8 +46,81 @@ if (!empty($_POST['_insert'])) {
$RCMAIL->output->command('display_message', rcube_label('errorsaving'), 'error');
}
}
+
+ // send response
+ $RCMAIL->output->send();
+}
+
+
+if ($RCMAIL->action == 'delete-response') {
+ if ($key = get_input_value('_key', RCUBE_INPUT_GPC)) {
+ $responses = $RCMAIL->get_compose_responses();
+ foreach ($responses as $i => $response) {
+ if (empty($response['key']))
+ $response['key'] = substr(md5($response['name']), 0, 16);
+ if ($response['key'] == $key) {
+ unset($responses[$i]);
+ $deleted = $RCMAIL->user->save_prefs(array('compose_responses' => $responses));
+ break;
+ }
+ }
+ }
+
+ if ($deleted) {
+ $RCMAIL->output->command('display_message', rcube_label('successfullydeleted'), 'confirmation');
+ $RCMAIL->output->command('remove_response', $key);
+ }
+
+ if ($RCMAIL->output->ajax_call) {
+ $RCMAIL->output->send();
+ }
+}
+
+
+$OUTPUT->set_pagetitle(rcube_label('responses'));
+$OUTPUT->include_script('list.js');
+
+
+/**
+ *
+ */
+function rcmail_responses_list($attrib)
+{
+ global $RCMAIL, $OUTPUT;
+
+ $attrib += array('id' => 'rcmresponseslist', 'tagname' => 'table', 'cols' => 1);
+
+ $plugin = $RCMAIL->plugins->exec_hook('responses_list', array(
+ 'list' => $RCMAIL->get_compose_responses(true),
+ 'cols' => array('name')
+ ));
+
+ $out = rcube_table_output($attrib, $plugin['list'], $plugin['cols'], 'key');
+
+ // set client env
+ $OUTPUT->add_gui_object('responseslist', $attrib['id']);
+
+ return $out;
+}
+
+
+// similar function as /steps/addressbook/func.inc::rcmail_contact_frame()
+function rcmail_response_frame($attrib)
+{
+ global $OUTPUT;
+
+ if (!$attrib['id']) {
+ $attrib['id'] = 'rcmResponseFrame';
+ }
+
+ $OUTPUT->set_env('contentframe', $attrib['id']);
+ return $OUTPUT->frame($attrib, true);
}
-// send response
-$RCMAIL->output->send();
+$OUTPUT->add_handlers(array(
+ 'responseframe' => 'rcmail_response_frame',
+ 'responseslist' => 'rcmail_responses_list',
+));
+$OUTPUT->add_label('deleteresponseconfirm');
+$OUTPUT->send('responses');