summaryrefslogtreecommitdiff
path: root/program/steps/mail/compose.inc
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/mail/compose.inc
parentb6be23ac4bb9ebe8fd90f347e3f209c2e0e5f24e (diff)
Add new feature to save and recall text snippets (aka canned responses) when composing messages
Diffstat (limited to 'program/steps/mail/compose.inc')
-rw-r--r--program/steps/mail/compose.inc42
1 files changed, 41 insertions, 1 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index f3ff19d72..efc0cc8e0 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -127,7 +127,8 @@ if (!is_array($COMPOSE))
$OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubjectwarning', 'cancel',
'nobodywarning', 'notsentwarning', 'notuploadedwarning', 'savingmessage', 'sendingmessage',
'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'uploadingmany',
- 'fileuploaderror', 'sendmessage');
+ 'fileuploaderror', 'sendmessage', 'savenewresponse', 'responsename', 'responsetext', 'save',
+ 'savingresponse');
$OUTPUT->set_env('compose_id', $COMPOSE['id']);
$OUTPUT->set_pagetitle(rcube_label('compose'));
@@ -1696,6 +1697,44 @@ function compose_file_drop_area($attrib)
}
+/**
+ *
+ */
+function rcmail_compose_responses_list($attrib)
+{
+ global $RCMAIL, $OUTPUT;
+
+ $attrib += array('id' => 'rcmresponseslist', 'tagname' => 'ul', 'cols' => 1);
+
+ $jsenv = array();
+ $items = array();
+ foreach ($RCMAIL->config->get('compose_responses', array()) as $response) {
+ $key = $response['key'] ? $response['key'] : substr(md5($response['name']), 0, 16);
+ $items[strtolower($response['name'])] = html::a(array(
+ 'href '=> '#'.urlencode($response['name']),
+ 'class' => rtrim('insertresponse ' . $attrib['itemclass']),
+ 'rel' => $key,
+ ), Q($response['name']));
+
+ $jsenv[$key] = $response;
+ }
+
+ // sort list by name
+ ksort($items, SORT_LOCALE_STRING);
+
+ $list = new html_table($attrib);
+ foreach ($items as $item) {
+ $list->add(array(), $item);
+ }
+
+ // set client env
+ $OUTPUT->set_env('textresponses', $jsenv);
+ $OUTPUT->add_gui_object('responseslist', $attrib['id']);
+
+ return $list->show();
+}
+
+
// register UI objects
$OUTPUT->add_handlers(array(
'composeheaders' => 'rcmail_compose_headers',
@@ -1712,6 +1751,7 @@ $OUTPUT->add_handlers(array(
'storetarget' => 'rcmail_store_target_selection',
'addressbooks' => 'rcmail_addressbook_list',
'addresslist' => 'rcmail_contacts_list',
+ 'responseslist' => 'rcmail_compose_responses_list',
));
$OUTPUT->send('compose');