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 >
2015-03-09 16:58:02 +01:00
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2015
2012-06-04 16:58:40 +02:00
the Initial Developer . All Rights Reserved .
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
2014-06-22 20:38:46 +02:00
Luis Daniel Lucio Quiroz < dlucio @ okay . com . mx >
2014-11-06 17:56:31 +01:00
Riccardo Granchi < riccardo . granchi @ nems . it >
2012-06-04 16:58:40 +02:00
*/
require_once " root.php " ;
2013-07-06 08:03:27 +02:00
require_once " resources/require.php " ;
2012-06-04 16:58:40 +02:00
//preferences
$v_menu_tab_show = false ;
$v_path_show = true ;
//get user defined variables
2013-09-15 07:06:34 +02:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/vars/app_config.php " )) {
if ( strlen ( $_SESSION [ 'user_defined_variables' ]) == 0 ) {
$sql = " select * from v_vars " ;
2014-02-23 07:20:09 +01:00
$sql .= " where var_cat = 'Defaults' and var_enabled = 'true' " ;
2013-09-15 07:06:34 +02:00
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
foreach ( $result as & $row ) {
switch ( $row [ " var_name " ]) {
2014-02-21 05:22:25 +01:00
case " domain " :
//not allowed to override this value
break ;
case " domain_name " :
//not allowed to override this value
break ;
case " domain_uuid " :
//not allowed to override this value
break ;
2013-09-15 07:06:34 +02:00
case " username " :
//not allowed to override this value
break ;
case " groups " :
//not allowed to override this value
break ;
case " menu " :
//not allowed to override this value
break ;
case " template_name " :
//not allowed to override this value
break ;
case " template_content " :
//not allowed to override this value
break ;
case " extension_array " :
//not allowed to override this value
break ;
case " user_extension_array " :
//not allowed to override this value
break ;
case " user_array " :
//not allowed to override this value
break ;
default :
$_SESSION [ $row [ " var_name " ]] = $row [ " var_value " ];
}
}
//when this value is cleared it will re-read the user defined variables
$_SESSION [ " user_defined_variables " ] = " set " ;
2012-06-04 16:58:40 +02:00
}
}
/*
function v_settings () {
global $db , $domain_uuid ;
//get the program directory
$program_dir = '' ;
$doc_root = $_SERVER [ " DOCUMENT_ROOT " ];
$doc_root = str_replace ( " \\ " , " / " , $doc_root );
$doc_root_array = explode ( " / " , $doc_root );
$doc_root_array_count = count ( $doc_root_array );
$x = 0 ;
foreach ( $doc_root_array as $value ) {
$program_dir = $program_dir . $value . " / " ;
if (( $doc_root_array_count - 3 ) == $x ) {
break ;
}
$x ++ ;
}
$program_dir = rtrim ( $program_dir , " / " );
2012-10-17 17:20:58 +02:00
2012-06-04 16:58:40 +02:00
//get the domains variables
$sql = " select * from v_domain_settings " ;
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
$sql .= " and domain_setting_enabled = 'true' " ;
$prep_statement = $db -> prepare ( $sql );
if ( $prep_statement ) {
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_NAMED );
foreach ( $result as $row ) {
$name = $row [ 'domain_setting_name' ];
$settings_array [ $name ] = $row [ 'domain_setting_value' ];
}
}
//get the server variables
$sql = " select * from v_server_settings " ;
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
$sql .= " and domain_setting_enabled = 'true' " ;
$prep_statement = $db -> prepare ( $sql );
if ( $prep_statement ) {
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_NAMED );
foreach ( $result as $row ) {
$name = $row [ 'server_setting_name' ];
$settings_array [ $name ] = $row [ 'server_setting_value' ];
}
}
//return the results
return $settings_array ;
}
//update the settings
//$settings_array = v_settings();
foreach ( $settings_array as $name => $value ) {
$$name = $value ;
}
*/
//get the event socket information
2013-09-15 07:06:34 +02:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/settings/app_config.php " )) {
if ( strlen ( $_SESSION [ 'event_socket_ip_address' ]) == 0 ) {
$sql = " select * from v_settings " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
if ( $prep_statement ) {
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
foreach ( $result as & $row ) {
$_SESSION [ 'event_socket_ip_address' ] = $row [ " event_socket_ip_address " ];
$_SESSION [ 'event_socket_port' ] = $row [ " event_socket_port " ];
$_SESSION [ 'event_socket_password' ] = $row [ " event_socket_password " ];
break ; //limit to 1 row
}
2012-06-04 16:58:40 +02:00
}
}
}
//get the extensions that are assigned to this user
2014-04-27 08:26:15 +02:00
function load_extensions () {
global $db ;
2013-09-15 07:06:34 +02:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/extensions/app_config.php " )) {
2013-11-01 16:50:49 +01:00
if ( strlen ( $_SESSION [ " domain_uuid " ]) > 0 && strlen ( $_SESSION [ " user_uuid " ]) > 0 && count ( $_SESSION [ 'user' ][ 'extension' ]) == 0 ) {
2013-09-15 07:06:34 +02:00
//get the user extension list
unset ( $_SESSION [ 'user' ][ 'extension' ]);
2015-04-06 23:57:06 +02:00
$sql = " select " ;
$sql .= " e.extension, " ;
$sql .= " e.number_alias, " ;
$sql .= " e.user_context, " ;
$sql .= " e.extension_uuid, " ;
$sql .= " e.outbound_caller_id_name, " ;
$sql .= " e.outbound_caller_id_number, " ;
$sql .= " v.voicemail_uuid " ;
$sql .= " from " ;
$sql .= " v_extension_users as u, " ;
$sql .= " v_extensions as e " ;
$sql .= " left outer join v_voicemails as v on ( " ;
$sql .= " e.domain_uuid = v.domain_uuid " ;
$sql .= " and v.voicemail_enabled = 'true' " ;
$sql .= " and ( " ;
$sql .= " e.extension = v.voicemail_id " ;
$sql .= " or e.number_alias = v.voicemail_id " ;
$sql .= " ) " ;
$sql .= " ) " ;
$sql .= " where " ;
$sql .= " e.domain_uuid = ' " . $_SESSION [ 'domain_uuid' ] . " ' " ;
$sql .= " and e.extension_uuid = u.extension_uuid " ;
$sql .= " and u.user_uuid = ' " . $_SESSION [ 'user_uuid' ] . " ' " ;
$sql .= " and e.enabled = 'true' " ;
$sql .= " order by " ;
$sql .= " e.extension asc " ;
2013-09-15 07:06:34 +02:00
$result = $db -> query ( $sql ) -> fetchAll ( PDO :: FETCH_ASSOC );
if ( count ( $result ) > 0 ) {
$x = 0 ;
foreach ( $result as $row ) {
$_SESSION [ 'user' ][ 'extension' ][ $x ][ 'user' ] = $row [ 'extension' ];
2014-11-15 01:16:29 +01:00
$_SESSION [ 'user' ][ 'extension' ][ $x ][ 'number_alias' ] = $row [ 'number_alias' ];
2013-09-15 07:06:34 +02:00
$_SESSION [ 'user' ][ 'extension' ][ $x ][ 'extension_uuid' ] = $row [ 'extension_uuid' ];
$_SESSION [ 'user' ][ 'extension' ][ $x ][ 'outbound_caller_id_name' ] = $row [ 'outbound_caller_id_name' ];
$_SESSION [ 'user' ][ 'extension' ][ $x ][ 'outbound_caller_id_number' ] = $row [ 'outbound_caller_id_number' ];
2015-04-06 23:57:06 +02:00
if ( $row [ 'voicemail_uuid' ] != '' ) {
$_SESSION [ 'user' ][ 'voicemail' ][][ 'voicemail_uuid' ] = $row [ 'voicemail_uuid' ];
}
2013-09-15 07:06:34 +02:00
$_SESSION [ 'user_context' ] = $row [ " user_context " ];
$x ++ ;
}
2012-06-04 16:58:40 +02:00
}
2015-06-06 04:37:26 +02:00
//if no extension has been assigned then setting the user_context will still need to be set
2013-09-15 07:06:34 +02:00
if ( strlen ( $_SESSION [ 'user_context' ]) == 0 ) {
if ( count ( $_SESSION [ 'domains' ]) == 1 ) {
$_SESSION [ 'user_context' ] = " default " ;
}
else {
$_SESSION [ 'user_context' ] = $_SESSION [ 'domain_name' ];
}
2012-06-04 16:58:40 +02:00
}
2013-09-15 07:06:34 +02:00
}
2012-06-04 16:58:40 +02:00
}
2014-04-27 08:26:15 +02:00
}
load_extensions ();
2012-06-04 16:58:40 +02:00
function build_menu () {
global $v_menu_tab_show ;
if ( $v_menu_tab_show ) {
global $config ;
if ( is_dir ( $_SERVER [ " DOCUMENT_ROOT " ] . '/fusionpbx' )){ $relative_url = $_SERVER [ " DOCUMENT_ROOT " ] . '/fusionpbx' ; } else { $relative_url = '/' ; }
$tab_array = array ();
$menu_selected = false ;
2013-09-21 23:45:35 +02:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /setting_edit.php " ) { $menu_selected = true ; }
$tab_array [] = array ( gettext ( " Settings " ), $menu_selected , $relative_url . " /setting_edit.php " );
2012-06-04 16:58:40 +02:00
unset ( $menu_selected );
$menu_selected = false ;
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /dialplans.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /dialplans.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /dialplan_edit.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /dialplan_details_edit.php " ) { $menu_selected = true ; }
$tab_array [] = array ( gettext ( " Dialplan " ), $menu_selected , $relative_url . " /dialplans.php " );
unset ( $menu_selected );
$menu_selected = false ;
2013-08-22 18:05:17 +02:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /extensions.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /extension_edit.php " ) { $menu_selected = true ; }
$tab_array [] = array ( gettext ( " Extensions " ), $menu_selected , $relative_url . " /extensions.php " );
2012-06-04 16:58:40 +02:00
unset ( $menu_selected );
$menu_selected = false ;
2012-11-13 03:17:12 +01:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /fax.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /fax_edit.php " ) { $menu_selected = true ; }
2013-08-22 18:05:17 +02:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /hunt_group.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /hunt_group_edit.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /hunt_group_destinations.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /hunt_group_destinations_edit.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /auto_attendant.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /auto_attendant_edit.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /auto_attendant_options_edit.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /modules.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /recordings.php " ) { $menu_selected = true ; }
2013-09-21 23:45:35 +02:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /recording_edit.php " ) { $menu_selected = true ; }
2012-06-04 16:58:40 +02:00
unset ( $menu_selected );
$menu_selected = false ;
2013-08-22 18:05:17 +02:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /gateways.php " ) { $menu_selected = true ; }
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /gateway_edit.php " ) { $menu_selected = true ; }
$tab_array [] = array ( gettext ( " Gateways " ), $menu_selected , $relative_url . " /gateways.php " );
2012-06-04 16:58:40 +02:00
unset ( $menu_selected );
$menu_selected = false ;
2013-08-22 18:05:17 +02:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /sip_profiles.php " ) { $menu_selected = true ; }
2013-09-23 19:03:26 +02:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /sip_profile_edit.php " ) { $menu_selected = true ; }
2013-08-22 18:05:17 +02:00
$tab_array [] = array ( gettext ( " Profiles " ), $menu_selected , $relative_url . " /sip_profiles.php " );
2012-06-04 16:58:40 +02:00
unset ( $menu_selected );
$menu_selected = false ;
2013-08-22 18:05:17 +02:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /sip_status.php " ) { $menu_selected = true ; }
$tab_array [] = array ( gettext ( " Status " ), $menu_selected , $relative_url . " /sip_status.php " );
2012-06-04 16:58:40 +02:00
unset ( $menu_selected );
$menu_selected = false ;
2013-08-22 18:05:17 +02:00
if ( $_SERVER [ " SCRIPT_NAME " ] == $relative_url . " /vars.php " ) { $menu_selected = true ; }
$tab_array [] = array ( gettext ( " Vars " ), $menu_selected , $relative_url . " /vars.php " );
2012-06-04 16:58:40 +02:00
unset ( $menu_selected );
}
}
2015-01-16 04:29:51 +01:00
function event_socket_create ( $host , $port , $password ) {
2012-06-04 16:58:40 +02:00
$fp = fsockopen ( $host , $port , $errno , $errdesc , 3 );
socket_set_blocking ( $fp , false );
if ( ! $fp ) {
//error "invalid handle<br />\n";
//echo "error number: ".$errno."<br />\n";
//echo "error description: ".$errdesc."<br />\n";
}
else {
//connected to the socket return the handle
while ( ! feof ( $fp )) {
$buffer = fgets ( $fp , 1024 );
usleep ( 100 ); //allow time for reponse
if ( trim ( $buffer ) == " Content-Type: auth/request " ) {
fputs ( $fp , " auth $password\n\n " );
break ;
}
}
return $fp ;
}
} //end function
function event_socket_request ( $fp , $cmd ) {
if ( $fp ) {
2015-01-16 04:29:51 +01:00
$cmd_array = explode ( " \n " , $cmd );
foreach ( $cmd_array as & $value ) {
fputs ( $fp , $value . " \n " );
}
fputs ( $fp , " \n " ); //second line feed to end the headers
2015-03-04 08:04:41 +01:00
2012-06-04 16:58:40 +02:00
usleep ( 100 ); //allow time for reponse
$response = " " ;
$i = 0 ;
2015-01-16 04:29:51 +01:00
$content_length = 0 ;
2012-06-04 16:58:40 +02:00
while ( ! feof ( $fp )) {
$buffer = fgets ( $fp , 4096 );
2015-01-16 04:29:51 +01:00
if ( $content_length > 0 ) {
2012-06-04 16:58:40 +02:00
$response .= $buffer ;
}
2015-01-16 04:29:51 +01:00
if ( $content_length == 0 ) { //if the content has length don't process again
2012-06-04 16:58:40 +02:00
if ( strlen ( trim ( $buffer )) > 0 ) { //run only if buffer has content
2015-01-16 04:29:51 +01:00
$array = explode ( " : " , trim ( $buffer ));
if ( $array [ 0 ] == " Content-Length " ) {
$content_length = trim ( $array [ 1 ]);
2012-06-04 16:58:40 +02:00
}
}
}
2015-03-18 11:45:34 +01:00
usleep ( 50 ); //allow time for reponse
2012-06-04 16:58:40 +02:00
2012-08-10 17:53:02 +02:00
//prevent an endless loop //optional because of script timeout
2015-04-24 06:43:32 +02:00
if ( $i > 30000 ) { break ; }
2012-06-04 16:58:40 +02:00
2015-01-16 04:29:51 +01:00
if ( $content_length > 0 ) { //is content_length set
2012-06-04 16:58:40 +02:00
//stop reading if all content has been read.
2015-01-16 04:29:51 +01:00
if ( strlen ( $response ) >= $content_length ) {
2012-06-04 16:58:40 +02:00
break ;
}
}
$i ++ ;
}
return $response ;
}
else {
echo " no handle " ;
}
}
function event_socket_request_cmd ( $cmd ) {
global $db , $domain_uuid , $host ;
2012-10-17 17:20:58 +02:00
2013-09-15 07:06:34 +02:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/settings/app_config.php " )) {
$sql = " select * from v_settings " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
foreach ( $result as & $row ) {
$event_socket_ip_address = $row [ " event_socket_ip_address " ];
$event_socket_port = $row [ " event_socket_port " ];
$event_socket_password = $row [ " event_socket_password " ];
break ; //limit to 1 row
}
unset ( $prep_statement );
2012-06-04 16:58:40 +02:00
}
$fp = event_socket_create ( $event_socket_ip_address , $event_socket_port , $event_socket_password );
$response = event_socket_request ( $fp , $cmd );
fclose ( $fp );
}
2012-10-17 17:20:58 +02:00
function byte_convert ( $bytes , $decimals = 2 ) {
if ( $bytes <= 0 ) { return '0 Bytes' ; }
$convention = 1024 ;
$formattedbytes = array_reduce ( array ( ' B' , ' KB' , ' MB' , ' GB' , ' TB' , ' PB' , ' EB' , 'ZB' ), create_function ( '$a,$b' , 'return is_numeric($a)?($a>=' . $convention . '?$a/' . $convention . ':number_format($a,' . $decimals . ').$b):$a;' ), $bytes );
return $formattedbytes ;
2012-06-04 16:58:40 +02:00
}
function ListFiles ( $dir ) {
if ( $dh = opendir ( $dir )) {
$files = Array ();
$inner_files = Array ();
while ( $file = readdir ( $dh )) {
if ( $file != " . " && $file != " .. " && $file [ 0 ] != '.' ) {
if ( is_dir ( $dir . " / " . $file )) {
//$inner_files = ListFiles($dir . "/" . $file); //recursive
2012-10-17 17:20:58 +02:00
if ( is_array ( $inner_files )) $files = array_merge ( $files , $inner_files );
2012-06-04 16:58:40 +02:00
} else {
array_push ( $files , $file );
//array_push($files, $dir . "/" . $file);
}
}
}
closedir ( $dh );
return $files ;
}
}
2015-03-27 02:09:25 +01:00
function switch_select_destination ( $select_type , $select_label , $select_name , $select_value , $select_style , $action = '' , $onchange = '' , $text_append = ' ...' ) {
2013-11-14 10:38:17 +01:00
//select_type can be ivr, dialplan, call_center_contact or bridge
2015-03-18 06:17:28 +01:00
global $text , $config , $db , $domain_uuid ;
2012-06-04 16:58:40 +02:00
2013-08-25 04:00:18 +02:00
//remove special characters from the name
$select_id = str_replace ( " ] " , " " , $select_name );
$select_id = str_replace ( " [ " , " _ " , $select_id );
2012-06-04 16:58:40 +02:00
if ( if_group ( " superadmin " )) {
echo " <script> \n " ;
echo " var Objs; \n " ;
echo " \n " ;
2013-08-25 04:00:18 +02:00
echo " function changeToInput " . $select_id . " (obj) { \n " ;
2012-06-04 16:58:40 +02:00
echo " tb=document.createElement('INPUT'); \n " ;
echo " tb.type='text'; \n " ;
echo " tb.name=obj.name; \n " ;
echo " tb.className='formfld'; \n " ;
2013-08-25 04:00:18 +02:00
echo " tb.setAttribute('id', ' " . $select_id . " '); \n " ;
2012-06-04 16:58:40 +02:00
echo " tb.setAttribute('style', ' " . $select_style . " '); \n " ;
2015-03-22 00:55:20 +01:00
if ( $onchange != '' ) {
echo " tb.setAttribute('onchange', \" " . $onchange . " \" ); \n " ;
echo " tb.setAttribute('onkeyup', \" " . $onchange . " \" ); \n " ;
}
2012-06-04 16:58:40 +02:00
echo " tb.value=obj.options[obj.selectedIndex].value; \n " ;
2013-08-25 04:00:18 +02:00
echo " document.getElementById('btn_select_to_input_ " . $select_id . " ').style.visibility = 'hidden'; \n " ;
2012-06-04 16:58:40 +02:00
echo " tbb=document.createElement('INPUT'); \n " ;
echo " tbb.setAttribute('class', 'btn'); \n " ;
2014-08-03 08:12:10 +02:00
echo " tbb.setAttribute('style', 'margin-left: 4px;'); \n " ;
2012-06-04 16:58:40 +02:00
echo " tbb.type='button'; \n " ;
2014-08-03 09:02:12 +02:00
echo " tbb.value= $ ('<div />').html('◁').text(); \n " ;
2012-06-04 16:58:40 +02:00
echo " tbb.objs=[obj,tb,tbb]; \n " ;
2013-08-25 04:00:18 +02:00
echo " tbb.onclick=function() { Replace " . $select_id . " (this.objs); } \n " ;
2012-06-04 16:58:40 +02:00
echo " obj.parentNode.insertBefore(tb,obj); \n " ;
echo " obj.parentNode.insertBefore(tbb,obj); \n " ;
echo " obj.parentNode.removeChild(obj); \n " ;
2013-08-25 04:00:18 +02:00
echo " Replace " . $select_id . " (this.objs); \n " ;
2012-06-04 16:58:40 +02:00
echo " } \n " ;
echo " \n " ;
2013-08-25 04:00:18 +02:00
echo " function Replace " . $select_id . " (obj) { \n " ;
2012-06-04 16:58:40 +02:00
echo " obj[2].parentNode.insertBefore(obj[0],obj[2]); \n " ;
echo " obj[0].parentNode.removeChild(obj[1]); \n " ;
echo " obj[0].parentNode.removeChild(obj[2]); \n " ;
2013-08-25 04:00:18 +02:00
echo " document.getElementById('btn_select_to_input_ " . $select_id . " ').style.visibility = 'visible'; \n " ;
2015-03-22 00:55:20 +01:00
if ( $onchange != '' ) {
echo " " . $onchange . " ; \n " ;
}
2012-06-04 16:58:40 +02:00
echo " } \n " ;
echo " </script> \n " ;
echo " \n " ;
}
//default selection found to false
$selection_found = false ;
2015-03-22 00:55:20 +01:00
echo " <select name=' " . $select_name . " ' id=' " . $select_id . " ' class='formfld' style=' " . $select_style . " ' onchange= \" " . $onchange . " \" > \n " ;
2015-03-18 06:17:28 +01:00
//display a default select label (specified explicitly or from the language file) if no selected value is passed in
2015-03-22 00:55:20 +01:00
if ( $select_value == '' && $select_label != '' && $select_label != ' ' ) {
$options [] = " <option value=''> " . $select_label . " </option> " ;
$options [] = " <option value='' disabled='disabled'></option> " ;
}
else if ( $select_value == '' && $select_label == '' && $text [ 'label-select_destination' ] != '' ) {
$options [] = " <option value=''> " . $text [ 'label-select_destination' ] . " </option> " ;
$options [] = " <option value='' disabled='disabled'></option> " ;
}
else {
$options [] = " <option value=''></option> " ;
2012-06-04 16:58:40 +02:00
}
2015-03-18 06:17:28 +01:00
//call center queues
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/call_center/app_config.php " )) {
2013-11-14 10:38:17 +01:00
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2014-03-18 07:39:13 +01:00
$sql = " select * from v_call_center_queues " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$sql .= " order by queue_name asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
2015-03-18 06:17:28 +01:00
$options [] = " <optgroup label='Call Center'> " ;
2015-04-17 03:04:29 +02:00
$previous_call_center_name = " " ;
foreach ( $result as & $row ) {
$queue_name = $row [ " queue_name " ];
$queue_name = str_replace ( '_${domain_name}@default' , '' , $queue_name );
$queue_extension = $row [ " queue_extension " ];
if ( $previous_call_center_name != $queue_name ) {
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " transfer: " . $queue_extension . " XML " . $_SESSION [ " context " ] ||
$select_value == " menu-exec-app:transfer " . $queue_extension . " XML " . $_SESSION [ " context " ]
) ? true : false ;
2015-04-17 03:04:29 +02:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer " . $queue_extension . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $queue_extension . " " . $queue_name . " </option> " ;
}
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer: " . $queue_extension . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $queue_extension . " " . $queue_name . " </option> " ;
}
if ( $selected ) { $selection_found = true ; }
$previous_call_center_name = $queue_name ;
2013-11-14 10:38:17 +01:00
}
}
2015-03-18 06:17:28 +01:00
$options [] = " </optgroup> " ;
2014-03-18 07:39:13 +01:00
}
unset ( $prep_statement );
2013-11-14 10:38:17 +01:00
}
2012-06-04 16:58:40 +02:00
}
2013-11-14 10:38:17 +01:00
2015-03-18 06:17:28 +01:00
//call flows
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/call_flows/app_config.php " )) {
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
$sql = " select * from v_call_flows " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$sql .= " order by call_flow_extension asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
$options [] = " <optgroup label='Call Flows'> " ;
foreach ( $result as & $row ) {
$call_flow_name = $row [ " call_flow_name " ];
$call_flow_extension = $row [ " call_flow_extension " ];
$call_flow_context = $row [ " call_flow_context " ];
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " transfer " . $call_flow_extension . " XML " . $call_flow_context ||
$select_value == " transfer: " . $call_flow_extension . " XML " . $call_flow_context ||
$select_value == " menu-exec-app:transfer " . $call_flow_extension . " XML " . $call_flow_context
) ? true : false ;
2015-04-17 03:04:29 +02:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer " . $call_flow_extension . " XML " . $call_flow_context . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $call_flow_extension . " " . $call_flow_name . " </option> " ;
}
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer: " . $call_flow_extension . " XML " . $call_flow_context . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $call_flow_extension . " " . $call_flow_name . " </option> " ;
}
if ( $selected ) { $selection_found = true ; }
2012-06-04 16:58:40 +02:00
}
2015-04-17 03:04:29 +02:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2014-03-18 07:39:13 +01:00
unset ( $prep_statement , $call_flow_extension );
2013-01-19 07:55:13 +01:00
}
}
2015-03-18 06:17:28 +01:00
//call groups
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/extensions/app_config.php " )) {
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
$sql = " select distinct(call_group) from v_extensions " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-04-24 12:04:18 +02:00
$sql .= " and call_group <> '' " ;
2014-03-18 07:39:13 +01:00
$sql .= " order by call_group asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$x = 0 ;
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
$previous_call_group_name = " " ;
$options [] = " <optgroup label='Call Group'> " ;
foreach ( $result as & $row ) {
$call_groups = $row [ " call_group " ];
$call_group_array = explode ( " , " , $call_groups );
foreach ( $call_group_array as $call_group ) {
$call_group = trim ( $call_group );
if ( $previous_call_group_name != $call_group ) {
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " bridge:group/ " . $call_group . " @ " . $_SESSION [ 'domain_name' ] ||
$select_value == " menu-exec-app:bridge group/ " . $call_group . " @ " . $_SESSION [ 'domain_name' ]
) ? true : false ;
2015-04-17 03:04:29 +02:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:bridge group/ " . $call_group . " @ " . $_SESSION [ 'domain_name' ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $call_group . " </option> " ;
}
if ( $select_type == " dialplan " ) {
$options [] = " <option value='bridge:group/ " . $call_group . " @ " . $_SESSION [ 'domain_name' ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $call_group . " </option> " ;
}
if ( $selected ) { $selection_found = true ; }
$previous_call_group_name = $call_group ;
2014-03-18 07:39:13 +01:00
}
2013-11-14 10:38:17 +01:00
}
2015-04-17 03:04:29 +02:00
$x ++ ;
2013-01-19 07:55:13 +01:00
}
2015-04-17 03:04:29 +02:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2013-11-14 10:38:17 +01:00
unset ( $prep_statement );
2013-01-19 07:55:13 +01:00
}
2012-06-04 16:58:40 +02:00
}
2015-03-18 06:17:28 +01:00
//conference centers
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/conference_centers/app_config.php " )) {
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
$sql = " select * from v_conference_centers " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$sql .= " order by conference_center_name asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
if ( count ( $result ) > 0 ) {
2015-03-18 06:17:28 +01:00
$options [] = " <optgroup label='Conference Centers'> " ;
2014-03-18 07:39:13 +01:00
foreach ( $result as & $row ) {
$name = $row [ " conference_center_name " ];
$extension = $row [ " conference_center_extension " ];
$description = $row [ " conference_center_description " ];
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " transfer " . $extension . " XML " . $_SESSION [ 'context' ] ||
$select_value == " transfer: " . $extension . " XML " . $_SESSION [ 'context' ] ||
$select_value == " menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ 'context' ]
) ? true : false ;
2015-03-18 06:17:28 +01:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ 'context' ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $name . " " . $description . " </option> " ;
2014-03-18 07:39:13 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer: " . $extension . " XML " . $_SESSION [ 'context' ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $name . " " . $description . " </option> " ;
2014-03-18 07:39:13 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-03-18 07:39:13 +01:00
}
2015-03-18 06:17:28 +01:00
$options [] = " </optgroup> " ;
2014-03-18 07:39:13 +01:00
unset ( $prep_statement );
2012-06-04 16:58:40 +02:00
}
}
2014-03-18 07:39:13 +01:00
}
2015-03-18 06:17:28 +01:00
//conferences
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/conferences/app_config.php " )) {
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
$sql = " select * from v_conferences " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$sql .= " order by conference_name asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
if ( count ( $result ) > 0 ) {
2015-03-18 06:17:28 +01:00
$options [] = " <optgroup label='Conferences'> " ;
2014-03-18 07:39:13 +01:00
foreach ( $result as & $row ) {
$name = $row [ " conference_name " ];
$extension = $row [ " conference_extension " ];
$description = $row [ " conference_description " ];
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " transfer " . $extension . " XML " . $_SESSION [ 'context' ] ||
$select_value == " transfer: " . $extension . " XML " . $_SESSION [ 'context' ] ||
$select_value == " menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ 'context' ]
) ? true : false ;
2015-03-18 06:17:28 +01:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ 'context' ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $name . " " . $description . " </option> " ;
2014-03-18 07:39:13 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer: " . $extension . " XML " . $_SESSION [ 'context' ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $name . " " . $description . " </option> " ;
2014-03-18 07:39:13 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-03-18 07:39:13 +01:00
}
2015-03-18 06:17:28 +01:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2015-04-17 03:04:29 +02:00
unset ( $prep_statement );
2012-06-04 16:58:40 +02:00
}
}
2013-08-25 04:00:18 +02:00
2015-03-18 06:17:28 +01:00
//extensions
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/extensions/app_config.php " )) {
if ( $select_type == " dialplan " || $select_type == " ivr " || $select_type == " call_center_contact " ) {
$sql = " select * from v_extensions " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$sql .= " and enabled = 'true' " ;
$sql .= " order by extension asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
$options [] = " <optgroup label='Extensions'> " ;
foreach ( $result as & $row ) {
$extension = $row [ " extension " ];
$context = $row [ " user_context " ];
$description = $row [ " description " ];
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " user/ " . $extension . " @ " . $_SESSION [ 'domains' ][ $domain_uuid ][ 'domain_name' ] ||
$select_value == " transfer: " . $extension . " XML " . $context ||
$select_value == " menu-exec-app:transfer " . $extension . " XML " . $context
) ? true : false ;
2015-04-17 03:04:29 +02:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer " . $extension . " XML " . $context . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $description . " </option> " ;
}
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer: " . $extension . " XML " . $context . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $description . " </option> " ;
}
if ( $select_type == " call_center_contact " ) {
$options [] = " <option value='user/ " . $extension . " @ " . $_SESSION [ 'domains' ][ $domain_uuid ][ 'domain_name' ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $description . " </option> " ;
}
if ( $selected ) { $selection_found = true ; }
2012-06-04 16:58:40 +02:00
}
2015-04-17 03:04:29 +02:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2014-03-18 07:39:13 +01:00
unset ( $prep_statement , $extension );
}
}
2015-03-18 06:17:28 +01:00
//fax extensions
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/fax/app_config.php " )) {
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
$sql = " select * from v_fax " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$sql .= " order by fax_extension asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
$options [] = " <optgroup label='FAX'> " ;
foreach ( $result as & $row ) {
$fax_name = $row [ " fax_name " ];
$extension = $row [ " fax_extension " ];
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " transfer " . $extension . " XML " . $_SESSION [ " context " ] ||
$select_value == " transfer: " . $extension . " XML " . $_SESSION [ " context " ] ||
$select_value == " menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ " context " ]
) ? true : false ;
2015-04-17 03:04:29 +02:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $fax_name . " </option> " ;
}
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer: " . $extension . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $fax_name . " </option> " ;
}
if ( $selected ) { $selection_found = true ; }
2012-06-04 16:58:40 +02:00
}
2015-04-17 03:04:29 +02:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2014-03-18 07:39:13 +01:00
unset ( $prep_statement , $extension );
2012-06-04 16:58:40 +02:00
}
}
2015-03-18 06:17:28 +01:00
//fifo queues
2014-04-07 16:41:15 +02:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/fifo/app_config.php " )) {
2013-11-14 10:38:17 +01:00
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2014-03-18 07:39:13 +01:00
$sql = " select * from v_dialplan_details " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2015-04-17 03:04:29 +02:00
$sql .= " and dialplan_detail_type = 'fifo' " ;
$sql .= " and dialplan_detail_data not like '%@ ${ domain_name } in%' " ;
2014-03-18 07:39:13 +01:00
$sql .= " order by dialplan_detail_data asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
$options [] = " <optgroup label='Queues (FIFO)'> " ;
foreach ( $result as & $row ) {
$dialplan_uuid = $row [ " dialplan_uuid " ];
//get the extension number using the dialplan_uuid
$sql = " select dialplan_detail_data as extension_number " ;
$sql .= " from v_dialplan_details " ;
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
$sql .= " and dialplan_uuid = ' " . $dialplan_uuid . " ' " ;
$sql .= " and dialplan_detail_type = 'destination_number' " ;
$tmp = $db -> query ( $sql ) -> fetch ( PDO :: FETCH_ASSOC );
$extension_number = $tmp [ 'extension_number' ];
$extension_number = ltrim ( $extension_number , " ^ " );
$extension_number = ltrim ( $extension_number , " \\ " );
$extension_number = rtrim ( $extension_number , " $ " );
unset ( $tmp );
//get the extension number using the dialplan_uuid
$sql = " select * " ;
$sql .= " from v_dialplans " ;
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
$sql .= " and dialplan_uuid = ' " . $dialplan_uuid . " ' " ;
$tmp = $db -> query ( $sql ) -> fetch ( PDO :: FETCH_ASSOC );
$dialplan_name = $tmp [ 'dialplan_name' ];
$dialplan_name = str_replace ( " _ " , " " , $dialplan_name );
unset ( $tmp );
$fifo_name = $row [ " dialplan_detail_data " ];
$fifo_name = str_replace ( '@${domain_name} in' , '' , $fifo_name );
$option_label = $extension_number . ' ' . $dialplan_name ;
if ( $select_type == " ivr " ) {
$selected = ( " menu-exec-app:transfer " . $row [ " dialplan_detail_data " ] == $select_value ) ? true : false ;
$options [] = " <option value='menu-exec-app:transfer " . $extension_number . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $option_label . " </option> " ;
if ( $selected ) { $selection_found = true ; }
}
if ( $select_type == " dialplan " ) {
$selected = ( " transfer: " . $extension_number . " XML " . $_SESSION [ " context " ] == $select_value ) ? true : false ;
$options [] = " <option value='transfer: " . $extension_number . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $option_label . " </option> " ;
if ( $selected ) { $selection_found = true ; }
2012-06-04 16:58:40 +02:00
}
}
2015-04-17 03:04:29 +02:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2014-03-18 07:39:13 +01:00
unset ( $prep_statement );
2012-06-04 16:58:40 +02:00
}
}
//gateways
2015-03-18 06:17:28 +01:00
if ( if_group ( " superadmin " )) {
$sql = " select v_gateways.gateway_uuid, v_gateways.gateway, v_domains.domain_name from v_gateways " ;
$sql .= " inner join v_domains on v_gateways.domain_uuid=v_domains.domain_uuid " ;
$sql .= " where enabled = 'true' " ;
$sql .= " order by gateway asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
$tmp_selected = '' ;
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
if ( $select_type == " dialplan " || $select_type == " ivr " || $select_type == " call_center_contact " || $select_type == " bridge " ) {
$options [] = " <optgroup label='Gateways'> " ;
}
foreach ( $result as $row ) {
switch ( $select_type ) {
case " dialplan " :
$default_value = 'bridge:sofia/gateway/' . $row [ 'gateway_uuid' ] . '/' ;
$selected = ( strpos ( $select_value , $default_value ) === 0 ) ? true : false ;
$value = ( $selected ) ? $select_value : $default_value . $text_append ;
$flag = ( $selected && $select_value != $default_value . $text_append ) ? " * " : null ;
$options [] = " <option value=' " . $value . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $row [ 'gateway' ] . " @ " . $row [ 'domain_name' ] . " " . $flag . " </option> " ;
break ;
case " bridge " :
2015-03-18 06:17:28 +01:00
$default_value = 'sofia/gateway/' . $row [ 'gateway_uuid' ] . '/' ;
$selected = ( strpos ( $select_value , $default_value ) === 0 ) ? true : false ;
2015-03-27 02:09:25 +01:00
$value = ( $selected ) ? $select_value : $default_value . $text_append ;
$flag = ( $selected && $select_value != $default_value . $text_append ) ? " * " : null ;
2015-03-18 06:17:28 +01:00
$options [] = " <option value=' " . $value . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $row [ 'gateway' ] . " @ " . $row [ 'domain_name' ] . " " . $flag . " </option> " ;
2015-04-17 03:04:29 +02:00
break ;
case " ivr " :
$default_value = 'menu-exec-app:bridge sofia/gateway/' . $row [ 'gateway_uuid' ] . '/' ;
$selected = ( strpos ( $select_value , $default_value ) === 0 ) ? true : false ;
$value = ( $selected ) ? $select_value : $default_value . $text_append ;
$flag = ( $selected && $select_value != $default_value . $text_append ) ? " * " : null ;
$options [] = " <option value=' " . $value . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $row [ 'gateway' ] . " @ " . $row [ 'domain_name' ] . " " . $flag . " </option> " ;
break ;
case " call_center_contact " :
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/conference_centers/app_config.php " )) {
$default_value = 'sofia/gateway/' . $row [ 'gateway_uuid' ] . '/' ;
$selected = ( strpos ( $select_value , $default_value ) === 0 ) ? true : false ;
$value = ( $selected ) ? $select_value : $default_value . $text_append ;
$flag = ( $selected && $select_value != $default_value . $text_append ) ? " * " : null ;
$options [] = " <option value=' " . $value . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $row [ 'gateway' ] . " @ " . $row [ 'domain_name' ] . " " . $flag . " </option> " ;
}
break ;
}
if ( $selected ) { $selection_found = true ; }
}
if ( $select_type == " dialplan " || $select_type == " ivr " || $select_type == " call_center_contact " ) {
$options [] = " </optgroup> " ;
2014-10-17 21:39:14 +02:00
}
}
2015-04-17 03:04:29 +02:00
unset ( $prep_statement , $sql , $result , $value , $default_value , $flag );
2015-03-18 06:17:28 +01:00
}
2015-03-04 08:04:41 +01:00
2014-10-17 21:39:14 +02:00
//xmpp
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/xmpp/app_config.php " )) {
2015-04-17 03:04:29 +02:00
if ( if_group ( " superadmin " ) && $select_type == " bridge " ) {
2014-10-17 21:39:14 +02:00
$sql = " select v_xmpp.xmpp_profile_uuid, v_xmpp.profile_name, v_domains.domain_name from v_xmpp " ;
$sql .= " inner join v_domains on v_xmpp.domain_uuid=v_domains.domain_uuid " ;
$sql .= " where enabled = 'true' " ;
$sql .= " order by profile_name asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
unset ( $prep_statement , $sql );
$tmp_selected = '' ;
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
2015-03-18 06:17:28 +01:00
$options [] = " <optgroup label='XMPP Gateways'> " ;
2015-04-17 03:04:29 +02:00
foreach ( $result as $row ) {
$selected = ( 'dingaling/' . $row [ 'profile_name' ] . '/' == $select_value ) ? true : false ;
2015-03-18 06:17:28 +01:00
$options [] = " <option value='dingaling/ " . $row [ 'profile_name' ] . " /' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $row [ 'profile_name' ] . " @ " . $row [ 'domain_name' ] . " </option> " ;
2015-04-17 03:04:29 +02:00
if ( $selected ) { $selection_found = true ; }
2014-10-17 21:39:14 +02:00
}
2015-03-18 06:17:28 +01:00
$options [] = " </optgroup> " ;
2013-11-14 10:38:17 +01:00
}
2015-03-18 06:17:28 +01:00
unset ( $sql , $result );
2012-06-04 16:58:40 +02:00
}
}
2015-03-18 06:17:28 +01:00
//hunt groups
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/hunt_groups/app_config.php " )) {
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2013-11-14 10:38:17 +01:00
$sql = " select * from v_hunt_groups " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2013-11-14 10:38:17 +01:00
$sql .= " and hunt_group_enabled = 'true' " ;
$sql .= " and ( " ;
$sql .= " hunt_group_type = 'simultaneous' " ;
$sql .= " or hunt_group_type = 'sequence' " ;
$sql .= " or hunt_group_type = 'sequentially' " ;
$sql .= " ) " ;
$sql .= " order by hunt_group_extension asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
$options [] = " <optgroup label='Hunt Groups'> " ;
foreach ( $result as & $row ) {
$extension = $row [ " hunt_group_extension " ];
$hunt_group_name = $row [ " hunt_group_name " ];
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " transfer " . $extension . " XML " . $_SESSION [ " context " ] ||
$select_value == " transfer: " . $extension . " XML " . $_SESSION [ " context " ] ||
$select_value == " menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ " context " ]
) ? true : false ;
2015-04-17 03:04:29 +02:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $hunt_group_name . " </option> " ;
}
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer: " . $extension . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $hunt_group_name . " </option> " ;
}
if ( $selected ) { $selection_found = true ; }
2013-11-14 10:38:17 +01:00
}
2015-04-17 03:04:29 +02:00
$options [] = " </optgroup> " ;
2013-11-14 10:38:17 +01:00
}
unset ( $prep_statement , $extension );
}
}
2015-03-18 06:17:28 +01:00
//ivr menus
2014-03-23 18:36:15 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/ivr_menu/app_config.php " )) {
2013-08-22 18:05:17 +02:00
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2014-03-18 07:39:13 +01:00
$sql = " select * from v_ivr_menus " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$sql .= " and ivr_menu_enabled = 'true' " ;
$sql .= " order by ivr_menu_extension asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
$options [] = " <optgroup label='IVR Menu'> " ;
foreach ( $result as & $row ) {
$extension = $row [ " ivr_menu_extension " ];
$extension_name = $row [ " ivr_menu_name " ];
$extension_label = $row [ " ivr_menu_name " ];
$extension_name = str_replace ( " " , " _ " , $extension_name );
if ( count ( $_SESSION [ " domains " ]) > 1 ) {
$extension_name = $_SESSION [ 'domains' ][ $row [ 'domain_uuid' ]][ 'domain_name' ] . '-' . $extension_name ;
}
$selected = (
$select_value == " ivr " . $extension_name ||
$select_value == " ivr: " . $extension_name ||
2015-04-17 04:46:25 +02:00
$select_value == " menu-exec-app:ivr " . $extension ||
2015-04-17 03:04:29 +02:00
$select_value == " transfer " . $extension . " XML " . $_SESSION [ " context " ] ||
2015-04-17 04:46:25 +02:00
$select_value == " transfer: " . $extension . " XML " . $_SESSION [ " context " ] ||
$select_value == " menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ " context " ]
2015-04-17 03:04:29 +02:00
) ? true : false ;
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer " . $extension . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $extension_label . " </option> " ;
}
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer: " . $extension . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $extension_label . " </option> " ;
}
if ( $selected ) { $selection_found = true ; }
2013-08-22 18:05:17 +02:00
}
2015-04-17 03:04:29 +02:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2014-03-18 07:39:13 +01:00
unset ( $prep_statement , $extension );
2012-06-04 16:58:40 +02:00
}
}
2015-03-18 06:17:28 +01:00
//languages
2012-06-04 16:58:40 +02:00
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <optgroup label='Language'> " ;
2012-06-04 16:58:40 +02:00
}
2015-03-18 06:17:28 +01:00
$tmp_lang_options = array (
'nl' => 'Dutch' ,
'en' => 'English' ,
'fr' => 'French' ,
'it' => 'Italian' ,
'de' => 'German' ,
'pt-pt' => 'Portuguese (Portugal)' ,
'pt-br' => 'Portuguese (Brazil)' ,
'es' => 'Spanish' );
foreach ( $tmp_lang_options as $tmp_lang_option_abbr => $tmp_lang_option_name ) {
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " menu-exec-app:set default_language= " . $tmp_lang_option_abbr ||
$select_value == " set:default_language= " . $tmp_lang_option_abbr
) ? true : false ;
2012-06-04 16:58:40 +02:00
if ( $select_type == " ivr " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='menu-exec-app:set default_language= " . $tmp_lang_option_abbr . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $tmp_lang_option_name . " </option> " ;
2012-06-04 16:58:40 +02:00
}
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='set:default_language= " . $tmp_lang_option_abbr . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $tmp_lang_option_name . " </option> " ;
2012-06-04 16:58:40 +02:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2012-06-04 16:58:40 +02:00
}
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2015-03-18 06:17:28 +01:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2015-03-18 06:17:28 +01:00
unset ( $tmp_lang_options );
2012-06-04 16:58:40 +02:00
//recordings
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/recordings/app_config.php " )) {
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2015-04-01 12:19:47 +02:00
$sql = " select * from v_recordings " ;
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
$sql .= " order by recording_name asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
2015-03-18 06:17:28 +01:00
$options [] = " <optgroup label='Recordings'> " ;
2015-04-17 02:18:03 +02:00
foreach ( $result as & $row ) {
2015-04-24 04:47:10 +02:00
$recording_name = $row [ " recording_name " ];
$recording_filename = $row [ " recording_filename " ];
2015-04-28 11:54:02 +02:00
$path_mod = ( $_SESSION [ 'recordings' ][ 'storage_type' ][ 'text' ] != 'base64' ) ? $_SESSION [ 'switch' ][ 'recordings' ][ 'dir' ] . " / " : null ;
2015-04-17 02:18:03 +02:00
if ( $select_type == " dialplan " ) {
2015-04-24 04:47:10 +02:00
$execute_method = 'lua:' ;
2015-04-17 02:18:03 +02:00
}
2015-04-24 04:47:10 +02:00
else if ( $select_type == " ivr " ) {
$execute_method = 'menu-exec-app:lua ' ;
2015-04-17 02:18:03 +02:00
}
2015-04-24 04:47:10 +02:00
$selected = (
$select_value == $execute_method . " streamfile.lua " . $_SESSION [ 'switch' ][ 'recordings' ][ 'dir' ] . " / " . $recording_filename ||
$select_value == $execute_method . " streamfile.lua " . $recording_filename
) ? true : false ;
$options [] = " <option value=' " . $execute_method . " streamfile.lua " . $path_mod . $recording_filename . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $recording_name . " </option> " ;
if ( $selected ) { $selection_found = true ; }
}
$options [] = " </optgroup> " ;
}
}
}
//phrases
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/phrases/app_config.php " )) {
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
$sql = " select * from v_phrases where domain_uuid = ' " . $domain_uuid . " ' " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_NAMED );
if ( count ( $result ) > 0 ) {
$options [] = " <optgroup label='Phrases'> " ;
foreach ( $result as & $row ) {
$selected = ( $select_value == " phrase: " . $row [ " phrase_name " ] . " . " . $domain_uuid ) ? true : false ;
$options [] = " <option value='phrase: " . $row [ " phrase_name " ] . " . " . $domain_uuid . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $row [ " phrase_name " ] . " </option> " ;
2015-04-17 02:18:03 +02:00
if ( $selected ) { $selection_found = true ; }
2013-11-14 10:38:17 +01:00
}
2015-03-18 06:17:28 +01:00
$options [] = " </optgroup> " ;
2013-11-14 10:38:17 +01:00
}
2015-04-24 04:47:10 +02:00
unset ( $prep_statement );
2012-06-04 16:58:40 +02:00
}
}
2013-11-14 10:38:17 +01:00
//ring groups
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/ring_groups/app_config.php " )) {
2013-11-14 10:38:17 +01:00
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2014-03-18 07:39:13 +01:00
$sql = " select * from v_ring_groups " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$sql .= " and ring_group_enabled = 'true' " ;
$sql .= " order by ring_group_extension asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
2015-03-18 06:17:28 +01:00
$options [] = " <optgroup label='Ring Groups'> " ;
2015-04-17 03:04:29 +02:00
foreach ( $result as & $row ) {
$extension = $row [ " ring_group_extension " ];
$context = $row [ " ring_group_context " ];
$description = $row [ " ring_group_description " ];
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " transfer " . $extension . " XML " . $context ||
$select_value == " transfer: " . $extension . " XML " . $context ||
$select_value == " menu-exec-app:transfer " . $extension . " XML " . $context
) ? true : false ;
2015-04-17 03:04:29 +02:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer " . $extension . " XML " . $context . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $description . " </option> " ;
}
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer: " . $extension . " XML " . $context . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $extension . " " . $description . " </option> " ;
}
if ( $selected ) { $selection_found = true ; }
2012-06-04 16:58:40 +02:00
}
2015-03-18 06:17:28 +01:00
$options [] = " </optgroup> " ;
2014-03-18 07:39:13 +01:00
}
2013-11-14 10:38:17 +01:00
}
2012-06-04 16:58:40 +02:00
}
2013-11-14 10:38:17 +01:00
2015-03-18 06:17:28 +01:00
//time conditions
2014-04-07 16:41:15 +02:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/time_conditions/app_config.php " )) {
2013-11-14 10:38:17 +01:00
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2014-03-18 07:39:13 +01:00
$sql = " select * from v_dialplan_details " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$x = 0 ;
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
foreach ( $result as & $row ) {
switch ( $row [ 'dialplan_detail_type' ]) {
case " hour " :
case " minute " :
case " minute-of-day " :
case " time-of-day " :
case " mday " :
case " mweek " :
case " mon " :
case " yday " :
case " year " :
case " wday " :
case " week " :
$time_array [ $row [ 'dialplan_uuid' ]] = $row [ 'dialplan_detail_type' ];
}
2013-11-14 10:38:17 +01:00
}
2015-03-18 06:17:28 +01:00
$options [] = " <optgroup label='Time Conditions'> " ;
2015-04-17 03:04:29 +02:00
foreach ( $time_array as $key => $val ) {
$dialplan_uuid = $key ;
//get the extension number using the dialplan_uuid
$sql = " select dialplan_detail_data as extension_number " ;
$sql .= " from v_dialplan_details " ;
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
$sql .= " and dialplan_uuid = ' " . $dialplan_uuid . " ' " ;
$sql .= " and dialplan_detail_type = 'destination_number' " ;
$sql .= " order by extension_number asc " ;
$tmp = $db -> query ( $sql ) -> fetch ( PDO :: FETCH_ASSOC );
$extension_number = $tmp [ 'extension_number' ];
$extension_number = ltrim ( $extension_number , " ^ " );
$extension_number = ltrim ( $extension_number , " \\ " );
$extension_number = rtrim ( $extension_number , " $ " );
unset ( $tmp );
//get the extension number using the dialplan_uuid
$sql = " select * " ;
$sql .= " from v_dialplans " ;
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
$sql .= " and dialplan_uuid = ' " . $dialplan_uuid . " ' " ;
$tmp = $db -> query ( $sql ) -> fetch ( PDO :: FETCH_ASSOC );
$dialplan_name = $tmp [ 'dialplan_name' ];
$dialplan_name = str_replace ( " _ " , " " , $dialplan_name );
unset ( $tmp );
2014-03-18 07:39:13 +01:00
2015-04-17 03:04:29 +02:00
$option_label = $extension_number . ' ' . $dialplan_name ;
if ( $select_type == " ivr " ) {
$selected = ( " menu-exec-app:transfer " . $extension_number . " XML " . $_SESSION [ " context " ] == $select_value ) ? true : false ;
$options [] = " <option value='menu-exec-app:transfer " . $extension_number . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $option_label . " </option> " ;
if ( $selected ) { $selection_found = true ; }
}
if ( $select_type == " dialplan " ) {
$selected = ( " transfer: " . $extension_number . " XML " . $_SESSION [ " context " ] == $select_value ) ? true : false ;
$options [] = " <option value='transfer: " . $extension_number . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $option_label . " </option> " ;
if ( $selected ) { $selection_found = true ; }
}
}
2015-03-18 06:17:28 +01:00
$options [] = " </optgroup> " ;
2014-03-18 07:39:13 +01:00
}
unset ( $prep_statement );
2013-11-14 10:38:17 +01:00
}
2012-06-04 16:58:40 +02:00
}
2015-03-18 06:17:28 +01:00
//voicemail
2014-03-18 07:39:13 +01:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/voicemails/app_config.php " )) {
2013-11-14 10:38:17 +01:00
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2014-03-18 07:39:13 +01:00
$sql = " select * from v_voicemails " ;
2015-03-18 06:17:28 +01:00
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2014-03-18 07:39:13 +01:00
$sql .= " and voicemail_enabled = 'true' " ;
$sql .= " order by voicemail_id asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
2015-04-17 03:04:29 +02:00
if ( count ( $result ) > 0 ) {
$options [] = " <optgroup label='Voicemail'> " ;
foreach ( $result as & $row ) {
$voicemail_id = $row [ " voicemail_id " ];
$description = $row [ " voicemail_description " ];
2015-04-17 04:46:25 +02:00
$selected = (
$select_value == " voicemail default \$ { domain_name} " . $voicemail_id ||
$select_value == " voicemail:default \$ { domain_name} " . $voicemail_id ||
$select_value == " transfer:*99 " . $voicemail_id . " XML " . $_SESSION [ " context " ] ||
$select_value == " menu-exec-app:transfer *99 " . $voicemail_id . " XML " . $_SESSION [ " context " ]
) ? true : false ;
2015-04-17 03:04:29 +02:00
if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer *99 " . $voicemail_id . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $voicemail_id . " " . $description . " </option> " ;
}
if ( $select_type == " dialplan " ) {
$options [] = " <option value='transfer:*99 " . $voicemail_id . " XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " > " . $voicemail_id . " " . $description . " </option> " ;
}
if ( $selected ) { $selection_found = true ; }
2013-11-14 10:38:17 +01:00
}
2015-04-17 03:04:29 +02:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2013-11-14 10:38:17 +01:00
}
2012-06-04 16:58:40 +02:00
}
//other
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " || $select_type == " ivr " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <optgroup label='Other'> " ;
2014-01-26 14:18:41 +01:00
//set the default value
$selected = '' ;
2014-02-04 09:36:18 +01:00
//check voicemail
2015-03-18 06:17:28 +01:00
$selected = ( $select_value == " transfer:*98 XML " . $_SESSION [ " context " ] || $select_value == " menu-exec-app:transfer *98 XML " . $_SESSION [ " context " ]) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='transfer:*98 XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " >check voicemail</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer *98 XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " >check voicemail</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//company directory
2015-03-18 06:17:28 +01:00
$selected = ( $select_value == " transfer:*411 XML " . $_SESSION [ " context " ] || $select_value == " menu-exec-app:transfer *411 XML " . $_SESSION [ " context " ]) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='transfer:*411 XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " >company directory</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer *411 XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " >company directory</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-03-21 07:34:55 +01:00
//record
2015-03-18 06:17:28 +01:00
$selected = ( $select_value == " transfer:*732 XML " . $_SESSION [ " context " ] || $select_value == " menu-exec-app:transfer *732 XML " . $_SESSION [ " context " ]) ? true : false ;
2014-03-21 07:34:55 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='transfer:*732 XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " >record</option> " ;
2014-03-21 07:34:55 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer *732 XML " . $_SESSION [ " context " ] . " ' " . (( $selected ) ? " selected='selected' " : null ) . " >record</option> " ;
2014-03-21 07:34:55 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//advanced
if ( if_group ( " superadmin " )) {
2014-02-04 09:36:18 +01:00
//answer
2015-03-18 06:17:28 +01:00
$selected = ( $select_value == " answer " || $select_value == " menu-exec-app:answer " ) ? true : false ;
2014-02-04 09:36:18 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='answer' " . (( $selected ) ? " selected='selected' " : null ) . " >answer</option> " ;
2014-02-04 09:36:18 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:answer' " . (( $selected ) ? " selected='selected' " : null ) . " >answer</option> " ;
2014-02-04 09:36:18 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-02-04 09:36:18 +01:00
//hangup
2015-03-18 06:17:28 +01:00
$selected = ( $select_value == " hangup " || $select_value == " menu-exec-app:hangup " ) ? true : false ;
2014-02-04 09:36:18 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='hangup' " . (( $selected ) ? " selected='selected' " : null ) . " >hangup</option> " ;
2014-02-04 09:36:18 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:hangup' " . (( $selected ) ? " selected='selected' " : null ) . " >hangup</option> " ;
2014-02-04 09:36:18 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-02-04 09:36:18 +01:00
//info
2015-03-18 06:17:28 +01:00
$selected = ( $select_value == " info " || $select_value == " menu-exec-app:info " ) ? true : false ;
2014-02-04 09:36:18 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='info' " . (( $selected ) ? " selected='selected' " : null ) . " >info</option> " ;
2014-02-04 09:36:18 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:info' " . (( $selected ) ? " selected='selected' " : null ) . " >info</option> " ;
2014-02-04 09:36:18 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//bridge
2015-03-18 06:17:28 +01:00
$selected = ( $select_value == " bridge " || $select_value == " bridge: " || $select_value == " menu-exec-app:bridge " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='bridge:' " . (( $selected ) ? " selected='selected' " : null ) . " >bridge</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:bridge ' " . (( $selected ) ? " selected='selected' " : null ) . " >bridge</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//db
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " db " || $select_value == " db: " || $select_value == " menu-exec-app:db " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='db:' " . (( $selected ) ? " selected='selected' " : null ) . " >db</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:db ' " . (( $selected ) ? " selected='selected' " : null ) . " >db</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//export
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " export " || $select_value == " export: " || $select_value == " menu-exec-app:export " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='export:' " . (( $selected ) ? " selected='selected' " : null ) . " >export</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:export ' " . (( $selected ) ? " selected='selected' " : null ) . " >export</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//global_set
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " global_set " || $select_value == " global_set: " || $select_value == " menu-exec-app:global_set " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='global_set:' " . (( $selected ) ? " selected='selected' " : null ) . " >global_set</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:global_set ' " . (( $selected ) ? " selected='selected' " : null ) . " >global_set</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//group
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " group " || $select_value == " group: " || $select_value == " menu-exec-app:group " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='group:' " . (( $selected ) ? " selected='selected' " : null ) . " >group</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:group ' " . (( $selected ) ? " selected='selected' " : null ) . " >group</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//javascript
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " javascript " || $select_value == " javascript: " || $select_value == " menu-exec-app:javascript " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='javascript:' " . (( $selected ) ? " selected='selected' " : null ) . " >javascript</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:javascript ' " . (( $selected ) ? " selected='selected' " : null ) . " >javascript</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//lua
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " lua " || $select_value == " lua: " || $select_value == " menu-exec-app:lua " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='lua:' " . (( $selected ) ? " selected='selected' " : null ) . " >lua</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:lua ' " . (( $selected ) ? " selected='selected' " : null ) . " >lua</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//perl
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " perl " || $select_value == " perl: " || $select_value == " menu-exec-app:perl " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='perl:' " . (( $selected ) ? " selected='selected' " : null ) . " >perl</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:perl ' " . (( $selected ) ? " selected='selected' " : null ) . " >perl</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//reject
2015-03-18 06:17:28 +01:00
$selected = ( $select_value == " reject " || $select_value == " menu-exec-app:reject " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='reject' " . (( $selected ) ? " selected='selected' " : null ) . " >reject</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:reject' " . (( $selected ) ? " selected='selected' " : null ) . " >reject</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//set
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " set " || $select_value == " set: " || $select_value == " menu-exec-app:set " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='set:' " . (( $selected ) ? " selected='selected' " : null ) . " >set</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:set ' " . (( $selected ) ? " selected='selected' " : null ) . " >set</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//sleep
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " sleep " || $select_value == " sleep: " || $select_value == " menu-exec-app:sleep " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='sleep:' " . (( $selected ) ? " selected='selected' " : null ) . " >sleep</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:sleep ' " . (( $selected ) ? " selected='selected' " : null ) . " >sleep</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2014-01-26 14:18:41 +01:00
//transfer
2015-04-17 04:46:25 +02:00
$selected = ( $select_value == " transfer " || $select_value == " transfer: " || $select_value == " menu-exec-app:transfer " ) ? true : false ;
2014-01-26 14:18:41 +01:00
if ( $select_type == " dialplan " ) {
2015-03-18 06:17:28 +01:00
$options [] = " <option value='transfer:' " . (( $selected ) ? " selected='selected' " : null ) . " >transfer</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
else if ( $select_type == " ivr " ) {
$options [] = " <option value='menu-exec-app:transfer ' " . (( $selected ) ? " selected='selected' " : null ) . " >transfer</option> " ;
2014-01-26 14:18:41 +01:00
}
2015-03-18 06:17:28 +01:00
if ( $selected ) { $selection_found = true ; }
2013-11-14 10:38:17 +01:00
}
2015-03-18 06:17:28 +01:00
$options [] = " </optgroup> " ;
2012-06-04 16:58:40 +02:00
}
2015-03-18 06:17:28 +01:00
//custom
if ( ! $selection_found && $select_value != '' ) {
array_unshift ( $options ,
" <option value=' " . $select_value . " ' selected='selected'> " . $select_value . " </option> " ,
" <option value='' disabled='disabled'></option> "
);
}
//output options
if ( sizeof ( $options ) > 0 ) {
echo implode ( " \n " , $options );
}
2012-06-04 16:58:40 +02:00
2015-03-18 06:17:28 +01:00
echo " </select> \n " ;
2012-06-04 16:58:40 +02:00
if ( if_group ( " superadmin " )) {
2014-08-03 09:02:12 +02:00
echo " <input type='button' id='btn_select_to_input_ " . $select_id . " ' class='btn' name='' alt='back' onclick='changeToInput " . $select_id . " (document.getElementById( \" " . $select_id . " \" ));this.style.visibility = \" hidden \" ;' value='◁'> " ;
2012-06-04 16:58:40 +02:00
}
}
function save_setting_xml () {
global $db , $domain_uuid , $host , $config ;
2012-08-17 10:52:10 +02:00
2012-06-04 16:58:40 +02:00
$sql = " select * from v_settings " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
if ( $prep_statement ) {
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
foreach ( $result as & $row ) {
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /directory/default/default.xml " , " w " );
2012-06-05 10:32:53 +02:00
$xml = " <include> \n " ;
$xml .= " <user id= \" default \" > <!--if id is numeric mailbox param is not necessary--> \n " ;
$xml .= " <variables> \n " ;
$xml .= " <!--all variables here will be set on all inbound calls that originate from this user --> \n " ;
$xml .= " <!-- set these to take advantage of a dialplan localized to this user --> \n " ;
$xml .= " <variable name= \" numbering_plan \" value= \" " . $row [ 'numbering_plan' ] . " \" /> \n " ;
$xml .= " <variable name= \" default_gateway \" value= \" " . $row [ 'default_gateway' ] . " \" /> \n " ;
$xml .= " <variable name= \" default_area_code \" value= \" " . $row [ 'default_area_code' ] . " \" /> \n " ;
$xml .= " </variables> \n " ;
$xml .= " </user> \n " ;
$xml .= " </include> \n " ;
fwrite ( $fout , $xml );
unset ( $xml );
2012-06-04 16:58:40 +02:00
fclose ( $fout );
$event_socket_ip_address = $row [ 'event_socket_ip_address' ];
if ( strlen ( $event_socket_ip_address ) == 0 ) { $event_socket_ip_address = '127.0.0.1' ; }
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /autoload_configs/event_socket.conf.xml " , " w " );
2012-06-05 10:32:53 +02:00
$xml = " <configuration name= \" event_socket.conf \" description= \" Socket Client \" > \n " ;
$xml .= " <settings> \n " ;
$xml .= " <param name= \" listen-ip \" value= \" " . $event_socket_ip_address . " \" /> \n " ;
$xml .= " <param name= \" listen-port \" value= \" " . $row [ 'event_socket_port' ] . " \" /> \n " ;
$xml .= " <param name= \" password \" value= \" " . $row [ 'event_socket_password' ] . " \" /> \n " ;
$xml .= " <!--<param name= \" apply-inbound-acl \" value= \" lan \" />--> \n " ;
$xml .= " </settings> \n " ;
$xml .= " </configuration> " ;
fwrite ( $fout , $xml );
unset ( $xml , $event_socket_password );
2012-06-04 16:58:40 +02:00
fclose ( $fout );
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /autoload_configs/xml_rpc.conf.xml " , " w " );
2012-06-05 10:32:53 +02:00
$xml = " <configuration name= \" xml_rpc.conf \" description= \" XML RPC \" > \n " ;
$xml .= " <settings> \n " ;
$xml .= " <!-- The port where you want to run the http service (default 8080) --> \n " ;
$xml .= " <param name= \" http-port \" value= \" " . $row [ 'xml_rpc_http_port' ] . " \" /> \n " ;
$xml .= " <!-- if all 3 of the following params exist all http traffic will require auth --> \n " ;
$xml .= " <param name= \" auth-realm \" value= \" " . $row [ 'xml_rpc_auth_realm' ] . " \" /> \n " ;
$xml .= " <param name= \" auth-user \" value= \" " . $row [ 'xml_rpc_auth_user' ] . " \" /> \n " ;
$xml .= " <param name= \" auth-pass \" value= \" " . $row [ 'xml_rpc_auth_pass' ] . " \" /> \n " ;
$xml .= " </settings> \n " ;
$xml .= " </configuration> \n " ;
fwrite ( $fout , $xml );
unset ( $xml );
2012-06-04 16:58:40 +02:00
fclose ( $fout );
//shout.conf.xml
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /autoload_configs/shout.conf.xml " , " w " );
2012-06-05 10:32:53 +02:00
$xml = " <configuration name= \" shout.conf \" description= \" mod shout config \" > \n " ;
$xml .= " <settings> \n " ;
$xml .= " <!-- Don't change these unless you are insane --> \n " ;
$xml .= " <param name= \" decoder \" value= \" " . $row [ 'mod_shout_decoder' ] . " \" /> \n " ;
$xml .= " <param name= \" volume \" value= \" " . $row [ 'mod_shout_volume' ] . " \" /> \n " ;
$xml .= " <!--<param name= \" outscale \" value= \" 8192 \" />--> \n " ;
$xml .= " </settings> \n " ;
$xml .= " </configuration> " ;
fwrite ( $fout , $xml );
unset ( $xml );
2012-06-04 16:58:40 +02:00
fclose ( $fout );
break ; //limit to 1 row
}
unset ( $prep_statement );
}
2012-08-30 16:33:11 +02:00
//apply settings
2012-06-04 16:58:40 +02:00
$_SESSION [ " reload_xml " ] = true ;
//$cmd = "api reloadxml";
//event_socket_request_cmd($cmd);
//unset($cmd);
}
function filename_safe ( $filename ) {
// lower case
$filename = strtolower ( $filename );
// replace spaces with a '_'
$filename = str_replace ( " " , " _ " , $filename );
// loop through string
$result = '' ;
for ( $i = 0 ; $i < strlen ( $filename ); $i ++ ) {
if ( preg_match ( '([0-9]|[a-z]|_)' , $filename [ $i ])) {
$result .= $filename [ $i ];
}
}
// return filename
return $result ;
}
function save_gateway_xml () {
2014-03-22 02:12:31 +01:00
//skip saving the gateway xml if the directory is not set
if ( strlen ( $_SESSION [ 'switch' ][ 'sip_profiles' ][ 'dir' ]) == 0 ) {
return ;
}
2012-06-04 16:58:40 +02:00
//declare the global variables
global $db , $domain_uuid , $config ;
//delete all old gateways to prepare for new ones
if ( count ( $_SESSION [ " domains " ]) > 1 ) {
$v_needle = 'v_' . $_SESSION [ 'domain_name' ] . '-' ;
}
else {
$v_needle = 'v_' ;
}
2014-03-22 00:45:05 +01:00
$gateway_list = glob ( $_SESSION [ 'switch' ][ 'sip_profiles' ][ 'dir' ] . " /*/ " . $v_needle . " *.xml " );
2012-06-04 16:58:40 +02:00
foreach ( $gateway_list as $gateway_file ) {
unlink ( $gateway_file );
}
//get the list of gateways and write the xml
$sql = " select * from v_gateways " ;
2015-01-29 08:07:54 +01:00
$sql .= " where (domain_uuid = ' $domain_uuid ' or domain_uuid is null) " ;
2012-06-04 16:58:40 +02:00
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
foreach ( $result as & $row ) {
if ( $row [ 'enabled' ] != " false " ) {
//set the default profile as external
$profile = $row [ 'profile' ];
if ( strlen ( $profile ) == 0 ) {
$profile = " external " ;
}
2013-12-06 13:36:52 +01:00
//open the xml file
2014-06-24 08:40:29 +02:00
$fout = fopen ( $_SESSION [ 'switch' ][ 'sip_profiles' ][ 'dir' ] . " / " . $profile . " /v_ " . strtolower ( $row [ 'gateway_uuid' ]) . " .xml " , " w " );
2013-12-06 13:36:52 +01:00
//build the xml
2012-06-05 10:32:53 +02:00
$xml .= " <include> \n " ;
2014-06-24 08:40:29 +02:00
$xml .= " <gateway name= \" " . strtolower ( $row [ 'gateway_uuid' ]) . " \" > \n " ;
2013-12-06 13:36:52 +01:00
if ( strlen ( $row [ 'username' ]) > 0 ) {
$xml .= " <param name= \" username \" value= \" " . $row [ 'username' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'distinct_to' ]) > 0 ) {
$xml .= " <param name= \" distinct-to \" value= \" " . $row [ 'distinct_to' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'auth_username' ]) > 0 ) {
$xml .= " <param name= \" auth-username \" value= \" " . $row [ 'auth_username' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'password' ]) > 0 ) {
$xml .= " <param name= \" password \" value= \" " . $row [ 'password' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'realm' ]) > 0 ) {
$xml .= " <param name= \" realm \" value= \" " . $row [ 'realm' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'from_user' ]) > 0 ) {
$xml .= " <param name= \" from-user \" value= \" " . $row [ 'from_user' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'from_domain' ]) > 0 ) {
$xml .= " <param name= \" from-domain \" value= \" " . $row [ 'from_domain' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'proxy' ]) > 0 ) {
$xml .= " <param name= \" proxy \" value= \" " . $row [ 'proxy' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'register_proxy' ]) > 0 ) {
$xml .= " <param name= \" register-proxy \" value= \" " . $row [ 'register_proxy' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'outbound_proxy' ]) > 0 ) {
2012-06-05 10:32:53 +02:00
$xml .= " <param name= \" outbound-proxy \" value= \" " . $row [ 'outbound_proxy' ] . " \" /> \n " ;
2012-06-04 16:58:40 +02:00
}
2013-12-06 13:36:52 +01:00
if ( strlen ( $row [ 'expire_seconds' ]) > 0 ) {
$xml .= " <param name= \" expire-seconds \" value= \" " . $row [ 'expire_seconds' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'register' ]) > 0 ) {
$xml .= " <param name= \" register \" value= \" " . $row [ 'register' ] . " \" /> \n " ;
}
2012-06-04 16:58:40 +02:00
2013-12-06 13:36:52 +01:00
if ( strlen ( $row [ 'register_transport' ]) > 0 ) {
switch ( $row [ 'register_transport' ]) {
case " udp " :
$xml .= " <param name= \" register-transport \" value= \" udp \" /> \n " ;
break ;
case " tcp " :
$xml .= " <param name= \" register-transport \" value= \" tcp \" /> \n " ;
break ;
case " tls " :
$xml .= " <param name= \" register-transport \" value= \" tls \" /> \n " ;
$xml .= " <param name= \" contact-params \" value= \" transport=tls \" /> \n " ;
break ;
default :
$xml .= " <param name= \" register-transport \" value= \" " . $row [ 'register_transport' ] . " \" /> \n " ;
}
}
if ( strlen ( $row [ 'retry_seconds' ]) > 0 ) {
$xml .= " <param name= \" retry-seconds \" value= \" " . $row [ 'retry_seconds' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'extension' ]) > 0 ) {
$xml .= " <param name= \" extension \" value= \" " . $row [ 'extension' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'ping' ]) > 0 ) {
$xml .= " <param name= \" ping \" value= \" " . $row [ 'ping' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'context' ]) > 0 ) {
$xml .= " <param name= \" context \" value= \" " . $row [ 'context' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'caller_id_in_from' ]) > 0 ) {
$xml .= " <param name= \" caller-id-in-from \" value= \" " . $row [ 'caller_id_in_from' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'supress_cng' ]) > 0 ) {
$xml .= " <param name= \" supress-cng \" value= \" " . $row [ 'supress_cng' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'sip_cid_type' ]) > 0 ) {
$xml .= " <param name= \" sip_cid_type \" value= \" " . $row [ 'sip_cid_type' ] . " \" /> \n " ;
}
if ( strlen ( $row [ 'extension_in_contact' ]) > 0 ) {
$xml .= " <param name= \" extension-in-contact \" value= \" " . $row [ 'extension_in_contact' ] . " \" /> \n " ;
}
2012-06-04 16:58:40 +02:00
2013-12-06 13:36:52 +01:00
$xml .= " </gateway> \n " ;
$xml .= " </include> " ;
2012-06-04 16:58:40 +02:00
2013-12-06 13:36:52 +01:00
//write the xml
fwrite ( $fout , $xml );
unset ( $xml );
fclose ( $fout );
2012-06-04 16:58:40 +02:00
}
} //end foreach
unset ( $prep_statement );
2012-08-30 16:33:11 +02:00
//apply settings
2012-06-04 16:58:40 +02:00
$_SESSION [ " reload_xml " ] = true ;
}
function save_module_xml () {
global $config , $db , $domain_uuid ;
$xml = " " ;
$xml .= " <configuration name= \" modules.conf \" description= \" Modules \" > \n " ;
$xml .= " <modules> \n " ;
2013-09-20 23:43:24 +02:00
$sql = " select * from v_modules order by module_category = 'Languages' OR module_category = 'Loggers' DESC, module_category " ;
2012-06-04 16:58:40 +02:00
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$prev_module_cat = '' ;
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
foreach ( $result as $row ) {
2013-07-29 19:22:43 +02:00
if ( $prev_module_cat != $row [ 'module_category' ]) {
$xml .= " \n <!-- " . $row [ 'module_category' ] . " --> \n " ;
2012-06-04 16:58:40 +02:00
}
if ( $row [ 'module_enabled' ] == " true " ){
2012-10-17 17:20:58 +02:00
$xml .= " <load module= \" " . $row [ 'module_name' ] . " \" /> \n " ;
2012-06-04 16:58:40 +02:00
}
2013-07-29 19:22:43 +02:00
$prev_module_cat = $row [ 'module_category' ];
2012-06-04 16:58:40 +02:00
}
$xml .= " \n " ;
$xml .= " </modules> \n " ;
$xml .= " </configuration> " ;
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /autoload_configs/modules.conf.xml " , " w " );
fwrite ( $fout , $xml );
unset ( $xml );
fclose ( $fout );
2012-08-30 16:33:11 +02:00
//apply settings
2012-06-04 16:58:40 +02:00
$_SESSION [ " reload_xml " ] = true ;
//$cmd = "api reloadxml";
//event_socket_request_cmd($cmd);
//unset($cmd);
}
function save_var_xml () {
global $config , $db , $domain_uuid ;
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /vars.xml " , " w " );
$xml = '' ;
$sql = " select * from v_vars " ;
$sql .= " where var_enabled = 'true' " ;
$sql .= " order by var_cat, var_order asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$prev_var_cat = '' ;
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
foreach ( $result as & $row ) {
if ( $row [ 'var_cat' ] != 'Provision' ) {
if ( $prev_var_cat != $row [ 'var_cat' ]) {
$xml .= " \n <!-- " . $row [ 'var_cat' ] . " --> \n " ;
if ( strlen ( $row [ " var_description " ]) > 0 ) {
$xml .= " <!-- " . base64_decode ( $row [ 'var_description' ]) . " --> \n " ;
}
}
2015-03-26 00:50:48 +01:00
if ( strlen ( $row [ 'var_hostname' ]) == 0 ) {
$xml .= " <X-PRE-PROCESS cmd= \" set \" data= \" " . $row [ 'var_name' ] . " = " . $row [ 'var_value' ] . " \" /> \n " ;
} elseif ( $row [ 'var_hostname' ] == system ( 'hostname' )) {
$xml .= " <X-PRE-PROCESS cmd= \" set \" data= \" " . $row [ 'var_name' ] . " = " . $row [ 'var_value' ] . " \" /> \n " ;
}
2012-06-04 16:58:40 +02:00
}
$prev_var_cat = $row [ 'var_cat' ];
}
2012-10-17 17:20:58 +02:00
$xml .= " \n " ;
2012-06-04 16:58:40 +02:00
fwrite ( $fout , $xml );
unset ( $xml );
fclose ( $fout );
2012-08-30 16:33:11 +02:00
//apply settings
2012-06-04 16:58:40 +02:00
$_SESSION [ " reload_xml " ] = true ;
//$cmd = "api reloadxml";
//event_socket_request_cmd($cmd);
//unset($cmd);
}
2012-09-04 18:34:34 +02:00
function outbound_route_to_bridge ( $domain_uuid , $destination_number ) {
2012-07-24 20:15:45 +02:00
global $db ;
2012-06-04 16:58:40 +02:00
$destination_number = trim ( $destination_number );
if ( is_numeric ( $destination_number )) {
//not found, continue to process the function
}
else {
//not a number, brige_array and exit the function
$bridge_array [ 0 ] = $destination_number ;
return $bridge_array ;
}
$sql = " select * from v_dialplans " ;
2014-07-13 08:56:23 +02:00
$sql .= " where (domain_uuid = ' " . $domain_uuid . " ' or domain_uuid is null) " ;
2012-06-04 16:58:40 +02:00
$sql .= " and app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' " ;
2012-07-24 20:07:20 +02:00
$sql .= " and dialplan_enabled = 'true' " ;
2012-06-04 16:58:40 +02:00
$sql .= " order by dialplan_order asc " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
$x = 0 ;
foreach ( $result as & $row ) {
//set as variables
$dialplan_uuid = $row [ 'dialplan_uuid' ];
$dialplan_detail_tag = $row [ " dialplan_detail_tag " ];
$dialplan_detail_type = $row [ 'dialplan_detail_type' ];
$dialplan_continue = $row [ 'dialplan_continue' ];
//get the extension number using the dialplan_uuid
$sql = " select * " ;
$sql .= " from v_dialplan_details " ;
2015-01-09 12:10:13 +01:00
$sql .= " where dialplan_uuid = ' $dialplan_uuid ' " ;
2012-06-04 16:58:40 +02:00
$sql .= " order by dialplan_detail_order asc " ;
$sub_result = $db -> query ( $sql ) -> fetchAll ( PDO :: FETCH_ASSOC );
$regex_match = false ;
foreach ( $sub_result as & $sub_row ) {
if ( $sub_row [ 'dialplan_detail_tag' ] == " condition " ) {
if ( $sub_row [ 'dialplan_detail_type' ] == " destination_number " ) {
$dialplan_detail_data = $sub_row [ 'dialplan_detail_data' ];
$pattern = '/' . $dialplan_detail_data . '/' ;
preg_match ( $pattern , $destination_number , $matches , PREG_OFFSET_CAPTURE );
if ( count ( $matches ) == 0 ) {
2012-07-11 07:50:53 +02:00
$regex_match = false ;
2012-06-04 16:58:40 +02:00
}
else {
2012-07-11 07:50:53 +02:00
$regex_match = true ;
$regex_match_1 = $matches [ 1 ][ 0 ];
$regex_match_2 = $matches [ 2 ][ 0 ];
$regex_match_3 = $matches [ 3 ][ 0 ];
$regex_match_4 = $matches [ 4 ][ 0 ];
$regex_match_5 = $matches [ 5 ][ 0 ];
2012-06-04 16:58:40 +02:00
}
}
}
}
if ( $regex_match ) {
foreach ( $sub_result as & $sub_row ) {
$dialplan_detail_data = $sub_row [ 'dialplan_detail_data' ];
if ( $sub_row [ 'dialplan_detail_tag' ] == " action " && $sub_row [ 'dialplan_detail_type' ] == " bridge " && $dialplan_detail_data != " \$ { enum_auto_route} " ) {
$dialplan_detail_data = str_replace ( " \$ 1 " , $regex_match_1 , $dialplan_detail_data );
$dialplan_detail_data = str_replace ( " \$ 2 " , $regex_match_2 , $dialplan_detail_data );
$dialplan_detail_data = str_replace ( " \$ 3 " , $regex_match_3 , $dialplan_detail_data );
$dialplan_detail_data = str_replace ( " \$ 4 " , $regex_match_4 , $dialplan_detail_data );
$dialplan_detail_data = str_replace ( " \$ 5 " , $regex_match_5 , $dialplan_detail_data );
//echo "dialplan_detail_data: $dialplan_detail_data";
$bridge_array [ $x ] = $dialplan_detail_data ;
$x ++ ;
if ( $dialplan_continue == " false " ) {
break 2 ;
}
}
}
}
}
return $bridge_array ;
unset ( $prep_statement );
}
2013-07-29 19:22:43 +02:00
function email_validate ( $strEmail ){
$validRegExp = '/^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.[a-zA-Z]{2,3}$/' ;
// search email text for regular exp matches
preg_match ( $validRegExp , $strEmail , $matches , PREG_OFFSET_CAPTURE );
if ( count ( $matches ) == 0 ) {
return 0 ;
}
else {
return 1 ;
}
}
2012-06-04 16:58:40 +02:00
//$destination_number = '1231234';
2012-09-04 18:34:34 +02:00
//$bridge_array = outbound_route_to_bridge ($domain_uuid, $destination_number);
2012-06-04 16:58:40 +02:00
//foreach ($bridge_array as &$bridge) {
// echo "bridge: ".$bridge."<br />";
//}
function extension_exists ( $extension ) {
global $db , $domain_uuid ;
$sql = " select * from v_extensions " ;
$sql .= " where domain_uuid = ' $domain_uuid ' " ;
$sql .= " and extension = ' $extension ' " ;
$sql .= " and enabled = 'true' " ;
$result = $db -> query ( $sql ) -> fetchAll ( PDO :: FETCH_ASSOC );
if ( count ( $result ) > 0 ) {
return true ;
}
else {
return false ;
}
}
function get_recording_filename ( $id ) {
global $domain_uuid , $db ;
$sql = " select * from v_recordings " ;
$sql .= " where recording_uuid = ' $id ' " ;
$sql .= " and domain_uuid = ' $domain_uuid ' " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
foreach ( $result as & $row ) {
//$filename = $row["filename"];
//$recording_name = $row["recording_name"];
//$recording_uuid = $row["recording_uuid"];
return $row [ " filename " ];
break ; //limit to 1 row
}
unset ( $prep_statement );
}
function dialplan_add ( $domain_uuid , $dialplan_uuid , $dialplan_name , $dialplan_order , $dialplan_context , $dialplan_enabled , $dialplan_description , $app_uuid ) {
global $db , $db_type ;
$sql = " insert into v_dialplans " ;
$sql .= " ( " ;
$sql .= " domain_uuid, " ;
$sql .= " dialplan_uuid, " ;
if ( strlen ( $app_uuid ) > 0 ) {
$sql .= " app_uuid, " ;
}
$sql .= " dialplan_name, " ;
$sql .= " dialplan_order, " ;
$sql .= " dialplan_context, " ;
$sql .= " dialplan_enabled, " ;
$sql .= " dialplan_description " ;
$sql .= " ) " ;
$sql .= " values " ;
$sql .= " ( " ;
$sql .= " ' $domain_uuid ', " ;
$sql .= " ' $dialplan_uuid ', " ;
if ( strlen ( $app_uuid ) > 0 ) {
$sql .= " ' $app_uuid ', " ;
}
$sql .= " ' $dialplan_name ', " ;
$sql .= " ' $dialplan_order ', " ;
$sql .= " ' $dialplan_context ', " ;
$sql .= " ' $dialplan_enabled ', " ;
$sql .= " ' $dialplan_description ' " ;
$sql .= " ) " ;
$db -> exec ( check_sql ( $sql ));
unset ( $sql );
}
2014-11-06 17:56:31 +01:00
function dialplan_detail_add ( $domain_uuid , $dialplan_uuid , $dialplan_detail_tag , $dialplan_detail_order , $dialplan_detail_group , $dialplan_detail_type , $dialplan_detail_data , $dialplan_detail_break , $dialplan_detail_inline ) {
2012-06-04 16:58:40 +02:00
global $db ;
$dialplan_detail_uuid = uuid ();
$sql = " insert into v_dialplan_details " ;
$sql .= " ( " ;
$sql .= " domain_uuid, " ;
$sql .= " dialplan_uuid, " ;
$sql .= " dialplan_detail_uuid, " ;
$sql .= " dialplan_detail_tag, " ;
$sql .= " dialplan_detail_group, " ;
$sql .= " dialplan_detail_order, " ;
$sql .= " dialplan_detail_type, " ;
2014-10-21 17:17:03 +02:00
$sql .= " dialplan_detail_data, " ;
2014-11-06 17:56:31 +01:00
$sql .= " dialplan_detail_break, " ;
$sql .= " dialplan_detail_inline " ;
2013-11-14 10:38:17 +01:00
$sql .= " ) " ;
2012-06-04 16:58:40 +02:00
$sql .= " values " ;
$sql .= " ( " ;
$sql .= " ' $domain_uuid ', " ;
$sql .= " ' " . check_str ( $dialplan_uuid ) . " ', " ;
$sql .= " ' " . check_str ( $dialplan_detail_uuid ) . " ', " ;
$sql .= " ' " . check_str ( $dialplan_detail_tag ) . " ', " ;
if ( strlen ( $dialplan_detail_group ) == 0 ) {
$sql .= " null, " ;
}
else {
$sql .= " ' " . check_str ( $dialplan_detail_group ) . " ', " ;
}
$sql .= " ' " . check_str ( $dialplan_detail_order ) . " ', " ;
$sql .= " ' " . check_str ( $dialplan_detail_type ) . " ', " ;
2014-10-21 17:17:03 +02:00
$sql .= " ' " . check_str ( $dialplan_detail_data ) . " ', " ;
if ( strlen ( $dialplan_detail_break ) == 0 ) {
2014-11-06 17:56:31 +01:00
$sql .= " null, " ;
}
else {
$sql .= " ' " . check_str ( $dialplan_detail_break ) . " ', " ;
}
if ( strlen ( $dialplan_detail_inline ) == 0 ) {
2014-10-21 17:17:03 +02:00
$sql .= " null " ;
}
else {
2014-11-06 17:56:31 +01:00
$sql .= " ' " . check_str ( $dialplan_detail_inline ) . " ' " ;
2014-10-21 17:17:03 +02:00
}
2012-06-04 16:58:40 +02:00
$sql .= " ) " ;
$db -> exec ( check_sql ( $sql ));
unset ( $sql );
}
function save_dialplan_xml () {
global $db , $domain_uuid ;
//get the context based from the domain_uuid
if ( count ( $_SESSION [ 'domains' ]) == 1 ) {
$user_context = " default " ;
}
else {
$user_context = $_SESSION [ 'domains' ][ $domain_uuid ][ 'domain_name' ];
}
//prepare for dialplan .xml files to be written. delete all dialplan files that are prefixed with dialplan_ and have a file extension of .xml
$dialplan_list = glob ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " /*/*v_dialplan*.xml " );
foreach ( $dialplan_list as $name => $value ) {
unlink ( $value );
}
$dialplan_list = glob ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " /*/*_v_*.xml " );
foreach ( $dialplan_list as $name => $value ) {
unlink ( $value );
}
$dialplan_list = glob ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " /*/*/*_v_*.xml " );
foreach ( $dialplan_list as $name => $value ) {
unlink ( $value );
}
2012-07-03 18:22:58 +02:00
//if dialplan dir exists then build and save the dialplan xml
if ( is_dir ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ])) {
$sql = " select * from v_dialplans " ;
$sql .= " where dialplan_enabled = 'true' " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
if ( $prep_statement ) {
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
foreach ( $result as & $row ) {
$tmp = " " ;
$tmp .= " \n " ;
2014-07-09 09:36:13 +02:00
$first_action = true ;
2012-06-04 16:58:40 +02:00
2012-07-03 18:22:58 +02:00
$dialplan_continue = '' ;
if ( $row [ 'dialplan_continue' ] == " true " ) {
$dialplan_continue = " continue= \" true \" " ;
}
$tmp = " <extension name= \" " . $row [ 'dialplan_name' ] . " \" $dialplan_continue > \n " ;
$sql = " select * from v_dialplan_details " ;
$sql .= " where dialplan_uuid = ' " . $row [ 'dialplan_uuid' ] . " ' " ;
$sql .= " order by dialplan_detail_group asc, dialplan_detail_order asc " ;
$prep_statement_2 = $db -> prepare ( $sql );
if ( $prep_statement_2 ) {
$prep_statement_2 -> execute ();
$result2 = $prep_statement_2 -> fetchAll ( PDO :: FETCH_NAMED );
$result_count2 = count ( $result2 );
unset ( $prep_statement_2 , $sql );
//create a new array that is sorted into groups and put the tags in order conditions, actions, anti-actions
$details = '' ;
$previous_tag = '' ;
$details [ $group ][ 'condition_count' ] = '' ;
//conditions
$x = 0 ;
2012-06-04 16:58:40 +02:00
$y = 0 ;
2012-07-03 18:22:58 +02:00
foreach ( $result2 as $row2 ) {
if ( $row2 [ 'dialplan_detail_tag' ] == " condition " ) {
//get the group
$group = $row2 [ 'dialplan_detail_group' ];
//get the generic type
switch ( $row2 [ 'dialplan_detail_type' ]) {
2015-03-15 02:33:27 +01:00
case " hour " :
case " minute " :
case " minute-of-day " :
case " time-of-day " :
case " mday " :
case " mweek " :
case " mon " :
case " yday " :
case " year " :
case " wday " :
case " week " :
$type = 'time' ;
break ;
default :
$type = 'default' ;
2012-07-03 18:22:58 +02:00
}
2012-06-04 16:58:40 +02:00
2012-07-03 18:22:58 +02:00
//add the conditions to the details array
$details [ $group ][ 'condition-' . $x ][ 'dialplan_detail_tag' ] = $row2 [ 'dialplan_detail_tag' ];
$details [ $group ][ 'condition-' . $x ][ 'dialplan_detail_type' ] = $row2 [ 'dialplan_detail_type' ];
$details [ $group ][ 'condition-' . $x ][ 'dialplan_uuid' ] = $row2 [ 'dialplan_uuid' ];
$details [ $group ][ 'condition-' . $x ][ 'dialplan_detail_order' ] = $row2 [ 'dialplan_detail_order' ];
$details [ $group ][ 'condition-' . $x ][ 'field' ][ $y ][ 'type' ] = $row2 [ 'dialplan_detail_type' ];
$details [ $group ][ 'condition-' . $x ][ 'field' ][ $y ][ 'data' ] = $row2 [ 'dialplan_detail_data' ];
$details [ $group ][ 'condition-' . $x ][ 'dialplan_detail_break' ] = $row2 [ 'dialplan_detail_break' ];
$details [ $group ][ 'condition-' . $x ][ 'dialplan_detail_group' ] = $row2 [ 'dialplan_detail_group' ];
$details [ $group ][ 'condition-' . $x ][ 'dialplan_detail_inline' ] = $row2 [ 'dialplan_detail_inline' ];
if ( $type == " time " ) {
$y ++ ;
}
}
if ( $type == " default " ) {
$x ++ ;
$y = 0 ;
}
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
//actions
$x = 0 ;
foreach ( $result2 as $row2 ) {
if ( $row2 [ 'dialplan_detail_tag' ] == " action " ) {
$group = $row2 [ 'dialplan_detail_group' ];
foreach ( $row2 as $key => $val ) {
$details [ $group ][ 'action-' . $x ][ $key ] = $val ;
2012-06-04 16:58:40 +02:00
}
}
2012-07-03 18:22:58 +02:00
$x ++ ;
}
//anti-actions
$x = 0 ;
foreach ( $result2 as $row2 ) {
if ( $row2 [ 'dialplan_detail_tag' ] == " anti-action " ) {
$group = $row2 [ 'dialplan_detail_group' ];
foreach ( $row2 as $key => $val ) {
$details [ $group ][ 'anti-action-' . $x ][ $key ] = $val ;
2012-06-04 16:58:40 +02:00
}
}
2012-07-03 18:22:58 +02:00
$x ++ ;
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
unset ( $result2 );
}
$i = 1 ;
if ( $result_count2 > 0 ) {
foreach ( $details as $group ) {
$current_count = 0 ;
$x = 0 ;
foreach ( $group as $ent ) {
$close_condition_tag = true ;
if ( empty ( $ent )) {
$close_condition_tag = false ;
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
$current_tag = $ent [ 'dialplan_detail_tag' ];
$c = 0 ;
if ( $ent [ 'dialplan_detail_tag' ] == " condition " ) {
//get the generic type
switch ( $ent [ 'dialplan_detail_type' ]) {
2015-03-15 02:15:23 +01:00
case " hour " :
case " minute " :
case " minute-of-day " :
case " time-of-day " :
case " mday " :
case " mweek " :
case " mon " :
case " yday " :
case " year " :
case " wday " :
case " week " :
$type = 'time' ;
break ;
default :
$type = 'default' ;
2012-07-03 18:22:58 +02:00
}
2012-06-04 16:58:40 +02:00
2012-07-03 18:22:58 +02:00
//set the attribute and expression
$condition_attribute = '' ;
foreach ( $ent [ 'field' ] as $field ) {
if ( $type == " time " ) {
if ( strlen ( $field [ 'type' ]) > 0 ) {
$condition_attribute .= $field [ 'type' ] . '="' . $field [ 'data' ] . '" ' ;
}
$condition_expression = '' ;
}
if ( $type == " default " ) {
$condition_attribute = '' ;
if ( strlen ( $field [ 'type' ]) > 0 ) {
$condition_attribute = 'field="' . $field [ 'type' ] . '" ' ;
}
$condition_expression = '' ;
if ( strlen ( $field [ 'data' ]) > 0 ) {
$condition_expression = 'expression="' . $field [ 'data' ] . '" ' ;
}
}
}
//get the condition break attribute
$condition_break = '' ;
if ( strlen ( $ent [ 'dialplan_detail_break' ]) > 0 ) {
$condition_break = " break= \" " . $ent [ 'dialplan_detail_break' ] . " \" " ;
}
//get the count
$count = 0 ;
foreach ( $details as $group2 ) {
foreach ( $group2 as $ent2 ) {
if ( $ent2 [ 'dialplan_detail_group' ] == $ent [ 'dialplan_detail_group' ] && $ent2 [ 'dialplan_detail_tag' ] == " condition " ) {
$count ++ ;
}
}
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
//use the correct type of dialplan_detail_tag open or self closed
if ( $count == 1 ) { //single condition
//start dialplan_detail_tag
$tmp .= " <condition " . $condition_attribute . " " . $condition_expression . " " . $condition_break . " > \n " ;
}
else { //more than one condition
$current_count ++ ;
if ( $current_count < $count ) {
//all tags should be self-closing except the last one
$tmp .= " <condition " . $condition_attribute . " " . $condition_expression . " " . $condition_break . " /> \n " ;
}
else {
//for the last dialplan_detail_tag use the start dialplan_detail_tag
$tmp .= " <condition " . $condition_attribute . " " . $condition_expression . " " . $condition_break . " > \n " ;
}
}
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
//actions
if ( $ent [ 'dialplan_detail_tag' ] == " action " ) {
2014-07-09 08:07:56 +02:00
//set the domain info for the public context
if ( $row [ 'dialplan_context' ] == " public " ) {
2014-07-09 09:36:13 +02:00
if ( $first_action ) {
$tmp .= " <action application= \" set \" data= \" call_direction=inbound \" /> \n " ;
$tmp .= " <action application= \" set \" data= \" domain_uuid= " . $row [ 'domain_uuid' ] . " \" /> \n " ;
$tmp .= " <action application= \" set \" data= \" domain_name= " . $_SESSION [ 'domains' ][ $row [ 'domain_uuid' ]][ 'domain_name' ] . " \" /> \n " ;
$tmp .= " <action application= \" set \" data= \" domain= " . $_SESSION [ 'domains' ][ $row [ 'domain_uuid' ]][ 'domain_name' ] . " \" /> \n " ;
$first_action = false ;
}
2014-07-09 08:07:56 +02:00
}
2012-07-03 18:22:58 +02:00
//get the action inline attribute
$action_inline = '' ;
if ( strlen ( $ent [ 'dialplan_detail_inline' ]) > 0 ) {
$action_inline = " inline= \" " . $ent [ 'dialplan_detail_inline' ] . " \" " ;
}
if ( strlen ( $ent [ 'dialplan_detail_data' ]) > 0 ) {
$tmp .= " <action application= \" " . $ent [ 'dialplan_detail_type' ] . " \" data= \" " . $ent [ 'dialplan_detail_data' ] . " \" $action_inline /> \n " ;
}
else {
$tmp .= " <action application= \" " . $ent [ 'dialplan_detail_type' ] . " \" $action_inline /> \n " ;
}
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
//anti-actions
if ( $ent [ 'dialplan_detail_tag' ] == " anti-action " ) {
2014-07-09 07:56:01 +02:00
//get the action inline attribute
$anti_action_inline = '' ;
if ( strlen ( $ent [ 'dialplan_detail_inline' ]) > 0 ) {
$anti_action_inline = " inline= \" " . $ent [ 'dialplan_detail_inline' ] . " \" " ;
}
2012-07-03 18:22:58 +02:00
if ( strlen ( $ent [ 'dialplan_detail_data' ]) > 0 ) {
2014-07-09 07:56:01 +02:00
$tmp .= " <anti-action application= \" " . $ent [ 'dialplan_detail_type' ] . " \" data= \" " . $ent [ 'dialplan_detail_data' ] . " \" $anti_action_inline /> \n " ;
2012-07-03 18:22:58 +02:00
}
else {
2014-07-09 07:56:01 +02:00
$tmp .= " <anti-action application= \" " . $ent [ 'dialplan_detail_type' ] . " \" $anti_action_inline /> \n " ;
2012-07-03 18:22:58 +02:00
}
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
//set the previous dialplan_detail_tag
$previous_tag = $ent [ 'dialplan_detail_tag' ];
$i ++ ;
} //end foreach
if ( $close_condition_tag == true ) {
$tmp .= " </condition> \n " ;
}
$x ++ ;
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
if ( $condition_count > 0 ) {
$condition_count = $result_count2 ;
}
unset ( $sql , $result_count2 , $result2 , $row_count2 );
} //end if results
$tmp .= " </extension> \n " ;
$dialplan_order = $row [ 'dialplan_order' ];
if ( strlen ( $dialplan_order ) == 0 ) { $dialplan_order = " 000 " . $dialplan_order ; }
if ( strlen ( $dialplan_order ) == 1 ) { $dialplan_order = " 00 " . $dialplan_order ; }
if ( strlen ( $dialplan_order ) == 2 ) { $dialplan_order = " 0 " . $dialplan_order ; }
if ( strlen ( $dialplan_order ) == 4 ) { $dialplan_order = " 999 " ; }
if ( strlen ( $dialplan_order ) == 5 ) { $dialplan_order = " 999 " ; }
//remove invalid characters from the file names
$dialplan_name = $row [ 'dialplan_name' ];
$dialplan_name = str_replace ( " " , " _ " , $dialplan_name );
$dialplan_name = preg_replace ( " /[ \ * \ : \\ / \ < \ > \ | \ ' \" \ ?]/ " , " " , $dialplan_name );
$dialplan_filename = $dialplan_order . " _v_ " . $dialplan_name . " .xml " ;
if ( strlen ( $row [ 'dialplan_context' ]) > 0 ) {
if ( ! is_dir ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " / " . $row [ 'dialplan_context' ])) {
mkdir ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " / " . $row [ 'dialplan_context' ], 0755 , true );
}
if ( $row [ 'dialplan_context' ] == " public " ) {
2014-02-04 09:36:18 +01:00
if ( count ( $_SESSION [ 'domains' ]) > 1 && strlen ( $row [ 'domain_uuid' ]) > 0 ) {
2012-07-03 18:22:58 +02:00
if ( ! is_dir ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " /public/ " . $_SESSION [ 'domains' ][ $row [ 'domain_uuid' ]][ 'domain_name' ])) {
mkdir ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " /public/ " . $_SESSION [ 'domains' ][ $row [ 'domain_uuid' ]][ 'domain_name' ], 0755 , true );
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
file_put_contents ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " /public/ " . $_SESSION [ 'domains' ][ $row [ 'domain_uuid' ]][ 'domain_name' ] . " / " . $dialplan_filename , $tmp );
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
else {
file_put_contents ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " /public/ " . $dialplan_filename , $tmp );
2012-06-04 16:58:40 +02:00
}
}
2012-07-03 18:22:58 +02:00
else {
if ( ! is_dir ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " / " . $row [ 'dialplan_context' ])) {
mkdir ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " / " . $row [ 'dialplan_context' ], 0755 , true );
}
file_put_contents ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ] . " / " . $row [ 'dialplan_context' ] . " / " . $dialplan_filename , $tmp );
}
2012-06-04 16:58:40 +02:00
}
2012-07-03 18:22:58 +02:00
unset ( $dialplan_filename );
unset ( $tmp );
} //end while
2012-06-04 16:58:40 +02:00
2012-08-30 16:33:11 +02:00
//apply settings
2012-07-03 18:22:58 +02:00
$_SESSION [ " reload_xml " ] = true ;
}
} //end if (is_dir($_SESSION['switch']['dialplan']['dir']))
2012-06-04 16:58:40 +02:00
}
if ( ! function_exists ( 'phone_letter_to_number' )) {
function phone_letter_to_number ( $tmp ) {
$tmp = strtolower ( $tmp );
if ( $tmp == " a " | $tmp == " b " | $tmp == " c " ) { return 2 ; }
if ( $tmp == " d " | $tmp == " e " | $tmp == " f " ) { return 3 ; }
if ( $tmp == " g " | $tmp == " h " | $tmp == " i " ) { return 4 ; }
if ( $tmp == " j " | $tmp == " k " | $tmp == " l " ) { return 5 ; }
if ( $tmp == " m " | $tmp == " n " | $tmp == " o " ) { return 6 ; }
if ( $tmp == " p " | $tmp == " q " | $tmp == " r " | $tmp == " s " ) { return 7 ; }
if ( $tmp == " t " | $tmp == " u " | $tmp == " v " ) { return 8 ; }
if ( $tmp == " w " | $tmp == " x " | $tmp == " y " | $tmp == " z " ) { return 9 ; }
}
}
if ( ! function_exists ( 'save_call_center_xml' )) {
function save_call_center_xml () {
global $db , $domain_uuid ;
2015-03-21 07:14:28 +01:00
if ( strlen ( $_SESSION [ 'switch' ][ 'call_center' ][ 'dir' ]) > 0 ) {
//include the classes
include " app/dialplan/resources/classes/dialplan.php " ;
2012-06-04 16:58:40 +02:00
2015-03-21 07:14:28 +01:00
$sql = " select * from v_call_center_queues " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
$result_count = count ( $result );
unset ( $prep_statement , $sql );
if ( $result_count > 0 ) {
foreach ( $result as $row ) {
//set the variables
$call_center_queue_uuid = $row [ " call_center_queue_uuid " ];
$domain_uuid = $row [ " domain_uuid " ];
$dialplan_uuid = $row [ " dialplan_uuid " ];
$queue_name = check_str ( $row [ " queue_name " ]);
$queue_extension = $row [ " queue_extension " ];
$queue_strategy = $row [ " queue_strategy " ];
$queue_moh_sound = $row [ " queue_moh_sound " ];
$queue_record_template = $row [ " queue_record_template " ];
$queue_time_base_score = $row [ " queue_time_base_score " ];
$queue_max_wait_time = $row [ " queue_max_wait_time " ];
$queue_max_wait_time_with_no_agent = $row [ " queue_max_wait_time_with_no_agent " ];
$queue_tier_rules_apply = $row [ " queue_tier_rules_apply " ];
$queue_tier_rule_wait_second = $row [ " queue_tier_rule_wait_second " ];
$queue_tier_rule_wait_multiply_level = $row [ " queue_tier_rule_wait_multiply_level " ];
$queue_tier_rule_no_agent_no_wait = $row [ " queue_tier_rule_no_agent_no_wait " ];
$queue_timeout_action = $row [ " queue_timeout_action " ];
$queue_discard_abandoned_after = $row [ " queue_discard_abandoned_after " ];
$queue_abandoned_resume_allowed = $row [ " queue_abandoned_resume_allowed " ];
$queue_cid_prefix = $row [ " queue_cid_prefix " ];
$queue_announce_sound = $row [ " queue_announce_sound " ];
$queue_announce_frequency = $row [ " queue_announce_frequency " ];
$queue_description = check_str ( $row [ " queue_description " ]);
//replace space with an underscore
$queue_name = str_replace ( " " , " _ " , $queue_name );
//add each Queue to the dialplan
if ( strlen ( $row [ 'call_center_queue_uuid' ]) > 0 ) {
$action = 'add' ; //set default action to add
$i = 0 ;
//determine the action add or update
if ( strlen ( $dialplan_uuid ) > 0 ) {
$sql = " select * from v_dialplans " ;
$sql .= " where dialplan_uuid = ' " . $dialplan_uuid . " ' " ;
$prep_statement_2 = $db -> prepare ( $sql );
$prep_statement_2 -> execute ();
while ( $row2 = $prep_statement_2 -> fetch ( PDO :: FETCH_ASSOC )) {
$action = 'update' ;
}
unset ( $sql , $prep_statement_2 );
2012-06-04 16:58:40 +02:00
}
2015-03-21 07:14:28 +01:00
if ( $action == 'add' ) {
//create queue entry in the dialplan
$dialplan_name = $queue_name ;
$dialplan_order = '210' ;
$dialplan_context = $_SESSION [ 'context' ];
$dialplan_enabled = 'true' ;
$dialplan_description = $queue_description ;
$app_uuid = '95788e50-9500-079e-2807-fd530b0ea370' ;
$dialplan_uuid = uuid ();
dialplan_add ( $domain_uuid , $dialplan_uuid , $dialplan_name , $dialplan_order , $dialplan_context , $dialplan_enabled , $dialplan_description , $app_uuid );
//add the dialplan_uuid to the call center table
$sql = " update v_call_center_queues set " ;
$sql .= " dialplan_uuid = ' $dialplan_uuid ' " ;
$sql .= " where domain_uuid = ' $domain_uuid ' " ;
$sql .= " and call_center_queue_uuid = ' " . $row [ 'call_center_queue_uuid' ] . " ' " ;
$db -> exec ( check_sql ( $sql ));
unset ( $sql );
}
if ( $action == 'update' ) {
//add the dialplan_uuid to the call center table
$sql = " update v_dialplans set " ;
$sql .= " dialplan_name = ' " . $queue_name . " ', " ;
$sql .= " dialplan_description = ' " . $queue_description . " ' " ;
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
$sql .= " and dialplan_uuid = ' " . $dialplan_uuid . " ' " ;
$db -> exec ( check_sql ( $sql ));
unset ( $sql );
//add the dialplan_uuid to the call center table
$sql = " delete from v_dialplan_details " ;
$sql .= " where domain_uuid = ' $domain_uuid ' " ;
$sql .= " and dialplan_uuid = ' $dialplan_uuid ' " ;
$db -> exec ( check_sql ( $sql ));
unset ( $sql );
}
//group 1
$dialplan = new dialplan ;
$dialplan -> domain_uuid = $domain_uuid ;
$dialplan -> dialplan_uuid = $dialplan_uuid ;
$dialplan -> dialplan_detail_tag = 'condition' ; //condition, action, antiaction
$dialplan -> dialplan_detail_type = '${caller_id_name}' ;
$dialplan -> dialplan_detail_data = '^([^#]+#)(.*)$' ;
$dialplan -> dialplan_detail_break = 'never' ;
$dialplan -> dialplan_detail_inline = '' ;
$dialplan -> dialplan_detail_group = '1' ;
$dialplan -> dialplan_detail_order = '010' ;
$dialplan -> dialplan_detail_add ();
unset ( $dialplan );
2015-02-07 19:28:12 +01:00
$dialplan = new dialplan ;
$dialplan -> domain_uuid = $domain_uuid ;
$dialplan -> dialplan_uuid = $dialplan_uuid ;
$dialplan -> dialplan_detail_tag = 'action' ; //condition, action, antiaction
$dialplan -> dialplan_detail_type = 'set' ;
2015-03-21 07:14:28 +01:00
$dialplan -> dialplan_detail_data = 'caller_id_name=$2' ;
$dialplan -> dialplan_detail_break = '' ;
$dialplan -> dialplan_detail_inline = '' ;
$dialplan -> dialplan_detail_group = '1' ;
$dialplan -> dialplan_detail_order = '020' ;
$dialplan -> dialplan_detail_add ();
unset ( $dialplan );
//group 2
$dialplan = new dialplan ;
$dialplan -> domain_uuid = $domain_uuid ;
$dialplan -> dialplan_uuid = $dialplan_uuid ;
$dialplan -> dialplan_detail_tag = 'condition' ; //condition, action, antiaction
$dialplan -> dialplan_detail_type = 'destination_number' ;
$dialplan -> dialplan_detail_data = '^' . $row [ 'queue_extension' ] . '$' ;
2015-02-07 19:28:12 +01:00
$dialplan -> dialplan_detail_break = '' ;
$dialplan -> dialplan_detail_inline = '' ;
$dialplan -> dialplan_detail_group = '2' ;
2015-03-21 07:14:28 +01:00
$dialplan -> dialplan_detail_order = '010' ;
2015-02-07 19:28:12 +01:00
$dialplan -> dialplan_detail_add ();
unset ( $dialplan );
2013-12-19 11:04:37 +01:00
$dialplan = new dialplan ;
$dialplan -> domain_uuid = $domain_uuid ;
$dialplan -> dialplan_uuid = $dialplan_uuid ;
$dialplan -> dialplan_detail_tag = 'action' ; //condition, action, antiaction
2015-03-21 07:14:28 +01:00
$dialplan -> dialplan_detail_type = 'answer' ;
$dialplan -> dialplan_detail_data = '' ;
2013-12-19 11:04:37 +01:00
$dialplan -> dialplan_detail_break = '' ;
$dialplan -> dialplan_detail_inline = '' ;
$dialplan -> dialplan_detail_group = '2' ;
2015-03-21 07:14:28 +01:00
$dialplan -> dialplan_detail_order = '020' ;
2013-12-19 11:04:37 +01:00
$dialplan -> dialplan_detail_add ();
unset ( $dialplan );
2015-03-21 07:14:28 +01:00
$dialplan = new dialplan ;
$dialplan -> domain_uuid = $domain_uuid ;
$dialplan -> dialplan_uuid = $dialplan_uuid ;
$dialplan -> dialplan_detail_tag = 'action' ; //condition, action, antiaction
$dialplan -> dialplan_detail_type = 'set' ;
$dialplan -> dialplan_detail_data = 'hangup_after_bridge=true' ;
$dialplan -> dialplan_detail_break = '' ;
$dialplan -> dialplan_detail_inline = '' ;
$dialplan -> dialplan_detail_group = '2' ;
$dialplan -> dialplan_detail_order = '030' ;
$dialplan -> dialplan_detail_add ();
unset ( $dialplan );
2012-06-04 16:58:40 +02:00
2015-03-21 07:14:28 +01:00
if ( strlen ( $queue_cid_prefix ) > 0 ) {
$dialplan = new dialplan ;
$dialplan -> domain_uuid = $domain_uuid ;
$dialplan -> dialplan_uuid = $dialplan_uuid ;
$dialplan -> dialplan_detail_tag = 'action' ; //condition, action, antiaction
$dialplan -> dialplan_detail_type = 'set' ;
$dialplan -> dialplan_detail_data = " effective_caller_id_name= " . $queue_cid_prefix . " - \$ { caller_id_name} " ;
$dialplan -> dialplan_detail_break = '' ;
$dialplan -> dialplan_detail_inline = '' ;
$dialplan -> dialplan_detail_group = '2' ;
$dialplan -> dialplan_detail_order = '040' ;
$dialplan -> dialplan_detail_add ();
unset ( $dialplan );
}
$dialplan = new dialplan ;
$dialplan -> domain_uuid = $domain_uuid ;
$dialplan -> dialplan_uuid = $dialplan_uuid ;
$dialplan -> dialplan_detail_tag = 'action' ; //condition, action, antiaction
$dialplan -> dialplan_detail_type = 'callcenter' ;
$dialplan -> dialplan_detail_data = $queue_name . " @ " . $_SESSION [ 'domains' ][ $domain_uuid ][ 'domain_name' ];
$dialplan -> dialplan_detail_break = '' ;
$dialplan -> dialplan_detail_inline = '' ;
$dialplan -> dialplan_detail_group = '2' ;
$dialplan -> dialplan_detail_order = '050' ;
$dialplan -> dialplan_detail_add ();
unset ( $dialplan );
if ( strlen ( $queue_timeout_action ) > 0 ) {
$action_array = explode ( " : " , $queue_timeout_action );
$dialplan = new dialplan ;
$dialplan -> domain_uuid = $domain_uuid ;
$dialplan -> dialplan_uuid = $dialplan_uuid ;
$dialplan -> dialplan_detail_tag = 'action' ; //condition, action, antiaction
$dialplan -> dialplan_detail_type = $action_array [ 0 ];
$dialplan -> dialplan_detail_data = substr ( $queue_timeout_action , strlen ( $action_array [ 0 ]) + 1 , strlen ( $queue_timeout_action ));
$dialplan -> dialplan_detail_break = '' ;
$dialplan -> dialplan_detail_inline = '' ;
$dialplan -> dialplan_detail_group = '2' ;
$dialplan -> dialplan_detail_order = '060' ;
$dialplan -> dialplan_detail_add ();
unset ( $dialplan );
}
$dialplan = new dialplan ;
$dialplan -> domain_uuid = $domain_uuid ;
$dialplan -> dialplan_uuid = $dialplan_uuid ;
$dialplan -> dialplan_detail_tag = 'action' ; //condition, action, antiaction
$dialplan -> dialplan_detail_type = 'hangup' ;
$dialplan -> dialplan_detail_data = '' ;
$dialplan -> dialplan_detail_break = '' ;
$dialplan -> dialplan_detail_inline = '' ;
$dialplan -> dialplan_detail_group = '2' ;
$dialplan -> dialplan_detail_order = '070' ;
$dialplan -> dialplan_detail_add ();
unset ( $dialplan );
//synchronize the xml config
save_dialplan_xml ();
//unset variables
unset ( $action );
} //end if strlen call_center_queue_uuid; add the call center queue to the dialplan
2012-06-04 16:58:40 +02:00
}
2015-03-21 07:14:28 +01:00
//prepare Queue XML string
$v_queues = '' ;
$sql = " select * from v_call_center_queues " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
$x = 0 ;
foreach ( $result as & $row ) {
$queue_name = $row [ " queue_name " ];
$queue_extension = $row [ " queue_extension " ];
$queue_strategy = $row [ " queue_strategy " ];
$queue_moh_sound = $row [ " queue_moh_sound " ];
$queue_record_template = $row [ " queue_record_template " ];
$queue_time_base_score = $row [ " queue_time_base_score " ];
$queue_max_wait_time = $row [ " queue_max_wait_time " ];
$queue_max_wait_time_with_no_agent = $row [ " queue_max_wait_time_with_no_agent " ];
$queue_tier_rules_apply = $row [ " queue_tier_rules_apply " ];
$queue_tier_rule_wait_second = $row [ " queue_tier_rule_wait_second " ];
$queue_tier_rule_wait_multiply_level = $row [ " queue_tier_rule_wait_multiply_level " ];
$queue_tier_rule_no_agent_no_wait = $row [ " queue_tier_rule_no_agent_no_wait " ];
$queue_discard_abandoned_after = $row [ " queue_discard_abandoned_after " ];
$queue_abandoned_resume_allowed = $row [ " queue_abandoned_resume_allowed " ];
$queue_announce_sound = $row [ " queue_announce_sound " ];
$queue_announce_frequency = $row [ " queue_announce_frequency " ];
$queue_description = $row [ " queue_description " ];
2012-06-04 16:58:40 +02:00
if ( $x > 0 ) {
2015-03-21 07:14:28 +01:00
$v_queues .= " \n " ;
$v_queues .= " " ;
2012-06-04 16:58:40 +02:00
}
2015-03-21 07:14:28 +01:00
$v_queues .= " <queue name= \" $queue_name @ " . $_SESSION [ 'domains' ][ $row [ " domain_uuid " ]][ 'domain_name' ] . " \" > \n " ;
$v_queues .= " <param name= \" strategy \" value= \" $queue_strategy\ " /> \n " ;
if ( strlen ( $queue_moh_sound ) == 0 ) {
$v_queues .= " <param name= \" moh-sound \" value= \" local_stream://default \" /> \n " ;
}
else {
if ( substr ( $queue_moh_sound , 0 , 15 ) == 'local_stream://' ) {
$v_queues .= " <param name= \" moh-sound \" value= \" " . $queue_moh_sound . " \" /> \n " ;
}
elseif ( substr ( $queue_moh_sound , 0 , 2 ) == '${' && substr ( $queue_moh_sound , - 5 ) == 'ring}' ) {
$v_queues .= " <param name= \" moh-sound \" value= \" tone_stream:// " . $queue_moh_sound . " ;loops=-1 \" /> \n " ;
2012-06-04 16:58:40 +02:00
}
else {
2015-03-21 07:14:28 +01:00
$v_queues .= " <param name= \" moh-sound \" value= \" " . $queue_moh_sound . " \" /> \n " ;
2012-06-04 16:58:40 +02:00
}
}
2015-03-21 07:14:28 +01:00
if ( strlen ( $queue_record_template ) > 0 ) {
$v_queues .= " <param name= \" record-template \" value= \" $queue_record_template\ " /> \n " ;
}
$v_queues .= " <param name= \" time-base-score \" value= \" $queue_time_base_score\ " /> \n " ;
$v_queues .= " <param name= \" max-wait-time \" value= \" $queue_max_wait_time\ " /> \n " ;
$v_queues .= " <param name= \" max-wait-time-with-no-agent \" value= \" $queue_max_wait_time_with_no_agent\ " /> \n " ;
$v_queues .= " <param name= \" max-wait-time-with-no-agent-time-reached \" value= \" $queue_max_wait_time_with_no_agent_time_reached\ " /> \n " ;
$v_queues .= " <param name= \" tier-rules-apply \" value= \" $queue_tier_rules_apply\ " /> \n " ;
$v_queues .= " <param name= \" tier-rule-wait-second \" value= \" $queue_tier_rule_wait_second\ " /> \n " ;
$v_queues .= " <param name= \" tier-rule-wait-multiply-level \" value= \" $queue_tier_rule_wait_multiply_level\ " /> \n " ;
$v_queues .= " <param name= \" tier-rule-no-agent-no-wait \" value= \" $queue_tier_rule_no_agent_no_wait\ " /> \n " ;
$v_queues .= " <param name= \" discard-abandoned-after \" value= \" $queue_discard_abandoned_after\ " /> \n " ;
$v_queues .= " <param name= \" abandoned-resume-allowed \" value= \" $queue_abandoned_resume_allowed\ " /> \n " ;
$v_queues .= " <param name= \" announce-sound \" value= \" $queue_announce_sound\ " /> \n " ;
$v_queues .= " <param name= \" announce-frequency \" value= \" $queue_announce_frequency\ " /> \n " ;
$v_queues .= " </queue> " ;
$x ++ ;
}
unset ( $prep_statement );
//prepare Agent XML string
$v_agents = '' ;
$sql = " select * from v_call_center_agents " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
$x = 0 ;
foreach ( $result as & $row ) {
//get the values from the db and set as php variables
$agent_name = $row [ " agent_name " ];
$agent_type = $row [ " agent_type " ];
$agent_call_timeout = $row [ " agent_call_timeout " ];
$agent_contact = $row [ " agent_contact " ];
$agent_status = $row [ " agent_status " ];
$agent_no_answer_delay_time = $row [ " agent_no_answer_delay_time " ];
$agent_max_no_answer = $row [ " agent_max_no_answer " ];
$agent_wrap_up_time = $row [ " agent_wrap_up_time " ];
$agent_reject_delay_time = $row [ " agent_reject_delay_time " ];
$agent_busy_delay_time = $row [ " agent_busy_delay_time " ];
if ( $x > 0 ) {
$v_agents .= " \n " ;
$v_agents .= " " ;
}
//get and then set the complete agent_contact with the call_timeout and when necessary confirm
//$tmp_confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1";
//if you change this variable also change app/call_center/call_center_agent_edit.php
$tmp_confirm = " group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1,group_confirm_read_timeout=2000,leg_timeout= " . $agent_call_timeout ;
if ( strstr ( $agent_contact , '}' ) === FALSE ) {
2012-06-04 16:58:40 +02:00
//not found
2015-03-21 07:14:28 +01:00
if ( stristr ( $agent_contact , 'sofia/gateway' ) === FALSE ) {
2012-06-04 16:58:40 +02:00
//add the call_timeout
2015-03-21 07:14:28 +01:00
$tmp_agent_contact = " { call_timeout= " . $agent_call_timeout . " } " . $agent_contact ;
2012-06-04 16:58:40 +02:00
}
else {
2015-03-21 07:14:28 +01:00
//add the call_timeout and confirm
$tmp_agent_contact = $tmp_first . ',call_timeout=' . $agent_call_timeout . $tmp_last ;
$tmp_agent_contact = " { " . $tmp_confirm . " ,call_timeout= " . $agent_call_timeout . " } " . $agent_contact ;
2012-06-04 16:58:40 +02:00
}
}
else {
//found
2015-03-21 07:14:28 +01:00
if ( stristr ( $agent_contact , 'sofia/gateway' ) === FALSE ) {
//not found
if ( stristr ( $agent_contact , 'call_timeout' ) === FALSE ) {
//add the call_timeout
$tmp_pos = strrpos ( $agent_contact , " } " );
$tmp_first = substr ( $agent_contact , 0 , $tmp_pos );
$tmp_last = substr ( $agent_contact , $tmp_pos );
$tmp_agent_contact = $tmp_first . ',call_timeout=' . $agent_call_timeout . $tmp_last ;
}
else {
//the string has the call timeout
$tmp_agent_contact = $agent_contact ;
}
2012-06-04 16:58:40 +02:00
}
else {
2015-03-21 07:14:28 +01:00
//found
$tmp_pos = strrpos ( $agent_contact , " } " );
$tmp_first = substr ( $agent_contact , 0 , $tmp_pos );
$tmp_last = substr ( $agent_contact , $tmp_pos );
if ( stristr ( $agent_contact , 'call_timeout' ) === FALSE ) {
//add the call_timeout and confirm
$tmp_agent_contact = $tmp_first . ',' . $tmp_confirm . ',call_timeout=' . $agent_call_timeout . $tmp_last ;
}
else {
//add confirm
$tmp_agent_contact = $tmp_first . ',' . $tmp_confirm . $tmp_last ;
}
2012-06-04 16:58:40 +02:00
}
}
2015-03-21 07:14:28 +01:00
$v_agents .= " <agent " ;
$v_agents .= " name= \" $agent_name @ " . $_SESSION [ 'domains' ][ $row [ " domain_uuid " ]][ 'domain_name' ] . " \" " ;
$v_agents .= " type= \" $agent_type\ " " ;
$v_agents .= " contact= \" $tmp_agent_contact\ " " ;
$v_agents .= " status= \" $agent_status\ " " ;
$v_agents .= " no-answer-delay-time= \" $agent_no_answer_delay_time\ " " ;
$v_agents .= " max-no-answer= \" $agent_max_no_answer\ " " ;
$v_agents .= " wrap-up-time= \" $agent_wrap_up_time\ " " ;
$v_agents .= " reject-delay-time= \" $agent_reject_delay_time\ " " ;
$v_agents .= " busy-delay-time= \" $agent_busy_delay_time\ " " ;
$v_agents .= " /> " ;
$x ++ ;
2012-06-04 16:58:40 +02:00
}
2015-03-21 07:14:28 +01:00
unset ( $prep_statement );
2012-06-04 16:58:40 +02:00
2015-03-21 07:14:28 +01:00
//prepare Tier XML string
$v_tiers = '' ;
$sql = " select * from v_call_center_tiers " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ( PDO :: FETCH_ASSOC );
$x = 0 ;
foreach ( $result as & $row ) {
$agent_name = $row [ " agent_name " ];
$queue_name = $row [ " queue_name " ];
$tier_level = $row [ " tier_level " ];
$tier_position = $row [ " tier_position " ];
if ( $x > 0 ) {
$v_tiers .= " \n " ;
$v_tiers .= " " ;
}
$v_tiers .= " <tier agent= \" $agent_name @ " . $_SESSION [ 'domains' ][ $row [ " domain_uuid " ]][ 'domain_name' ] . " \" queue= \" $queue_name @ " . $_SESSION [ 'domains' ][ $row [ " domain_uuid " ]][ 'domain_name' ] . " \" level= \" $tier_level\ " position = \ " $tier_position\ " /> " ;
$x ++ ;
}
2014-04-13 06:45:05 +02:00
2015-03-21 07:14:28 +01:00
//set the path
if ( file_exists ( '/usr/share/examples/fusionpbx/resources/templates/conf' )) {
$path = " /usr/share/examples/fusionpbx/resources/templates/conf " ;
}
else {
$path = $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . " /resources/templates/conf " ;
}
2012-06-04 16:58:40 +02:00
2015-03-21 07:14:28 +01:00
//get the contents of the template
$file_contents = file_get_contents ( $path . " /autoload_configs/callcenter.conf.xml " );
2012-06-04 16:58:40 +02:00
2015-03-21 07:14:28 +01:00
//add the Call Center Queues, Agents and Tiers to the XML config
$file_contents = str_replace ( " { v_queues} " , $v_queues , $file_contents );
unset ( $v_queues );
2012-06-04 16:58:40 +02:00
2015-03-21 07:14:28 +01:00
$file_contents = str_replace ( " { v_agents} " , $v_agents , $file_contents );
unset ( $v_agents );
2012-06-04 16:58:40 +02:00
2015-03-21 07:14:28 +01:00
$file_contents = str_replace ( " { v_tiers} " , $v_tiers , $file_contents );
unset ( $v_tiers );
2012-06-04 16:58:40 +02:00
2015-03-21 07:14:28 +01:00
//write the XML config file
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /autoload_configs/callcenter.conf.xml " , " w " );
fwrite ( $fout , $file_contents );
fclose ( $fout );
2012-06-04 16:58:40 +02:00
2015-03-21 07:14:28 +01:00
//save the dialplan xml files
save_dialplan_xml ();
2012-08-10 17:53:02 +02:00
2015-03-21 07:14:28 +01:00
//apply settings
$_SESSION [ " reload_xml " ] = true ;
}
2012-06-04 16:58:40 +02:00
}
}
}
if ( ! function_exists ( 'switch_conf_xml' )) {
function switch_conf_xml () {
//get the global variables
global $db , $domain_uuid ;
//get the contents of the template
2014-10-23 20:03:33 +02:00
if ( file_exists ( '/usr/share/examples/fusionpbx/resources/templates/conf' )) {
$path = " /usr/share/examples/fusionpbx/resources/templates/conf " ;
2014-04-12 22:54:32 +02:00
}
else {
$path = $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . " /resources/templates/conf " ;
}
$file_contents = file_get_contents ( $path . " /autoload_configs/switch.conf.xml " );
2012-06-04 16:58:40 +02:00
2012-10-17 17:20:58 +02:00
//prepare the php variables
2012-06-04 16:58:40 +02:00
if ( stristr ( PHP_OS , 'WIN' )) {
$bindir = getenv ( PHPRC );
2013-06-03 18:32:02 +02:00
$v_mailer_app = '""' . $bindir . " /php " . '" -f ' . $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/secure/v_mailto.php -- "' ;
2012-06-04 16:58:40 +02:00
$v_mailer_app = sprintf ( " '%s' " , $v_mailer_app );
$v_mailer_app_args = " " ;
}
else {
if ( file_exists ( PHP_BINDIR . '/php' )) { define ( " PHP_BIN " , " php " ); }
$v_mailer_app = PHP_BINDIR . " / " . PHP_BIN . " " . $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . " /secure/v_mailto.php " ;
$v_mailer_app = sprintf ( '"%s"' , $v_mailer_app );
$v_mailer_app_args = " -t " ;
}
//replace the values in the template
$file_contents = str_replace ( " { v_mailer_app} " , $v_mailer_app , $file_contents );
unset ( $v_mailer_app );
//replace the values in the template
$file_contents = str_replace ( " { v_mailer_app_args} " , $v_mailer_app_args , $file_contents );
unset ( $v_mailer_app_args );
//write the XML config file
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /autoload_configs/switch.conf.xml " , " w " );
fwrite ( $fout , $file_contents );
fclose ( $fout );
2012-08-30 16:33:11 +02:00
//apply settings
2012-06-04 16:58:40 +02:00
$_SESSION [ " reload_xml " ] = true ;
}
}
if ( ! function_exists ( 'xml_cdr_conf_xml' )) {
function xml_cdr_conf_xml () {
//get the global variables
global $db , $domain_uuid ;
//get the contents of the template
2014-10-23 20:03:33 +02:00
if ( file_exists ( '/usr/share/examples/fusionpbx/resources/templates/conf' )) {
$path = " /usr/share/examples/fusionpbx/resources/templates/conf " ;
2014-04-13 00:10:22 +02:00
}
else {
2014-04-13 06:45:05 +02:00
$path = $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . " /resources/templates/conf " ;
2014-04-13 00:10:22 +02:00
}
2014-04-13 06:45:05 +02:00
$file_contents = file_get_contents ( $path . " /autoload_configs/xml_cdr.conf.xml " );
2012-06-04 16:58:40 +02:00
//replace the values in the template
$file_contents = str_replace ( " { v_http_protocol} " , " http " , $file_contents );
$file_contents = str_replace ( " { domain_name} " , " 127.0.0.1 " , $file_contents );
$file_contents = str_replace ( " { v_project_path} " , PROJECT_PATH , $file_contents );
$v_user = generate_password ();
$file_contents = str_replace ( " { v_user} " , $v_user , $file_contents );
unset ( $v_user );
$v_pass = generate_password ();
$file_contents = str_replace ( " { v_pass} " , $v_pass , $file_contents );
unset ( $v_pass );
//write the XML config file
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /autoload_configs/xml_cdr.conf.xml " , " w " );
fwrite ( $fout , $file_contents );
fclose ( $fout );
2012-08-30 16:33:11 +02:00
//apply settings
2012-06-04 16:58:40 +02:00
$_SESSION [ " reload_xml " ] = true ;
}
}
if ( ! function_exists ( 'save_sip_profile_xml' )) {
function save_sip_profile_xml () {
2014-03-22 03:03:04 +01:00
//skip saving the sip profile xml if the directory is not set
if ( strlen ( $_SESSION [ 'switch' ][ 'sip_profiles' ][ 'dir' ]) == 0 ) {
return ;
}
2012-06-04 16:58:40 +02:00
//get the global variables
global $db , $domain_uuid ;
//get the sip profiles from the database
$sql = " select * from v_sip_profiles " ;
2015-05-02 07:08:41 +02:00
$sql .= " where sip_profile_enabled = 'true' " ;
2012-06-04 16:58:40 +02:00
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ();
$result_count = count ( $result );
unset ( $prep_statement , $sql );
if ( $result_count > 0 ) {
foreach ( $result as $row ) {
$sip_profile_uuid = $row [ 'sip_profile_uuid' ];
$sip_profile_name = $row [ 'sip_profile_name' ];
//get the xml sip profile template
if ( $sip_profile_name == " internal " || $sip_profile_name == " external " || $sip_profile_name == " internal-ipv6 " ) {
$file_contents = file_get_contents ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . " /app/sip_profiles/resources/xml/sip_profiles/ " . $sip_profile_name . " .xml " );
}
else {
$file_contents = file_get_contents ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . " /app/sip_profiles/resources/xml/sip_profiles/default.xml " );
}
//get the sip profile settings
$sql = " select * from v_sip_profile_settings " ;
$sql .= " where sip_profile_uuid = ' $sip_profile_uuid ' " ;
$sql .= " and sip_profile_setting_enabled = 'true' " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$result = $prep_statement -> fetchAll ();
$sip_profile_settings = '' ;
foreach ( $result as & $row ) {
$sip_profile_settings .= " <param name= \" " . $row [ " sip_profile_setting_name " ] . " \" value= \" " . $row [ " sip_profile_setting_value " ] . " \" /> \n " ;
}
unset ( $prep_statement );
//replace the values in the template
$file_contents = str_replace ( " { v_sip_profile_name} " , $sip_profile_name , $file_contents );
$file_contents = str_replace ( " { v_sip_profile_settings} " , $sip_profile_settings , $file_contents );
//write the XML config file
if ( is_readable ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /sip_profiles/ " )) {
$fout = fopen ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /sip_profiles/ " . $sip_profile_name . " .xml " , " w " );
fwrite ( $fout , $file_contents );
fclose ( $fout );
}
//if the directory does not exist then create it
if ( ! is_readable ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /sip_profiles/ " . $sip_profile_name )) { mkdir ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ] . " /sip_profiles/ " . $sip_profile_name , 0775 , true ); }
} //end foreach
unset ( $sql , $result , $row_count );
} //end if results
2012-08-30 16:33:11 +02:00
//apply settings
2012-06-04 16:58:40 +02:00
$_SESSION [ " reload_xml " ] = true ;
}
}
if ( ! function_exists ( 'save_switch_xml' )) {
function save_switch_xml () {
if ( is_readable ( $_SESSION [ 'switch' ][ 'dialplan' ][ 'dir' ])) {
save_dialplan_xml ();
}
if ( is_readable ( $_SESSION [ 'switch' ][ 'extensions' ][ 'dir' ])) {
2015-03-18 07:17:09 +01:00
if ( file_exists ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . " /app/extensions/resources/classes/extension.php " )) {
require_once $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . " app/extensions/resources/classes/extension.php " ;
2014-07-15 07:46:15 +02:00
$extension = new extension ;
$extension -> xml ();
}
2012-06-04 16:58:40 +02:00
}
if ( is_readable ( $_SESSION [ 'switch' ][ 'conf' ][ 'dir' ])) {
2013-09-15 07:06:34 +02:00
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/settings/app_config.php " )) {
save_setting_xml ();
}
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/modules/app_config.php " )) {
save_module_xml ();
}
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/vars/app_config.php " )) {
save_var_xml ();
}
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/call_center/app_config.php " )) {
save_call_center_xml ();
}
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/gateways/app_config.php " )) {
save_gateway_xml ();
}
//if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/ivr_menu/app_config.php")) {
// save_ivr_menu_xml();
//}
if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . PROJECT_PATH . " /app/sip_profiles/app_config.php " )) {
save_sip_profile_xml ();
}
2012-06-04 16:58:40 +02:00
}
}
}
2015-03-27 02:09:25 +01:00
?>