mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Remove redundant database instances (#7535)
This commit is contained in:
@@ -121,7 +121,7 @@ function save_gateway_xml() {
|
||||
}
|
||||
|
||||
//declare the global variables
|
||||
global $domain_uuid, $config;
|
||||
global $database, $domain_uuid, $config;
|
||||
|
||||
//delete all old gateways to prepare for new ones
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
@@ -139,7 +139,6 @@ function save_gateway_xml() {
|
||||
$sql = "select * from v_gateways ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $row) {
|
||||
@@ -256,7 +255,8 @@ function save_gateway_xml() {
|
||||
|
||||
function save_var_xml() {
|
||||
if (!empty($_SESSION['switch']['conf']) && is_array($_SESSION['switch']['conf'])) {
|
||||
global $config, $domain_uuid;
|
||||
//declare the global variables
|
||||
global $database, $config, $domain_uuid;
|
||||
|
||||
//skip this function if the conf directory is empty
|
||||
if (empty($_SESSION['switch']['conf']['dir'])) {
|
||||
@@ -279,7 +279,6 @@ function save_var_xml() {
|
||||
$sql = "select * from v_vars ";
|
||||
$sql .= "where var_enabled = true ";
|
||||
$sql .= "order by var_category, var_order asc ";
|
||||
$database = new database;
|
||||
$variables = $database->select($sql, null, 'all');
|
||||
$prev_var_category = '';
|
||||
$xml = '';
|
||||
@@ -315,6 +314,8 @@ function save_var_xml() {
|
||||
}
|
||||
|
||||
function outbound_route_to_bridge($domain_uuid, $destination_number, array $channel_variables=null) {
|
||||
//declare the global variables
|
||||
global $database;
|
||||
|
||||
$destination_number = trim($destination_number);
|
||||
preg_match('/^[\*\+0-9]*$/', $destination_number, $matches, PREG_OFFSET_CAPTURE);
|
||||
@@ -355,7 +356,6 @@ function outbound_route_to_bridge($domain_uuid, $destination_number, array $chan
|
||||
$sql .= "and (dd.dialplan_detail_enabled = true or dd.dialplan_detail_enabled is null) ";
|
||||
$sql .= "order by d.domain_uuid, d.dialplan_order, dd.dialplan_detail_order ";
|
||||
$parameters['hostname'] = $hostname;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
if (!empty($result)) {
|
||||
@@ -438,7 +438,8 @@ function outbound_route_to_bridge($domain_uuid, $destination_number, array $chan
|
||||
//}
|
||||
|
||||
function extension_exists($extension) {
|
||||
global $domain_uuid;
|
||||
//declare the global variables
|
||||
global $database, $domain_uuid;
|
||||
|
||||
$sql = "select count(*) from v_extensions ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
@@ -449,14 +450,13 @@ function extension_exists($extension) {
|
||||
$sql .= "and enabled = true ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$parameters['extension'] = $extension;
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
return $num_rows > 0 ? true : false;
|
||||
}
|
||||
|
||||
function extension_presence_id($extension, $number_alias = false) {
|
||||
global $domain_uuid;
|
||||
global $database, $domain_uuid;
|
||||
|
||||
if ($number_alias === false) {
|
||||
$sql = "select extension, number_alias from v_extensions ";
|
||||
@@ -467,7 +467,6 @@ function extension_presence_id($extension, $number_alias = false) {
|
||||
$sql .= ") ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$parameters['extension'] = $extension;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (!empty($row)) {
|
||||
$extension = $row['extension'];
|
||||
@@ -488,14 +487,13 @@ function extension_presence_id($extension, $number_alias = false) {
|
||||
}
|
||||
|
||||
function get_recording_filename($id) {
|
||||
global $domain_uuid;
|
||||
global $database, $domain_uuid;
|
||||
|
||||
$sql = "select * from v_recordings ";
|
||||
$sql .= "where recording_uuid = :recording_uuid ";
|
||||
$sql .= "and domain_uuid = :domain_uuid ";
|
||||
$parameters['recording_uuid'] = $id;
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (!empty($row)) {
|
||||
//$filename = $row["filename"];
|
||||
@@ -522,13 +520,12 @@ if (!function_exists('phone_letter_to_number')) {
|
||||
|
||||
if (!function_exists('save_call_center_xml')) {
|
||||
function save_call_center_xml() {
|
||||
global $domain_uuid;
|
||||
global $database, $domain_uuid;
|
||||
|
||||
if (!empty($_SESSION['switch']['call_center']['dir'])) {
|
||||
|
||||
//get the call center queue array
|
||||
$sql = "select * from v_call_center_queues ";
|
||||
$database = new database;
|
||||
$call_center_queues = $database->select($sql, null, 'all');
|
||||
unset($sql);
|
||||
|
||||
@@ -600,7 +597,6 @@ if (!function_exists('save_call_center_xml')) {
|
||||
//prepare Agent XML string
|
||||
$v_agents = '';
|
||||
$sql = "select * from v_call_center_agents ";
|
||||
$database = new database;
|
||||
$result = $database->select($sql, null, 'all');
|
||||
unset($sql);
|
||||
|
||||
@@ -690,7 +686,6 @@ if (!function_exists('save_call_center_xml')) {
|
||||
//prepare Tier XML string
|
||||
$v_tiers = '';
|
||||
$sql = "select * from v_call_center_tiers ";
|
||||
$database = new database;
|
||||
$result = $database->select($sql, null, 'all');
|
||||
unset($sql);
|
||||
|
||||
@@ -840,6 +835,9 @@ if (!function_exists('xml_cdr_conf_xml')) {
|
||||
|
||||
if (!function_exists('save_sip_profile_xml')) {
|
||||
function save_sip_profile_xml() {
|
||||
//declare the global variables
|
||||
global $database;
|
||||
|
||||
//skip saving the sip profile xml if the directory is not set
|
||||
if (empty($_SESSION['switch']['sip_profiles']['dir'])) {
|
||||
return;
|
||||
@@ -853,7 +851,6 @@ if (!function_exists('save_sip_profile_xml')) {
|
||||
|
||||
//get the sip profiles from the database
|
||||
$sql = "select * from v_sip_profiles";
|
||||
$database = new database;
|
||||
$result = $database->select($sql, null, 'all');
|
||||
unset($sql);
|
||||
|
||||
@@ -884,7 +881,6 @@ if (!function_exists('save_sip_profile_xml')) {
|
||||
$sql .= "where sip_profile_uuid = :sip_profile_uuid ";
|
||||
$sql .= "and sip_profile_setting_enabled = true ";
|
||||
$parameters['sip_profile_uuid'] = $sip_profile_uuid;
|
||||
$database = new database;
|
||||
$result_2 = $database->select($sql, $parameters, 'all');
|
||||
if (!empty($result_2)) {
|
||||
$sip_profile_settings = '';
|
||||
|
||||
Reference in New Issue
Block a user