Portions created by the Initial Developer are Copyright (C) 2022
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('fax_queue_add') || permission_exists('fax_queue_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";
$fax_queue_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (is_array($_POST)) {
$fax_uuid = $_POST["fax_uuid"];
$fax_date = $_POST["fax_date"];
$hostname = $_POST["hostname"];
$fax_caller_id_name = $_POST["fax_caller_id_name"];
$fax_caller_id_number = $_POST["fax_caller_id_number"];
$fax_number = $_POST["fax_number"];
$fax_prefix = $_POST["fax_prefix"];
$fax_email_address = $_POST["fax_email_address"];
$fax_file = $_POST["fax_file"];
$fax_status = $_POST["fax_status"];
$fax_retry_date = $_POST["fax_retry_date"];
$fax_notify_date = $_POST["fax_notify_date"];
$fax_retry_count = $_POST["fax_retry_count"];
$fax_accountcode = $_POST["fax_accountcode"];
$fax_command = $_POST["fax_command"];
}
//process the user data and save it to the database
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: fax_queue.php');
exit;
}
//process the http post data by submitted action
if ($_POST['action'] != '' && strlen($_POST['action']) > 0) {
//prepare the array(s)
//send the array to the database class
switch ($_POST['action']) {
case 'copy':
if (permission_exists('fax_queue_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('fax_queue_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('fax_queue_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle') && is_uuid($id))) {
header('Location: fax_queue_edit.php?id='.$id);
exit;
}
}
//check for all required data
$msg = '';
//if (strlen($fax_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-fax_uuid']."
\n"; }
if (strlen($fax_date) == 0) { $msg .= $text['message-required']." ".$text['label-fax_date']."
\n"; }
if (strlen($hostname) == 0) { $msg .= $text['message-required']." ".$text['label-hostname']."
\n"; }
//if (strlen($fax_caller_id_name) == 0) { $msg .= $text['message-required']." ".$text['label-fax_caller_id_name']."
\n"; }
//if (strlen($fax_caller_id_number) == 0) { $msg .= $text['message-required']." ".$text['label-fax_caller_id_number']."
\n"; }
if (strlen($fax_number) == 0) { $msg .= $text['message-required']." ".$text['label-fax_number']."
\n"; }
//if (strlen($fax_prefix) == 0) { $msg .= $text['message-required']." ".$text['label-fax_prefix']."
\n"; }
//if (strlen($fax_email_address) == 0) { $msg .= $text['message-required']." ".$text['label-fax_email_address']."
\n"; }
if (strlen($fax_file) == 0) { $msg .= $text['message-required']." ".$text['label-fax_file']."
\n"; }
if (strlen($fax_status) == 0) { $msg .= $text['message-required']." ".$text['label-fax_status']."
\n"; }
//if (strlen($fax_retry_date) == 0) { $msg .= $text['message-required']." ".$text['label-fax_retry_date']."
\n"; }
//if (strlen($fax_retry_count) == 0) { $msg .= $text['message-required']." ".$text['label-fax_retry_count']."
\n"; }
//if (strlen($fax_accountcode) == 0) { $msg .= $text['message-required']." ".$text['label-fax_accountcode']."
\n"; }
//if (strlen($fax_command) == 0) { $msg .= $text['message-required']." ".$text['label-fax_command']."
\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 " |