2012-06-04 16:58:40 +02:00
< ? php
/*
FusionPBX
Version : MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 ( the " License " ); you may not use this file except in compliance with
the License . You may obtain a copy of the License at
http :// www . mozilla . org / MPL /
Software distributed under the License is distributed on an " AS IS " basis ,
WITHOUT WARRANTY OF ANY KIND , either express or implied . See the License
for the specific language governing rights and limitations under the
License .
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane < markjcrane @ fusionpbx . com >
2022-01-27 08:06:29 +01:00
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2022
2012-06-04 16:58:40 +02:00
the Initial Developer . All Rights Reserved .
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
*/
2023-05-09 17:50:16 +02:00
//update dialplan details when group is null set to 0
if ( $domains_processed == 1 ) {
//change dialplan context ${domain_name} to global
$sql = " update v_dialplan_details set dialplan_detail_group = '0' " ;
$sql .= " where dialplan_detail_group is null; \n " ;
$database -> execute ( $sql );
unset ( $sql );
}
2012-07-09 11:05:35 +02:00
//get the $apps array from the installed apps from the core and mod directories
2014-01-19 14:09:17 +01:00
if ( $domains_processed == 1 ) {
2019-10-20 03:09:30 +02:00
//get the list of domains
2022-01-27 08:06:29 +01:00
$sql = " select * from v_domains " ;
$domains = $database -> select ( $sql , null , 'all' );
unset ( $sql );
2016-07-02 00:49:12 +02:00
//dialplan class
2022-01-27 08:06:29 +01:00
$dialplan = new dialplan ;
$dialplan -> import ( $domains );
2016-07-24 21:45:03 +02:00
//update the dialplan order
2022-01-27 08:06:29 +01:00
$sql = " update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup'; \n " ;
$database -> execute ( $sql );
$sql = " update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen'; \n " ;
$database -> execute ( $sql );
$sql = " update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension'; \n " ;
$database -> execute ( $sql );
unset ( $sql );
2018-09-14 07:51:38 +02:00
2018-06-18 00:31:59 +02:00
//set empty strings to null
2022-01-27 08:06:29 +01:00
$sql = " update v_device_lines set outbound_proxy_primary = null where outbound_proxy_primary = ''; \n " ;
$database -> execute ( $sql );
$sql = " update v_device_lines set outbound_proxy_secondary = null where outbound_proxy_secondary = ''; \n " ;
$database -> execute ( $sql );
unset ( $sql );
2019-03-15 06:53:15 +01:00
//change recording_slots to recording_id
2022-01-27 08:06:29 +01:00
$sql = " update v_dialplan_details set dialplan_detail_data = 'recording_id=true' " ;
$sql .= " where dialplan_uuid in (select dialplan_uuid from v_dialplans where app_uuid = '430737df-5385-42d1-b933-22600d3fb79e') " ;
$sql .= " and dialplan_detail_data = 'recording_slots=true'; \n " ;
$database -> execute ( $sql );
$sql = " update v_dialplan_details set dialplan_detail_data = 'recording_id=false' " ;
$sql .= " where dialplan_uuid in (select dialplan_uuid from v_dialplans where app_uuid = '430737df-5385-42d1-b933-22600d3fb79e') " ;
$sql .= " and dialplan_detail_data = 'recording_slots=false'; \n " ;
$database -> execute ( $sql );
unset ( $sql );
2014-01-19 14:09:17 +01:00
}
2023-11-03 09:18:57 +01:00
//additional dialplan upgrade commands
2016-09-29 21:10:35 +02:00
if ( $domains_processed == 1 ) {
2022-01-27 08:06:29 +01:00
//add xml for each dialplan where the dialplan xml is empty
2018-09-14 07:50:08 +02:00
$sql = " select domain_name " ;
$sql .= " from v_domains \n " ;
2019-08-06 03:18:21 +02:00
$results = $database -> select ( $sql , null , 'all' );
if ( is_array ( $results ) && @ sizeof ( $results ) != 0 ) {
foreach ( $results as $row ) {
$dialplans = new dialplan ;
$dialplans -> source = " details " ;
$dialplans -> destination = " database " ;
$dialplans -> context = $row [ " domain_name " ];
$dialplans -> is_empty = " dialplan_xml " ;
$array = $dialplans -> xml ();
}
2018-09-14 07:50:08 +02:00
}
2019-08-06 03:18:21 +02:00
unset ( $sql , $results );
2016-09-29 21:10:35 +02:00
$dialplans = new dialplan ;
$dialplans -> source = " details " ;
$dialplans -> destination = " database " ;
$dialplans -> is_empty = " dialplan_xml " ;
$array = $dialplans -> xml ();
2022-01-27 08:06:29 +01:00
//delete the follow me bridge dialplan
2019-03-08 00:37:47 +01:00
$sql = " delete from v_dialplan_details where dialplan_uuid = '8ed73d1f-698f-466c-8a7a-1cf4cd229f7f' " ;
2019-08-06 03:18:21 +02:00
$database -> execute ( $sql );
2019-03-08 00:37:47 +01:00
$sql = " delete from v_dialplans where dialplan_uuid = '8ed73d1f-698f-466c-8a7a-1cf4cd229f7f' " ;
2019-08-06 03:18:21 +02:00
$database -> execute ( $sql );
unset ( $sql );
2022-01-27 08:06:29 +01:00
//change dialplan context ${domain_name} to global
2022-01-29 03:20:33 +01:00
$sql = " update v_dialplans set dialplan_context = 'global' " ;
$sql .= " where dialplan_context = ' \$ { domain_name}'; \n " ;
2022-01-27 08:06:29 +01:00
$database -> execute ( $sql );
unset ( $sql );
//update recordings dialplan change recording_id=true to recording_id
$sql = " update v_dialplans set dialplan_xml = replace(dialplan_xml, 'recording_id=true','recording_id=') where dialplan_xml like '%recording_id=true%' \n " ;
$database -> execute ( $sql );
$sql = " update v_dialplan_details set dialplan_detail_data = 'recording_id=' where dialplan_detail_data = 'recording_id=true' \n " ;
$database -> execute ( $sql );
unset ( $sql );
2019-03-08 00:37:47 +01:00
}
2023-11-03 09:18:57 +01:00
//remove origination_callee_id_name from domain-variables dialplan
2023-07-29 20:55:52 +02:00
if ( $domains_processed == 1 ) {
$sql = " select count(*) from v_dialplans " ;
$sql .= " where dialplan_name = 'domain-variables' " ;
$sql .= " and dialplan_xml like '%origination_callee_id_name%' " ;
$num_rows = $database -> select ( $sql , null , 'column' );
if ( $num_rows > 0 ) {
2023-11-03 09:18:57 +01:00
$sql = " update v_dialplan_details set dialplan_detail_data = 'origination_callee_id_name= \$ { caller_destination}', update_date = now() \n " ;
$sql .= " where dialplan_uuid in (select dialplan_uuid from v_dialplans where dialplan_name = 'domain-variables' or dialplan_name = 'variables') \n " ;
$sql .= " and dialplan_detail_data = 'origination_callee_id_name= \$ { destination_number}'; \n " ;
$database -> execute ( $sql );
$sql = " update v_dialplans set dialplan_xml = REPLACE(dialplan_xml, '<action application= \" export \" data= \" origination_callee_id_name= \$ { destination_number} \" />', '<action application= \" export \" data= \" origination_callee_id_name= \$ { caller_destination} \" />'), update_date = now() \n " ;
$sql .= " where dialplan_uuid in (select dialplan_uuid from v_dialplans where dialplan_name = 'domain-variables' or dialplan_name = 'variables'); \n " ;
$database -> execute ( $sql );
$sql = " update v_dialplans set dialplan_xml = REPLACE(dialplan_xml, '<action application= \" export \" data= \" origination_callee_id_name= \$ { destination_number} \" inline= \" true \" />', '<action application= \" export \" data= \" origination_callee_id_name= \$ { caller_destination} \" inline= \" true \" />'), update_date = now() \n " ;
$sql .= " where dialplan_uuid in (select dialplan_uuid from v_dialplans where dialplan_name = 'domain-variables' or dialplan_name = 'variables'); \n " ;
$database -> execute ( $sql );
2023-07-29 20:55:52 +02:00
}
unset ( $sql , $num_rows );
}
2014-05-20 09:19:30 +02:00
//add not found dialplan to inbound routes
2014-08-16 20:22:36 +02:00
/*
2014-05-20 09:19:30 +02:00
if ( $domains_processed == 1 ) {
2023-09-16 08:22:12 +02:00
if ( is_readable ( $setting -> get ( 'switch' , 'dialplan' ))) {
2019-08-06 03:18:21 +02:00
$sql = " select count(*) from v_dialplans " ;
2014-07-24 01:06:14 +02:00
$sql .= " where dialplan_uuid = 'ea5339de-1982-46ca-9695-c35176165314' " ;
2019-08-06 03:18:21 +02:00
$num_rows = $database -> select ( $sql , null , 'column' );
if ( $num_rows == 0 ) {
$array [ 'dialplans' ][ 0 ][ 'dialplan_uuid' ] = 'ea5339de-1982-46ca-9695-c35176165314' ;
$array [ 'dialplans' ][ 0 ][ 'app_uuid' ] = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ;
$array [ 'dialplans' ][ 0 ][ 'dialplan_context' ] = 'public' ;
$array [ 'dialplans' ][ 0 ][ 'dialplan_name' ] = 'not-found' ;
$array [ 'dialplans' ][ 0 ][ 'dialplan_continue' ] = 'false' ;
$array [ 'dialplans' ][ 0 ][ 'dialplan_order' ] = '999' ;
$array [ 'dialplans' ][ 0 ][ 'dialplan_enabled' ] = 'false' ;
$array [ 'dialplan_details' ][ 0 ][ 'dialplan_uuid' ] = 'ea5339de-1982-46ca-9695-c35176165314' ;
$array [ 'dialplan_details' ][ 0 ][ 'dialplan_detail_uuid' ] = '8a21744d-b381-4cb0-9930-55b776e4e461' ;
$array [ 'dialplan_details' ][ 0 ][ 'dialplan_detail_tag' ] = 'condition' ;
$array [ 'dialplan_details' ][ 0 ][ 'dialplan_detail_type' ] = 'context' ;
$array [ 'dialplan_details' ][ 0 ][ 'dialplan_detail_data' ] = 'public' ;
$array [ 'dialplan_details' ][ 0 ][ 'dialplan_detail_order' ] = '10' ;
$array [ 'dialplan_details' ][ 1 ][ 'dialplan_uuid' ] = 'ea5339de-1982-46ca-9695-c35176165314' ;
$array [ 'dialplan_details' ][ 1 ][ 'dialplan_detail_uuid' ] = 'e391530c-4078-4b49-bc11-bda4a23ad566' ;
$array [ 'dialplan_details' ][ 1 ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplan_details' ][ 1 ][ 'dialplan_detail_type' ] = 'log' ;
2019-12-03 23:35:24 +01:00
$array [ 'dialplan_details' ][ 1 ][ 'dialplan_detail_data' ] = 'WARNING [inbound routes] 404 not found \${sip_network_ip}' ;
2019-08-06 03:18:21 +02:00
$array [ 'dialplan_details' ][ 1 ][ 'dialplan_detail_order' ] = '20' ;
2024-11-29 21:57:01 +01:00
$p = permissions :: new ();
2019-08-06 03:18:21 +02:00
$p -> add ( 'dialplan_add' , 'temp' );
$p -> add ( 'dialplan_detail_add' , 'temp' );
$database -> app_name = 'dialplans' ;
$database -> app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db' ;
2021-12-24 20:42:16 +01:00
$database -> save ( $array , false );
2019-08-06 03:18:21 +02:00
unset ( $array );
$p -> delete ( 'dialplan_add' , 'temp' );
$p -> delete ( 'dialplan_detail_add' , 'temp' );
2014-05-20 09:19:30 +02:00
}
2019-08-06 03:18:21 +02:00
unset ( $sql , $num_rows );
2014-05-20 09:19:30 +02:00
}
}
2014-08-16 20:22:36 +02:00
*/
2016-09-29 21:10:35 +02:00
2016-07-01 22:35:45 +02:00
?>