Skip to content
Snippets Groups Projects
Commit 8aec31d2 authored by Jared Hancock's avatar Jared Hancock
Browse files

Add context typeahead to access email templates

parent e939f1be
No related branches found
No related tags found
No related merge requests found
......@@ -209,13 +209,17 @@ class ContentAjaxAPI extends AjaxController {
Http::response(400, '`root` is required parameter');
switch ($_GET['root']) {
case 'thank-you':
case 'cannedresponse':
$roots = array('ticket');
break;
default:
// Get the template for this template
if ($info = Page::getContext($_GET['root'])) {
$roots = $info;
break;
}
// Get the context for an email template
$tpl_info = EmailTemplateGroup::getTemplateDescription($_GET['root']);
if (!$tpl_info)
Http::response(422, 'No such context');
......@@ -223,21 +227,29 @@ class ContentAjaxAPI extends AjaxController {
}
$contextTypes = array(
'assignee' => array('class' => 'Staff', 'desc' => 'Newly assigned agent'),
'assigner' => array('class' => 'Staff', 'desc' => 'Agent performing the assignment'),
'comments' => 'Agent supplied comments',
'activity' => __('Type of recent activity'),
'assignee' => array('class' => 'Staff', 'desc' => __('Assigned agent/team')),
'assigner' => array('class' => 'Staff', 'desc' => __('Agent performing the assignment')),
'comments' => __('Assign/transfer comments'),
'link' => __('Access link'),
'message' => array('class' => 'MessageThreadEntry', 'desc' => 'Message from the EndUser'),
'note' => array('class' => 'NoteThreadEntry', 'desc' => 'Internal note'),
'note' => array('class' => 'NoteThreadEntry', 'desc' => __('Internal note')),
'poster' => array('class' => 'User', 'desc' => 'EndUser or Agent originating the message'),
// XXX: This could be EndUser -or- Staff object
'recipient' => array('class' => 'TicketUser', 'desc' => 'Message recipient'),
'response' => array('class' => 'ResponseThreadEntry', 'desc' => 'Agent reply'),
'response' => array('class' => 'ResponseThreadEntry', 'desc' => __('Outgoing response')),
'signature' => 'Selected staff or department signature',
'staff' => array('class' => 'Staff', 'desc' => 'Agent originating the activity'),
'ticket' => array('class' => 'Ticket', 'desc' => 'The ticket'),
'user' => array('class' => 'User', 'desc' => __('Message recipient')),
);
$context = array();
foreach ($roots as $C) {
$context[$C] = $contextTypes[$C];
foreach ($roots as $C=>$desc) {
// $desc may be either the root or the description array
if (is_array($desc))
$context[$C] = $desc;
else
$context[$desc] = $contextTypes[$desc];
}
$global = osTicket::getVarScope();
$items = VariableReplacer::compileScope($context + $global);
......
......@@ -341,5 +341,34 @@ class Page extends VerySimpleModel {
}
return true;
}
static function getContext($type) {
$context = array(
'thank-you' => array('ticket'),
'registration-staff' => array(
// 'token' => __('Special authentication token'),
'staff' => array('class' => 'Staff', 'desc' => __('Message recipient')),
'recipient' => array('class' => 'Staff', 'desc' => __('Message recipient')),
'link',
),
'pwreset-staff' => array(
'staff' => array('class' => 'Staff', 'desc' => __('Message recipient')),
'recipient' => array('class' => 'Staff', 'desc' => __('Message recipient')),
'link',
),
'registration-client' => array(
// 'token' => __('Special authentication token'),
'recipient' => array('class' => 'User', 'desc' => __('Message recipient')),
'link', 'user',
),
'pwreset-client' => array(
'recipient' => array('class' => 'User', 'desc' => __('Message recipient')),
'link', 'user',
),
'access-link' => array('ticket', 'recipient'),
);
return $context[$type];
}
}
?>
......@@ -30,9 +30,10 @@ if (count($langs) > 1) { ?>
echo Format::htmlchars($info['title']); ?>" />
<div style="margin-top: 5px">
<div class="error"><?php echo $errors['body']; ?></div>
<textarea class="richtext no-bar" name="body"><?php
echo Format::htmlchars(Format::viewableImages($info['body']));
?></textarea>
<textarea class="richtext no-bar" name="body"
data-root-context="<?php echo $content->getType();
?>"><?php echo Format::htmlchars(Format::viewableImages($info['body']));
?></textarea>
</div>
</div>
......@@ -48,6 +49,7 @@ if (count($langs) > 1) { ?>
placeholder="<?php echo __('Title'); ?>" />
<div style="margin-top: 5px">
<textarea class="richtext no-bar" data-direction=<?php echo $nfo['direction']; ?>
data-root-context="<?php echo $content->getType(); ?>"
placeholder="<?php echo __('Message content'); ?>"
name="trans[<?php echo $tag; ?>][body]"><?php
echo Format::htmlchars(Format::viewableImages($trans['body']));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment