SIP Profiles: Database class integration.
This commit is contained in:
@@ -47,122 +47,83 @@
|
||||
$text = $language->get();
|
||||
|
||||
//set the http get/post variable(s) to a php variable
|
||||
if (isset($_REQUEST["id"])) {
|
||||
$sip_profile_uuid = check_str($_REQUEST["id"]);
|
||||
$sip_profile_name = check_str($_REQUEST["name"]);
|
||||
}
|
||||
$sip_profile_uuid = $_REQUEST["id"];
|
||||
$sip_profile_name = $_REQUEST["name"];
|
||||
|
||||
//get the sip profile data
|
||||
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
|
||||
$sql = "select * from v_sip_profiles ";
|
||||
$sql .= "where sip_profile_uuid = '$sip_profile_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll();
|
||||
foreach ($result as &$row) {
|
||||
$sip_profile_description = $row["sip_profile_description"];
|
||||
if (is_uuid($sip_profile_uuid) && $sip_profile_name != '') {
|
||||
|
||||
//get the sip profile data
|
||||
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
|
||||
$sql = "select sip_profile_description from v_sip_profiles ";
|
||||
$sql .= "where sip_profile_uuid = :sip_profile_uuid ";
|
||||
$parameters['sip_profile_uuid'] = $sip_profile_uuid;
|
||||
$database = new database;
|
||||
$sip_profile_description = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
|
||||
//copy the v_sip_profiles
|
||||
$sip_profile_uuid_new = uuid();
|
||||
$sip_profile_enabled = 'true';
|
||||
$sql = "insert into v_sip_profiles ";
|
||||
$sql .= "(";
|
||||
$sql .= "sip_profile_uuid, ";
|
||||
$sql .= "sip_profile_name, ";
|
||||
$sql .= "sip_profile_enabled, ";
|
||||
$sql .= "sip_profile_description ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$sip_profile_uuid_new."', ";
|
||||
$sql .= "'".$sip_profile_name."', ";
|
||||
$sql .= "'".$sip_profile_enabled."', ";
|
||||
$sql .= "'".$sip_profile_description."' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
//copy the sip profile
|
||||
$sip_profile_uuid_new = uuid();
|
||||
$array['sip_profiles'][0]['sip_profile_uuid'] = $sip_profile_uuid_new;
|
||||
$array['sip_profiles'][0]['sip_profile_name'] = $sip_profile_name;
|
||||
$array['sip_profiles'][0]['sip_profile_enabled'] = 'true';
|
||||
$array['sip_profiles'][0]['sip_profile_description'] = $sip_profile_description;
|
||||
|
||||
//get the the sip profile settings
|
||||
$sql = "select * from v_sip_profile_domains ";
|
||||
$sql .= "where sip_profile_uuid = '$sip_profile_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll();
|
||||
foreach ($result as &$row) {
|
||||
$sip_profile_domain_name = $row["sip_profile_domain_name"];
|
||||
$sip_profile_domain_alias = $row["sip_profile_domain_alias"];
|
||||
$sip_profile_domain_parse = $row["sip_profile_domain_parse"];
|
||||
//get the the sip profile settings
|
||||
$sql = "select * from v_sip_profile_domains ";
|
||||
$sql .= "where sip_profile_uuid = :sip_profile_uuid ";
|
||||
$parameters['sip_profile_uuid'] = $sip_profile_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $x => &$row) {
|
||||
$array['sip_profile_domains'][$x]['sip_profile_domain_uuid'] = uuid();
|
||||
$array['sip_profile_domains'][$x]['sip_profile_uuid'] = $sip_profile_uuid_new;
|
||||
$array['sip_profile_domains'][$x]['sip_profile_domain_name'] = $row["sip_profile_domain_name"];
|
||||
$array['sip_profile_domains'][$x]['sip_profile_domain_alias'] = $row["sip_profile_domain_alias"];
|
||||
$array['sip_profile_domains'][$x]['sip_profile_domain_parse'] = $row["sip_profile_domain_parse"];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $result, $row);
|
||||
|
||||
//add the sip profile setting
|
||||
$sql = "insert into v_sip_profile_domains ";
|
||||
$sql .= "(";
|
||||
$sql .= "sip_profile_domain_uuid, ";
|
||||
$sql .= "sip_profile_uuid, ";
|
||||
$sql .= "sip_profile_domain_name, ";
|
||||
$sql .= "sip_profile_domain_alias, ";
|
||||
$sql .= "sip_profile_domain_parse ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'$sip_profile_uuid_new', ";
|
||||
$sql .= "'$sip_profile_domain_name', ";
|
||||
$sql .= "'$sip_profile_domain_alias', ";
|
||||
$sql .= "'$sip_profile_domain_parse' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
unset ($prep_statement);
|
||||
//get the the sip profile settings
|
||||
$sql = "select * from v_sip_profile_settings ";
|
||||
$sql .= "where sip_profile_uuid = :sip_profile_uuid ";
|
||||
$parameters['sip_profile_uuid'] = $sip_profile_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $x => &$row) {
|
||||
$array['sip_profile_settings'][$x]['sip_profile_setting_uuid'] = uuid();
|
||||
$array['sip_profile_settings'][$x]['sip_profile_uuid'] = $sip_profile_uuid_new;
|
||||
$array['sip_profile_settings'][$x]['sip_profile_setting_name'] = $row["sip_profile_setting_name"];
|
||||
$array['sip_profile_settings'][$x]['sip_profile_setting_value'] = $row["sip_profile_setting_value"];
|
||||
$array['sip_profile_settings'][$x]['sip_profile_setting_enabled'] = $row["sip_profile_setting_enabled"];
|
||||
$array['sip_profile_settings'][$x]['sip_profile_setting_description'] = $row["sip_profile_setting_description"];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $result, $row);
|
||||
|
||||
//get the the sip profile settings
|
||||
$sql = "select * from v_sip_profile_settings ";
|
||||
$sql .= "where sip_profile_uuid = '$sip_profile_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll();
|
||||
foreach ($result as &$row) {
|
||||
$sip_profile_setting_name = $row["sip_profile_setting_name"];
|
||||
$sip_profile_setting_value = $row["sip_profile_setting_value"];
|
||||
$sip_profile_setting_enabled = $row["sip_profile_setting_enabled"];
|
||||
$sip_profile_setting_description = $row["sip_profile_setting_description"];
|
||||
//execute insert
|
||||
$database = new database;
|
||||
$database->app_name = 'sip_profiles';
|
||||
$database->app_uuid = '159a8da8-0e8c-a26b-6d5b-19c532b6d470';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//add the sip profile setting
|
||||
$sql = "insert into v_sip_profile_settings ";
|
||||
$sql .= "(";
|
||||
$sql .= "sip_profile_setting_uuid, ";
|
||||
$sql .= "sip_profile_uuid, ";
|
||||
$sql .= "sip_profile_setting_name, ";
|
||||
$sql .= "sip_profile_setting_value, ";
|
||||
$sql .= "sip_profile_setting_enabled, ";
|
||||
$sql .= "sip_profile_setting_description ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'$sip_profile_uuid_new', ";
|
||||
$sql .= "'$sip_profile_setting_name', ";
|
||||
$sql .= "'$sip_profile_setting_value', ";
|
||||
$sql .= "'$sip_profile_setting_enabled', ";
|
||||
$sql .= "'$sip_profile_setting_description' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
unset ($prep_statement);
|
||||
//save the sip profile xml
|
||||
save_sip_profile_xml();
|
||||
|
||||
//save the sip profile xml
|
||||
save_sip_profile_xml();
|
||||
//apply settings reminder
|
||||
$_SESSION["reload_xml"] = true;
|
||||
|
||||
//apply settings reminder
|
||||
$_SESSION["reload_xml"] = true;
|
||||
//set message
|
||||
message::add($text['message-copy']);
|
||||
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
message::add($text['message-copy']);
|
||||
header("Location: ".PROJECT_PATH."/app/sip_profiles/sip_profiles.php");
|
||||
return;
|
||||
header("Location: sip_profiles.php");
|
||||
exit;
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user