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 >
2023-05-29 22:07:53 +02:00
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2023
2020-04-14 20:56:14 +02:00
the Initial Developer . All Rights Reserved .
2012-06-04 16:58:40 +02:00
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
2014-06-25 19:45:48 +02:00
Luis Daniel Lucio Quiroz < dlucio @ okay . com . mx >
2012-06-04 16:58:40 +02:00
*/
2016-08-28 20:58:19 +02:00
2022-10-11 00:35:14 +02:00
//includes files
2023-06-15 19:28:23 +02:00
require_once dirname ( __DIR__ , 2 ) . " /resources/require.php " ;
2016-08-28 20:58:19 +02:00
require_once " resources/check_auth.php " ;
//check permissions
if ( permission_exists ( 'extension_add' ) || permission_exists ( 'extension_edit' )) {
//access granted
}
else {
echo " access denied " ;
exit ;
}
2012-06-04 16:58:40 +02:00
2025-02-13 22:12:48 +01:00
//get the domain and user UUIDs
$domain_uuid = $domain_uuid ? ? '' ;
$user_uuid = $user_uuid ? ? '' ;
2024-07-27 01:04:02 +02:00
2013-05-04 02:35:21 +02:00
//add multi-lingual support
2015-01-18 11:06:08 +01:00
$language = new text ;
$text = $language -> get ();
2013-05-04 02:35:21 +02:00
2025-02-13 22:12:48 +01:00
//initialize the core objects
$domain_uuid = $_SESSION [ 'domain_uuid' ] ? ? '' ;
$user_uuid = $_SESSION [ 'user_uuid' ] ? ? '' ;
$config = config :: load ();
$database = database :: new ([ 'config' => $config ]);
$domain_name = $database -> select ( 'select domain_name from v_domains where domain_uuid = :domain_uuid' , [ 'domain_uuid' => $domain_uuid ], 'column' );
$settings = new settings ([ 'database' => $database , 'domain_uuid' => $domain_uuid , 'user_uuid' => $user_uuid ]);
//set defaults
$limit_extensions = $settings -> get ( 'limit' , 'extensions' , null );
$limit_devices = $settings -> get ( 'limit' , 'devices' , null );
$extension_limit_max = $settings -> get ( 'extension' , 'limit_max' , 5 );
$extension_call_timeout = $settings -> get ( 'extension' , 'call_timeout' , 30 );
$extension_max_registrations = $settings -> get ( 'extension' , 'max_registrations' , null );
$extension_password_length = $settings -> get ( 'extension' , 'password_length' , 20 ); //set default to 20
$extension_password_strength = $settings -> get ( 'extension' , 'password_strength' , 4 ); //set default to use numbers, Upper/Lowercase letters, special characters
$extension_user_record_default = $settings -> get ( 'extension' , 'user_record_default' , '' );
$provision_path = $settings -> get ( 'provision' , 'path' , '' );
$provision_line_label = $settings -> get ( 'provision' , 'line_label' , null );
$provision_line_display_name = $settings -> get ( 'provision' , 'line_display_name' , null );
$provision_outbound_proxy_primary = $settings -> get ( 'provision' , 'outbound_proxy_primary' , null );
$provision_outbound_proxy_secondary = $settings -> get ( 'provision' , 'outbound_proxy_primary' , null );
$provision_server_address_primary = $settings -> get ( 'provision' , 'outbound_proxy_primary' , null );
$provision_server_address_secondary = $settings -> get ( 'provision' , 'outbound_proxy_primary' , null );
$provision_line_sip_port = $settings -> get ( 'provision' , 'line_sip_port' , null );
$provision_line_sip_transport = $settings -> get ( 'provision' , 'line_sip_transport' , null );
$provision_line_register_expires = $settings -> get ( 'provision' , 'line_register_expires' , null );
$theme_input_toggle_style = $settings -> get ( 'theme' , 'input_toggle_style' , '' ); //set default to empty string
$voicemail_password_length = $settings -> get ( 'voicemail' , 'password_length' , 6 ); //set default to 6
$voicemail_transcription_enabled_default = $settings -> get ( 'voicemail' , 'transcription_enabled_default' , false ); //set default to false
$voicemail_enabled_default = $settings -> get ( 'voicemail' , 'enabled_default' , true );
$switch_voicemail = $settings -> get ( 'switch' , 'voicemail' , '/var/lib/freeswitch/storage/voicemail' ) . " /default/ $domain_name " ;
$switch_extensions = $settings -> get ( 'switch' , 'extensions' , '/etc/freeswitch/directory' );
$switch_sounds = $settings -> get ( 'switch' , 'sounds' , '/usr/share/freeswitch/sounds' );
$transcribe_enabled = $settings -> get ( 'transcribe' , 'enabled' , false );
//cast to integers if they have values
if ( $limit_extensions !== null ) $limit_extensions = intval ( $limit_extensions );
if ( $limit_devices !== null ) $limit_devices = intval ( $limit_devices );
if ( $extension_password_length !== null ) $extension_password_length = intval ( $extension_password_length );
if ( $extension_max_registrations !== null ) $extension_max_registrations = intval ( $extension_max_registrations );
2012-06-04 16:58:40 +02:00
//set the action as an add or an update
2023-05-17 09:02:45 +02:00
if ( ! empty ( $_REQUEST [ " id " ]) && is_uuid ( $_REQUEST [ " id " ])) {
2012-06-04 16:58:40 +02:00
$action = " update " ;
2016-11-24 11:21:35 +01:00
$extension_uuid = $_REQUEST [ " id " ];
2023-06-22 20:35:59 +02:00
$page = $_REQUEST [ 'page' ] ? ? null ;
2012-06-04 16:58:40 +02:00
}
else {
$action = " add " ;
}
2015-03-22 09:17:04 +01:00
//get total extension count from the database, check limit, if defined
if ( $action == 'add' ) {
2025-02-13 22:12:48 +01:00
if ( $limit_extensions > 0 ) {
$sql = " select count(extension_uuid) " ;
2019-08-07 03:49:59 +02:00
$sql .= " from v_extensions " ;
$sql .= " where domain_uuid = :domain_uuid " ;
2025-02-13 22:12:48 +01:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
2019-08-07 03:49:59 +02:00
$total_extensions = $database -> select ( $sql , $parameters , 'column' );
unset ( $sql , $parameters );
2025-02-13 22:12:48 +01:00
if ( $total_extensions >= $limit_extensions ) {
message :: add ( $text [ 'message-maximum_extensions' ] . ' ' . $limit_extensions , 'negative' );
2023-06-13 01:06:56 +02:00
header ( 'Location: extensions.php' . ( isset ( $page ) && is_numeric ( $page ) ? '?page=' . $page : null ));
2019-08-07 03:49:59 +02:00
exit ;
2015-03-22 09:17:04 +01:00
}
}
}
2012-06-04 16:58:40 +02:00
//get the http values and set them as php variables
2023-06-29 17:32:43 +02:00
if ( ! empty ( $_POST )) {
2018-03-21 01:15:15 +01:00
2012-06-04 16:58:40 +02:00
//get the values from the HTTP POST and save them as PHP variables
2021-01-22 20:12:29 +01:00
if ( $action == 'add' || permission_exists ( " extension_extension " )) {
$extension = str_replace ( ' ' , '-' , $_POST [ " extension " ]);
}
else { //lookup extension based on submitted uuid
$sql = " select extension from v_extensions where extension_uuid = :extension_uuid " ;
$parameters [ 'extension_uuid' ] = $extension_uuid ;
$extension = $database -> select ( $sql , $parameters , 'column' );
unset ( $sql , $parameters );
}
2023-05-17 09:02:45 +02:00
$number_alias = $_POST [ " number_alias " ] ? ? null ;
$password = $_POST [ " password " ] ? ? null ;
2014-08-08 14:37:06 +02:00
2020-03-29 04:16:05 +02:00
//server verification on account code
2016-10-14 15:42:01 +02:00
$accountcode = $_POST [ " accountcode " ];
2014-08-08 14:37:06 +02:00
2016-11-24 11:21:35 +01:00
$effective_caller_id_name = $_POST [ " effective_caller_id_name " ];
$effective_caller_id_number = $_POST [ " effective_caller_id_number " ];
$outbound_caller_id_name = $_POST [ " outbound_caller_id_name " ];
$outbound_caller_id_number = $_POST [ " outbound_caller_id_number " ];
2023-06-09 20:40:15 +02:00
$emergency_caller_id_name = $_POST [ " emergency_caller_id_name " ] ? ? null ;
$emergency_caller_id_number = $_POST [ " emergency_caller_id_number " ] ? ? null ;
2017-06-17 19:37:22 +02:00
$directory_first_name = $_POST [ " directory_first_name " ];
$directory_last_name = $_POST [ " directory_last_name " ];
2016-11-24 11:21:35 +01:00
$directory_visible = $_POST [ " directory_visible " ];
$directory_exten_visible = $_POST [ " directory_exten_visible " ];
2021-04-11 06:28:06 +02:00
$max_registrations = $_POST [ " max_registrations " ];
2016-11-24 11:21:35 +01:00
$limit_max = $_POST [ " limit_max " ];
$limit_destination = $_POST [ " limit_destination " ];
2020-03-29 04:16:05 +02:00
//$device_uuid = $_POST["device_uuid"];
//$device_line = $_POST["device_line"];
2016-11-24 11:21:35 +01:00
$voicemail_password = $_POST [ " voicemail_password " ];
2023-05-17 09:02:45 +02:00
$voicemail_enabled = $_POST [ " voicemail_enabled " ] ? ? 'false' ;
2016-11-24 11:21:35 +01:00
$voicemail_mail_to = $_POST [ " voicemail_mail_to " ];
2022-01-29 10:28:07 +01:00
$voicemail_transcription_enabled = $_POST [ " voicemail_transcription_enabled " ];
2016-11-24 11:21:35 +01:00
$voicemail_file = $_POST [ " voicemail_file " ];
$voicemail_local_after_email = $_POST [ " voicemail_local_after_email " ];
$user_context = $_POST [ " user_context " ];
2023-05-17 09:02:45 +02:00
$range = $_POST [ " range " ] ? ? null ;
2016-11-24 11:21:35 +01:00
$missed_call_app = $_POST [ " missed_call_app " ];
$missed_call_data = $_POST [ " missed_call_data " ];
$toll_allow = $_POST [ " toll_allow " ];
$call_timeout = $_POST [ " call_timeout " ];
$call_group = $_POST [ " call_group " ];
$call_screen_enabled = $_POST [ " call_screen_enabled " ];
$user_record = $_POST [ " user_record " ];
$hold_music = $_POST [ " hold_music " ];
$auth_acl = $_POST [ " auth_acl " ];
$cidr = $_POST [ " cidr " ];
$sip_force_contact = $_POST [ " sip_force_contact " ];
$sip_force_expires = $_POST [ " sip_force_expires " ];
2023-05-17 09:02:45 +02:00
$nibble_account = $_POST [ " nibble_account " ] ? ? null ;
2016-11-24 11:21:35 +01:00
$mwi_account = $_POST [ " mwi_account " ];
$sip_bypass_media = $_POST [ " sip_bypass_media " ];
$absolute_codec_string = $_POST [ " absolute_codec_string " ];
$force_ping = $_POST [ " force_ping " ];
$dial_string = $_POST [ " dial_string " ];
2024-01-10 23:55:00 +01:00
$extension_language = $_POST [ " extension_language " ];
2023-07-14 01:11:07 +02:00
$extension_type = $_POST [ " extension_type " ];
2023-05-17 09:02:45 +02:00
$enabled = $_POST [ " enabled " ] ? ? 'false' ;
2016-11-24 11:21:35 +01:00
$description = $_POST [ " description " ];
2017-04-14 10:12:24 +02:00
2024-01-10 23:55:00 +01:00
//set defaults
$extension_language = $extension_language ? ? '' ;
2021-10-20 18:58:23 +02:00
//outbound caller id number - only allow numeric and +
2023-05-05 18:46:37 +02:00
if ( ! empty ( $outbound_caller_id_number )) {
2021-10-20 18:58:23 +02:00
$outbound_caller_id_number = preg_replace ( '#[^\+0-9]#' , '' , $outbound_caller_id_number );
}
2017-04-14 10:12:24 +02:00
$voicemail_id = $extension ;
2023-05-05 18:46:37 +02:00
if ( permission_exists ( 'number_alias' ) && ! empty ( $number_alias )) {
2017-04-14 10:12:24 +02:00
$voicemail_id = $number_alias ;
}
2020-05-28 03:10:20 +02:00
2020-12-14 02:18:02 +01:00
$cidrs = preg_split ( " /[ \ s,]+/ " , $cidr );
2021-09-19 08:42:40 +02:00
$ips = array ();
foreach ( $cidrs as $ipaddr ){
$cx = strpos ( $ipaddr , '/' );
if ( $cx ){
$subnet = ( int )( substr ( $ipaddr , $cx + 1 ));
$ipaddr = substr ( $ipaddr , 0 , $cx );
}
else {
$subnet = 32 ;
}
2024-01-10 23:55:00 +01:00
2021-09-19 08:42:40 +02:00
if (( $addr = inet_pton ( $ipaddr )) !== false ){
$ips [] = $ipaddr . '/' . $subnet ;
}
}
$cidr = implode ( ',' , $ips );
2020-03-29 04:16:05 +02:00
//change toll allow delimiter
2019-01-19 21:38:55 +01:00
$toll_allow = str_replace ( ',' , ':' , $toll_allow );
2020-03-29 04:16:05 +02:00
//set assigned user variables
2023-05-17 09:02:45 +02:00
$user_uuid = $_POST [ " extension_users " ][ 0 ][ " user_uuid " ] ? ? null ;
2020-03-29 04:16:05 +02:00
//device provisioning variables
2025-02-13 22:12:48 +01:00
if ( ! empty ( $_POST [ " devices " ])) {
2023-07-01 00:40:17 +02:00
//get the devices
$sql = " select count(device_uuid) from v_devices " ;
$sql .= " where domain_uuid = :domain_uuid " ;
if ( ! permission_exists ( 'device_all' ) && ! permission_exists ( 'device_domain_all' )) {
$sql .= " and device_user_uuid = :user_uuid " ;
2025-02-13 22:12:48 +01:00
$parameters [ 'user_uuid' ] = $user_uuid ;
2023-07-01 00:40:17 +02:00
}
$sql .= " order by device_address asc " ;
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$total_devices = $database -> select ( $sql , $parameters , 'column' );
unset ( $sql , $parameters );
2020-03-29 04:16:05 +02:00
foreach ( $_POST [ " devices " ] as $d => $device ) {
2023-07-01 00:40:17 +02:00
if (
2023-07-03 16:33:34 +02:00
! empty ( $device [ " device_address " ]) &&
strtolower ( $device [ " device_address " ]) == 'uuid' &&
2023-07-01 00:40:17 +02:00
(
2025-02-13 22:12:48 +01:00
$limit_devices === null ||
$total_devices < $limit_devices
2023-07-01 00:40:17 +02:00
)) {
$device_address = strtolower ( uuid ());
}
else {
$device_address = strtolower ( $device [ " device_address " ]);
}
2023-07-03 20:04:19 +02:00
$device_address = preg_replace ( '#[^a-fA-F0-9./]#' , '' , $device_address );
2020-03-29 04:16:05 +02:00
$line_numbers [ $d ] = $device [ " line_number " ];
2023-06-30 07:40:11 +02:00
$device_addresses [ $d ] = $device_address ;
2020-03-29 04:16:05 +02:00
$device_templates [ $d ] = $device [ " device_template " ];
}
}
//get or set the device_uuid
2023-06-30 07:40:11 +02:00
if ( ! empty ( $device_addresses ) && is_array ( $device_addresses ) && @ sizeof ( $device_addresses ) != 0 ) {
foreach ( $device_addresses as $d => $device_address ) {
$device_address = strtolower ( $device_address );
$device_address = preg_replace ( '#[^a-fA-F0-9./]#' , '' , $device_address );
2020-05-28 03:10:20 +02:00
2021-09-19 08:42:40 +02:00
$sql = " select " ;
$sql .= " d1.device_uuid, " ;
$sql .= " d1.domain_uuid, " ;
$sql .= " d2.domain_name " ;
$sql .= " from " ;
$sql .= " v_devices as d1, " ;
$sql .= " v_domains as d2 " ;
$sql .= " where " ;
$sql .= " d1.domain_uuid = d2.domain_uuid and " ;
2023-06-30 07:40:11 +02:00
$sql .= " d1.device_address = :device_address " ;
$parameters [ 'device_address' ] = $device_address ;
2021-09-19 08:42:40 +02:00
$row = $database -> select ( $sql , $parameters , 'row' );
if ( is_array ( $row )) {
2025-02-13 22:12:48 +01:00
if ( $domain_uuid == $row [ 'domain_uuid' ]) {
2021-09-19 08:42:40 +02:00
$device_uuid = $row [ 'device_uuid' ];
$device_domain_name = $row [ 'device_domain_name' ];
2021-09-24 01:55:32 +02:00
$device_unique = true ;
2021-09-19 08:42:40 +02:00
}
else {
$device_domain_name = $row [ 'device_domain_name' ];
2021-09-24 01:55:32 +02:00
$device_unique = false ;
2021-09-19 08:42:40 +02:00
}
}
else {
$device_unique = true ;
}
2020-05-28 03:10:20 +02:00
unset ( $sql , $parameters );
2023-05-17 09:02:45 +02:00
$device_uuids [ $d ] = ! empty ( $device_uuid ) && is_uuid ( $device_uuid ) ? $device_uuid : uuid ();
2020-03-29 04:16:05 +02:00
}
}
2012-06-04 16:58:40 +02:00
}
//delete the user from the v_extension_users
2023-05-17 09:02:45 +02:00
if ( ! empty ( $_REQUEST [ " delete_type " ]) && $_REQUEST [ " delete_type " ] == " user " && is_uuid ( $_REQUEST [ " delete_uuid " ]) && permission_exists ( " extension_delete " )) {
2012-06-04 16:58:40 +02:00
//set the variables
2016-11-24 11:21:35 +01:00
$extension_uuid = $_REQUEST [ " id " ];
$user_uuid = $_REQUEST [ " delete_uuid " ];
2021-11-10 16:12:22 +01:00
2012-06-04 16:58:40 +02:00
//delete the group from the users
2019-08-07 03:49:59 +02:00
$array [ 'extension_users' ][ 0 ][ 'extension_uuid' ] = $extension_uuid ;
$array [ 'extension_users' ][ 0 ][ 'user_uuid' ] = $user_uuid ;
2020-07-03 04:16:39 +02:00
//add temporary permission
2024-11-29 21:57:01 +01:00
$p = permissions :: new ();
2019-08-07 03:49:59 +02:00
$p -> add ( 'extension_user_delete' , 'temp' );
2020-07-03 04:16:39 +02:00
//save the array
2019-08-07 03:49:59 +02:00
$database -> app_name = 'extensions' ;
$database -> app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3' ;
$database -> delete ( $array );
unset ( $array );
2020-07-03 04:16:39 +02:00
//remove temporary permission
2019-08-07 03:49:59 +02:00
$p -> delete ( 'extension_user_delete' , 'temp' );
2020-07-03 04:16:39 +02:00
2020-03-29 04:16:05 +02:00
//redirect
header ( " Location: extension_edit.php?id= " . $extension_uuid );
exit ;
2012-06-04 16:58:40 +02:00
}
2013-11-26 11:14:38 +01:00
//delete the line from the v_device_lines
2014-03-04 06:59:34 +01:00
if ( is_dir ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/app/devices' )) {
2023-05-17 09:02:45 +02:00
if ( ! empty ( $_REQUEST [ " delete_type " ]) && $_REQUEST [ " delete_type " ] == " device_line " && is_uuid ( $_REQUEST [ " delete_uuid " ]) && permission_exists ( " extension_delete " )) {
2014-03-04 06:59:34 +01:00
//set the variables
2016-11-24 11:21:35 +01:00
$device_line_uuid = $_REQUEST [ " delete_uuid " ];
2020-07-03 04:16:39 +02:00
2014-03-04 06:59:34 +01:00
//delete device_line
2019-08-07 03:49:59 +02:00
$array [ 'device_lines' ][ 0 ][ 'device_line_uuid' ] = $device_line_uuid ;
2020-07-03 04:16:39 +02:00
//add temporary permission
2024-11-29 21:57:01 +01:00
$p = permissions :: new ();
2019-08-07 03:49:59 +02:00
$p -> add ( 'device_line_delete' , 'temp' );
2020-07-03 04:16:39 +02:00
//save the array
2019-08-07 03:49:59 +02:00
$database -> app_name = 'extensions' ;
$database -> app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3' ;
$database -> delete ( $array );
unset ( $array );
2020-07-03 04:16:39 +02:00
//remove temporary permission
2019-08-07 03:49:59 +02:00
$p -> delete ( 'device_line_delete' , 'temp' );
2020-07-03 04:16:39 +02:00
2020-03-29 04:16:05 +02:00
//redirect
header ( " Location: extension_edit.php?id= " . $extension_uuid );
exit ;
2014-03-04 06:59:34 +01:00
}
2013-04-28 09:24:41 +02:00
}
2016-10-05 07:55:02 +02:00
//process the user data and save it to the database
2023-06-29 17:32:43 +02:00
if ( ! empty ( $_POST ) && empty ( $_POST [ " persistformvar " ])) {
2015-01-20 21:59:27 +01:00
2016-10-05 07:55:02 +02:00
//set the domain_uuid
2020-07-03 04:16:39 +02:00
if ( permission_exists ( 'extension_domain' ) && is_uuid ( $_POST [ " domain_uuid " ])) {
$domain_uuid = $_POST [ " domain_uuid " ];
}
else {
2025-02-13 22:12:48 +01:00
$domain_uuid = $domain_uuid ;
2020-07-03 04:16:39 +02:00
}
2012-06-04 16:58:40 +02:00
2019-09-19 14:22:40 +02:00
//validate the token
$token = new token ;
if ( ! $token -> validate ( $_SERVER [ 'PHP_SELF' ])) {
message :: add ( $text [ 'message-invalid_token' ], 'negative' );
header ( 'Location: extensions.php' );
exit ;
}
2016-10-05 07:55:02 +02:00
//check for all required data
$msg = '' ;
2023-05-05 18:46:37 +02:00
if ( empty ( $extension )) { $msg .= $text [ 'message-required' ] . $text [ 'label-extension' ] . " <br> \n " ; }
2016-10-05 07:55:02 +02:00
if ( permission_exists ( 'extension_enabled' )) {
2023-05-05 18:46:37 +02:00
if ( empty ( $enabled )) { $msg .= $text [ 'message-required' ] . $text [ 'label-enabled' ] . " <br> \n " ; }
2016-10-05 07:55:02 +02:00
}
2023-05-05 18:46:37 +02:00
if ( ! empty ( $msg ) && empty ( $_POST [ " persistformvar " ])) {
2016-10-05 07:55:02 +02:00
require_once " resources/header.php " ;
require_once " resources/persist_form_var.php " ;
echo " <div align='center'> \n " ;
echo " <table><tr><td> \n " ;
echo $msg . " <br /> " ;
echo " </td></tr></table> \n " ;
persistformvar ( $_POST );
echo " </div> \n " ;
require_once " resources/footer.php " ;
return ;
}
2012-06-04 16:58:40 +02:00
2016-10-05 07:55:02 +02:00
//prevent users from bypassing extension limit by using range
2025-02-13 22:12:48 +01:00
if ( isset ( $total_extensions ) && ( $total_extensions ? ? 0 ) + $range > $limit_extensions ) {
$range = $limit_extensions - $total_extensions ;
2016-10-05 07:55:02 +02:00
}
2012-06-04 16:58:40 +02:00
2016-10-05 07:55:02 +02:00
//add or update the database
2023-05-17 09:02:45 +02:00
if ( empty ( $_POST [ " persistformvar " ]) || $_POST [ " persistformvar " ] != " true " ) {
2016-10-05 07:55:02 +02:00
//prep missed call values for db insert/update
switch ( $missed_call_app ) {
case 'email' :
$missed_call_data = str_replace ( ';' , ',' , $missed_call_data );
$missed_call_data = str_replace ( ' ' , '' , $missed_call_data );
if ( substr_count ( $missed_call_data , ',' ) > 0 ) {
$missed_call_data_array = explode ( ',' , $missed_call_data );
foreach ( $missed_call_data_array as $array_index => $email_address ) {
if ( ! valid_email ( $email_address )) { unset ( $missed_call_data_array [ $array_index ]); }
}
//echo "<pre>".print_r($missed_call_data_array, true)."</pre><br><br>";
if ( sizeof ( $missed_call_data_array ) > 0 ) {
$missed_call_data = implode ( ',' , $missed_call_data_array );
}
else {
unset ( $missed_call_app , $missed_call_data );
}
//echo "Multiple Emails = ".$missed_call_data;
}
else {
//echo "Single Email = ".$missed_call_data."<br>";
if ( ! valid_email ( $missed_call_data )) {
//echo "Invalid Email<br><br>";
unset ( $missed_call_app , $missed_call_data );
}
}
break ;
case 'text' :
$missed_call_data = str_replace ( '-' , '' , $missed_call_data );
$missed_call_data = str_replace ( '.' , '' , $missed_call_data );
$missed_call_data = str_replace ( '(' , '' , $missed_call_data );
$missed_call_data = str_replace ( ')' , '' , $missed_call_data );
$missed_call_data = str_replace ( ' ' , '' , $missed_call_data );
if ( ! is_numeric ( $missed_call_data )) { unset ( $missed_call_app , $missed_call_data ); }
break ;
2015-05-23 04:11:26 +02:00
}
2016-10-05 07:55:02 +02:00
//build the data array
if ( ! isset ( $range )) { $range = 1 ; }
2020-03-29 04:16:05 +02:00
$j = 0 ;
2017-04-14 12:09:11 +02:00
for ( $i = 0 ; $i < $range ; $i ++ ) {
2016-10-05 07:55:02 +02:00
//check if the extension exists
if ( $action == " add " && extension_exists ( $extension )) {
//extension exists
2013-04-13 01:30:48 +02:00
}
2016-10-05 07:55:02 +02:00
else {
2025-02-08 01:32:09 +01:00
//password permission not assigned get the password from the database
if ( $action == " update " && ! permission_exists ( 'extension_password' )) {
$sql = " select password from v_extensions " ;
$sql .= " where extension_uuid = :extension_uuid " ;
$sql .= " and domain_uuid = :domain_uuid " ;
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$parameters [ 'extension_uuid' ] = $extension_uuid ;
$row = $database -> select ( $sql , $parameters , 'row' );
if ( is_array ( $row ) && @ sizeof ( $row ) != 0 ) {
$password = $row [ " password " ];
}
unset ( $sql , $parameters , $row );
}
2016-10-05 07:55:02 +02:00
2020-05-12 19:07:46 +02:00
//get the password length and strength
2025-02-13 22:12:48 +01:00
$password_length = $extension_password_length ;
$password_strength = $extension_password_strength ;
2020-05-12 19:07:46 +02:00
2016-10-05 07:55:02 +02:00
//extension does not exist add it
if ( $action == " add " || $range > 1 ) {
$extension_uuid = uuid ();
2017-12-21 18:06:53 +01:00
$voicemail_uuid = uuid ();
2020-05-12 19:07:46 +02:00
$password = generate_password ( $password_length , $password_strength );
2013-04-13 01:30:48 +02:00
}
2016-10-05 07:55:02 +02:00
2020-05-12 19:07:46 +02:00
//prepare the values for mwi account
2023-06-29 17:32:43 +02:00
if ( ! empty ( $mwi_account ) && strpos ( $mwi_account , '@' ) === false ) {
2025-02-13 22:12:48 +01:00
$mwi_account .= " @ " . $domain_name ;
2016-10-05 07:55:02 +02:00
}
//generate a password
2023-05-05 18:46:37 +02:00
if ( $action == " add " && empty ( $password )) {
2020-05-12 19:07:46 +02:00
$password = generate_password ( $password_length , $password_strength );
2019-01-14 05:59:03 +01:00
}
2023-05-05 18:46:37 +02:00
if ( $action == " update " && permission_exists ( 'extension_password' ) && empty ( $password )) {
2020-05-12 19:07:46 +02:00
$password = generate_password ( $password_length , $password_strength );
2016-10-05 07:55:02 +02:00
}
2024-01-10 23:55:00 +01:00
//seperate the language components into language, dialect and voice
2024-01-11 00:21:37 +01:00
$language_array = explode ( " / " , $extension_language );
$extension_language = $language_array [ 0 ] ? ? 'en' ;
$extension_dialect = $language_array [ 1 ] ? ? 'us' ;
$extension_voice = $language_array [ 2 ] ? ? 'callie' ;
2024-01-10 23:55:00 +01:00
2016-10-05 07:55:02 +02:00
//create the data array
$array [ " extensions " ][ $i ][ " domain_uuid " ] = $domain_uuid ;
$array [ " extensions " ][ $i ][ " extension_uuid " ] = $extension_uuid ;
$array [ " extensions " ][ $i ][ " extension " ] = $extension ;
if ( permission_exists ( 'number_alias' )) {
$array [ " extensions " ][ $i ][ " number_alias " ] = $number_alias ;
}
2023-05-05 18:46:37 +02:00
if ( ! empty ( $password )) {
2019-01-14 05:59:03 +01:00
$array [ " extensions " ][ $i ][ " password " ] = $password ;
}
2017-11-03 21:57:12 +01:00
if ( permission_exists ( 'extension_accountcode' )) {
2016-10-05 07:55:02 +02:00
$array [ " extensions " ][ $i ][ " accountcode " ] = $accountcode ;
}
2021-05-06 03:28:47 +02:00
else {
if ( $action == " add " ) {
$array [ " extensions " ][ $i ][ " accountcode " ] = get_accountcode ();
}
}
2019-01-29 21:22:17 +01:00
if ( permission_exists ( " effective_caller_id_name " )) {
$array [ " extensions " ][ $i ][ " effective_caller_id_name " ] = $effective_caller_id_name ;
}
if ( permission_exists ( " effective_caller_id_number " )) {
$array [ " extensions " ][ $i ][ " effective_caller_id_number " ] = $effective_caller_id_number ;
}
2018-10-16 00:50:59 +02:00
if ( permission_exists ( " outbound_caller_id_name " )) {
$array [ " extensions " ][ $i ][ " outbound_caller_id_name " ] = $outbound_caller_id_name ;
}
if ( permission_exists ( " outbound_caller_id_number " )) {
$array [ " extensions " ][ $i ][ " outbound_caller_id_number " ] = $outbound_caller_id_number ;
}
if ( permission_exists ( " emergency_caller_id_name " )) {
$array [ " extensions " ][ $i ][ " emergency_caller_id_name " ] = $emergency_caller_id_name ;
}
if ( permission_exists ( " emergency_caller_id_number " )) {
$array [ " extensions " ][ $i ][ " emergency_caller_id_number " ] = $emergency_caller_id_number ;
}
2020-12-29 06:24:03 +01:00
if ( permission_exists ( " extension_directory " )) {
$array [ " extensions " ][ $i ][ " directory_first_name " ] = $directory_first_name ;
$array [ " extensions " ][ $i ][ " directory_last_name " ] = $directory_last_name ;
$array [ " extensions " ][ $i ][ " directory_visible " ] = $directory_visible ;
$array [ " extensions " ][ $i ][ " directory_exten_visible " ] = $directory_exten_visible ;
}
2021-04-11 16:36:45 +02:00
if ( permission_exists ( " extension_max_registrations " )) {
$array [ " extensions " ][ $i ][ " max_registrations " ] = $max_registrations ;
}
else {
if ( $action == " add " ) {
2025-02-13 22:12:48 +01:00
$array [ " extensions " ][ $i ][ " max_registrations " ] = $extension_max_registrations ;
2021-04-11 16:36:45 +02:00
}
2021-04-11 06:28:06 +02:00
}
2020-12-29 06:24:03 +01:00
if ( permission_exists ( " extension_limit " )) {
$array [ " extensions " ][ $i ][ " limit_max " ] = $limit_max ;
$array [ " extensions " ][ $i ][ " limit_destination " ] = $limit_destination ;
}
2020-11-03 22:17:58 +01:00
if ( permission_exists ( " extension_user_context " )) {
$array [ " extensions " ][ $i ][ " user_context " ] = $user_context ;
}
else {
if ( $action == " add " ) {
2025-02-13 22:12:48 +01:00
$array [ " extensions " ][ $i ][ " user_context " ] = $domain_name ;
2020-11-03 22:17:58 +01:00
}
}
2016-10-05 07:55:02 +02:00
if ( permission_exists ( 'extension_missed_call' )) {
$array [ " extensions " ][ $i ][ " missed_call_app " ] = $missed_call_app ;
$array [ " extensions " ][ $i ][ " missed_call_data " ] = $missed_call_data ;
}
if ( permission_exists ( 'extension_toll' )) {
$array [ " extensions " ][ $i ][ " toll_allow " ] = $toll_allow ;
}
2023-05-05 18:46:37 +02:00
if ( ! empty ( $call_timeout )) {
2016-10-05 07:55:02 +02:00
$array [ " extensions " ][ $i ][ " call_timeout " ] = $call_timeout ;
}
2020-12-29 06:24:03 +01:00
if ( permission_exists ( " extension_call_group " )) {
2021-09-19 08:42:40 +02:00
$array [ " extensions " ][ $i ][ " call_group " ] = $call_group ;
2020-12-29 06:24:03 +01:00
}
2016-10-05 07:55:02 +02:00
$array [ " extensions " ][ $i ][ " call_screen_enabled " ] = $call_screen_enabled ;
2018-07-30 19:23:46 +02:00
if ( permission_exists ( 'extension_user_record' )) {
$array [ " extensions " ][ $i ][ " user_record " ] = $user_record ;
}
2020-12-29 06:24:03 +01:00
if ( permission_exists ( 'extension_hold_music' )) {
2021-09-19 08:42:40 +02:00
$array [ " extensions " ][ $i ][ " hold_music " ] = $hold_music ;
2020-12-29 06:24:03 +01:00
}
2022-12-31 19:57:41 +01:00
if ( permission_exists ( " extension_advanced " )) {
$array [ " extensions " ][ $i ][ " auth_acl " ] = $auth_acl ;
if ( permission_exists ( " extension_cidr " )) {
$array [ " extensions " ][ $i ][ " cidr " ] = $cidr ;
}
$array [ " extensions " ][ $i ][ " sip_force_contact " ] = $sip_force_contact ;
$array [ " extensions " ][ $i ][ " sip_force_expires " ] = $sip_force_expires ;
if ( permission_exists ( 'extension_nibble_account' )) {
2023-05-05 18:46:37 +02:00
if ( ! empty ( $nibble_account )) {
2022-12-31 19:57:41 +01:00
$array [ " extensions " ][ $i ][ " nibble_account " ] = $nibble_account ;
}
}
$array [ " extensions " ][ $i ][ " mwi_account " ] = $mwi_account ;
$array [ " extensions " ][ $i ][ " sip_bypass_media " ] = $sip_bypass_media ;
if ( permission_exists ( 'extension_absolute_codec_string' )) {
$array [ " extensions " ][ $i ][ " absolute_codec_string " ] = $absolute_codec_string ;
}
if ( permission_exists ( 'extension_force_ping' )) {
$array [ " extensions " ][ $i ][ " force_ping " ] = $force_ping ;
}
if ( permission_exists ( 'extension_dial_string' )) {
$array [ " extensions " ][ $i ][ " dial_string " ] = $dial_string ;
2016-10-05 07:55:02 +02:00
}
}
2024-01-10 23:55:00 +01:00
if ( permission_exists ( 'extension_language' )) {
2024-01-11 00:21:37 +01:00
$array [ 'extensions' ][ 0 ][ " extension_language " ] = $extension_language ;
$array [ 'extensions' ][ 0 ][ " extension_dialect " ] = $extension_dialect ;
$array [ 'extensions' ][ 0 ][ " extension_voice " ] = $extension_voice ;
2024-01-10 23:55:00 +01:00
}
2023-07-14 01:11:07 +02:00
if ( permission_exists ( 'extension_type' )) {
$array [ " extensions " ][ $i ][ " extension_type " ] = $extension_type ;
}
2020-02-17 23:06:00 +01:00
if ( permission_exists ( 'extension_enabled' )) {
$array [ " extensions " ][ $i ][ " enabled " ] = $enabled ;
}
2016-10-05 07:55:02 +02:00
$array [ " extensions " ][ $i ][ " description " ] = $description ;
2020-03-28 23:21:48 +01:00
//assign the user to the extension
2020-03-29 04:16:05 +02:00
if ( is_uuid ( $user_uuid )) {
2020-03-28 23:21:48 +01:00
$array [ " extension_users " ][ $i ][ " extension_user_uuid " ] = uuid ();
2020-04-11 21:56:03 +02:00
$array [ " extension_users " ][ $i ][ " domain_uuid " ] = $domain_uuid ;
2020-03-29 04:16:05 +02:00
$array [ " extension_users " ][ $i ][ " user_uuid " ] = $user_uuid ;
2020-03-28 23:21:48 +01:00
$array [ " extension_users " ][ $i ][ " extension_uuid " ] = $extension_uuid ;
}
2020-03-29 04:16:05 +02:00
//assign the device to the extension(s)
2023-06-30 07:40:11 +02:00
if ( is_array ( $device_addresses ) && @ sizeof ( $device_addresses ) != 0 ) {
foreach ( $device_addresses as $d => $device_address ) {
2023-06-30 22:26:36 +02:00
if ( ! empty ( $device_address )) {
2021-07-23 19:56:19 +02:00
//get the device vendor
if ( isset ( $device_templates [ $d ])) {
//use the the template to get the vendor
$template_array = explode ( " / " , $device_templates [ $d ]);
$device_vendor = $template_array [ 0 ];
}
else {
2023-06-30 07:40:11 +02:00
//use the device address to get the vendor
$device_vendor = device :: get_vendor ( $device_address );
2021-07-23 19:56:19 +02:00
}
2021-12-15 22:39:34 +01:00
//determine the name
2023-05-05 18:46:37 +02:00
if ( ! empty ( $effective_caller_id_name )) {
2021-12-15 22:39:34 +01:00
$name = $effective_caller_id_name ;
}
2023-05-05 18:46:37 +02:00
elseif ( strlen ( $directory_first_name ) > 0 && ! empty ( $directory_last_name )) {
2021-12-15 22:39:34 +01:00
$name = $directory_first_name . ' ' . $directory_last_name ;
}
2023-05-05 18:46:37 +02:00
elseif ( ! empty ( $directory_first_name )) {
2021-12-15 22:39:34 +01:00
$name = $directory_first_name ;
}
2023-05-05 18:46:37 +02:00
elseif ( ! empty ( $directory_first_name )) {
2021-12-15 22:39:34 +01:00
$name = $directory_first_name . ' ' . $directory_last_name ;
}
else {
$name = '' ;
}
//get the dislplay label
2025-02-13 22:12:48 +01:00
if ( $provision_line_label == 'auto' ) {
2021-12-15 23:06:13 +01:00
$line_label = $extension ;
2021-12-15 22:39:34 +01:00
}
else {
2025-02-13 22:12:48 +01:00
$line_label = $provision_line_label ;
2021-12-15 22:39:34 +01:00
$line_label = str_replace ( " \$ { name} " , $name , $line_label );
$line_label = str_replace ( " \$ { effective_caller_id_name} " , $effective_caller_id_name , $line_label );
2023-03-10 02:39:58 +01:00
$line_label = str_replace ( " \$ { caller_id_name} " , $effective_caller_id_name , $line_label );
2021-12-15 22:39:34 +01:00
$line_label = str_replace ( " \$ { first_name} " , $directory_first_name , $line_label );
$line_label = str_replace ( " \$ { last_name} " , $directory_last_name , $line_label );
$line_label = str_replace ( " \$ { user_id} " , $extension , $line_label );
$line_label = str_replace ( " \$ { auth_id} " , $extension , $line_label );
$line_label = str_replace ( " \$ { extension} " , $extension , $line_label );
$line_label = str_replace ( " \$ { description} " , $description , $line_label );
}
//get the dislplay name
2025-02-13 22:12:48 +01:00
if ( $provision_line_display_name == 'auto' ) {
2021-12-15 22:39:34 +01:00
$line_display_name = $name ;
}
else {
2025-02-13 22:12:48 +01:00
$line_display_name = $provision_line_display_name ;
2021-12-16 03:36:05 +01:00
$line_display_name = str_replace ( " \$ { name} " , $name , $line_display_name );
2021-12-15 22:39:34 +01:00
$line_display_name = str_replace ( " \$ { effective_caller_id_name} " , $effective_caller_id_name , $line_display_name );
2023-03-10 02:39:58 +01:00
$line_display_name = str_replace ( " \$ { caller_id_name} " , $effective_caller_id_name , $line_display_name );
2021-12-15 22:39:34 +01:00
$line_display_name = str_replace ( " \$ { first_name} " , $directory_first_name , $line_display_name );
$line_display_name = str_replace ( " \$ { last_name} " , $directory_last_name , $line_display_name );
$line_display_name = str_replace ( " \$ { user_id} " , $extension , $line_display_name );
$line_display_name = str_replace ( " \$ { auth_id} " , $extension , $line_display_name );
$line_display_name = str_replace ( " \$ { extension} " , $extension , $line_display_name );
$line_display_name = str_replace ( " \$ { description} " , $description , $line_display_name );
}
2021-09-19 08:42:40 +02:00
//send a message to the user the device is not unique
if ( ! $device_unique ) {
2025-02-13 22:12:48 +01:00
$message = $text [ 'message-duplicate' ] . ( if_group ( " superadmin " ) && $domain_name != $device_domain_name ? " : " . $device_domain_name : null );
2021-09-19 08:42:40 +02:00
message :: add ( $message , 'negative' );
}
2021-07-23 19:56:19 +02:00
//build the devices array
2023-06-30 07:40:11 +02:00
if ( $device_unique && $device_address != '000000000000' ) {
2021-09-19 08:42:40 +02:00
$array [ " devices " ][ $j ][ " device_uuid " ] = $device_uuids [ $d ];
2025-02-13 22:12:48 +01:00
$array [ " devices " ][ $j ][ " domain_uuid " ] = $domain_uuid ;
2023-06-30 07:40:11 +02:00
$array [ " devices " ][ $j ][ " device_address " ] = $device_address ;
2021-09-19 08:42:40 +02:00
$array [ " devices " ][ $j ][ " device_label " ] = $extension ;
2023-06-16 21:02:47 +02:00
if ( ! empty ( $device_vendor )) {
$array [ " devices " ][ $j ][ " device_vendor " ] = $device_vendor ;
}
2023-05-05 18:46:37 +02:00
if ( ! empty ( $device_templates [ $d ])) {
2021-09-19 08:42:40 +02:00
$array [ " devices " ][ $j ][ " device_template " ] = $device_templates [ $d ];
}
$array [ " devices " ][ $j ][ " device_enabled " ] = " true " ;
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " device_uuid " ] = $device_uuids [ $d ];
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " device_line_uuid " ] = uuid ();
2025-02-13 22:12:48 +01:00
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " domain_uuid " ] = $domain_uuid ;
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " server_address " ] = $domain_name ;
if ( $provision_outbound_proxy_primary !== null ) $array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " outbound_proxy_primary " ] = $provision_outbound_proxy_primary ;
if ( $provision_outbound_proxy_secondary !== null ) $array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " outbound_proxy_secondary " ] = $provision_outbound_proxy_secondary ;
if ( $provision_server_address_primary !== null ) $array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " server_address_primary " ] = $provision_server_address_primary ;
if ( $provision_server_address_secondary !== null ) $array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " server_address_secondary " ] = $provision_server_address_secondary ;
2021-12-15 23:02:17 +01:00
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " label " ] = $line_label ;
2021-12-15 22:39:34 +01:00
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " display_name " ] = $line_display_name ;
2021-09-19 08:42:40 +02:00
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " user_id " ] = $extension ;
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " auth_id " ] = $extension ;
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " password " ] = $password ;
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " line_number " ] = is_numeric ( $line_numbers [ $d ]) ? $line_numbers [ $d ] : '1' ;
2025-02-13 22:12:48 +01:00
if ( $provision_line_sip_port !== null ) $array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " sip_port " ] = $provision_line_sip_port ;
if ( $provision_line_sip_transport !== null ) $array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " sip_transport " ] = $provision_line_sip_transport ;
if ( $provision_line_register_expires !== null ) $array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " register_expires " ] = $provision_line_register_expires ;
2021-09-19 08:42:40 +02:00
$array [ " devices " ][ $j ][ " device_lines " ][ 0 ][ " enabled " ] = " true " ;
2020-03-29 04:16:05 +02:00
}
2021-09-19 08:42:40 +02:00
//increment
2020-03-29 04:16:05 +02:00
$j ++ ;
}
}
}
2013-12-16 22:56:19 +01:00
}
2015-04-10 16:42:55 +02:00
2016-10-05 07:55:02 +02:00
//add or update voicemail
if ( is_dir ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/app/voicemails' )) {
//set the voicemail password
2023-05-05 18:46:37 +02:00
if ( empty ( $voicemail_password )) {
2025-02-13 22:12:48 +01:00
$voicemail_password = generate_password ( $voicemail_password_length , 1 );
2016-10-05 07:55:02 +02:00
}
2014-03-04 06:49:38 +01:00
2021-11-23 18:09:08 +01:00
//add the voicemail to the array
2017-04-14 10:12:24 +02:00
if ( $voicemail_id !== NULL ) {
//get the voicemail_uuid
$sql = " select voicemail_uuid from v_voicemails " ;
2019-08-07 03:49:59 +02:00
$sql .= " where voicemail_id = :voicemail_id " ;
$sql .= " and domain_uuid = :domain_uuid " ;
$parameters [ 'voicemail_id' ] = $voicemail_id ;
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$row = $database -> select ( $sql , $parameters , 'row' );
if ( is_array ( $row ) && @ sizeof ( $row ) != 0 ) {
2017-04-14 10:12:24 +02:00
$voicemail_uuid = $row [ " voicemail_uuid " ];
}
2019-08-07 03:49:59 +02:00
unset ( $sql , $parameters , $row );
2014-06-25 19:45:48 +02:00
2017-04-14 10:12:24 +02:00
//if voicemail_uuid does not exist then get a new uuid
2019-08-07 03:49:59 +02:00
if ( ! is_uuid ( $voicemail_uuid )) {
2017-04-14 10:12:24 +02:00
$voicemail_uuid = uuid ();
$voicemail_tutorial = 'true' ;
2022-01-29 10:28:07 +01:00
//if adding a mailbox and don't have the transcription permission, set the default transcribe behavior
2025-02-13 22:12:48 +01:00
if ( ! permission_exists ( 'voicemail_transcription_enabled' )) {
$voicemail_transcription_enabled = $voicemail_transcription_enabled_default ;
2022-01-29 10:28:07 +01:00
}
2017-04-14 10:12:24 +02:00
}
2013-04-13 01:30:48 +02:00
2021-11-23 18:09:08 +01:00
//add the voicemail to the array
2017-04-14 10:12:24 +02:00
$array [ " voicemails " ][ $i ][ " domain_uuid " ] = $domain_uuid ;
$array [ " voicemails " ][ $i ][ " voicemail_uuid " ] = $voicemail_uuid ;
$array [ " voicemails " ][ $i ][ " voicemail_id " ] = $voicemail_id ;
2017-04-14 12:09:11 +02:00
2017-04-14 10:12:24 +02:00
$array [ " voicemails " ][ $i ][ " voicemail_password " ] = $voicemail_password ;
//$array["voicemails"][$i]["greeting_id"] = $greeting_id;
//$array["voicemails"][$i]["voicemail_alternate_greet_id"] = $alternate_greet_id;
$array [ " voicemails " ][ $i ][ " voicemail_mail_to " ] = $voicemail_mail_to ;
//$array["voicemails"][$i]["voicemail_attach_file"] = $voicemail_attach_file;
2022-06-01 18:48:33 +02:00
if ( permission_exists ( 'voicemail_file' )) {
$array [ " voicemails " ][ $i ][ " voicemail_file " ] = $voicemail_file ;
}
2017-07-05 18:26:45 +02:00
if ( permission_exists ( 'voicemail_local_after_email' )) {
$array [ " voicemails " ][ $i ][ " voicemail_local_after_email " ] = $voicemail_local_after_email ;
}
2022-05-02 16:06:21 +02:00
$array [ " voicemails " ][ $i ][ " voicemail_transcription_enabled " ] = $voicemail_transcription_enabled ;
2023-05-17 09:02:45 +02:00
$array [ " voicemails " ][ $i ][ " voicemail_tutorial " ] = $voicemail_tutorial ? ? null ;
2017-04-14 10:12:24 +02:00
$array [ " voicemails " ][ $i ][ " voicemail_enabled " ] = $voicemail_enabled ;
2018-05-10 01:35:54 +02:00
$array [ " voicemails " ][ $i ][ " voicemail_description " ] = $description ;
2021-11-23 18:09:08 +01:00
//make sure the voicemail directory exists
2025-02-13 22:12:48 +01:00
if ( ! file_exists ( $switch_voicemail . '/' . $voicemail_id )) {
mkdir ( $switch_voicemail . " / " . $voicemail_id , 0770 , true );
2021-11-23 18:09:08 +01:00
}
2017-03-09 00:30:31 +01:00
}
2012-06-04 16:58:40 +02:00
}
2016-10-05 07:55:02 +02:00
//increment the extension number
if ( $action != " update " ) {
$extension ++ ;
2017-12-21 18:06:53 +01:00
$voicemail_id = $extension ;
2016-11-17 19:46:25 +01:00
2023-05-05 18:46:37 +02:00
if ( ! empty ( $number_alias )) {
2016-11-17 19:46:25 +01:00
$number_alias ++ ;
2018-01-30 06:38:51 +01:00
$voicemail_id = $number_alias ;
2016-11-17 19:46:25 +01:00
}
2023-05-05 18:46:37 +02:00
if ( ! empty ( $mwi_account )) {
2016-11-17 19:46:25 +01:00
$mwi_account_array = explode ( '@' , $mwi_account );
$mwi_account_array [ 0 ] ++ ;
$mwi_account = implode ( '@' , $mwi_account_array );
unset ( $mwi_account_array );
}
2012-06-04 16:58:40 +02:00
}
2018-04-20 21:55:30 +02:00
}
2016-10-05 07:55:02 +02:00
2017-04-14 10:12:24 +02:00
//update devices having extension assigned to line(s) with new password
if ( $action == " update " && $range == 1 && permission_exists ( 'extension_password' )) {
$sql = " update v_device_lines set " ;
2019-08-07 03:49:59 +02:00
$sql .= " password = :password " ;
$sql .= " where domain_uuid = :domain_uuid " ;
$sql .= " and server_address = :server_address " ;
$sql .= " and user_id = :user_id " ;
$parameters [ 'password' ] = $password ;
2025-02-13 22:12:48 +01:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$parameters [ 'server_address' ] = $domain_name ;
2019-08-07 03:49:59 +02:00
$parameters [ 'user_id' ] = $extension ;
$database -> execute ( $sql , $parameters );
unset ( $sql , $parameters );
2017-04-14 10:12:24 +02:00
}
2020-03-28 23:21:48 +01:00
2019-01-05 17:02:31 +01:00
//update device key label
2023-05-05 18:46:37 +02:00
if ( ! empty ( $effective_caller_id_name )) {
2019-01-05 17:50:10 +01:00
$sql = " update v_device_keys set " ;
2019-08-07 03:49:59 +02:00
$sql .= " device_key_label = :device_key_label " ;
$sql .= " where domain_uuid = :domain_uuid " ;
$sql .= " and device_key_value = :device_key_value " ;
$parameters [ 'device_key_label' ] = $effective_caller_id_name ;
2025-02-13 22:12:48 +01:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
2019-08-07 03:49:59 +02:00
$parameters [ 'device_key_value' ] = $extension ;
$database -> execute ( $sql , $parameters );
unset ( $sql , $parameters );
2019-01-05 17:50:10 +01:00
}
2020-03-28 23:21:48 +01:00
2017-04-14 10:12:24 +02:00
//save to the data
$database -> app_name = 'extensions' ;
2019-08-07 03:49:59 +02:00
$database -> app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3' ;
2024-07-27 01:04:02 +02:00
$message = $database -> save ( $array );
2019-08-07 03:49:59 +02:00
unset ( $array );
2021-09-19 08:42:40 +02:00
2024-07-27 01:04:02 +02:00
//reload the access control list
2020-01-08 18:45:10 +01:00
if ( permission_exists ( " extension_cidr " )) {
2024-07-27 01:04:02 +02:00
$event_socket = event_socket :: create ();
if ( $event_socket -> is_connected ()) { event_socket :: api ( " reloadacl " ); }
2020-01-08 18:45:10 +01:00
}
2017-04-14 10:12:24 +02:00
//check the permissions
if ( permission_exists ( 'extension_add' ) || permission_exists ( 'extension_edit' )) {
//synchronize configuration
2025-02-13 22:12:48 +01:00
if ( is_writable ( $switch_extensions )) {
2017-04-14 10:12:24 +02:00
$ext = new extension ;
$ext -> xml ();
unset ( $ext );
}
2012-06-04 16:58:40 +02:00
2017-04-14 10:12:24 +02:00
//write the provision files
2025-02-13 22:12:48 +01:00
if ( ! empty ( $provision_path ) && is_dir ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/app/provision' )) {
$prov = new provision ;
$prov -> domain_uuid = $domain_uuid ;
$response = $prov -> write ();
2016-12-06 18:29:44 +01:00
}
2012-06-04 16:58:40 +02:00
2017-04-14 10:12:24 +02:00
//clear the cache
2021-03-16 22:36:11 +01:00
if ( ! permission_exists ( " extension_user_context " ) && $action == " update " ) {
$sql = " select user_context from v_extensions " ;
$sql .= " where extension_uuid = :extension_uuid " ;
$parameters [ 'extension_uuid' ] = $extension_uuid ;
$user_context = $database -> select ( $sql , $parameters , 'column' );
}
2017-04-14 10:12:24 +02:00
$cache = new cache ;
$cache -> delete ( " directory: " . $extension . " @ " . $user_context );
2023-05-05 18:46:37 +02:00
if ( permission_exists ( 'number_alias' ) && ! empty ( $number_alias )) {
2017-04-14 10:12:24 +02:00
$cache -> delete ( " directory: " . $number_alias . " @ " . $user_context );
}
2020-11-30 22:15:57 +01:00
//clear the destinations session array
if ( isset ( $_SESSION [ 'destinations' ][ 'array' ])) {
unset ( $_SESSION [ 'destinations' ][ 'array' ]);
}
2017-04-14 10:12:24 +02:00
}
2012-06-04 16:58:40 +02:00
2020-02-18 14:17:27 +01:00
//set the message and redirect
2017-04-14 10:12:24 +02:00
if ( $action == " add " ) {
2020-02-18 14:17:27 +01:00
message :: add ( $text [ 'message-add' ]);
2017-04-14 10:12:24 +02:00
}
if ( $action == " update " ) {
2018-08-31 05:09:01 +02:00
message :: add ( $text [ 'message-update' ]);
2020-02-18 14:17:27 +01:00
}
if ( $range > 1 ) {
header ( " Location: extensions.php " );
}
else {
2023-06-13 01:06:56 +02:00
header ( " Location: extension_edit.php?id= " . $extension_uuid . ( isset ( $page ) && is_numeric ( $page ) ? '&page=' . $page : null ));
2016-10-05 07:55:02 +02:00
}
2020-02-18 14:17:27 +01:00
exit ;
2019-08-07 03:49:59 +02:00
}
}
2012-06-04 16:58:40 +02:00
//pre-populate the form
2023-06-29 17:32:43 +02:00
if ( ! empty ( $_GET ) && ( empty ( $_POST [ " persistformvar " ]) || $_POST [ " persistformvar " ] != " true " )) {
2016-11-24 11:21:35 +01:00
$extension_uuid = $_GET [ " id " ];
2012-06-04 16:58:40 +02:00
$sql = " select * from v_extensions " ;
2019-08-07 03:49:59 +02:00
$sql .= " where extension_uuid = :extension_uuid " ;
$parameters [ 'extension_uuid' ] = $extension_uuid ;
$row = $database -> select ( $sql , $parameters , 'row' );
if ( is_array ( $row ) && @ sizeof ( $row ) != 0 ) {
2018-02-19 00:03:24 +01:00
$domain_uuid = $row [ " domain_uuid " ];
2012-06-04 16:58:40 +02:00
$extension = $row [ " extension " ];
$number_alias = $row [ " number_alias " ];
$password = $row [ " password " ];
$accountcode = $row [ " accountcode " ];
$effective_caller_id_name = $row [ " effective_caller_id_name " ];
$effective_caller_id_number = $row [ " effective_caller_id_number " ];
$outbound_caller_id_name = $row [ " outbound_caller_id_name " ];
$outbound_caller_id_number = $row [ " outbound_caller_id_number " ];
2014-05-01 06:24:44 +02:00
$emergency_caller_id_name = $row [ " emergency_caller_id_name " ];
2012-06-04 16:58:40 +02:00
$emergency_caller_id_number = $row [ " emergency_caller_id_number " ];
2017-06-17 19:37:22 +02:00
$directory_first_name = $row [ " directory_first_name " ];
$directory_last_name = $row [ " directory_last_name " ];
2012-06-04 16:58:40 +02:00
$directory_visible = $row [ " directory_visible " ];
$directory_exten_visible = $row [ " directory_exten_visible " ];
2021-04-11 06:28:06 +02:00
$max_registrations = $row [ " max_registrations " ];
2012-06-04 16:58:40 +02:00
$limit_max = $row [ " limit_max " ];
$limit_destination = $row [ " limit_destination " ];
$user_context = $row [ " user_context " ];
2015-05-23 04:11:26 +02:00
$missed_call_app = $row [ " missed_call_app " ];
$missed_call_data = $row [ " missed_call_data " ];
2012-06-04 16:58:40 +02:00
$toll_allow = $row [ " toll_allow " ];
2013-04-02 09:36:28 +02:00
$call_timeout = $row [ " call_timeout " ];
2012-06-04 16:58:40 +02:00
$call_group = $row [ " call_group " ];
2015-06-23 22:42:26 +02:00
$call_screen_enabled = $row [ " call_screen_enabled " ];
2014-04-03 19:32:38 +02:00
$user_record = $row [ " user_record " ];
2012-06-04 16:58:40 +02:00
$hold_music = $row [ " hold_music " ];
$auth_acl = $row [ " auth_acl " ];
$cidr = $row [ " cidr " ];
$sip_force_contact = $row [ " sip_force_contact " ];
$sip_force_expires = $row [ " sip_force_expires " ];
$nibble_account = $row [ " nibble_account " ];
$mwi_account = $row [ " mwi_account " ];
$sip_bypass_media = $row [ " sip_bypass_media " ];
2015-10-29 20:24:24 +01:00
$absolute_codec_string = $row [ " absolute_codec_string " ];
2016-08-11 17:46:54 +02:00
$force_ping = $row [ " force_ping " ];
2012-06-04 17:04:54 +02:00
$dial_string = $row [ " dial_string " ];
2024-01-11 00:21:37 +01:00
$extension_language = $row [ " extension_language " ];
$extension_voice = $row [ " extension_voice " ];
$extension_dialect = $row [ " extension_dialect " ];
2023-07-14 01:11:07 +02:00
$extension_type = $row [ " extension_type " ];
2012-06-04 16:58:40 +02:00
$enabled = $row [ " enabled " ];
$description = $row [ " description " ];
}
2019-08-07 03:49:59 +02:00
unset ( $sql , $parameters , $row );
2012-06-04 16:58:40 +02:00
2021-10-20 18:58:23 +02:00
//outbound caller id number - only allow numeric and +
2023-05-05 18:46:37 +02:00
if ( ! empty ( $outbound_caller_id_number )) {
2021-10-20 18:58:23 +02:00
$outbound_caller_id_number = preg_replace ( '#[^\+0-9]#' , '' , $outbound_caller_id_number );
}
2015-03-20 02:09:18 +01:00
//get the voicemail data
if ( is_dir ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/app/voicemails' )) {
2022-01-29 10:28:07 +01:00
$sql = " select * from v_voicemails " ;
$sql .= " where domain_uuid = :domain_uuid " ;
$sql .= " and voicemail_id = :voicemail_id " ;
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$parameters [ 'voicemail_id' ] = is_numeric ( $number_alias ) ? $number_alias : $extension ;
$row = $database -> select ( $sql , $parameters , 'row' );
if ( is_array ( $row ) && @ sizeof ( $row ) != 0 ) {
2023-05-17 09:02:45 +02:00
$voicemail_password = str_replace ( " # " , " " , $row [ " voicemail_password " ] ? ? '' );
$voicemail_mail_to = str_replace ( " " , " " , $row [ " voicemail_mail_to " ] ? ? '' );
2022-01-29 10:28:07 +01:00
$voicemail_transcription_enabled = $row [ " voicemail_transcription_enabled " ];
2022-05-02 16:27:15 +02:00
$voicemail_tutorial = $row [ " voicemail_tutorial " ];
2022-01-29 10:28:07 +01:00
$voicemail_file = $row [ " voicemail_file " ];
$voicemail_local_after_email = $row [ " voicemail_local_after_email " ];
$voicemail_enabled = $row [ " voicemail_enabled " ];
}
unset ( $sql , $parameters , $row );
2015-03-20 02:09:18 +01:00
}
}
else {
2025-02-13 22:12:48 +01:00
$voicemail_file = $settings -> get ( 'voicemail' , 'voicemail_file' , 'attach' );
$voicemail_local_after_email = $settings -> get ( 'voicemail' , 'keep_local' , true );
2013-09-29 10:06:54 +02:00
}
2013-06-03 16:26:50 +02:00
2015-08-21 04:16:07 +02:00
//get the device lines
2023-06-30 07:40:11 +02:00
$sql = " select d.device_address, d.device_template, d.device_description, l.device_line_uuid, l.device_uuid, l.line_number " ;
2019-08-07 03:49:59 +02:00
$sql .= " from v_device_lines as l, v_devices as d " ;
$sql .= " where (l.user_id = :user_id_1 or l.user_id = :user_id_2) " ;
2023-12-27 20:29:19 +01:00
$sql .= " and l.password = :password " ;
2019-08-07 03:49:59 +02:00
$sql .= " and l.domain_uuid = :domain_uuid " ;
$sql .= " and l.device_uuid = d.device_uuid " ;
2023-06-30 07:40:11 +02:00
$sql .= " order by l.line_number, d.device_address asc " ;
2023-05-17 09:02:45 +02:00
$parameters [ 'user_id_1' ] = $extension ? ? null ;
$parameters [ 'user_id_2' ] = $number_alias ? ? null ;
2023-12-27 20:29:19 +01:00
$parameters [ 'password' ] = $password ? ? null ;
2019-08-07 03:49:59 +02:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$device_lines = $database -> select ( $sql , $parameters , 'all' );
unset ( $sql , $parameters );
2015-08-21 04:16:07 +02:00
//get the devices
2019-08-07 03:49:59 +02:00
$sql = " select * from v_devices " ;
$sql .= " where domain_uuid = :domain_uuid " ;
2023-07-01 00:40:17 +02:00
if ( ! permission_exists ( 'device_all' ) && ! permission_exists ( 'device_domain_all' )) {
$sql .= " and device_user_uuid = :user_uuid " ;
2025-02-13 22:12:48 +01:00
$parameters [ 'user_uuid' ] = $user_uuid ;
2023-07-01 00:40:17 +02:00
}
2023-06-30 07:40:11 +02:00
$sql .= " order by device_address asc " ;
2019-08-07 03:49:59 +02:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$devices = $database -> select ( $sql , $parameters , 'all' );
2023-07-01 00:40:17 +02:00
if ( ! empty ( $devices ) && is_array ( $devices )) {
$total_devices = @ sizeof ( $devices );
}
2019-08-07 03:49:59 +02:00
unset ( $sql , $parameters );
2015-08-21 04:16:07 +02:00
2018-10-24 07:14:07 +02:00
//get the device vendors
2019-08-07 03:49:59 +02:00
$sql = " select name " ;
$sql .= " from v_device_vendors " ;
$sql .= " where enabled = 'true' " ;
$sql .= " order by name asc " ;
$device_vendors = $database -> select ( $sql , null , 'all' );
unset ( $sql );
2018-10-24 07:14:07 +02:00
2015-08-21 04:16:07 +02:00
//get assigned users
2023-05-17 09:02:45 +02:00
if ( ! empty ( $extension_uuid ) && is_uuid ( $extension_uuid )) {
2019-08-07 03:49:59 +02:00
$sql = " select u.username, e.user_uuid " ;
$sql .= " from v_extension_users as e, v_users as u " ;
2016-11-24 20:21:55 +01:00
$sql .= " where e.user_uuid = u.user_uuid " ;
$sql .= " and u.user_enabled = 'true' " ;
2019-08-07 03:49:59 +02:00
$sql .= " and e.domain_uuid = :domain_uuid " ;
$sql .= " and e.extension_uuid = :extension_uuid " ;
2016-11-24 20:21:55 +01:00
$sql .= " order by u.username asc " ;
2019-08-07 03:49:59 +02:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$parameters [ 'extension_uuid' ] = $extension_uuid ;
$assigned_users = $database -> select ( $sql , $parameters , 'all' );
if ( is_array ( $assigned_users ) && @ sizeof ( $assigned_users ) != 0 ) {
foreach ( $assigned_users as $row ) {
$assigned_user_uuids [] = $row [ 'user_uuid' ];
}
2016-11-24 20:21:55 +01:00
}
2019-08-07 03:49:59 +02:00
unset ( $sql , $parameters , $row );
2015-08-21 04:16:07 +02:00
}
//get the users
2019-08-07 03:49:59 +02:00
$sql = " select * from v_users " ;
$sql .= " where domain_uuid = :domain_uuid " ;
2023-05-17 09:02:45 +02:00
if ( ! empty ( $assigned_user_uuids ) && is_array ( $assigned_user_uuids ) && @ sizeof ( $assigned_user_uuids ) != 0 ) {
2019-08-07 03:49:59 +02:00
foreach ( $assigned_user_uuids as $index => $assigned_user_uuid ) {
$sql .= " and user_uuid <> :user_uuid_ " . $index . " " ;
$parameters [ 'user_uuid_' . $index ] = $assigned_user_uuid ;
}
2015-08-21 04:16:07 +02:00
}
$sql .= " and user_enabled = 'true' " ;
$sql .= " order by username asc " ;
2019-08-07 03:49:59 +02:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$users = $database -> select ( $sql , $parameters , 'all' );
unset ( $sql , $parameters , $assigned_user_uuids , $assigned_user_uuid );
2015-08-21 04:16:07 +02:00
//get the destinations
$sql = " select * from v_destinations " ;
2019-08-07 03:49:59 +02:00
$sql .= " where domain_uuid = :domain_uuid " ;
2015-08-21 04:16:07 +02:00
$sql .= " and destination_type = 'inbound' " ;
$sql .= " order by destination_number asc " ;
2019-08-07 03:49:59 +02:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$destinations = $database -> select ( $sql , $parameters , 'all' );
unset ( $sql , $parameters );
2015-08-21 04:16:07 +02:00
2020-12-12 01:24:14 +01:00
//get the emergency destinations
if ( permission_exists ( 'emergency_caller_id_select' )) {
$sql = " select * from v_destinations " ;
$sql .= " where domain_uuid = :domain_uuid " ;
$sql .= " and destination_type = 'inbound' " ;
$sql .= " and destination_type_emergency = 1 " ;
$sql .= " order by destination_number asc " ;
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$emergency_destinations = $database -> select ( $sql , $parameters , 'all' );
unset ( $sql , $parameters );
}
2019-01-19 21:38:55 +01:00
//change toll allow delimiter
2023-05-17 09:02:45 +02:00
$toll_allow = str_replace ( ':' , ',' , $toll_allow ? ? '' );
2019-01-19 21:38:55 +01:00
2024-01-11 00:12:32 +01:00
//get installed languages
2025-02-13 22:12:48 +01:00
$language_paths = glob ( $switch_sounds . " /*/*/* " );
2024-01-11 00:12:32 +01:00
foreach ( $language_paths as $key => $path ) {
2025-02-13 22:12:48 +01:00
$path = str_replace ( $switch_sounds . '/' , " " , $path );
2024-01-11 00:12:32 +01:00
$path_array = explode ( '/' , $path );
if ( count ( $path_array ) <> 3 || strlen ( $path_array [ 0 ]) <> 2 || strlen ( $path_array [ 1 ]) <> 2 ) {
unset ( $language_paths [ $key ]);
}
2025-02-13 22:12:48 +01:00
$language_paths [ $key ] = str_replace ( $switch_sounds . " / " , " " , $language_paths [ $key ] ? ? '' );
2024-01-11 00:12:32 +01:00
if ( empty ( $language_paths [ $key ])) {
unset ( $language_paths [ $key ]);
}
}
2012-06-04 16:58:40 +02:00
//set the defaults
2025-02-13 22:12:48 +01:00
if ( empty ( $user_context )) { $user_context = $domain_name ; }
if ( empty ( $max_registrations )) { $max_registrations = $extension_max_registrations ? ? '' ; }
2023-05-05 18:46:37 +02:00
if ( empty ( $accountcode )) { $accountcode = get_accountcode (); }
2025-02-13 22:12:48 +01:00
if ( empty ( $limit_max )) { $limit_max = $extension_limit_max ; }
2023-05-05 18:46:37 +02:00
if ( empty ( $limit_destination )) { $limit_destination = '!USER_BUSY' ; }
2025-02-13 22:12:48 +01:00
if ( empty ( $call_timeout )) { $call_timeout = $extension_call_timeout ; }
2023-05-05 18:46:37 +02:00
if ( empty ( $call_screen_enabled )) { $call_screen_enabled = 'false' ; }
2025-02-13 22:12:48 +01:00
if ( empty ( $user_record )) { $user_record = $extension_user_record_default ; }
if ( empty ( $voicemail_transcription_enabled )) { $voicemail_transcription_enabled = $voicemail_transcription_enabled_default ; }
if ( empty ( $voicemail_enabled )) { $voicemail_enabled = $voicemail_enabled_default ; }
2023-05-05 18:46:37 +02:00
if ( empty ( $enabled )) { $enabled = 'true' ; }
2012-06-04 16:58:40 +02:00
2019-09-19 14:22:40 +02:00
//create token
$object = new token ;
$token = $object -> create ( $_SERVER [ 'PHP_SELF' ]);
2024-12-11 22:53:55 +01:00
//set the back button
$_SESSION [ 'call_forward_back' ] = $_SERVER [ 'PHP_SELF' ] . " ?id= $extension_uuid " ;
2012-06-04 16:58:40 +02:00
//begin the page content
2013-07-06 08:29:50 +02:00
require_once " resources/header.php " ;
2013-05-08 01:11:37 +02:00
if ( $action == " update " ) {
2014-07-10 02:32:50 +02:00
$document [ 'title' ] = $text [ 'title-extension-edit' ];
2013-05-08 01:11:37 +02:00
}
2015-07-31 17:18:27 +02:00
elseif ( $action == " add " ) {
2014-07-10 02:32:50 +02:00
$document [ 'title' ] = $text [ 'title-extension-add' ];
2013-05-08 01:11:37 +02:00
}
2012-06-04 16:58:40 +02:00
echo " <script type= \" text/javascript \" language= \" JavaScript \" > \n " ;
echo " \n " ;
echo " function enable_change(enable_over) { \n " ;
echo " var endis; \n " ;
echo " endis = !(document.iform.enable.checked || enable_over); \n " ;
echo " document.iform.range_from.disabled = endis; \n " ;
echo " document.iform.range_to.disabled = endis; \n " ;
echo " } \n " ;
echo " \n " ;
2020-10-05 17:49:23 +02:00
if ( permission_exists ( 'extension_advanced' )) {
2020-07-02 08:22:38 +02:00
echo " function show_advanced_config() { \n " ;
echo " $ ('#show_advanced_box').slideToggle(); \n " ;
echo " $ ('#show_advanced').slideToggle(); \n " ;
echo " } \n " ;
echo " \n " ;
}
2014-05-01 04:48:25 +02:00
echo " function copy_extension() { \n " ;
echo " var new_ext = prompt(' " . $text [ 'message-extension' ] . " '); \n " ;
echo " if (new_ext != null) { \n " ;
echo " if (!isNaN(new_ext)) { \n " ;
2023-05-17 09:02:45 +02:00
echo " document.location.href='extension_copy.php?id= " . escape ( $extension_uuid ? ? '' ) . " &ext=' + new_ext " . ( ! empty ( $page ) && is_numeric ( $page ) ? " + '&page= " . $page . " ' " : null ) . " ; \n " ;
2014-05-01 04:48:25 +02:00
echo " } \n " ;
echo " else { \n " ;
echo " var new_number_alias = prompt(' " . $text [ 'message-number_alias' ] . " '); \n " ;
echo " if (new_number_alias != null) { \n " ;
echo " if (!isNaN(new_number_alias)) { \n " ;
2023-05-17 09:02:45 +02:00
echo " document.location.href='extension_copy.php?id= " . escape ( $extension_uuid ? ? '' ) . " &ext=' + new_ext + '&alias=' + new_number_alias " . ( ! empty ( $page ) && is_numeric ( $page ) ? " + '&page= " . $page . " ' " : null ) . " ; \n " ;
2014-05-01 04:48:25 +02:00
echo " } \n " ;
echo " } \n " ;
echo " } \n " ;
echo " } \n " ;
echo " } \n " ;
2012-06-04 16:58:40 +02:00
echo " </script> " ;
2020-03-05 18:02:25 +01:00
echo " <form method='post' name='frm' id='frm'> \n " ;
2020-01-11 19:06:49 +01:00
echo " <div class='action_bar' id='action_bar'> \n " ;
echo " <div class='heading'> " ;
2012-06-04 16:58:40 +02:00
if ( $action == " add " ) {
2020-01-11 19:06:49 +01:00
echo " <b> " . $text [ 'header-extension-add' ] . " </b> " ;
2012-06-04 16:58:40 +02:00
}
if ( $action == " update " ) {
2020-01-11 19:06:49 +01:00
echo " <b> " . $text [ 'header-extension-edit' ] . " </b> " ;
2012-06-04 16:58:40 +02:00
}
2020-01-11 19:06:49 +01:00
echo " </div> \n " ;
echo " <div class='actions'> \n " ;
2025-02-13 22:12:48 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-back' ], 'icon' => $settings -> get ( 'theme' , 'button_icon_back' ), 'id' => 'btn_back' , 'link' => 'extensions.php' . ( isset ( $page ) && is_numeric ( $page ) ? '?page=' . $page : null )]);
2020-03-05 08:05:45 +01:00
if ( $action == 'update' ) {
$button_margin = 'margin-left: 15px;' ;
if ( permission_exists ( 'xml_cdr_view' )) {
2023-05-17 09:02:45 +02:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-cdr' ], 'icon' => 'info-circle' , 'style' => ( $button_margin ? ? '' ), 'link' => '../xml_cdr/xml_cdr.php?extension_uuid=' . urlencode ( $extension_uuid )]);
2020-03-05 08:05:45 +01:00
unset ( $button_margin );
}
if ( permission_exists ( 'follow_me' ) || permission_exists ( 'call_forward' ) || permission_exists ( 'do_not_disturb' )) {
2024-08-10 02:14:52 +02:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-call_forward' ], 'icon' => 'diagram-project' , 'style' => ( $button_margin ? ? '' ), 'link' => '../call_forward/call_forward_edit.php?id=' . urlencode ( $extension_uuid )]);
2020-03-05 08:05:45 +01:00
unset ( $button_margin );
}
2021-02-10 08:42:08 +01:00
if ( permission_exists ( 'extension_setting_view' )) {
2025-02-13 22:12:48 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-settings' ], 'icon' => $settings -> get ( 'theme' , 'button_icon_settings' ), 'id' => 'btn_settings' , 'style' => '' , 'link' => PROJECT_PATH . '/app/extension_settings/extension_settings.php?id=' . urlencode ( $extension_uuid )]);
2021-02-10 08:42:08 +01:00
}
2020-03-05 08:05:45 +01:00
if ( permission_exists ( 'extension_copy' )) {
2025-02-13 22:12:48 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-copy' ], 'icon' => $settings -> get ( 'theme' , 'button_icon_copy' ), 'id' => 'btn_copy' , 'style' => 'margin-left: 15px;' , 'onclick' => " copy_extension(); " ]);
2020-03-05 08:05:45 +01:00
}
2021-02-10 08:42:08 +01:00
2013-05-04 02:35:21 +02:00
}
2025-02-13 22:12:48 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-save' ], 'icon' => $settings -> get ( 'theme' , 'button_icon_save' ), 'id' => 'btn_save' , 'style' => 'margin-left: 15px;' , 'onclick' => 'submit_form();' ]);
2020-01-11 19:06:49 +01:00
echo " </div> \n " ;
echo " <div style='clear: both;'></div> \n " ;
echo " </div> \n " ;
2024-09-06 07:37:34 +02:00
echo " <div class='card'> \n " ;
2020-01-11 19:06:49 +01:00
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2020-01-11 19:06:49 +01:00
echo " <td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-extension' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
2020-01-11 19:06:49 +01:00
echo " <td width='70%' class='vtable' align='left'> \n " ;
2021-01-19 05:38:08 +01:00
if ( $action == " add " || permission_exists ( " extension_extension " )) {
2025-02-13 22:12:48 +01:00
echo " <input class='formfld' type='text' name='extension' autocomplete='new-password' maxlength='255' value= \" " . escape ( $extension ? ? '' ) . " \" required='required' placeholder= \" " . $settings -> get ( 'extension' , 'extension_range' , '' ) . " \" > \n " ;
2021-01-19 05:38:08 +01:00
echo " <input type='text' style='display: none;' disabled='disabled'> \n " ; //help defeat browser auto-fill
echo " <br /> \n " ;
echo $text [ 'description-extension' ] . " \n " ;
}
else {
echo escape ( $extension );
}
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2016-05-11 21:36:31 +02:00
if ( permission_exists ( 'number_alias' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-number_alias' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='number' name='number_alias' autocomplete='new-password' maxlength='255' min='0' step='1' value= \" " . escape ( $number_alias ? ? '' ) . " \" > \n " ;
2020-03-05 08:05:45 +01:00
echo " <input type='text' style='display: none;' disabled='disabled'> \n " ; //help defeat browser auto-fill
2016-05-11 21:36:31 +02:00
echo " <br /> \n " ;
echo $text [ 'description-number_alias' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
2015-05-21 00:34:16 +02:00
if ( permission_exists ( 'extension_password' ) && $action == " update " ) {
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
echo " <td class='vncellreq' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-password' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2020-03-05 08:05:45 +01:00
echo " <input type='password' style='display: none;' disabled='disabled'> \n " ; //help defeat browser auto-fill
2025-03-19 00:55:41 +01:00
echo " <input class='formfld password' type='password' name='password' id='password' autocomplete='new-password' onmouseover= \" this.type='text'; \" onfocus= \" this.type='text'; \" onmouseout= \" if (! $ (this).is(':focus')) { this.type='password'; } \" onblur= \" this.type='password'; \" maxlength='50' value= \" " . escape ( $password ? ? '' ) . " \" > \n " ;
2014-03-07 00:31:03 +01:00
echo " <br /> \n " ;
echo " " . $text [ 'description-password' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
if ( $action == " add " ) {
echo " <tr> \n " ;
2020-03-29 04:16:05 +02:00
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-range' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='range'> \n " ;
echo " <option value='1'>1</option> \n " ;
echo " <option value='2'>2</option> \n " ;
echo " <option value='3'>3</option> \n " ;
echo " <option value='4'>4</option> \n " ;
echo " <option value='5'>5</option> \n " ;
echo " <option value='6'>6</option> \n " ;
echo " <option value='7'>7</option> \n " ;
echo " <option value='8'>8</option> \n " ;
echo " <option value='9'>9</option> \n " ;
echo " <option value='10'>10</option> \n " ;
echo " <option value='15'>15</option> \n " ;
echo " <option value='20'>20</option> \n " ;
echo " <option value='25'>25</option> \n " ;
echo " <option value='30'>30</option> \n " ;
echo " <option value='35'>35</option> \n " ;
echo " <option value='40'>40</option> \n " ;
echo " <option value='45'>45</option> \n " ;
echo " <option value='50'>50</option> \n " ;
echo " <option value='75'>75</option> \n " ;
echo " <option value='100'>100</option> \n " ;
echo " <option value='150'>150</option> \n " ;
echo " <option value='200'>200</option> \n " ;
echo " <option value='250'>250</option> \n " ;
echo " <option value='500'>500</option> \n " ;
2015-04-10 16:42:55 +02:00
echo " <option value='750'>750</option> \n " ;
2012-06-04 16:58:40 +02:00
echo " <option value='1000'>1000</option> \n " ;
echo " <option value='5000'>5000</option> \n " ;
echo " </select> \n " ;
echo " <br /> \n " ;
2020-02-18 14:17:27 +01:00
echo $text [ 'description-range' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
2020-03-28 23:21:48 +01:00
if ( permission_exists ( 'extension_user_edit' )) {
2012-06-04 16:58:40 +02:00
echo " <tr> " ;
2020-03-28 23:21:48 +01:00
echo " <td class='vncell' valign='top'> " . ( $action == " update " ? $text [ 'label-users' ] : $text [ 'label-user' ]) . " </td> " ;
2012-06-04 16:58:40 +02:00
echo " <td class='vtable'> " ;
2023-05-17 09:02:45 +02:00
if ( ! empty ( $assigned_users ) && is_array ( $assigned_users ) && @ sizeof ( $assigned_users ) != 0 && $action == " update " ) {
2014-05-06 22:21:11 +02:00
echo " <table width='30%'> \n " ;
2015-08-21 04:16:07 +02:00
foreach ( $assigned_users as $field ) {
2014-05-02 07:07:29 +02:00
echo " <tr> \n " ;
2018-06-13 09:13:38 +02:00
echo " <td class='vtable'><a href='/core/users/user_edit.php?id= " . escape ( $field [ 'user_uuid' ]) . " '> " . escape ( $field [ 'username' ]) . " </a></td> \n " ;
2014-05-02 07:07:29 +02:00
echo " <td> \n " ;
2018-06-24 22:02:43 +02:00
echo " <a href='#' onclick= \" if (confirm(' " . $text [ 'confirm-delete' ] . " ')) { document.getElementById('delete_type').value = 'user'; document.getElementById('delete_uuid').value = ' " . $field [ 'user_uuid' ] . " '; document.getElementById('frm').submit(); } \" alt=' " . $text [ 'button-delete' ] . " '> $v_link_label_delete </a> \n " ;
2014-05-02 07:07:29 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
echo " </table> \n " ;
echo " <br /> \n " ;
2012-06-04 16:58:40 +02:00
}
2020-04-15 21:11:29 +02:00
if ( is_array ( $users ) && @ sizeof ( $users ) != 0 ) {
echo " <select name='extension_users[0][user_uuid]' id='user_uuid' class='formfld' style='width: auto;'> \n " ;
echo " <option value=''></option> \n " ;
foreach ( $users as $field ) {
echo " <option value=' " . escape ( $field [ 'user_uuid' ]) . " '> " . escape ( $field [ 'username' ]) . " </option> \n " ;
}
echo " </select> " ;
if ( $action == " update " ) {
2025-02-13 22:12:48 +01:00
echo button :: create ([ 'type' => 'submit' , 'label' => $text [ 'button-add' ], 'icon' => $settings -> get ( 'theme' , 'button_icon_add' )]);
2020-04-15 21:11:29 +02:00
}
echo " <br> \n " ;
2020-03-28 23:21:48 +01:00
}
2013-05-04 02:35:21 +02:00
echo " " . $text [ 'description-user_list' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " <br /> \n " ;
echo " </td> " ;
echo " </tr> " ;
}
2016-10-09 18:32:49 +02:00
if ( permission_exists ( 'voicemail_edit' ) && is_dir ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/app/voicemails' )) {
2014-03-04 06:49:38 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-voicemail_password' ] . " \n " ;
2014-03-04 06:49:38 +01:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2019-04-14 01:39:43 +02:00
echo " <input type='password' style='display: none;' disabled='disabled'> \n " ; //help defeat browser auto-fill
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='password' name='voicemail_password' id='voicemail_password' autocomplete='new-password' onmouseover= \" this.type='text'; \" onfocus= \" this.type='text'; \" onmouseout= \" if (! $ (this).is(':focus')) { this.type='password'; } \" onblur= \" this.type='password'; \" maxlength='255' value=' " . escape ( $voicemail_password ? ? '' ) . " '> \n " ;
2014-03-07 00:31:03 +01:00
echo " <br /> \n " ;
2014-05-25 03:43:47 +02:00
echo " " . $text [ 'description-voicemail_password' ] . " \n " ;
2014-03-04 06:49:38 +01:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
2013-12-19 09:29:36 +01:00
2017-11-03 21:57:12 +01:00
if ( permission_exists ( 'extension_accountcode' )) {
2016-10-14 15:42:01 +02:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-accountcode' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2018-06-08 22:44:21 +02:00
echo " <input class='formfld' type='text' name='accountcode' id='accountcode' maxlength='255' value=' " . escape ( $accountcode ) . " '> \n " ;
2016-10-14 15:42:01 +02:00
echo " <br /> \n " ;
echo " " . $text [ 'description-accountcode' ] . " \n " ;
echo " </td> \n " ;
2024-01-10 23:55:00 +01:00
echo " </tr> \n " ;
2016-10-14 15:42:01 +02:00
}
2023-07-14 05:40:43 +02:00
if ( permission_exists ( 'device_edit' ) && ( empty ( $extension_type ) || $extension_type != 'virtual' )) {
2015-06-23 21:43:12 +02:00
if ( is_dir ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/app/devices' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-provisioning' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <input type='hidden' name='device_line_uuid' id='device_line_uuid' value=''> " ;
2020-03-29 04:16:05 +02:00
echo " <table cellpadding='0' cellspacing='0'> \n " ;
2015-06-23 21:43:12 +02:00
echo " <tr> \n " ;
echo " <td class='vtable'> \n " ;
echo " " . $text [ 'label-line' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable'> \n " ;
2023-06-30 07:40:11 +02:00
echo " " . $text [ 'label-device_address' ] . " \n " ;
2015-06-23 21:43:12 +02:00
echo " </td> \n " ;
2023-07-01 00:40:17 +02:00
echo " <td class='vtable' style='padding-left: 8px;'> \n " ;
2015-06-23 21:43:12 +02:00
echo " " . $text [ 'label-device_template' ] . " \n " ;
echo " </td> \n " ;
2020-03-29 04:16:05 +02:00
if ( $action == 'update' ) {
echo " <td> </td> \n " ;
2015-06-23 21:43:12 +02:00
}
2020-03-29 04:16:05 +02:00
echo " </tr> \n " ;
if ( $action == 'update' ) {
if ( is_array ( $device_lines ) && @ sizeof ( $device_lines ) != 0 ) {
foreach ( $device_lines as $row ) {
2023-06-30 07:40:11 +02:00
$device_address = format_device_address ( $row [ 'device_address' ]);
2020-03-29 04:16:05 +02:00
echo " <tr> \n " ;
echo " <td class='vtable'> " . escape ( $row [ 'line_number' ]) . " </td> \n " ;
2023-06-30 07:40:11 +02:00
echo " <td class='vtable'><a href=' " . PROJECT_PATH . " /app/devices/device_edit.php?id= " . escape ( $row [ 'device_uuid' ]) . " '> " . escape ( $device_address ) . " </a></td> \n " ;
2023-07-01 00:40:17 +02:00
echo " <td class='vtable' style='padding-left: 10px;'> " . escape ( $row [ 'device_template' ]) . " </td> \n " ;
2020-03-29 04:16:05 +02:00
//echo " <td class='vtable'>".$row['device_description']." </td>\n";
echo " <td> \n " ;
echo " <a href='#' onclick= \" if (confirm(' " . $text [ 'confirm-delete' ] . " ')) { document.getElementById('delete_type').value = 'device_line'; document.getElementById('delete_uuid').value = ' " . escape ( $row [ 'device_line_uuid' ]) . " '; document.getElementById('frm').submit(); } \" alt=' " . $text [ 'button-delete' ] . " '> $v_link_label_delete </a> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
}
2015-06-23 21:43:12 +02:00
}
2020-03-29 04:16:05 +02:00
for ( $d = 0 ; $d <= 4 ; $d ++ ) {
echo " <tr> \n " ;
echo " <td " . ( $action == 'edit' ? " class='vtable' " : null ) . " > " ;
2023-05-17 09:02:45 +02:00
echo " <select id='line_number' name='devices[ " . $d . " ][line_number]' class='formfld' style='width: auto;' onchange= \" " . escape ( $onchange ? ? '' ) . " \" > \n " ;
2020-03-29 04:16:05 +02:00
echo " <option value=''></option> \n " ;
for ( $n = 1 ; $n <= 99 ; $n ++ ) {
echo " <option value=' " . escape ( $n ) . " '> " . escape ( $n ) . " </option> \n " ;
}
echo " </select> \n " ;
echo " </td> \n " ;
echo " <td " . ( $action == 'edit' ? " class='vtable' " : null ) . " > " ;
echo " <table border='0' cellpadding='0' cellspacing='0'> \n " ;
echo " <tr> \n " ;
echo " <td nowrap='nowrap'> \n " ;
?>
< script >
var Objs ;
2023-06-30 07:40:11 +02:00
function changeToInput_device_address_ < ? php echo $d ; ?> (obj){
2020-03-29 04:16:05 +02:00
tb = document . createElement ( 'INPUT' );
tb . type = 'text' ;
tb . name = obj . name ;
tb . className = 'formfld' ;
2023-06-30 07:40:11 +02:00
tb . setAttribute ( 'id' , 'device_address_<?php echo $d; ?>' );
2023-07-01 00:40:17 +02:00
tb . setAttribute ( 'style' , 'width: 250px;' );
2020-03-29 04:16:05 +02:00
tb . value = obj . options [ obj . selectedIndex ] . value ;
2023-07-01 00:40:17 +02:00
document . getElementById ( 'btn_select_to_input_device_address_<?php echo $d; ?>' ) . style . display = 'none' ;
2020-03-29 04:16:05 +02:00
tbb = document . createElement ( 'INPUT' );
tbb . setAttribute ( 'class' , 'btn' );
tbb . setAttribute ( 'style' , 'margin-left: 4px;' );
tbb . type = 'button' ;
tbb . value = $ ( " <div /> " ) . html ( '◁' ) . text ();
tbb . objs = [ obj , tb , tbb ];
2023-06-30 07:40:11 +02:00
tbb . onclick = function (){ replace_device_address_ < ? php echo $d ; ?> (this.objs); }
2020-03-29 04:16:05 +02:00
obj . parentNode . insertBefore ( tb , obj );
obj . parentNode . insertBefore ( tbb , obj );
obj . parentNode . removeChild ( obj );
2023-06-30 07:40:11 +02:00
replace_device_address_ < ? php echo $d ; ?> (this.objs);
2020-03-29 04:16:05 +02:00
}
2015-06-23 21:43:12 +02:00
2023-06-30 07:40:11 +02:00
function replace_device_address_ < ? php echo $d ; ?> (obj){
2020-03-29 04:16:05 +02:00
obj [ 2 ] . parentNode . insertBefore ( obj [ 0 ], obj [ 2 ]);
obj [ 0 ] . parentNode . removeChild ( obj [ 1 ]);
obj [ 0 ] . parentNode . removeChild ( obj [ 2 ]);
2023-07-01 00:40:17 +02:00
document . getElementById ( 'btn_select_to_input_device_address_<?php echo $d; ?>' ) . style . display = 'inline' ;
2020-03-29 04:16:05 +02:00
}
</ script >
< ? php
2023-07-01 00:40:17 +02:00
echo " <select id='device_address_ " . $d . " ' name='devices[ " . $d . " ][device_address]' class='formfld' style='width: 250px;' onchange= \" changeToInput_device_address_ " . $d . " (this); this.style.visibility='hidden'; \" > \n " ;
2020-03-29 04:16:05 +02:00
echo " <option value=''></option> \n " ;
if ( is_array ( $devices ) && @ sizeof ( $devices ) != 0 ) {
foreach ( $devices as $field ) {
2023-06-30 07:40:11 +02:00
if ( ! empty ( $field [ " device_address " ])) {
2023-07-01 00:40:17 +02:00
$selected = ! empty ( $field_current_value ) && $field_current_value == $field [ " device_address " ] ? " selected='selected' " : null ;
2023-06-30 23:49:44 +02:00
echo " <option value=' " . escape ( $field [ " device_address " ]) . " ' " . $selected . " > " . escape ( format_device_address ( $field [ " device_address " ])) . ( ! empty ( $field [ 'device_model' ]) || ! empty ( $field [ 'device_description' ]) ? " - " . escape ( $field [ 'device_model' ]) . " " . escape ( $field [ 'device_description' ]) : null ) . " </option> \n " ;
2015-06-23 21:43:12 +02:00
}
}
}
2025-02-13 22:12:48 +01:00
if ( permission_exists ( 'device_address_uuid' ) && ( $limit_devices === null || $total_devices < $limit_devices )) {
2023-07-01 00:40:17 +02:00
echo " <option disabled='disabled'></option> \n " ;
echo " <option value='UUID'> " . $text [ 'label-generate' ] . " </option> \n " ;
}
2020-03-29 04:16:05 +02:00
echo " </select> \n " ;
2023-06-30 07:40:11 +02:00
echo " <input type='button' id='btn_select_to_input_device_address_ " . $d . " ' class='btn' alt=' " . $text [ 'button-back' ] . " ' onclick= \" changeToInput_device_address_ " . $d . " (document.getElementById('device_address_ " . $d . " ')); this.style.visibility='hidden'; \" value='◁'> \n " ;
2020-03-29 04:16:05 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
echo " </table> \n " ;
echo " </td> \n " ;
2023-07-01 00:40:17 +02:00
echo " <td " . ( $action == 'edit' ? " class='vtable' " : null ) . " style='padding-left: 5px;'> " ;
2020-03-29 04:16:05 +02:00
$device = new device ;
$template_dir = $device -> get_template_dir ();
echo " <select id='device_template' name='devices[ " . $d . " ][device_template]' class='formfld'> \n " ;
echo " <option value=''></option> \n " ;
if ( is_dir ( $template_dir ) && is_array ( $device_vendors )) {
foreach ( $device_vendors as $row ) {
echo " <optgroup label=' " . escape ( $row [ " name " ]) . " '> \n " ;
if ( is_dir ( $template_dir . '/' . $row [ " name " ])) {
$templates = scandir ( $template_dir . '/' . $row [ " name " ]);
foreach ( $templates as $dir ) {
2023-05-18 09:42:48 +02:00
if ( ! empty ( $dir ) && $dir != " . " && $dir != " .. " && $dir [ 0 ] != '.' && ! empty ( $template_dir ) && is_dir ( $template_dir . '/' . $row [ " name " ] . '/' . $dir )) {
2023-05-29 22:07:53 +02:00
$selected = ! empty ( $device_template ) && $device_template == $row [ " name " ] . " / " . $dir ? " selected='selected' " : null ;
2020-03-29 04:16:05 +02:00
echo " <option value=' " . escape ( $row [ " name " ]) . " / " . escape ( $dir ) . " ' " . $selected . " > " . escape ( $row [ " name " ]) . " / " . escape ( $dir ) . " </option> \n " ;
2015-06-23 21:43:12 +02:00
}
}
}
2020-03-29 04:16:05 +02:00
echo " </optgroup> \n " ;
2015-06-23 21:43:12 +02:00
}
}
2020-03-29 04:16:05 +02:00
echo " </select> \n " ;
echo " </td> \n " ;
if ( is_array ( $device_lines ) && @ sizeof ( $device_lines ) != 0 ) {
echo " <td> \n " ;
2025-02-13 22:12:48 +01:00
echo button :: create ([ 'type' => 'submit' , 'label' => $text [ 'button-add' ], 'icon' => $settings -> get ( 'theme' , 'button_icon_add' )]);
2020-03-29 04:16:05 +02:00
echo " </td> \n " ;
}
echo " </tr> \n " ;
2020-05-12 19:32:02 +02:00
break ; //show one empty row whether adding or editing
2015-06-23 21:43:12 +02:00
}
echo " </table> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-provisioning' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
}
2019-01-29 21:22:17 +01:00
if ( permission_exists ( " effective_caller_id_name " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-effective_caller_id_name' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='effective_caller_id_name' maxlength='255' value= \" " . escape ( $effective_caller_id_name ? ? '' ) . " \" > \n " ;
2019-01-29 21:22:17 +01:00
echo " <br /> \n " ;
echo $text [ 'description-effective_caller_id_name' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
2019-01-29 21:22:17 +01:00
if ( permission_exists ( " effective_caller_id_number " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-effective_caller_id_number' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='effective_caller_id_number' min='0' step='1' maxlength='255' value= \" " . escape ( $effective_caller_id_number ? ? '' ) . " \" > \n " ;
2019-01-29 21:22:17 +01:00
echo " <br /> \n " ;
echo $text [ 'description-effective_caller_id_number' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
2018-10-16 00:50:59 +02:00
if ( permission_exists ( " outbound_caller_id_name " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-outbound_caller_id_name' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
if ( permission_exists ( 'outbound_caller_id_select' )) {
2023-06-29 17:32:43 +02:00
if ( ! empty ( $destinations )) {
2018-10-16 00:50:59 +02:00
echo " <select name='outbound_caller_id_name' id='outbound_caller_id_name' class='formfld'> \n " ;
echo " <option value=''></option> \n " ;
2024-08-22 20:41:10 +02:00
foreach ( $destinations as $row ) {
2023-06-29 17:32:43 +02:00
if ( ! empty ( $row [ " destination_caller_id_name " ])){
if ( ! empty ( $outbound_caller_id_name ) && $row [ " destination_caller_id_name " ] == $outbound_caller_id_name ) {
echo " <option value=' " . escape ( $row [ " destination_caller_id_name " ]) . " ' selected='selected'> " . escape ( $row [ " destination_caller_id_name " ]) . " </option> \n " ;
2018-10-16 00:50:59 +02:00
}
else {
2023-06-29 17:32:43 +02:00
echo " <option value=' " . escape ( $row [ " destination_caller_id_name " ]) . " '> " . escape ( $row [ " destination_caller_id_name " ]) . " </option> \n " ;
2018-10-16 00:50:59 +02:00
}
2015-10-23 14:05:24 +02:00
}
2012-10-25 08:29:59 +02:00
}
2018-10-16 00:50:59 +02:00
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-outbound_caller_id_name-select' ] . " \n " ;
}
else {
2023-05-17 09:02:45 +02:00
echo " <input type='button' class='btn' name='' alt= \" " . $text [ 'button-add' ] . " \" onclick= \" window.location=' " . PROJECT_PATH . " /app/destinations/destinations.php' \" value=' " . $text [ 'button-add' ] . " '> \n " ;
2012-10-25 08:29:59 +02:00
}
}
else {
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='outbound_caller_id_name' maxlength='255' value= \" " . escape ( $outbound_caller_id_name ? ? '' ) . " \" > \n " ;
2018-10-16 00:50:59 +02:00
echo " <br /> \n " ;
echo $text [ 'description-outbound_caller_id_name-custom' ] . " \n " ;
2012-10-25 08:29:59 +02:00
}
2018-10-16 00:50:59 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2012-10-25 08:29:59 +02:00
}
2012-06-04 16:58:40 +02:00
2018-10-16 00:50:59 +02:00
if ( permission_exists ( " outbound_caller_id_number " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-outbound_caller_id_number' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
if ( permission_exists ( 'outbound_caller_id_select' )) {
2023-06-29 17:32:43 +02:00
if ( ! empty ( $destinations )) {
2018-10-16 00:50:59 +02:00
echo " <select name='outbound_caller_id_number' id='outbound_caller_id_number' class='formfld'> \n " ;
echo " <option value=''></option> \n " ;
2024-08-22 20:41:10 +02:00
foreach ( $destinations as $row ) {
2018-10-16 00:50:59 +02:00
$tmp = $row [ " destination_caller_id_number " ];
2023-05-05 18:46:37 +02:00
if ( empty ( $tmp )){
2018-10-16 00:50:59 +02:00
$tmp = $row [ " destination_number " ];
2015-10-23 14:05:24 +02:00
}
2023-05-05 18:46:37 +02:00
if ( ! empty ( $tmp )){
2023-06-13 01:04:33 +02:00
if ( ! empty ( $outbound_caller_id_number ) && $outbound_caller_id_number == $tmp ) {
2018-10-16 00:50:59 +02:00
echo " <option value=' " . escape ( $tmp ) . " ' selected='selected'> " . escape ( $tmp ) . " </option> \n " ;
}
else {
echo " <option value=' " . escape ( $tmp ) . " '> " . escape ( $tmp ) . " </option> \n " ;
}
2015-10-23 14:05:24 +02:00
}
2012-10-25 08:29:59 +02:00
}
2018-10-16 00:50:59 +02:00
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-outbound_caller_id_number-select' ] . " \n " ;
2012-10-25 08:29:59 +02:00
}
2018-10-16 00:50:59 +02:00
else {
2023-05-17 09:02:45 +02:00
echo " <input type='submit' class='btn' name='' alt= \" " . $text [ 'button-add' ] . " \" onclick= \" window.location=' " . PROJECT_PATH . " /app/destinations/destinations.php' \" value=' " . $text [ 'button-add' ] . " '> \n " ;
2018-10-16 00:50:59 +02:00
}
2012-10-25 08:29:59 +02:00
}
else {
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='outbound_caller_id_number' maxlength='255' min='0' step='1' value= \" " . escape ( $outbound_caller_id_number ? ? '' ) . " \" > \n " ;
2018-10-16 00:50:59 +02:00
echo " <br /> \n " ;
echo $text [ 'description-outbound_caller_id_number-custom' ] . " \n " ;
2012-10-25 08:29:59 +02:00
}
2018-10-16 00:50:59 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2012-10-25 08:29:59 +02:00
}
2018-10-16 00:50:59 +02:00
if ( permission_exists ( " emergency_caller_id_name " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-emergency_caller_id_name' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2020-12-12 01:24:14 +01:00
if ( permission_exists ( 'emergency_caller_id_select' )) {
2023-06-29 17:32:43 +02:00
if ( ! empty ( $emergency_destinations )) {
2020-12-12 01:24:14 +01:00
echo " <select name='emergency_caller_id_name' id='emergency_caller_id_name' class='formfld'> \n " ;
echo " <option value=''></option> \n " ;
2024-08-22 20:41:10 +02:00
foreach ( $emergency_destinations as $row ) {
2020-12-12 01:24:14 +01:00
$tmp = $row [ " destination_caller_id_name " ];
2023-05-05 18:46:37 +02:00
if ( empty ( $tmp )){
2020-12-12 01:24:14 +01:00
$tmp = $row [ " destination_description " ];
}
2023-05-05 18:46:37 +02:00
if ( ! empty ( $tmp )){
2020-12-12 01:24:14 +01:00
if ( $emergency_caller_id_name == $tmp ) {
echo " <option value=' " . escape ( $tmp ) . " ' selected='selected'> " . escape ( $tmp ) . " </option> \n " ;
}
else {
echo " <option value=' " . escape ( $tmp ) . " '> " . escape ( $tmp ) . " </option> \n " ;
}
}
}
echo " </select> \n " ;
}
else {
echo " <input type= \" button \" class= \" btn \" name= \" \" alt= \" " . $text [ 'button-add' ] . " \" onclick= \" window.location=' " . PROJECT_PATH . " /app/destinations/destinations.php' \" value=' " . $text [ 'button-add' ] . " '> \n " ;
}
}
2019-07-15 22:21:46 +02:00
else {
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='emergency_caller_id_name' maxlength='255' value= \" " . escape ( $emergency_caller_id_name ? ? '' ) . " \" > \n " ;
2019-07-15 22:21:46 +02:00
}
2013-05-04 02:35:21 +02:00
echo " <br /> \n " ;
2020-04-14 20:56:14 +02:00
if ( permission_exists ( 'outbound_caller_id_select' ) && count ( $destinations ) > 0 ) {
echo $text [ 'description-emergency_caller_id_name-select' ] . " \n " ;
}
else {
echo $text [ 'description-emergency_caller_id_name' ] . " \n " ;
}
2018-10-16 00:50:59 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2012-10-25 08:29:59 +02:00
}
2012-06-04 16:58:40 +02:00
2018-10-16 00:50:59 +02:00
if ( permission_exists ( " emergency_caller_id_number " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-emergency_caller_id_number' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2020-12-12 01:24:14 +01:00
if ( permission_exists ( 'emergency_caller_id_select' )) {
2023-06-29 17:32:43 +02:00
if ( ! empty ( $emergency_destinations )) {
2020-12-12 01:24:14 +01:00
echo " <select name='emergency_caller_id_number' id='emergency_caller_id_number' class='formfld'> \n " ;
2021-11-16 21:42:31 +01:00
if ( permission_exists ( 'emergency_caller_id_select_empty' )) {
echo " <option value=''></option> \n " ;
}
2024-08-22 20:41:10 +02:00
foreach ( $emergency_destinations as $row ) {
2020-12-12 01:24:14 +01:00
$tmp = $row [ " destination_caller_id_number " ];
2023-05-05 18:46:37 +02:00
if ( empty ( $tmp )){
2020-12-12 01:24:14 +01:00
$tmp = $row [ " destination_number " ];
2019-07-15 22:21:46 +02:00
}
2023-05-05 18:46:37 +02:00
if ( ! empty ( $tmp )){
2019-12-13 02:05:13 +01:00
if ( $emergency_caller_id_number == $tmp ) {
2019-07-15 22:21:46 +02:00
echo " <option value=' " . escape ( $tmp ) . " ' selected='selected'> " . escape ( $tmp ) . " </option> \n " ;
}
else {
echo " <option value=' " . escape ( $tmp ) . " '> " . escape ( $tmp ) . " </option> \n " ;
}
}
}
echo " </select> \n " ;
}
else {
echo " <input type= \" button \" class= \" btn \" name= \" \" alt= \" " . $text [ 'button-add' ] . " \" onclick= \" window.location=' " . PROJECT_PATH . " /app/destinations/destinations.php' \" value=' " . $text [ 'button-add' ] . " '> \n " ;
}
}
else {
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='emergency_caller_id_number' maxlength='255' min='0' step='1' value= \" " . escape ( $emergency_caller_id_number ? ? '' ) . " \" > \n " ;
2019-07-15 22:21:46 +02:00
}
2018-10-16 00:50:59 +02:00
echo " <br /> \n " ;
2023-06-29 17:32:43 +02:00
if ( permission_exists ( 'emergency_caller_id_select' ) && ! empty ( $emergency_destinations )){
2020-12-12 01:24:14 +01:00
echo $text [ 'description-emergency_caller_id_number-select' ] . " \n " ;
}
2023-06-29 17:32:43 +02:00
elseif ( permission_exists ( 'outbound_caller_id_select' ) && ! empty ( $destinations )) {
2020-04-14 20:56:14 +02:00
echo $text [ 'description-emergency_caller_id_number-select' ] . " \n " ;
}
else {
echo $text [ 'description-emergency_caller_id_number' ] . " \n " ;
}
2018-10-16 00:50:59 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
2020-12-29 06:24:03 +01:00
if ( permission_exists ( " extension_directory " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-directory_full_name' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='directory_first_name' maxlength='255' value= \" " . escape ( $directory_first_name ? ? '' ) . " \" > \n " ;
echo " <input class='formfld' type='text' name='directory_last_name' maxlength='255' value= \" " . escape ( $directory_last_name ? ? '' ) . " \" > \n " ;
2020-12-29 06:24:03 +01:00
echo " <br /> \n " ;
echo $text [ 'description-directory_full_name' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
2020-12-29 06:24:03 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-directory_visible' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='directory_visible'> \n " ;
2023-05-17 09:02:45 +02:00
if ( ! empty ( $directory_visible ) && $directory_visible == " true " ) {
2020-12-29 06:24:03 +01:00
echo " <option value='true' selected='selected'> " . $text [ 'label-true' ] . " </option> \n " ;
}
else {
echo " <option value='true'> " . $text [ 'label-true' ] . " </option> \n " ;
}
2023-05-17 09:02:45 +02:00
if ( ! empty ( $directory_visible ) && $directory_visible == " false " ) {
2020-12-29 06:24:03 +01:00
echo " <option value='false' selected > " . $text [ 'label-false' ] . " </option> \n " ;
}
else {
echo " <option value='false'> " . $text [ 'label-false' ] . " </option> \n " ;
}
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-directory_visible' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
2020-12-29 06:24:03 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-directory_exten_visible' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='directory_exten_visible'> \n " ;
2023-05-17 09:02:45 +02:00
if ( ! empty ( $directory_exten_visible ) && $directory_exten_visible == " true " ) {
2020-12-29 06:24:03 +01:00
echo " <option value='true' selected='selected'> " . $text [ 'label-true' ] . " </option> \n " ;
}
else {
echo " <option value='true'> " . $text [ 'label-true' ] . " </option> \n " ;
}
2023-05-17 09:02:45 +02:00
if ( ! empty ( $directory_exten_visible ) && $directory_exten_visible == " false " ) {
2020-12-29 06:24:03 +01:00
echo " <option value='false' selected > " . $text [ 'label-false' ] . " </option> \n " ;
}
else {
echo " <option value='false'> " . $text [ 'label-false' ] . " </option> \n " ;
}
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-directory_exten_visible' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
}
2021-04-11 06:28:06 +02:00
if ( permission_exists ( " extension_max_registrations " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-max_registrations' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='max_registrations' maxlength='255' value= \" " . escape ( $max_registrations ? ? '' ) . " \" > \n " ;
2021-04-11 06:28:06 +02:00
echo " <br /> \n " ;
echo $text [ 'description-max_registrations' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2020-12-29 06:24:03 +01:00
if ( permission_exists ( " extension_limit " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-limit_max' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='limit_max' maxlength='255' value= \" " . escape ( $limit_max ? ? '' ) . " \" > \n " ;
2020-12-29 06:24:03 +01:00
echo " <br /> \n " ;
echo $text [ 'description-limit_max' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
2020-12-29 06:24:03 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-limit_destination' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='limit_destination' maxlength='255' value= \" " . escape ( $limit_destination ? ? '' ) . " \" > \n " ;
2020-12-29 06:24:03 +01:00
echo " <br /> \n " ;
echo $text [ 'description-limit_destination' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
2016-10-09 18:32:49 +02:00
if ( permission_exists ( 'voicemail_edit' ) && is_dir ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/app/voicemails' )) {
2014-03-04 06:49:38 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-voicemail_enabled' ] . " \n " ;
2014-03-04 06:49:38 +01:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2014-05-25 03:43:47 +02:00
echo " <select class='formfld' name='voicemail_enabled'> \n " ;
2024-07-19 07:43:36 +02:00
echo " <option value=''></option> \n " ;
2014-05-25 03:43:47 +02:00
if ( $voicemail_enabled == " true " ) {
2014-03-04 06:49:38 +01:00
echo " <option value='true' selected='selected'> " . $text [ 'label-true' ] . " </option> \n " ;
}
else {
echo " <option value='true'> " . $text [ 'label-true' ] . " </option> \n " ;
}
2014-05-25 03:43:47 +02:00
if ( $voicemail_enabled == " false " ) {
2014-03-04 06:49:38 +01:00
echo " <option value='false' selected='selected'> " . $text [ 'label-false' ] . " </option> \n " ;
}
else {
echo " <option value='false'> " . $text [ 'label-false' ] . " </option> \n " ;
}
echo " </select> \n " ;
echo " <br /> \n " ;
2014-05-25 03:43:47 +02:00
echo $text [ 'description-voicemail_enabled' ] . " \n " ;
2014-03-04 06:49:38 +01:00
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
2014-03-04 06:49:38 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-voicemail_mail_to' ] . " \n " ;
2014-03-04 06:49:38 +01:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2024-10-30 21:11:46 +01:00
echo " <input class='formfld' type='text' name='voicemail_mail_to' maxlength='1024' value= \" " . escape ( $voicemail_mail_to ? ? '' ) . " \" > \n " ;
2014-03-04 06:49:38 +01:00
echo " <br /> \n " ;
2014-05-25 03:43:47 +02:00
echo $text [ 'description-voicemail_mail_to' ] . " \n " ;
2014-03-04 06:49:38 +01:00
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
2025-02-13 22:12:48 +01:00
if ( permission_exists ( 'voicemail_transcription_enabled' ) && $transcribe_enabled ) {
2022-01-29 10:28:07 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-voicemail_transcription_enabled' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='voicemail_transcription_enabled' id='voicemail_transcription_enabled'> \n " ;
2024-07-19 07:43:36 +02:00
echo " <option value=''></option> \n " ;
2022-01-29 10:28:07 +01:00
echo " <option value='true' " . (( $voicemail_transcription_enabled == " true " ) ? " selected='selected' " : null ) . " > " . $text [ 'label-true' ] . " </option> \n " ;
echo " <option value='false' " . (( $voicemail_transcription_enabled == " false " ) ? " selected='selected' " : null ) . " > " . $text [ 'label-false' ] . " </option> \n " ;
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-voicemail_transcription_enabled' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2022-06-01 18:48:33 +02:00
if ( permission_exists ( 'voicemail_file' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-voicemail_file' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='voicemail_file' id='voicemail_file' onchange= \" if (this.selectedIndex != 2) { document.getElementById('voicemail_local_after_email').selectedIndex = 0; } \" > \n " ;
2023-02-07 00:24:49 +01:00
echo " <option value=''> " . $text [ 'option-voicemail_file_listen' ] . " </option> \n " ;
2022-06-01 18:48:33 +02:00
echo " <option value='link' " . (( $voicemail_file == " link " ) ? " selected='selected' " : null ) . " > " . $text [ 'option-voicemail_file_link' ] . " </option> \n " ;
echo " <option value='attach' " . (( $voicemail_file == " attach " ) ? " selected='selected' " : null ) . " > " . $text [ 'option-voicemail_file_attach' ] . " </option> \n " ;
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-voicemail_file' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
2017-07-05 18:26:45 +02:00
if ( permission_exists ( 'voicemail_local_after_email' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-voicemail_local_after_email' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='voicemail_local_after_email' id='voicemail_local_after_email' onchange= \" if (this.selectedIndex == 1) { document.getElementById('voicemail_file').selectedIndex = 2; } \" > \n " ;
echo " <option value='true' " . (( $voicemail_local_after_email == " true " ) ? " selected='selected' " : null ) . " > " . $text [ 'label-true' ] . " </option> \n " ;
echo " <option value='false' " . (( $voicemail_local_after_email == " false " ) ? " selected='selected' " : null ) . " > " . $text [ 'label-false' ] . " </option> \n " ;
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-voicemail_local_after_email' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
}
2015-05-23 04:11:26 +02:00
if ( permission_exists ( 'extension_missed_call' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-missed_call' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='missed_call_app' id='missed_call_app' onchange= \" if (this.selectedIndex != 0) { document.getElementById('missed_call_data').style.display = ''; document.getElementById('missed_call_data').focus(); } else { document.getElementById('missed_call_data').style.display='none'; } \" > \n " ;
echo " <option value=''></option> \n " ;
2023-06-29 17:32:43 +02:00
echo " <option value='email' " . (( ! empty ( $missed_call_app ) && $missed_call_app == " email " && ! empty ( $missed_call_data ) && ! empty ( $missed_call_data )) ? " selected='selected' " : null ) . " > " . $text [ 'label-email' ] . " </option> \n " ;
//echo " <option value='text' ".(($missed_call_app == "text" && !empty($missed_call_data)) ? "selected='selected'" : null).">".$text['label-text']."</option>\n";
//echo " <option value='url' ".(($missed_call_app == "url" && !empty($missed_call_data)) ? "selected='selected'" : null).">".$text['label-url']."</option>\n";
2015-05-23 04:11:26 +02:00
echo " </select> \n " ;
2023-05-17 09:02:45 +02:00
$missed_call_data = ! empty ( $missed_call_app ) && $missed_call_app == 'text' ? format_phone ( $missed_call_data ? ? '' ) : $missed_call_data ? ? '' ;
echo " <input class='formfld' type='text' name='missed_call_data' id='missed_call_data' maxlength='255' value= \" " . escape ( $missed_call_data ? ? '' ) . " \" style='min-width: 200px; width: 200px; " . (( empty ( $missed_call_app ) || empty ( $missed_call_data )) ? " display: none; " : null ) . " '> \n " ;
2015-05-23 04:11:26 +02:00
echo " <br /> \n " ;
echo $text [ 'description-missed_call' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
if ( permission_exists ( 'extension_toll' )) {
2013-05-04 02:35:21 +02:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-toll_allow' ] . " \n " ;
2013-05-04 02:35:21 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
if ( ! empty ( $_SESSION [ 'toll allow' ][ 'name' ]) && is_array ( $_SESSION [ 'toll allow' ][ 'name' ])) {
2017-11-05 23:49:25 +01:00
echo " <select class='formfld' name='toll_allow' id='toll_allow'> \n " ;
2016-01-14 00:26:55 +01:00
echo " <option value=''></option> \n " ;
foreach ( $_SESSION [ 'toll allow' ][ 'name' ] as $name ) {
2017-11-05 23:49:25 +01:00
if ( $name == $toll_allow ) {
2018-06-13 09:13:38 +02:00
echo " <option value=' " . escape ( $name ) . " ' selected='selected'> " . escape ( $name ) . " </option> \n " ;
2016-01-14 01:57:25 +01:00
}
else {
2018-06-13 09:13:38 +02:00
echo " <option value=' " . escape ( $name ) . " '> " . escape ( $name ) . " </option> \n " ;
2016-01-14 01:57:25 +01:00
}
2016-01-14 00:26:55 +01:00
}
echo " </select> \n " ;
}
else {
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='toll_allow' maxlength='255' value= \" " . escape ( $toll_allow ? ? '' ) . " \" > \n " ;
2016-01-14 00:26:55 +01:00
}
2012-06-04 16:58:40 +02:00
echo " <br /> \n " ;
2013-05-04 02:35:21 +02:00
echo $text [ 'description-toll_allow' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
}
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-call_timeout' ] . " \n " ;
2013-04-02 09:36:28 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='number' name='call_timeout' maxlength='255' min='1' step='1' value= \" " . escape ( $call_timeout ? ? '' ) . " \" > \n " ;
2013-04-02 09:36:28 +02:00
echo " <br /> \n " ;
2013-05-04 02:35:21 +02:00
echo $text [ 'description-call_timeout' ] . " \n " ;
2013-04-02 09:36:28 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2020-12-29 06:24:03 +01:00
if ( permission_exists ( " extension_call_group " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-call_group' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2025-02-13 22:12:48 +01:00
if ( ! empty ( $settings -> get ( 'call_group' , 'name' )) && is_array ( $settings -> get ( 'call_group' , 'name' ))) {
2020-12-29 06:24:03 +01:00
echo " <select class='formfld' name='call_group'> \n " ;
echo " <option value=''></option> \n " ;
2025-02-13 22:12:48 +01:00
foreach ( $settings -> get ( 'call_group' , 'name' ) as $name ) {
2020-12-29 06:24:03 +01:00
if ( $name == $call_group ) {
echo " <option value=' " . escape ( $name ) . " ' selected='selected'> " . escape ( $name ) . " </option> \n " ;
}
else {
echo " <option value=' " . escape ( $name ) . " '> " . escape ( $name ) . " </option> \n " ;
}
2016-01-14 01:57:25 +01:00
}
2020-12-29 06:24:03 +01:00
echo " </select> \n " ;
2023-05-17 09:02:45 +02:00
}
else {
echo " <input class='formfld' type='text' name='call_group' maxlength='255' value= \" " . escape ( $call_group ? ? '' ) . " \" > \n " ;
2016-01-14 00:26:55 +01:00
}
2020-12-29 06:24:03 +01:00
echo " <br /> \n " ;
echo $text [ 'description-call_group' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2016-01-14 00:26:55 +01:00
}
2012-06-04 16:58:40 +02:00
2015-06-23 22:06:44 +02:00
if ( permission_exists ( 'extension_call_screen' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-call_screen_enabled' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='call_screen_enabled'> \n " ;
2024-07-19 07:43:36 +02:00
echo " <option value=''></option> \n " ;
2015-06-23 22:06:44 +02:00
if ( $call_screen_enabled == " true " ) {
echo " <option value='true' selected='selected'> " . $text [ 'label-true' ] . " </option> \n " ;
}
else {
echo " <option value='true'> " . $text [ 'label-true' ] . " </option> \n " ;
}
if ( $call_screen_enabled == " false " ) {
echo " <option value='false' selected='selected'> " . $text [ 'label-false' ] . " </option> \n " ;
}
else {
echo " <option value='false'> " . $text [ 'label-false' ] . " </option> \n " ;
}
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-call_screen_enabled' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2015-06-23 21:59:51 +02:00
}
2016-01-27 23:56:22 +01:00
if ( permission_exists ( 'extension_user_record' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-user_record' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='user_record'> \n " ;
echo " <option value=''> " . $text [ 'label-user_record_none' ] . " </option> \n " ;
if ( $user_record == " all " ) {
echo " <option value='all' selected='selected'> " . $text [ 'label-user_record_all' ] . " </option> \n " ;
}
else {
echo " <option value='all'> " . $text [ 'label-user_record_all' ] . " </option> \n " ;
}
if ( $user_record == " local " ) {
echo " <option value='local' selected='selected'> " . $text [ 'label-user_record_local' ] . " </option> \n " ;
}
else {
echo " <option value='local'> " . $text [ 'label-user_record_local' ] . " </option> \n " ;
}
if ( $user_record == " inbound " ) {
echo " <option value='inbound' selected='selected'> " . $text [ 'label-user_record_inbound' ] . " </option> \n " ;
}
else {
echo " <option value='inbound'> " . $text [ 'label-user_record_inbound' ] . " </option> \n " ;
}
if ( $user_record == " outbound " ) {
echo " <option value='outbound' selected='selected'> " . $text [ 'label-user_record_outbound' ] . " </option> \n " ;
}
else {
echo " <option value='outbound'> " . $text [ 'label-user_record_outbound' ] . " </option> \n " ;
}
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-user_record' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2014-04-02 08:43:11 +02:00
}
2020-12-29 06:24:03 +01:00
if ( is_dir ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/app/music_on_hold' ) && permission_exists ( 'extension_hold_music' )) {
2014-03-04 06:41:28 +01:00
echo " <tr> \n " ;
echo " <td width= \" 30% \" class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-hold_music' ] . " \n " ;
2014-03-04 06:41:28 +01:00
echo " </td> \n " ;
echo " <td width= \" 70% \" class='vtable' align='left'> \n " ;
2016-12-03 01:25:51 +01:00
$options = '' ;
2016-06-08 23:15:36 +02:00
$moh = new switch_music_on_hold ;
2023-05-17 09:02:45 +02:00
echo $moh -> select ( 'hold_music' , $hold_music ? ? '' , $options );
2014-03-04 06:41:28 +01:00
echo " <br /> \n " ;
echo $text [ 'description-hold_music' ] . " \n " ;
echo " </td> \n " ;
2023-07-14 01:11:07 +02:00
echo " </tr> \n " ;
}
2024-07-27 01:04:02 +02:00
2024-01-10 23:55:00 +01:00
if ( permission_exists ( 'extension_language' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap> \n " ;
echo " " . $text [ 'label-language' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' type='text' name='extension_language'> \n " ;
echo " <option></option> \n " ;
if ( ! empty ( $extension_language ) && ! empty ( $extension_dialect ) && ! empty ( $extension_voice )) {
$language_formatted = $extension_language . " - " . $extension_dialect . " " . $extension_voice ;
echo " <option value=' " . escape ( $extension_language . '/' . $extension_dialect . '/' . $extension_voice ) . " ' selected='selected'> " . escape ( $language_formatted ) . " </option> \n " ;
}
if ( ! empty ( $language_paths )) {
foreach ( $language_paths as $key => $language_variables ) {
$language_variables = explode ( '/' , $language_paths [ $key ]);
$language = $language_variables [ 0 ];
$dialect = $language_variables [ 1 ];
$voice = $language_variables [ 2 ];
if ( empty ( $language_formatted ) || $language_formatted != $language . '-' . $dialect . ' ' . $voice ) {
echo " <option value=' " . $language . " / " . $dialect . " / " . $voice . " '> " . $language . " - " . $dialect . " " . $voice . " </option> \n " ;
}
}
}
2024-01-11 02:11:19 +01:00
echo " </select> \n " ;
2024-01-10 23:55:00 +01:00
echo " <br /> \n " ;
2024-01-11 01:57:06 +01:00
echo $text [ 'description-language' ] . " \n " ;
2024-01-10 23:55:00 +01:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
2023-07-14 01:11:07 +02:00
if ( permission_exists ( 'extension_type' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-extension_type' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='extension_type' id='extension_type'> \n " ;
2024-07-19 07:43:36 +02:00
echo " <option value=''></option> \n " ;
2023-07-14 01:11:07 +02:00
echo " <option value='default' " . (( $extension_type == " default " ) ? " selected='selected' " : null ) . " > " . $text [ 'label-default' ] . " </option> \n " ;
echo " <option value='virtual' " . (( $extension_type == " virtual " ) ? " selected='selected' " : null ) . " > " . $text [ 'label-virtual' ] . " </option> \n " ;
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-extension_type' ] . " \n " ;
echo " </td> \n " ;
2014-03-04 06:41:28 +01:00
echo " </tr> \n " ;
}
2012-11-20 20:36:37 +01:00
2020-07-03 04:16:39 +02:00
if ( permission_exists ( 'extension_domain' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-domain' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='domain_uuid'> \n " ;
foreach ( $_SESSION [ 'domains' ] as $row ) {
if ( $row [ 'domain_uuid' ] == $domain_uuid ) {
echo " <option value=' " . escape ( $row [ 'domain_uuid' ]) . " ' selected='selected'> " . escape ( $row [ 'domain_name' ]) . " </option> \n " ;
}
else {
echo " <option value=' " . escape ( $row [ 'domain_uuid' ]) . " '> " . escape ( $row [ 'domain_name' ]) . " </option> \n " ;
}
}
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-domain_name' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2017-11-03 21:48:54 +01:00
if ( permission_exists ( " extension_user_context " )) {
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
echo " <td class='vncellreq' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-user_context' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='user_context' maxlength='255' value= \" " . escape ( $user_context ? ? '' ) . " \" required='required'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <br /> \n " ;
2013-05-04 02:35:21 +02:00
echo $text [ 'description-user_context' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
//--- begin: show_advanced -----------------------
2014-05-25 04:49:00 +02:00
2020-07-03 21:41:45 +02:00
if ( permission_exists ( " extension_advanced " )) {
2020-07-02 08:22:38 +02:00
echo " <tr> \n " ;
echo " <td style='padding: 0px;' colspan='2' class='' valign='top' align='left' nowrap> \n " ;
echo " <div id= \" show_advanced_box \" > \n " ;
echo " <table width= \" 100% \" border= \" 0 \" cellpadding= \" 0 \" cellspacing= \" 0 \" > \n " ;
echo " <tr> \n " ;
echo " <td width= \" 30% \" valign= \" top \" class= \" vncell \" > </td> \n " ;
echo " <td width= \" 70% \" class= \" vtable \" > \n " ;
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-advanced' ], 'icon' => 'tools' , 'onclick' => 'show_advanced_config();' ]);
echo " </td> \n " ;
echo " </tr> \n " ;
echo " </table> \n " ;
echo " </div> \n " ;
echo " <div id= \" show_advanced \" style= \" display:none \" > \n " ;
echo " <table width= \" 100% \" border= \" 0 \" cellpadding= \" 0 \" cellspacing= \" 0 \" > \n " ;
2014-07-07 21:33:17 +02:00
2020-07-02 08:22:38 +02:00
echo " <tr> \n " ;
echo " <td width= \" 30% \" class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-auth_acl' ] . " \n " ;
echo " </td> \n " ;
echo " <td width= \" 70% \" class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='auth_acl' maxlength='255' value= \" " . escape ( $auth_acl ? ? '' ) . " \" > \n " ;
2020-07-02 08:22:38 +02:00
echo " <br /> \n " ;
echo $text [ 'description-auth_acl' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
2020-07-02 08:22:38 +02:00
if ( permission_exists ( " extension_cidr " )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-cidr' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='cidr' maxlength='255' value= \" " . escape ( $cidr ? ? '' ) . " \" > \n " ;
2020-07-02 08:22:38 +02:00
echo " <br /> \n " ;
echo $text [ 'description-cidr' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
2019-02-12 04:42:59 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2020-07-02 08:22:38 +02:00
echo " " . $text [ 'label-sip_force_contact' ] . " \n " ;
2019-02-12 04:42:59 +01:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2020-07-02 08:22:38 +02:00
echo " <select class='formfld' name='sip_force_contact'> \n " ;
echo " <option value=''></option> \n " ;
2023-05-17 09:02:45 +02:00
switch ( $sip_force_contact ? ? null ) {
2020-07-02 08:22:38 +02:00
case " NDLB-connectile-dysfunction " : $selected [ 1 ] = " selected='selected' " ; break ;
case " NDLB-connectile-dysfunction-2.0 " : $selected [ 2 ] = " selected='selected' " ; break ;
case " NDLB-tls-connectile-dysfunction " : $selected [ 3 ] = " selected='selected' " ; break ;
}
2023-05-17 09:02:45 +02:00
echo " <option value='NDLB-connectile-dysfunction' " . ( $selected [ 1 ] ? ? '' ) . " > " . $text [ 'label-rewrite_contact_ip_and_port' ] . " </option> \n " ;
echo " <option value='NDLB-connectile-dysfunction-2.0' " . ( $selected [ 2 ] ? ? '' ) . " > " . $text [ 'label-rewrite_contact_ip_and_port_2' ] . " </option> \n " ;
echo " <option value='NDLB-tls-connectile-dysfunction' " . ( $selected [ 3 ] ? ? '' ) . " > " . $text [ 'label-rewrite_tls_contact_port' ] . " </option> \n " ;
2020-07-02 08:22:38 +02:00
unset ( $selected );
echo " </select> \n " ;
2019-02-12 04:42:59 +01:00
echo " <br /> \n " ;
2020-07-02 08:22:38 +02:00
echo $text [ 'description-sip_force_contact' ] . " \n " ;
2019-02-12 04:42:59 +01:00
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
2014-07-26 00:33:56 +02:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2020-07-02 08:22:38 +02:00
echo " " . $text [ 'label-sip_force_expires' ] . " \n " ;
2014-07-26 00:33:56 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='number' name='sip_force_expires' maxlength='255' min='1' step='1' value= \" " . escape ( $sip_force_expires ? ? '' ) . " \" > \n " ;
2014-07-26 00:33:56 +02:00
echo " <br /> \n " ;
2020-07-02 08:22:38 +02:00
echo $text [ 'description-sip_force_expires' ] . " \n " ;
2014-07-26 00:33:56 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
2020-07-02 08:22:38 +02:00
if ( permission_exists ( 'extension_nibble_account' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-nibble_account' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='nibble_account' maxlength='255' value= \" " . escape ( $nibble_account ? ? '' ) . " \" > \n " ;
2020-07-02 08:22:38 +02:00
echo " <br /> \n " ;
echo $text [ 'description-nibble_account' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
2015-10-29 20:24:24 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2020-07-02 08:22:38 +02:00
echo " " . $text [ 'label-mwi_account' ] . " \n " ;
2015-10-29 20:24:24 +01:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='mwi_account' maxlength='255' value= \" " . escape ( $mwi_account ? ? '' ) . " \" > \n " ;
2015-10-29 20:24:24 +01:00
echo " <br /> \n " ;
2020-07-02 08:22:38 +02:00
echo $text [ 'description-mwi_account' ] . " \n " ;
2015-10-29 20:24:24 +01:00
echo " </td> \n " ;
echo " </tr> \n " ;
2016-08-11 17:46:54 +02:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2020-07-02 08:22:38 +02:00
echo " " . $text [ 'label-sip_bypass_media' ] . " \n " ;
2016-08-11 17:46:54 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2020-07-02 08:22:38 +02:00
echo " <select class='formfld' name='sip_bypass_media'> \n " ;
echo " <option value=''></option> \n " ;
2023-05-17 09:02:45 +02:00
switch ( $sip_bypass_media ? ? null ) {
2020-07-02 08:22:38 +02:00
case " bypass-media " : $selected [ 1 ] = " selected='selected' " ; break ;
case " bypass-media-after-bridge " : $selected [ 2 ] = " selected='selected' " ; break ;
case " proxy-media " : $selected [ 3 ] = " selected='selected' " ; break ;
2016-08-11 17:46:54 +02:00
}
2023-05-17 09:02:45 +02:00
echo " <option value='bypass-media' " . ( $selected [ 1 ] ? ? '' ) . " > " . $text [ 'label-bypass_media' ] . " </option> \n " ;
echo " <option value='bypass-media-after-bridge' " . ( $selected [ 2 ] ? ? '' ) . " > " . $text [ 'label-bypass_media_after_bridge' ] . " </option> \n " ;
echo " <option value='proxy-media' " . ( $selected [ 3 ] ? ? '' ) . " > " . $text [ 'label-proxy_media' ] . " </option> \n " ;
2020-07-02 08:22:38 +02:00
unset ( $selected );
2016-08-11 17:46:54 +02:00
echo " </select> \n " ;
echo " <br /> \n " ;
2020-07-02 08:22:38 +02:00
echo $text [ 'description-sip_bypass_media' ] . " \n " ;
2016-08-11 17:46:54 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2020-07-02 08:22:38 +02:00
if ( permission_exists ( 'extension_absolute_codec_string' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-absolute_codec_string' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='absolute_codec_string' maxlength='255' value= \" " . escape ( $absolute_codec_string ? ? '' ) . " \" > \n " ;
2020-07-02 08:22:38 +02:00
echo " <br /> \n " ;
echo $text [ 'description-absolute_codec_string' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
if ( permission_exists ( 'extension_force_ping' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-force_ping' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
echo " <select class='formfld' name='force_ping'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <option value=''></option> \n " ;
echo " <option value='true' " . ( ! empty ( $force_ping ) && $force_ping == " true " ? " selected='selected' " : null ) . " > " . $text [ 'label-true' ] . " </option> \n " ;
echo " <option value='false' " . ( ! empty ( $force_ping ) && $force_ping == " false " ? " selected='selected' " : null ) . " > " . $text [ 'label-false' ] . " </option> \n " ;
2020-07-02 08:22:38 +02:00
echo " </select> \n " ;
echo " <br /> \n " ;
echo $text [ 'description-force_ping' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2015-01-20 21:59:27 +01:00
}
2020-07-02 08:22:38 +02:00
if ( permission_exists ( 'extension_dial_string' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-dial_string' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input class='formfld' type='text' name='dial_string' maxlength='4096' value= \" " . escape ( $dial_string ? ? '' ) . " \" > \n " ;
2020-07-02 08:22:38 +02:00
echo " <br /> \n " ;
echo $text [ 'description-dial_string' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
2014-07-07 21:33:17 +02:00
2020-07-02 08:22:38 +02:00
echo " </table> \n " ;
echo " </div> " ;
2014-07-07 21:33:17 +02:00
2020-07-02 08:22:38 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
2012-06-04 16:58:40 +02:00
//--- end: show_advanced -----------------------
2013-12-14 01:50:57 +01:00
if ( permission_exists ( 'extension_enabled' )) {
echo " <tr> \n " ;
echo " <td class='vncellreq' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-enabled' ] . " \n " ;
2013-12-14 01:50:57 +01:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2025-02-13 22:12:48 +01:00
if ( substr ( $settings -> get ( 'theme' , 'input_toggle_style' ), 0 , 6 ) == 'switch' ) {
2023-02-10 19:14:43 +01:00
echo " <label class='switch'> \n " ;
echo " <input type='checkbox' id='enabled' name='enabled' value='true' " . ( $enabled == 'true' ? " checked='checked' " : null ) . " > \n " ;
echo " <span class='slider'></span> \n " ;
echo " </label> \n " ;
2013-12-14 01:50:57 +01:00
}
else {
2023-02-10 19:14:43 +01:00
echo " <select class='formfld' id='enabled' name='enabled'> \n " ;
echo " <option value='true' " . ( $enabled == 'true' ? " selected='selected' " : null ) . " > " . $text [ 'option-true' ] . " </option> \n " ;
2023-02-14 19:19:02 +01:00
echo " <option value='false' " . ( $enabled == 'false' ? " selected='selected' " : null ) . " > " . $text [ 'option-false' ] . " </option> \n " ;
2023-02-10 19:14:43 +01:00
echo " </select> \n " ;
2013-12-14 01:50:57 +01:00
}
echo " <br /> \n " ;
echo $text [ 'description-enabled' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
}
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-description' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-17 09:02:45 +02:00
echo " <input type='text' class='formfld' name='description' value= \" " . escape ( $description ? ? '' ) . " \" > \n " ;
2012-06-04 16:58:40 +02:00
echo " <br /> \n " ;
2013-05-04 02:35:21 +02:00
echo $text [ 'description-description' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2020-01-11 19:06:49 +01:00
echo " </table> " ;
2024-09-06 07:37:34 +02:00
echo " </div> \n " ;
2020-01-11 19:06:49 +01:00
echo " <br><br> " ;
2023-05-17 09:02:45 +02:00
if ( isset ( $page ) && is_numeric ( $page )) {
2020-01-11 19:06:49 +01:00
echo " <input type='hidden' name='page' value=' " . $page . " '> \n " ;
}
2012-06-04 16:58:40 +02:00
if ( $action == " update " ) {
2020-01-11 19:06:49 +01:00
echo " <input type='hidden' name='extension_uuid' value=' " . escape ( $extension_uuid ) . " '> \n " ;
echo " <input type='hidden' name='id' id='id' value=' " . escape ( $extension_uuid ) . " '> " ;
2015-01-20 21:59:27 +01:00
if ( ! permission_exists ( 'extension_domain' )) {
2025-02-13 22:12:48 +01:00
echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value=' " . $domain_uuid . " '> " ;
2015-01-20 21:59:27 +01:00
}
2020-01-11 19:06:49 +01:00
echo " <input type='hidden' name='delete_type' id='delete_type' value=''> " ;
echo " <input type='hidden' name='delete_uuid' id='delete_uuid' value=''> " ;
2012-06-04 16:58:40 +02:00
}
2020-01-11 19:06:49 +01:00
echo " <input type='hidden' name=' " . $token [ 'name' ] . " ' value=' " . $token [ 'hash' ] . " '> \n " ;
2012-06-04 16:58:40 +02:00
echo " </form> " ;
2020-03-05 08:05:45 +01:00
echo " <script> \n " ;
2020-07-03 04:16:39 +02:00
2020-03-05 08:05:45 +01:00
//hide password fields before submit
echo " function submit_form() { \n " ;
echo " hide_password_fields(); \n " ;
echo " $ ('form#frm').submit(); \n " ;
echo " } \n " ;
echo " </script> \n " ;
2015-01-20 21:59:27 +01:00
//include the footer
require_once " resources/footer.php " ;
2024-09-06 07:37:34 +02:00
?>