Portions created by the Initial Developer are Copyright (C) 2025
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (!(permission_exists('transcribe_queue_add') || permission_exists('transcribe_queue_edit'))) {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//connect to the database
$database = database::new();
//add the settings object
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
//set from session variables
$button_icon_back = $settings->get('theme', 'button_icon_back', '');
$button_icon_copy = $settings->get('theme', 'button_icon_copy', '');
$button_icon_delete = $settings->get('theme', 'button_icon_delete', '');
$button_icon_save = $settings->get('theme', 'button_icon_save', '');
$input_toggle_style = $settings->get('theme', 'input_toggle_style', 'switch round');
//action add or update
if (is_uuid($_REQUEST["id"])) {
$action = "update";
$transcribe_queue_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$hostname = $_POST["hostname"];
$transcribe_status = $_POST["transcribe_status"];
$transcribe_app_class = $_POST["transcribe_app_class"];
$transcribe_app_method = $_POST["transcribe_app_method"];
$transcribe_audio_path = $_POST["transcribe_audio_path"];
$transcribe_audio_name = $_POST["transcribe_audio_name"];
$transcribe_message = $_POST["transcribe_message"];
}
//process the data and save it to the database
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: transcribe_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('transcribe_queue_add')) {
$obj = new transcribe_queue;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('transcribe_queue_delete')) {
$obj = new transcribe_queue;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('transcribe_queue_update')) {
$obj = new transcribe_queue;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) {
header('Location: transcribe_queue_edit.php?id='.$id);
exit;
}
}
//check for all required data
$msg = '';
if (strlen($hostname) == 0) { $msg .= $text['message-required']." ".$text['label-hostname']."
\n"; }
if (strlen($transcribe_status) == 0) { $msg .= $text['message-required']." ".$text['label-transcribe_status']."
\n"; }
if (strlen($transcribe_app_class) == 0) { $msg .= $text['message-required']." ".$text['label-transcribe_app_class']."
\n"; }
if (strlen($transcribe_app_method) == 0) { $msg .= $text['message-required']." ".$text['label-transcribe_app_method']."
\n"; }
if (strlen($transcribe_audio_path) == 0) { $msg .= $text['message-required']." ".$text['label-transcribe_audio_path']."
\n"; }
if (strlen($transcribe_audio_name) == 0) { $msg .= $text['message-required']." ".$text['label-transcribe_audio_name']."
\n"; }
//if (strlen($transcribe_message) == 0) { $msg .= $text['message-required']." ".$text['label-transcribe_message']."
\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 " |