function emailTemplate_loadFromDB($options)
{
    // set defaults
    if (!@$options['template_table']) {
        $options['template_table'] = '_email_templates';
    }
    // v2.50
    // error checking
    if (!$options['template_id']) {
        dieAsCaller(__FUNCTION__ . ": No 'template_id' set in options");
    }
    if (!$options['placeholders']) {
        dieAsCaller(__FUNCTION__ . ": No 'placeholders' set in options");
    }
    // load template
    $template = array();
    if (!$template) {
        // try and load custom translated TEMPLATE-ID with language suffix first, eg: MY-TEMPLATE-FR
        $template = mysql_get($options['template_table'], null, array('template_id' => $options['template_id'] . '-' . strtoupper($GLOBALS['SETTINGS']['language'])));
    }
    if (!$template) {
        // if not found, try loading default template next
        $template = mysql_get($options['template_table'], null, array('template_id' => $options['template_id']));
    }
    if (!$template) {
        // if not found, re-add default templates and try again unless template wasn't added or was removed
        emailTemplate_addDefaults();
        $template = mysql_get($options['template_table'], null, array('template_id' => $options['template_id']));
    }
    if (!$template) {
        // otherwise, die with error
        dieAsCaller(__FUNCTION__ . ": Couldn't find email template_id '" . htmlencode($options['template_id']) . "'");
    }
    // get email values
    $emailHeaders = array();
    $emailHeaders['from'] = coalesce(@$options['override-from'], $template['from']);
    $emailHeaders['to'] = coalesce(@$options['override-to'], $template['to']);
    if ($template['reply-to'] || @$options['override-reply-to']) {
        $emailHeaders['headers']['Reply-To'] = coalesce(@$options['override-reply-to'], $template['reply-to']);
    }
    if ($template['cc'] || @$options['override-cc']) {
        $emailHeaders['headers']['CC'] = coalesce(@$options['override-cc'], $template['cc']);
    }
    if ($template['bcc'] || @$options['override-bcc']) {
        $emailHeaders['headers']['BCC'] = coalesce(@$options['override-bcc'], $template['bcc']);
    }
    $emailHeaders['subject'] = coalesce(@$options['override-subject'], $template['subject']);
    $emailHeaders['disabled'] = coalesce(@$options['override-disabled'], @$template['disabled']);
    $emailHeaders['html'] = coalesce(@$options['override-html'], $template['html']);
    // v2.51
    $passThruFields = array('attachments', 'headers', 'logging');
    foreach ($passThruFields as $field) {
        if (!array_key_exists($field, $options)) {
            continue;
        }
        $emailHeaders[$field] = $options[$field];
    }
    // replace placeholders
    list($emailHeaders, $textPlaceholderList) = emailTemplate_replacePlaceholders($emailHeaders, @$options['placeholders']);
    // update template placeholder list
    if ($template['placeholders'] != $textPlaceholderList) {
        mysql_update($options['template_table'], $template['num'], null, array('placeholders' => $textPlaceholderList));
    }
    // error checking
    if (!$emailHeaders['from']) {
        die(__FUNCTION__ . ": No 'From' set by program or email template id '" . htmlencode($options['template_id']) . "'");
    }
    if (!$emailHeaders['to']) {
        die(__FUNCTION__ . ": No 'To' set by program or email template id '" . htmlencode($options['template_id']) . "'");
    }
    if (!$emailHeaders['subject']) {
        die(__FUNCTION__ . ": No 'Subject' set by program or email template id '" . htmlencode($options['template_id']) . "'");
    }
    if (!$emailHeaders['html']) {
        die(__FUNCTION__ . ": No 'Message HTML' found by program or email template id '" . htmlencode($options['template_id']) . "'");
    }
    // add html header/footer
    if (@$options['addHeaderAndFooter'] !== false) {
        // added in 2.50
        $htmlTitle = htmlencode($emailHeaders['subject']);
        $header = <<<__HTML__
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$htmlTitle}</title>
</head>
<body>

<style type="text/css">
  p { margin-bottom: 1em; }
</style>


__HTML__;
        // ***NOTE*** style tag is for Yahoo Mail which otherwise drops paragraph spacing - http://www.email-standards.org/blog/entry/yahoo-drops-paragraph-spacing/
        // ... having a defined <title></title> helps get by spam filters
        $footer = <<<__HTML__
</body>
</html>
__HTML__;
        $emailHeaders['html'] = $header . $emailHeaders['html'] . $footer;
    }
    //
    return $emailHeaders;
}
// define globals
global $APP;
//, $SETTINGS, $CURRENT_USER, $TABLE_PREFIX;
$APP['selectedMenu'] = 'admin';
// show admin menu as selected
// check access level - admin only!
if (!$GLOBALS['CURRENT_USER']['isAdmin']) {
    alert(t("You don't have permissions to access this menu."));
    showInterface('');
}
// list-page display plugin hooks
addAction('record_preedit', '_emt_cmsList_customWysiwyg', null, 2);
addFilter('listHeader_displayLabel', '_emt_cmsList_messageColumn', null, 3);
addFilter('listRow_displayValue', '_emt_cmsList_messageColumn', null, 4);
// add default templates
emailTemplate_addDefaults();
### Advanced Command: Developers: Export Templates As PHP
addFilter('list_advancedCommands', 'emailTemplatesMenu_addAdvancedOption', null, 1);
function emailTemplatesMenu_addAdvancedOption($labelsToValues)
{
    $labelsToValues[t('Developers: Export Templates As PHP')] = 'emailTemplatesMenu_exportTemplatesPHP';
    $labelsToValues[t('Developers: Show sendMessage() PHP')] = 'emailTemplatesMenu_showSendMessagePHP';
    return $labelsToValues;
}
if (@$_REQUEST['_advancedAction'] == 'emailTemplatesMenu_exportTemplatesPHP') {
    emailTemplatesMenu_exportTemplatesPHP();
}
if (@$_REQUEST['_advancedAction'] == 'emailTemplatesMenu_showSendMessagePHP') {
    emailTemplatesMenu_showSendMessagePHP();
}
// Let regular actionHandler run