Email Templates: Database class integration.
This commit is contained in:
@@ -40,9 +40,9 @@
|
||||
$text = $language->get();
|
||||
|
||||
//action add or update
|
||||
if (isset($_REQUEST["id"])) {
|
||||
if (is_uuid($_REQUEST["id"])) {
|
||||
$action = "update";
|
||||
$email_template_uuid = check_str($_REQUEST["id"]);
|
||||
$email_template_uuid = $_REQUEST["id"];
|
||||
}
|
||||
else {
|
||||
$action = "add";
|
||||
@@ -50,15 +50,15 @@
|
||||
|
||||
//get http post variables and set them to php variables
|
||||
if (is_array($_POST)) {
|
||||
$domain_uuid = check_str($_POST["domain_uuid"]);
|
||||
$template_language = check_str($_POST["template_language"]);
|
||||
$template_category = check_str($_POST["template_category"]);
|
||||
$template_subcategory = check_str($_POST["template_subcategory"]);
|
||||
$template_subject = check_str($_POST["template_subject"]);
|
||||
$template_body = check_str($_POST["template_body"]);
|
||||
$template_type = check_str($_POST["template_type"]);
|
||||
$template_enabled = check_str($_POST["template_enabled"]);
|
||||
$template_description = check_str($_POST["template_description"]);
|
||||
$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
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
//get the uuid from the POST
|
||||
if ($action == "update") {
|
||||
$email_template_uuid = check_str($_POST["email_template_uuid"]);
|
||||
$email_template_uuid = $_POST["email_template_uuid"];
|
||||
}
|
||||
|
||||
//check for all required data
|
||||
@@ -94,7 +94,7 @@
|
||||
}
|
||||
|
||||
//add the email_template_uuid
|
||||
if (strlen($_POST["email_template_uuid"]) == 0) {
|
||||
if (!is_uuid($_POST["email_template_uuid"])) {
|
||||
$email_template_uuid = uuid();
|
||||
$_POST["email_template_uuid"] = $email_template_uuid;
|
||||
}
|
||||
@@ -105,42 +105,37 @@
|
||||
//save to the data
|
||||
$database = new database;
|
||||
$database->app_name = 'email_templates';
|
||||
$database->app_uuid = null;
|
||||
$database->app_uuid = '8173e738-2523-46d5-8943-13883befd2fd';
|
||||
if (strlen($email_template_uuid) > 0) {
|
||||
$database->uuid($email_template_uuid);
|
||||
}
|
||||
$database->save($array);
|
||||
$message = $database->message;
|
||||
|
||||
//debug info
|
||||
//echo "<pre>";
|
||||
//print_r($message);
|
||||
//echo "</pre>";
|
||||
//exit;
|
||||
|
||||
//redirect the user
|
||||
if (isset($action)) {
|
||||
if ($action == "add") {
|
||||
$_SESSION["message"] = $text['message-add'];
|
||||
message::add($text['message-add']);
|
||||
}
|
||||
if ($action == "update") {
|
||||
$_SESSION["message"] = $text['message-update'];
|
||||
message::add($text['message-update']);
|
||||
}
|
||||
header('Location: email_template_edit.php?id='.escape($email_template_uuid));
|
||||
return;
|
||||
exit;
|
||||
}
|
||||
} //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0)
|
||||
}
|
||||
|
||||
//pre-populate the form
|
||||
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
|
||||
$email_template_uuid = check_str($_GET["id"]);
|
||||
$email_template_uuid = $_GET["id"];
|
||||
$sql = "select * from v_email_templates ";
|
||||
$sql .= "where email_template_uuid = '$email_template_uuid' ";
|
||||
//$sql .= "and domain_uuid = '$domain_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$sql .= "where email_template_uuid = :email_template_uuid ";
|
||||
//$sql .= "and domain_uuid = :domain_uuid ";
|
||||
$parameters['email_template_uuid'] = $email_template_uuid;
|
||||
//$parameters['domain_uuid'] = $domain_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
$template_language = $row["template_language"];
|
||||
$template_category = $row["template_category"];
|
||||
@@ -151,7 +146,7 @@
|
||||
$template_enabled = $row["template_enabled"];
|
||||
$template_description = $row["template_description"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
unset($sql, $parameters, $row);
|
||||
}
|
||||
|
||||
//show the header
|
||||
@@ -230,7 +225,7 @@
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' style='position: relative;' align='left'>\n";
|
||||
echo " <select class='formfld' name='domain_uuid'>\n";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
if (!is_uuid($domain_uuid)) {
|
||||
echo " <option value='' selected='selected'>".$text['label-global']."</option>\n";
|
||||
}
|
||||
else {
|
||||
@@ -267,7 +262,6 @@
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' style='position: relative;' align='left'>\n";
|
||||
echo " <select class='formfld' name='template_enabled'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if ($template_enabled == "true") {
|
||||
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user