summaryrefslogtreecommitdiff
path: root/program/steps/settings
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/settings')
-rw-r--r--program/steps/settings/edit_folder.inc4
-rw-r--r--program/steps/settings/edit_response.inc107
-rw-r--r--program/steps/settings/folders.inc4
-rw-r--r--program/steps/settings/func.inc22
-rw-r--r--program/steps/settings/responses.inc128
-rw-r--r--program/steps/settings/save_folder.inc6
-rw-r--r--program/steps/settings/save_prefs.inc1
7 files changed, 265 insertions, 7 deletions
diff --git a/program/steps/settings/edit_folder.inc b/program/steps/settings/edit_folder.inc
index f19e2177b..7f2a10ebc 100644
--- a/program/steps/settings/edit_folder.inc
+++ b/program/steps/settings/edit_folder.inc
@@ -28,11 +28,11 @@ function rcmail_folder_form($attrib)
$storage = $RCMAIL->get_storage();
// edited folder name (empty in create-folder mode)
- $mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true));
+ $mbox = get_input_value('_mbox', RCUBE_INPUT_GPC, true);
$mbox_imap = rcube_charset_convert($mbox, RCMAIL_CHARSET, 'UTF7-IMAP');
// predefined path for new folder
- $parent = trim(get_input_value('_path', RCUBE_INPUT_GPC, true));
+ $parent = get_input_value('_path', RCUBE_INPUT_GPC, true);
$parent_imap = rcube_charset_convert($parent, RCMAIL_CHARSET, 'UTF7-IMAP');
$threading_supported = $storage->get_capability('THREAD');
diff --git a/program/steps/settings/edit_response.inc b/program/steps/settings/edit_response.inc
new file mode 100644
index 000000000..49856775a
--- /dev/null
+++ b/program/steps/settings/edit_response.inc
@@ -0,0 +1,107 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/edit_response.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: |
+ | Show edit form for a canned response record or to add a new one |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+*/
+
+$responses = $RCMAIL->get_compose_responses();
+
+// edit-response
+if (($key = get_input_value('_key', RCUBE_INPUT_GPC))) {
+ foreach ($responses as $i => $response) {
+ if ($response['key'] == $key) {
+ $RESPONSE_RECORD = $response;
+ $RESPONSE_RECORD['index'] = $i;
+ break;
+ }
+ }
+}
+
+// save response
+if ($RCMAIL->action == 'save-response' && isset($_POST['_name']) && !$RESPONSE_RECORD['static']) {
+ $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;
+ foreach ($responses as $i => $resp) {
+ if ($RESPONSE_RECORD && $RESPONSE_RECORD['index'] === $i)
+ continue;
+ 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));
+ if ($RESPONSE_RECORD && $responses[$RESPONSE_RECORD['index']]) {
+ $responses[$RESPONSE_RECORD['index']] = $response;
+ }
+ else {
+ $responses[] = $response;
+ }
+
+ $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('parent.update_response_row', $response, $key);
+ $RCMAIL->overwrite_action('edit-response');
+ $RESPONSE_RECORD = $response;
+ }
+ }
+ else {
+ $RCMAIL->output->show_message('formincomplete', 'error');
+ }
+}
+
+
+function rcube_response_form($attrib)
+{
+ global $RCMAIL, $OUTPUT, $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']);
+
+ // return the complete edit form as table
+ $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'], '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'], 'disabled' => $disabled), 'textarea'));
+
+ $out .= $table->show($attrib);
+ $out .= $form_end;
+
+ return $out;
+}
+
+$OUTPUT->set_env('readonly', !empty($RESPONSE_RECORD['static']));
+$OUTPUT->add_handler('responseform', 'rcube_response_form');
+$OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-response' ? 'savenewresponse' : 'editresponse')));
+
+$OUTPUT->send('responseedit');
+
diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc
index 64af18d62..44482e938 100644
--- a/program/steps/settings/folders.inc
+++ b/program/steps/settings/folders.inc
@@ -109,7 +109,7 @@ else if ($RCMAIL->action == 'delete-folder')
else if ($RCMAIL->action == 'rename-folder')
{
$name_utf8 = trim(get_input_value('_folder_newname', RCUBE_INPUT_POST, true));
- $oldname_utf8 = trim(get_input_value('_folder_oldname', RCUBE_INPUT_POST, true));
+ $oldname_utf8 = get_input_value('_folder_oldname', RCUBE_INPUT_POST, true);
if (strlen($name_utf8) && strlen($oldname_utf8)) {
$name = rcube_charset_convert($name_utf8, RCMAIL_CHARSET, 'UTF7-IMAP');
@@ -167,7 +167,7 @@ else if ($RCMAIL->action == 'purge')
// get mailbox size
else if ($RCMAIL->action == 'folder-size')
{
- $name = trim(get_input_value('_mbox', RCUBE_INPUT_POST, true));
+ $name = get_input_value('_mbox', RCUBE_INPUT_POST, true);
$size = $STORAGE->folder_size($name);
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index af278e5fa..c922aca08 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -869,6 +869,24 @@ function rcmail_user_prefs($current = null)
$select_default_font_size->show($RCMAIL->config->get('default_font_size', 1))
);
}
+
+ if (!isset($no_override['reply_all_mode'])) {
+ if (!$current) {
+ continue 2;
+ }
+
+ $field_id = 'rcmfd_reply_all_mode';
+ $select = new html_select(array('name' => '_reply_all_mode', 'id' => $field_id));
+
+ $select->add(rcube_label('replyalldefault'), 0);
+ $select->add(rcube_label('replyalllist'), 1);
+
+ $blocks['main']['options']['reply_all_mode'] = array(
+ 'title' => html::label($field_id, Q(rcube_label('replyallmode'))),
+ 'content' => $select->show(intval($config['reply_all_mode'])),
+ );
+ }
+
break;
// Addressbook config
@@ -1260,6 +1278,7 @@ function rcmail_settings_tabs($attrib)
array('command' => 'preferences', 'type' => 'link', 'label' => 'preferences', 'title' => 'editpreferences'),
array('command' => 'folders', 'type' => 'link', 'label' => 'folders', 'title' => 'managefolders'),
array('command' => 'identities', 'type' => 'link', 'label' => 'identities', 'title' => 'manageidentities'),
+ array('command' => 'responses', 'type' => 'link', 'label' => 'responses', 'title' => 'editresponses'),
);
// get all identites from DB and define list of cols to be displayed
@@ -1321,4 +1340,7 @@ $RCMAIL->register_action_map(array(
'purge' => 'folders.inc',
'folder-size' => 'folders.inc',
'add-identity' => 'edit_identity.inc',
+ 'add-response' => 'edit_response.inc',
+ 'save-response' => 'edit_response.inc',
+ 'delete-response' => 'responses.inc',
));
diff --git a/program/steps/settings/responses.inc b/program/steps/settings/responses.inc
new file mode 100644
index 000000000..cfc4148c3
--- /dev/null
+++ b/program/steps/settings/responses.inc
@@ -0,0 +1,128 @@
+<?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 = 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->get_compose_responses(false, true);
+ 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();
+}
+
+
+if ($RCMAIL->action == 'delete-response') {
+ if ($key = get_input_value('_key', RCUBE_INPUT_GPC)) {
+ $responses = $RCMAIL->get_compose_responses(false, true);
+ 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('deletedsuccessfully'), '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']);
+ $OUTPUT->set_env('readonly_responses', array_values(array_map(function($rec){ return $rec['key']; },
+ array_filter($plugin['list'], function($item){ return !empty($item['static']); }))));
+
+ 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);
+}
+
+$OUTPUT->add_handlers(array(
+ 'responseframe' => 'rcmail_response_frame',
+ 'responseslist' => 'rcmail_responses_list',
+));
+$OUTPUT->add_label('deleteresponseconfirm');
+
+$OUTPUT->send('responses');
diff --git a/program/steps/settings/save_folder.inc b/program/steps/settings/save_folder.inc
index 877b0fbbe..efb096d57 100644
--- a/program/steps/settings/save_folder.inc
+++ b/program/steps/settings/save_folder.inc
@@ -5,7 +5,7 @@
| program/steps/settings/save_folder.inc |
| |
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2005-2012, The Roundcube Dev Team |
+ | Copyright (C) 2005-2013, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@@ -26,8 +26,8 @@ $STORAGE = $RCMAIL->get_storage();
$name = trim(get_input_value('_name', RCUBE_INPUT_POST, true));
-$old = trim(get_input_value('_mbox', RCUBE_INPUT_POST, true));
-$path = trim(get_input_value('_parent', RCUBE_INPUT_POST, true));
+$old = get_input_value('_mbox', RCUBE_INPUT_POST, true);
+$path = get_input_value('_parent', RCUBE_INPUT_POST, true);
$name_imap = rcube_charset_convert($name, RCMAIL_CHARSET, 'UTF7-IMAP');
$old_imap = rcube_charset_convert($old, RCMAIL_CHARSET, 'UTF7-IMAP');
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index 717c7ad8c..bcd05bb85 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -90,6 +90,7 @@ switch ($CURR_SECTION)
'strip_existing_sig' => isset($_POST['_strip_existing_sig']),
'default_font' => get_input_value('_default_font', RCUBE_INPUT_POST),
'default_font_size' => get_input_value('_default_font_size', RCUBE_INPUT_POST),
+ 'reply_all_mode' => intval($_POST['_reply_all_mode']),
'forward_attachment' => !empty($_POST['_forward_attachment']),
);