Skip to content
Snippets Groups Projects
tpl.inc.php 4.43 KiB
Newer Older
Jared Hancock's avatar
Jared Hancock committed
<?php
$info=Format::htmlchars(($errors && $_POST)?$_POST:$_REQUEST);

if (is_a($template, EmailTemplateGroup)) {
    // New template implementation
    $id = 0;
    $tpl_id = $template->getId();
    $name = $template->getName();
    $group = $template;
    $selected = $_REQUEST['code_name'];
    $action = 'implement';
    $extras = array('code_name'=>$selected, 'tpl_id'=>$tpl_id);
    $msgtemplates=$template->all_names;
    // Attempt to lookup the default data if it is defined
    $default = @$template->getMsgTemplate($selected);
    if ($default) {
        $info['subject'] = $default->getSubject();
        $info['body'] = Format::viewableImages($default->getBody());
} else {
    // Template edit
    $id = $template->getId();
    $tpl_id = $template->getTplId();
    $name = $template->getGroup()->getName();
    $group = $template->getGroup();
    $selected = $template->getCodeName();
    $action = 'updatetpl';
    $extras = array();
    $msgtemplates=$template->getGroup()->all_names;
    $info=array_merge(array('subject'=>$template->getSubject(), 'body'=>$template->getBodyWithImages()),$info);
$tpl=$msgtemplates[$selected];
<h2>Email Template Message - <span><?php echo $name; ?></span></h2>
Jared Hancock's avatar
Jared Hancock committed
<div style="padding-top:10px;padding-bottom:5px;">
    <form method="get" action="templates.php">
    <input type="hidden" name="a" value="manage">
    Message Template:
    <select id="tpl_options" name="id" style="width:300px;">
Jared Hancock's avatar
Jared Hancock committed
        <option value="">&mdash; Select Setting Group &mdash;</option>
        <?php
        foreach($group->getTemplates() as $cn=>$t) {
            $nfo=$t->getDescription();
            if (!$nfo['name'])
                continue;
            $sel=($selected==$cn)?'selected="selected"':'';
            echo sprintf('<option value="%s" %s>%s</option>',
                    $t->getId(),$sel,$nfo['name']);
        if ($id == 0) { ?>
            <option selected="selected" value="<?php echo $id; ?>"><?php
            echo $msgtemplates[$selected]['name']; ?></option>
        <?php }
Jared Hancock's avatar
Jared Hancock committed
        ?>
    </select>
    <input type="submit" value="Go">
    &nbsp;&nbsp;&nbsp;<font color="red"><?php echo $errors['tpl']; ?></font>
    </form>
</div>
<form action="templates.php?id=<?php echo $id; ?>&amp;a=manage" method="post" id="save">
<?php csrf_token(); ?>
<?php foreach ($extras as $k=>$v) { ?>
    <input type="hidden" name="<?php echo $k; ?>" value="<?php echo $v; ?>" />
<?php } ?>
<input type="hidden" name="id" value="<?php echo $id; ?>">
Jared Hancock's avatar
Jared Hancock committed
<input type="hidden" name="a" value="manage">
<input type="hidden" name="do" value="<?php echo $action; ?>">
Jared Hancock's avatar
Jared Hancock committed

<table class="form_table settings_table" width="940" border="0" cellspacing="0" cellpadding="2">
   <thead>
     <tr>
        <th colspan="2">
            <h4><?php echo Format::htmlchars($tpl['desc']); ?></h4>
            <em>Subject and body required.  <a class="tip" href="ticket_variables.txt">Supported Variables</a>.</em>
        </th>
     </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan=2>
                <strong>Message Subject:</strong> <em>Email message subject</em> <font class="error">*&nbsp;<?php echo $errors['subject']; ?></font><br>
                <input type="text" name="subject" size="60" value="<?php echo $info['subject']; ?>" >
Jared Hancock's avatar
Jared Hancock committed
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div style="margin-bottom:0.5em;margin-top:0.5em">
                <strong>Message Body:</strong> <em>Email message body.</em> <font class="error">*&nbsp;<?php echo $errors['body']; ?></font>
                </div>
                <input type="hidden" name="draft_id" value=""/>
                <textarea name="body" cols="21" rows="16" style="width:98%;" wrap="soft"
                    class="richtext draft" data-draft-namespace="tpl.<?php echo $selected; ?>"
                    data-draft-object-id="<?php echo $tpl_id; ?>"><?php echo $info['body']; ?></textarea>
Jared Hancock's avatar
Jared Hancock committed
            </td>
        </tr>
    </tbody>
</table>
<p style="padding-left:210px;">
    <input class="button" type="submit" name="submit" value="Save Changes">
    <input class="button" type="reset" name="reset" value="Reset Changes" onclick="javascript:
        setTimeout('location.reload()', 25);" />
    <input class="button" type="button" name="cancel" value="Cancel Changes"
        onclick='window.location.href="templates.php?tpl_id=<?php echo $tpl_id; ?>"'>
Jared Hancock's avatar
Jared Hancock committed
</p>
</form>