get();
//action add or update
if (is_uuid($_REQUEST["id"])) {
$action = "update";
$sofia_global_setting_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (is_array($_POST)) {
$global_setting_name = $_POST["global_setting_name"];
$global_setting_value = $_POST["global_setting_value"];
$global_setting_enabled = $_POST["global_setting_enabled"];
$global_setting_description = $_POST["global_setting_description"];
}
//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: sofia_global_settings.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('sofia_global_setting_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('sofia_global_setting_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('sofia_global_setting_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) {
header('Location: sofia_global_setting_edit.php?id='.$id);
exit;
}
}
//check for all required data
$msg = '';
if (strlen($global_setting_name) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_name']."
\n"; }
if (strlen($global_setting_value) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_value']."
\n"; }
if (strlen($global_setting_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_enabled']."
\n"; }
//if (strlen($global_setting_description) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_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 " |