get();
//action add or update
if (is_uuid($_REQUEST["id"])) {
$action = "update";
$email_queue_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (is_array($_POST)) {
$email_date = $_POST["email_date"];
$email_from = $_POST["email_from"];
$email_to = $_POST["email_to"];
$email_subject = $_POST["email_subject"];
$email_body = $_POST["email_body"];
$email_status = $_POST["email_status"];
$email_retry_count = $_POST["email_retry_count"];
//$email_action_before = $_POST["email_action_before"];
$email_action_after = $_POST["email_action_after"];
}
//process the user data and save it to the database
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: email_queue.php');
exit;
}
//process the http post data by submitted action
if ($_POST['action'] != '' && !empty($_POST['action'])) {
//prepare the array(s)
//send the array to the database class
switch ($_POST['action']) {
case 'copy':
if (permission_exists('email_queue_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('email_queue_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('email_queue_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) {
header('Location: email_queue_edit.php?id='.$id);
exit;
}
}
//check for all required data
$msg = '';
//if (empty($email_date)) { $msg .= $text['message-required']." ".$text['label-email_date']."
\n"; }
//if (empty($email_from)) { $msg .= $text['message-required']." ".$text['label-email_from']."
\n"; }
//if (empty($email_to)) { $msg .= $text['message-required']." ".$text['label-email_to']."
\n"; }
//if (empty($email_subject)) { $msg .= $text['message-required']." ".$text['label-email_subject']."
\n"; }
//if (empty($email_body)) { $msg .= $text['message-required']." ".$text['label-email_body']."
\n"; }
//if (empty($email_status)) { $msg .= $text['message-required']." ".$text['label-email_status']."
\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "
| \n";
echo $msg." "; echo " |