Portions created by the Initial Developer are Copyright (C) 2018
the Initial Developer. All Rights Reserved.
*/
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('email_template_add') || permission_exists('email_template_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
if (is_uuid($_REQUEST["id"])) {
$action = "update";
$email_template_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (is_array($_POST)) {
$domain_uuid = $_POST["domain_uuid"];
$template_language = $_POST["template_language"];
$template_category = $_POST["template_category"];
$template_subcategory = $_POST["template_subcategory"];
$template_subject = $_POST["template_subject"];
$template_body = $_POST["template_body"];
$template_type = $_POST["template_type"];
$template_enabled = $_POST["template_enabled"];
$template_description = $_POST["template_description"];
}
//process the user data and save it to the database
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//get the uuid from the POST
if ($action == "update") {
$email_template_uuid = $_POST["email_template_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: email_templates.php');
exit;
}
//check for all required data
$msg = '';
if (strlen($template_language) == 0) { $msg .= $text['message-required']." ".$text['label-template_language']."
\n"; }
if (strlen($template_category) == 0) { $msg .= $text['message-required']." ".$text['label-template_category']."
\n"; }
//if (strlen($template_subcategory) == 0) { $msg .= $text['message-required']." ".$text['label-template_subcategory']."
\n"; }
if (strlen($template_subject) == 0) { $msg .= $text['message-required']." ".$text['label-template_subject']."
\n"; }
if (strlen($template_body) == 0) { $msg .= $text['message-required']." ".$text['label-template_body']."
\n"; }
//if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; }
//if (strlen($template_type) == 0) { $msg .= $text['message-required']." ".$text['label-template_type']."
\n"; }
if (strlen($template_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-template_enabled']."
\n"; }
//if (strlen($template_description) == 0) { $msg .= $text['message-required']." ".$text['label-template_description']."
\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "
\n";
echo $msg." "; echo " |