Merge branch 'dev-canned-responses'
Conflicts (resolved): skins/classic/includes/settingstabs.html skins/larry/includes/settingstabs.htmlpull/146/head
commit
98b7b548a2
@ -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');
|
||||
|
@ -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');
|
Binary file not shown.
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 38 KiB |
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title><roundcube:object name="pagetitle" /></title>
|
||||
<roundcube:include file="/includes/links.html" />
|
||||
<script type="text/javascript" src="/functions.js"></script>
|
||||
|
||||
</head>
|
||||
<body class="iframe">
|
||||
|
||||
<div id="prefs-title" class="boxtitle"><roundcube:object name="steptitle" /></div>
|
||||
|
||||
<div id="response-details" class="boxcontent">
|
||||
<roundcube:object name="responseform" class="propform" size="60" textareacols="60" textarearows="18" />
|
||||
|
||||
<div id="formfooter">
|
||||
<div class="footerindent">
|
||||
<roundcube:button command="save" type="input" class="button mainaction" label="save" condition="!env:readonly" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title><roundcube:object name="pagetitle" /></title>
|
||||
<roundcube:include file="/includes/links.html" />
|
||||
<script type="text/javascript" src="/functions.js"></script>
|
||||
<script type="text/javascript" src="/splitter.js"></script>
|
||||
<style type="text/css">
|
||||
#identities-list { width: <roundcube:exp expression="!empty(cookie:identviewsplitter) ? cookie:identviewsplitter-5 : 295" />px; }
|
||||
#identity-box { left: <roundcube:exp expression="!empty(cookie:identviewsplitter) ? cookie:identviewsplitter+5 : 305" />px;
|
||||
<roundcube:exp expression="browser:ie ? ('width:expression((parseInt(this.parentNode.offsetWidth)-'.(!empty(cookie:identviewsplitter) ? cookie:identviewsplitter+5 : 305).')+\\'px\\');') : ''" />
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<roundcube:include file="/includes/taskbar.html" />
|
||||
<roundcube:include file="/includes/header.html" />
|
||||
<roundcube:include file="/includes/settingstabs.html" />
|
||||
|
||||
<div id="mainscreen">
|
||||
|
||||
<div id="identities-list">
|
||||
<div id="identity-title" class="boxtitle"><roundcube:label name="responses" /></div>
|
||||
<div class="boxlistcontent">
|
||||
<roundcube:object name="responsesList" id="identities-table" class="records-table" cellspacing="0" summary="Responses list" noheader="true" editIcon="" />
|
||||
</div>
|
||||
<div class="boxfooter">
|
||||
<roundcube:button command="add" type="link" title="newidentity" class="buttonPas addgroup" classAct="button addgroup" content=" " condition="config:identities_level:0<2" /><roundcube:button command="delete" type="link" title="delete" class="buttonPas delgroup" classAct="button delgroup" content=" " condition="config:identities_level:0<2" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var identviewsplit = new rcube_splitter({id:'identviewsplitter', p1: 'identities-list', p2: 'identity-box', orientation: 'v', relative: true, start: 300 });
|
||||
rcmail.add_onload('identviewsplit.init()');
|
||||
</script>
|
||||
|
||||
<div id="identity-box">
|
||||
<roundcube:object name="responseframe" id="identity-frame" width="100%" height="100%" frameborder="0" src="/watermark.html" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 38 KiB |
Binary file not shown.
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
@ -0,0 +1,22 @@
|
||||
<roundcube:object name="doctype" value="html5" />
|
||||
<html>
|
||||
<head>
|
||||
<title><roundcube:object name="pagetitle" /></title>
|
||||
<roundcube:include file="/includes/links.html" />
|
||||
</head>
|
||||
<body class="iframe">
|
||||
|
||||
<h1 class="boxtitle"><roundcube:object name="steptitle" /></h1>
|
||||
|
||||
<div id="preferences-details" class="boxcontent">
|
||||
<roundcube:object name="responseform" class="propform" size="60" textareacols="60" textarearows="18" />
|
||||
</div>
|
||||
|
||||
<div class="footerleft formbuttons">
|
||||
<roundcube:button command="save" type="input" class="button mainaction" label="save" condition="!env:readonly" />
|
||||
</div>
|
||||
|
||||
<roundcube:include file="/includes/footer.html" />
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,41 @@
|
||||
<roundcube:object name="doctype" value="html5" />
|
||||
<html>
|
||||
<head>
|
||||
<title><roundcube:object name="pagetitle" /></title>
|
||||
<roundcube:include file="/includes/links.html" />
|
||||
</head>
|
||||
<body class="noscroll">
|
||||
|
||||
<roundcube:include file="/includes/header.html" />
|
||||
|
||||
<div id="mainscreen" class="offset">
|
||||
|
||||
<roundcube:include file="/includes/settingstabs.html" />
|
||||
|
||||
<div id="settings-right">
|
||||
|
||||
<div id="identitieslist" class="uibox listbox">
|
||||
<h2 class="boxtitle"><roundcube:label name="responses" /></h2>
|
||||
<div class="scroller withfooter">
|
||||
<roundcube:object name="responsesList" id="identities-table" class="listing" cellspacing="0" summary="Responses list" noheader="true" />
|
||||
</div>
|
||||
<div class="boxfooter">
|
||||
<roundcube:button command="add" type="link" title="savenewresponse" class="listbutton add disabled" classAct="listbutton add" innerClass="inner" content="+" /><roundcube:button command="delete" type="link" title="delete" class="listbutton delete disabled" classAct="listbutton delete" innerClass="inner" content="-" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="identity-details" class="uibox contentbox">
|
||||
<div class="iframebox">
|
||||
<roundcube:object name="responseframe" id="preferences-frame" style="width:100%; height:100%" frameborder="0" src="/watermark.html" />
|
||||
</div>
|
||||
<roundcube:object name="message" id="message" class="statusbar" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<roundcube:include file="/includes/footer.html" />
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue