Update default_setting_edit.php

This commit is contained in:
FusionPBX 2020-02-27 21:55:49 -07:00 committed by GitHub
parent 834880e0e7
commit 4ffbceeb93
1 changed files with 54 additions and 25 deletions

View File

@ -111,35 +111,64 @@
//update switch timezone variables //update switch timezone variables
if ($default_setting_category == "domain" && $default_setting_subcategory == "time_zone" && $default_setting_name == "name" ) { if ($default_setting_category == "domain" && $default_setting_subcategory == "time_zone" && $default_setting_name == "name" ) {
//get the action //get the dialplan_uuid
$sql = "select count(*) from v_vars "; $sql = "select dialplan_uuid from v_dialplans ";
$sql .= "where var_name = 'timezone' "; $sql .= "where app_uuid = 'd49ee3bd-5085-4619-a2f9-2b62c8c461c5' ";
$database = new database; $database = new database;
$num_rows = $database->select($sql, null, 'column'); $dialplan_uuid = $database->select($sql, null, 'column');
unset($sql); unset($sql);
//update
if ($num_rows != 0) { //get the action
$sql = "update v_vars "; $sql = "select dialplan_detail_uuid from v_dialplan_details ";
$sql .= "set var_value = :default_setting_value "; $sql .= "where dialplan_uuid = :dialplan_uuid ";
$sql .= "where var_name = 'timezone' "; $sql .= "and dialplan_detail_tag = 'action' ";
$parameters['default_setting_value'] = $default_setting_value; $sql .= "and dialplan_detail_type = 'set' ";
} $sql .= "and dialplan_detail_data like 'timezone=%' ";
//insert $parameters['dialplan_uuid'] = $dialplan_uuid;
else {
$sql = "insert into v_vars ";
$sql .= "(var_uuid, var_name, var_value, var_category, var_command, var_enabled) ";
$sql .= "values ('".uuid()."', 'timezone', :default_setting_value, 'Defaults', 'set', 'true'); ";
$parameters['default_setting_value'] = $default_setting_value;
}
//execute
$database = new database; $database = new database;
$database->app_name = 'default_settings'; $dialplan_detail_uuid = $database->select($sql, $parameters, 'column');
$database->app_uuid = '2c2453c0-1bea-4475-9f44-4d969650de09'; $detail_action = is_uuid($dialplan_detail_uuid) ? 'update' : 'add';
$database->execute($sql, $parameters);
unset($sql, $parameters); unset($sql, $parameters);
//synchronize the configuration //update the timezone
save_var_xml(); $p = new permissions;
if ($detail_action == "update") {
$array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
$array['dialplan_details'][0]['dialplan_detail_data'] = 'timezone='.$default_setting_value;
$p->add('dialplan_detail_edit', 'temp');
}
else {
$array['dialplan_details'][0]['dialplan_detail_uuid'] = uuid();
$array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid;
$array['dialplan_details'][0]['dialplan_detail_tag'] = 'action';
$array['dialplan_details'][0]['dialplan_detail_type'] = 'set';
$array['dialplan_details'][0]['dialplan_detail_data'] = 'timezone='.$default_setting_value;
$array['dialplan_details'][0]['dialplan_detail_inline'] = 'true';
$array['dialplan_details'][0]['dialplan_detail_group'] = '0';
$array['dialplan_details'][0]['dialplan_detail_order'] = '20';
$p->add('dialplan_detail_add', 'temp');
}
if (is_array($array) && sizeof($array) != 0) {
$database = new database;
$database->app_name = 'domain_settings';
$database->app_uuid = 'd49ee3bd-5085-4619-a2f9-2b62c8c461c5';
$database->save($array);
unset($array);
$p->delete('dialplan_detail_edit', 'temp');
$p->delete('dialplan_detail_add', 'temp');
}
//update the dialplan xml
$dialplans = new dialplan;
$dialplans->source = "details";
$dialplans->destination = "database";
$dialplans->uuid = $dialplan_uuid;
$dialplans->xml();
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$domain_name);
} }
//build the array of data //build the array of data