1 Commits
Author SHA1 Message Date
FusionPBX 7cd6aec9df Add ring group call screen translations 2024-09-16 23:56:57 -06:00
402 changed files with 9309 additions and 11677 deletions
+1 -1
View File
@@ -202,7 +202,7 @@
//attempt digs
if (!empty($digs) && is_array($digs)) {
foreach ($digs as $dig) {
$response = shell_exec("dig +noall +answer ".escapeshellarg($dig['value'])." | awk '{ print $5 }'");
$response = shell_exec("dig +noall +answer ".$dig['value']." | awk '{ print $5 }'");
if (!empty($response)) {
$lines = explode("\n", $response);
foreach ($lines as $l => $line) {
+2 -2
View File
@@ -74,7 +74,7 @@
$array['access_controls'][0]['access_control_name'] = $access_control_name;
$array['access_controls'][0]['access_control_default'] = $access_control_default;
$p = permissions::new();
$p = new permissions;
$p->add('access_control_add', 'temp');
$database->app_name = 'access_controls';
@@ -106,7 +106,7 @@
$array['access_control_nodes'][0]['node_cidr'] = $node_cidr;
$array['access_control_nodes'][0]['node_description'] = $node_description;
$p = permissions::new();
$p = new permissions;
$p->add('access_control_node_add', 'temp');
$database->app_name = 'access_controls';
@@ -69,7 +69,7 @@ if (!class_exists('access_controls')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('access_control_node_delete', 'temp');
//execute delete
@@ -236,7 +236,7 @@ if (!class_exists('access_controls')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('access_control_node_add', 'temp');
//save the array
+2 -2
View File
@@ -65,7 +65,7 @@
//update the status
if (permission_exists("user_setting_edit")) {
//add the user_edit permission
$p = permissions::new();
$p = new permissions;
$p->add("user_edit", "temp");
//update the database user_status
@@ -153,7 +153,7 @@
}
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('extension_edit', 'temp');
//execute update
+1 -1
View File
@@ -166,7 +166,7 @@
$array['dialplans'][$index]['dialplan_enabled'] = 'true';
}
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
$database->save($array);
@@ -435,7 +435,7 @@ if (!class_exists('call_block')) {
unset($rows, $parameters);
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
//save the array
+1 -1
View File
@@ -216,7 +216,7 @@
$apps[$x]['default_settings'][$y]['default_setting_category'] = "call_center";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "record_name";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "\${sip_from_user}-\${sip_to_user}-\${strftime(%Y)}\${strftime(%b)}\${strftime(%d)}-\${uuid}.\${record_ext}";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "\${sip_from_user}-\${sip_to_user}-\${strftime(%Y)}\${strftime(%b)}\${strftime(%d)}.\${record_ext}";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Custom name for call recording. Options: \${record_ext}, \${sip_from_user}, \${sip_to_user}, \${caller_id_number}, \${uuid}";
$y++;
+2 -2
View File
@@ -58,7 +58,7 @@ if ($domains_processed == 1) {
}
if (!empty($array)) {
$p = permissions::new();
$p = new permissions;
$p->add('call_center_tier_edit', 'temp');
$database->app_name = 'call_centers';
@@ -168,7 +168,7 @@ if ($domains_processed == 1) {
//save the array to the database
if (!empty($array)) {
//add the dialplan permission
$p = permissions::new();
$p = new permissions;
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
+91 -14
View File
@@ -42,14 +42,36 @@
$language = new text;
$text = $language->get();
//connect to the database
$database = new database;
//set the defaults
$agent_id = '';
$agent_name = '';
$agent_password = '';
//check for duplicates
if (!empty($_GET["check"]) && $_GET["check"] == 'duplicate') {
//agent id
if (!empty($_GET["agent_id"])) {
$sql = "select agent_name ";
$sql .= "from v_call_center_agents ";
$sql .= "where agent_id = :agent_id ";
$sql .= "and domain_uuid = :domain_uuid ";
if (!empty($_GET["agent_uuid"]) && is_uuid($_GET["agent_uuid"])) {
$sql .= " and call_center_agent_uuid <> :call_center_agent_uuid ";
$parameters['call_center_agent_uuid'] = $_GET["agent_uuid"];
}
$parameters['agent_id'] = $_GET["agent_id"];
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row) && !empty($row['agent_name'])) {
echo $text['message-duplicate_agent_id'].(if_group("superadmin") ? ": ".$row["agent_name"] : null);
}
unset($sql, $parameters);
}
exit;
}
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
@@ -59,14 +81,6 @@
$action = "add";
}
//get the users array
$sql = "select * from v_users ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by username asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get http post variables and set them to php variables
if (!empty($_POST)) {
$call_center_agent_uuid = $_POST["call_center_agent_uuid"] ?? null;
@@ -137,6 +151,15 @@
$call_center_agent_uuid = uuid();
}
//get the users array
$sql = "select * from v_users ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by username asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//change the contact string to loopback - Not recommended added for backwards comptability causes multiple problems
if ($_SESSION['call_center']['agent_contact_method']['text'] == 'loopback') {
$agent_contact = str_replace("user/", "loopback/", $agent_contact);
@@ -170,9 +193,11 @@
}
//save to the data
$database = new database;
$database->app_name = 'call_center';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->save($array);
//$message = $database->message;
//syncrhonize configuration
save_call_center_xml();
@@ -270,6 +295,7 @@
$sql .= "and call_center_agent_uuid = :call_center_agent_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['call_center_agent_uuid'] = $call_center_agent_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$call_center_agent_uuid = $row["call_center_agent_uuid"];
@@ -312,12 +338,47 @@
if ($action == "update") {
$document['title'] = $text['title-call_center_agent_edit'];
}
//include the header
require_once "resources/header.php";
//get the list of users for this domain
$sql = "select * from v_users ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and user_enabled = 'true' ";
$sql .= "order by username asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//javascript to check for duplicates
?>
<script language="javascript">
function check_duplicates() {
//check agent id
var agent_id = document.getElementById('agent_id').value;
$("#duplicate_agent_id_response").load("call_center_agent_edit.php?check=duplicate&agent_id="+agent_id+"&agent_uuid=<?php echo escape($call_center_agent_uuid ?? ''); ?>", function() {
var duplicate_agent_id = false;
if ($("#duplicate_agent_id_response").html() != '') {
$('#agent_id').addClass('formfld_highlight_bad');
display_message($("#duplicate_agent_id_response").html(), 'negative'<?php if (if_group("superadmin")) { echo ', 3000'; } ?>);
duplicate_agent_id = true;
}
else {
$("#duplicate_agent_id_response").html('');
$('#agent_id').removeClass('formfld_highlight_bad');
duplicate_agent_id = false;
}
if (duplicate_agent_id == false) {
document.getElementById('frm').submit();
}
});
}
</script>
<?php
//show the content
echo "<form method='post' name='frm' id='frm' onsubmit=''>\n";
echo "<form method='post' name='frm' id='frm' onsubmit='check_duplicates(); return false;'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
@@ -343,6 +404,21 @@
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='agent_name' maxlength='255' value=\"".escape($agent_name)."\" />\n";
/*
echo "<select id=\"agent_name\" name=\"agent_name\" class='formfld'>\n";
echo "<option value=\"\"></option>\n";
if (is_array($users)) {
foreach($users as $field) {
if ($field[username] == $agent_name) {
echo "<option value='".escape($field[username])."' selected='selected'>".escape($field[username])."</option>\n";
}
else {
echo "<option value='".escape($field[username])."'>".escape($field[username])."</option>\n";
}
}
}
echo "</select>";
*/
echo "<br />\n";
echo $text['description-agent_name']."\n";
echo "</td>\n";
@@ -391,6 +467,7 @@
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='agent_id' id='agent_id' maxlength='255' min='1' step='1' value='".escape($agent_id)."'>\n";
echo " <div style='display: none;' id='duplicate_agent_id_response'></div>\n";
echo "<br />\n";
echo $text['description-agent_id']."\n";
echo "</td>\n";
@@ -172,7 +172,7 @@
$array['users'][0]['user_status'] = $row['agent_status'];
$array['users'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$p = permissions::new();
$p = new permissions;
$p->add('user_edit', 'temp');
$database = new database;
+47 -41
View File
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2025
Portions created by the Initial Developer are Copyright (C) 2008-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -42,10 +42,6 @@
$language = new text;
$text = $language->get();
//initialize database and settings
$database = database::new();
$settings = new settings(['database' => $database, $_SESSION['domain_uuid'] ?? '', $_SESSION['user_uuid'] ?? '']);
//set the defaults
$queue_name = '';
$queue_extension = '';
@@ -65,24 +61,24 @@
$action = "add";
}
//get the domain details
//get the domain_uuid
$domain_uuid = $_SESSION['domain_uuid'];
$domain_name = $_SESSION['domain_name'];
//initialize the destination object
//initialize the destinations object
$destination = new destinations;
//get total call center queues count from the database, check limit, if defined
if ($action == 'add') {
if (!empty($settings->get('limit','call_center_queues', ''))) {
if (!empty($_SESSION['limit']['call_center_queues']['numeric'])) {
$sql = "select count(*) from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$total_call_center_queues = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
if ($total_call_center_queues >= $settings->get('limit','call_center_queues', 0)) {
message::add($text['message-maximum_queues'].' '.$settings->get('limit','call_center_queues', ''), 'negative');
if ($total_call_center_queues >= $_SESSION['limit']['call_center_queues']['numeric']) {
message::add($text['message-maximum_queues'].' '.$_SESSION['limit']['call_center_queues']['numeric'], 'negative');
header('Location: call_center_queues.php');
return;
}
@@ -128,7 +124,7 @@
$queue_context = $_POST["queue_context"];
}
else if ($action == 'add') {
$queue_context = $domain_name;
$queue_context = $_SESSION['domain_name'];
}
//remove invalid characters
@@ -153,6 +149,7 @@
$sql .= "and t.call_center_queue_uuid = q.call_center_queue_uuid; ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['call_center_tier_uuid'] = $call_center_tier_uuid;
$database = new database;
$tiers = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
@@ -171,7 +168,7 @@
if ($esl->is_connected()) {
//callcenter_config tier del [queue_name] [agent_name]
if (is_numeric($queue_extension) && is_uuid($call_center_agent_uuid)) {
$cmd = "callcenter_config tier del ".$queue_extension."@".$domain_name." ".$call_center_agent_uuid;
$cmd = "callcenter_config tier del ".$queue_extension."@".$_SESSION['domain_name']." ".$call_center_agent_uuid;
$response = event_socket::api($cmd);
}
}
@@ -181,9 +178,10 @@
$array['call_center_tiers'][0]['call_center_tier_uuid'] = $call_center_tier_uuid;
$array['call_center_tiers'][0]['domain_uuid'] = $domain_uuid;
$p = permissions::new();
$p = new permissions;
$p->add('call_center_tier_delete', 'temp');
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->delete($array);
@@ -207,6 +205,7 @@
$sql = "select * from v_call_center_queues ";
$sql .= "where call_center_queue_uuid = :call_center_queue_uuid ";
$parameters['call_center_queue_uuid'] = $call_center_queue_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
//if (!permission_exists('call_center_queue_domain')) {
@@ -299,8 +298,8 @@
//add the recording path if needed
if (!empty($queue_greeting)) {
if (file_exists($settings->get('switch','recordings', '').'/'.$domain_name.'/'.$queue_greeting)) {
$queue_greeting_path = $settings->get('switch','recordings', '').'/'.$domain_name.'/'.$queue_greeting;
if (file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$queue_greeting)) {
$queue_greeting_path = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$queue_greeting;
}
else {
$queue_greeting_path = trim($queue_greeting);
@@ -372,8 +371,8 @@
//add definable export variables can be set in default settings
$export_variables = 'call_center_queue_uuid,sip_h_Alert-Info';
if (!empty($settings->get('call_center','export_vars', []))) {
foreach ($settings->get('call_center','export_vars', []) as $export_variable) {
if (!empty($_SESSION['call_center']['export_vars'])) {
foreach ($_SESSION['call_center']['export_vars'] as $export_variable) {
$export_variables .= ','.$export_variable;
}
}
@@ -414,7 +413,7 @@
if (!empty($queue_cc_exit_keys)) {
$dialplan_xml .= " <action application=\"set\" data=\"cc_exit_keys=".xml::sanitize($queue_cc_exit_keys)."\"/>\n";
}
$dialplan_xml .= " <action application=\"callcenter\" data=\"".xml::sanitize($queue_extension)."@".$domain_name."\"/>\n";
$dialplan_xml .= " <action application=\"callcenter\" data=\"".xml::sanitize($queue_extension)."@".$_SESSION["domain_name"]."\"/>\n";
if ($destination->valid($queue_timeout_app.':'.$queue_timeout_data)) {
$dialplan_xml .= " <action application=\"".xml::sanitize($queue_timeout_app)."\" data=\"".xml::sanitize($queue_timeout_data)."\"/>\n";
}
@@ -435,11 +434,12 @@
$array['dialplans'][0]["app_uuid"] = "95788e50-9500-079e-2807-fd530b0ea370";
//add the dialplan permission
$p = permissions::new();
$p = new permissions;
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
//save to the data
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->save($array);
@@ -457,7 +457,7 @@
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$domain_name);
$cache->delete("dialplan:".$_SESSION["domain_name"]);
//clear the destinations session array
if (isset($_SESSION['destinations']['array'])) {
@@ -496,19 +496,19 @@
*/
//add the agent
if (is_numeric($queue_extension) && is_uuid($call_center_agent_uuid) && is_numeric($tier_level) && is_numeric($tier_position)) {
$cmd = "callcenter_config tier add ".$queue_extension."@".$domain_name." ".$call_center_agent_uuid." ".$tier_level." ".$tier_position;
$cmd = "callcenter_config tier add ".$queue_extension."@".$_SESSION["domain_name"]." ".$call_center_agent_uuid." ".$tier_level." ".$tier_position;
$response = event_socket::api($cmd);
}
usleep(200);
//agent set level
if (is_numeric($queue_extension) && is_numeric($tier_level)) {
$cmd = "callcenter_config tier set level ".$queue_extension."@".$domain_name." ".$call_center_agent_uuid." ".$tier_level;
$cmd = "callcenter_config tier set level ".$queue_extension."@".$_SESSION["domain_name"]." ".$call_center_agent_uuid." ".$tier_level;
$response = event_socket::api($cmd);
}
usleep(200);
//agent set position
if (is_numeric($queue_extension) && is_numeric($tier_position)) {
$cmd = "callcenter_config tier set position ".$queue_extension."@".$domain_name." ".$tier_position;
$cmd = "callcenter_config tier set position ".$queue_extension."@".$_SESSION["domain_name"]." ".$tier_position;
$response = event_socket::api($cmd);
}
usleep(200);
@@ -538,6 +538,7 @@
$sql .= "and call_center_queue_uuid = :call_center_queue_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['call_center_queue_uuid'] = $call_center_queue_uuid;
$database = new database;
$call_center_queues = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
@@ -586,16 +587,17 @@
$sql .= "order by tier_level asc, tier_position asc, a.agent_name asc";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['call_center_queue_uuid'] = $call_center_queue_uuid ?? null;
$database = new database;
$tiers = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//add an empty row to the tiers array
if (count($tiers) == 0) {
$rows = $settings->get('call_center','agent_add_rows', null);
$rows = $_SESSION['call_center']['agent_add_rows']['numeric'] ?? null;
$id = 0;
}
if (count($tiers) > 0) {
$rows = $settings->get('call_center','agent_edit_rows', null);
$rows = $_SESSION['call_center']['agent_edit_rows']['numeric'];
$id = count($tiers)+1;
}
for ($x = 0; $x < $rows; $x++) {
@@ -613,6 +615,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by agent_name asc";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$agents = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
@@ -621,7 +624,6 @@
$audio_files[0] = $sounds->get();
unset($sounds);
//get the list of sounds
if (permission_exists('call_center_announce_sound')) {
$sounds = new sounds;
$sounds->sound_types = ['recordings'];
@@ -644,7 +646,7 @@
if (empty($queue_tier_rule_no_agent_no_wait)) { $queue_tier_rule_no_agent_no_wait = "true"; }
if (empty($queue_discard_abandoned_after)) { $queue_discard_abandoned_after = "900"; }
if (empty($queue_abandoned_resume_allowed)) { $queue_abandoned_resume_allowed = "false"; }
if (empty($queue_context)) { $queue_context = $domain_name; }
if (empty($queue_context)) { $queue_context = $_SESSION['domain_name']; }
//create token
$object = new token;
@@ -665,8 +667,12 @@
}
//set the record_template
$record_template = $settings->get('switch','recordings', '')."/".$domain_name."/archive/";
$record_template .= $settings->get('call_center','record_name', "\${strftime(%Y)}/\${strftime(%b)}/\${strftime(%d)}/\${uuid}.\${record_ext}");
if (empty($_SESSION['call_center']['record_name']['text'])) {
$record_template = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/\${strftime(%Y)}/\${strftime(%b)}/\${strftime(%d)}/\${uuid}.\${record_ext}";
}
else {
$record_template = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".$_SESSION['call_center']['record_name']['text'];
}
//show the content
if (permission_exists('recording_play') || permission_exists('recording_download')) {
@@ -751,7 +757,7 @@
}
echo "</div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme','button_icon_back', ''),'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'call_center_queues.php']);
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'call_center_queues.php']);
if ($action == "update") {
if (permission_exists('call_center_wallboard')) {
@@ -759,10 +765,10 @@
}
//echo button::create(['type'=>'button','label'=>$text['button-stop'],'icon'=>$_SESSION['theme']['button_icon_stop'],'link'=>'cmd.php?cmd=unload&id='.urlencode($call_center_queue_uuid)]);
//echo button::create(['type'=>'button','label'=>$text['button-start'],'icon'=>$_SESSION['theme']['button_icon_start'],'link'=>'cmd.php?cmd=load&id='.urlencode($call_center_queue_uuid)]);
echo button::create(['type'=>'button','label'=>$text['button-reload'],'icon'=>$settings->get('theme','button_icon_reload', ''),'link'=>'cmd.php?cmd=reload&id='.urlencode($call_center_queue_uuid)]);
echo button::create(['type'=>'button','label'=>$text['button-view'],'icon'=>$settings->get('theme','button_icon_view', ''),'style'=>'margin-right: 15px;','link'=>PROJECT_PATH.'/app/call_center_active/call_center_active.php?queue_name='.urlencode($call_center_queue_uuid)]);
echo button::create(['type'=>'button','label'=>$text['button-reload'],'icon'=>$_SESSION['theme']['button_icon_reload'],'link'=>'cmd.php?cmd=reload&id='.urlencode($call_center_queue_uuid)]);
echo button::create(['type'=>'button','label'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'style'=>'margin-right: 15px;','link'=>PROJECT_PATH.'/app/call_center_active/call_center_active.php?queue_name='.urlencode($call_center_queue_uuid)]);
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme','button_icon_save', ''),'id'=>'btn_save']);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
@@ -785,7 +791,7 @@
echo " ".$text['label-extension']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='queue_extension' maxlength='255' min='0' step='1' value=\"".escape($queue_extension)."\" required='required' placeholder=\"".$settings->get('call_center','extension_range', '')."\">\n";
echo " <input class='formfld' type='number' name='queue_extension' maxlength='255' min='0' step='1' value=\"".escape($queue_extension)."\" required='required' placeholder=\"".($_SESSION['call_center']['extension_range']['text'] ?? '')."\">\n";
echo "<br />\n";
echo $text['description-extension']."\n";
echo "</td>\n";
@@ -812,8 +818,8 @@
if ($key == 'recordings') {
if (
!empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $settings->get('switch','recordings', '')."/".$domain_name.'/'.$row["value"]) &&
file_exists($settings->get('switch','recordings', '')."/".$domain_name.'/'.pathinfo($row["value"], PATHINFO_BASENAME))
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) {
$selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);
@@ -856,7 +862,7 @@
case 'ogg' : $mime_type = 'audio/ogg'; break;
}
echo "<audio id='recording_audio_".$instance_id."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$instance_id."')\" onended=\"recording_reset('".$instance_id."');\" src='".($playable ?? '')."' type='".($mime_type ?? '')."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$settings->get('theme','button_icon_play', ''),'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'))"]);
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'))"]);
unset($playable, $mime_type);
}
echo "<br />\n";
@@ -1312,8 +1318,8 @@
if ($key == 'recordings') {
if (
!empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $settings->get('switch','recordings', '')."/".$domain_name.'/'.$row["value"]) &&
file_exists($settings->get('switch','recordings', '')."/".$domain_name.'/'.pathinfo($row["value"], PATHINFO_BASENAME))
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) {
$selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);
@@ -1356,7 +1362,7 @@
case 'ogg' : $mime_type = 'audio/ogg'; break;
}
echo "<audio id='recording_audio_".$instance_id."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$instance_id."')\" onended=\"recording_reset('".$instance_id."');\" src='".($playable ?? '')."' type='".($mime_type ?? '')."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$settings->get('theme','button_icon_play', ''),'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'))"]);
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'))"]);
unset($playable, $mime_type);
}
echo "<br />\n";
@@ -78,7 +78,7 @@
$array['dialplan_details'][0]['domain_uuid'] = $this->domain_uuid;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -216,7 +216,7 @@
$array["dialplans"][0] = $dialplan;
//add temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add("dialplan_add", 'temp');
$p->add("dialplan_detail_add", 'temp');
$p->add("dialplan_edit", 'temp');
@@ -242,7 +242,7 @@
$array['call_center_queues'][0]['dialplan_uuid'] = $this->dialplan_uuid;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('call_center_queue_edit', 'temp');
//execute update
@@ -349,7 +349,7 @@
}
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('call_center_tier_delete', 'temp');
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -446,7 +446,7 @@
}
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('call_center_tier_delete', 'temp');
//execute delete
@@ -578,7 +578,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('call_center_tier_add', 'temp');
$p->add('dialplan_add', 'temp');
+1 -1
View File
@@ -237,7 +237,7 @@
$array["call_flows"][$i]["call_flow_description"] = $call_flow_description;
//add the dialplan permission
$p = permissions::new();
$p = new permissions;
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
@@ -121,7 +121,7 @@ if (!class_exists('call_flows')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -223,7 +223,7 @@ if (!class_exists('call_flows')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
//save the array
@@ -374,7 +374,7 @@ if (!class_exists('call_flows')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_add', 'temp');
//save the array
+1 -1
View File
@@ -248,7 +248,7 @@
}
//add the dialplan permission
$p = permissions::new();
$p = new permissions;
$p->add("extension_edit", "temp");
//save the data
@@ -89,7 +89,7 @@
}
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('extension_add', 'temp');
//execute update
@@ -214,7 +214,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('extension_edit', 'temp');
//save the array
@@ -95,7 +95,7 @@
$array['extensions'][0]['do_not_disturb'] = $this->enabled;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('extension_edit', 'temp');
//execute update
@@ -226,7 +226,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('extension_edit', 'temp');
//save the array
@@ -91,7 +91,7 @@
$array['follow_me'][0]['follow_me_enabled'] = $this->follow_me_enabled;
$array['follow_me'][0]['follow_me_ignore_busy'] = $this->follow_me_ignore_busy;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('follow_me_add', 'temp');
//execute insert
$database = new database;
@@ -115,7 +115,7 @@
$array['follow_me'][0]['follow_me_enabled'] = $this->follow_me_enabled;
$array['follow_me'][0]['follow_me_ignore_busy'] = $this->follow_me_ignore_busy;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('follow_me_add', 'temp');
//execute update
$database = new database;
@@ -135,7 +135,7 @@
//delete related follow me destinations
$array['follow_me_destinations'][0]['follow_me_uuid'] = $this->follow_me_uuid;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('follow_me_destination_delete', 'temp');
//execute delete
$database = new database;
@@ -210,7 +210,7 @@
}
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('follow_me_destination_add', 'temp');
//execute insert
$database = new database;
@@ -234,7 +234,7 @@
$extension_uuid = $result[0]['extension_uuid'];
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add("follow_me_edit", 'temp');
$p->add("extension_edit", 'temp');
@@ -389,7 +389,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('extension_edit', 'temp');
$p->add('follow_me_edit', 'temp');
-12
View File
@@ -34,9 +34,6 @@
$y++;
$apps[$x]['permissions'][$y]['name'] = 'call_recording_download';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'call_recording_transcribe';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y = 0;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "95cb740e-e377-4852-8894-06441c61e78b";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "call_recordings";
@@ -45,13 +42,4 @@
$apps[$x]['default_settings'][$y]['default_setting_value'] = "90";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of days to retain the maintenance logs in the database.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "e329db05-2967-422a-a71f-d0175b083828";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "call_recordings";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "record_extension";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "mp3";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Call recording file format options: wav, mp3";
?>
+356 -334
View File
@@ -1,334 +1,356 @@
<?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>
Portions created by the Initial Developer are Copyright (C) 2018-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('call_recording_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//create the database connection
$database = new database;
//add multi-lingual support
$language = new text;
$text = $language->get();
//add the settings object
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
$transcribe_enabled = $settings->get('transcribe', 'enabled', false);
$transcribe_engine = $settings->get('transcribe', 'engine', '');
//set additional variables
$search = $_GET["search"] ?? '';
$show = $_GET["show"] ?? '';
//get the http post data
if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$call_recordings = $_POST['call_recordings'];
}
//process the http post data by action
if (!empty($action) && is_array($call_recordings) && @sizeof($call_recordings) != 0) {
switch ($action) {
case 'download':
if (permission_exists('call_recording_download')) {
$obj = new call_recordings;
$obj->download($call_recordings);
}
break;
case 'transcribe':
if (permission_exists('call_recording_transcribe')) {
$obj = new call_recordings;
$obj->transcribe($call_recordings);
}
break;
case 'delete':
if (permission_exists('call_recording_delete')) {
$obj = new call_recordings;
$obj->delete($call_recordings);
}
break;
}
//redirect the user
header('Location: call_recordings.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search string
if (!empty($search)) {
$search = strtolower($_GET["search"]);
}
//set the time zone
if (!empty($_SESSION['domain']['time_zone']['name'])) {
$time_zone = $_SESSION['domain']['time_zone']['name'];
}
else {
$time_zone = date_default_timezone_get();
}
$parameters['time_zone'] = $time_zone;
//prepare some of the paging values
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
$page = $_GET['page'] ?? '';
if (empty($page)) { $page = 0; $_GET['page'] = 0; }
$offset = $rows_per_page * $page;
//get the list
$sql = "select r.domain_uuid, d.domain_name, r.call_recording_uuid, r.call_direction, ";
$sql .= "r.call_recording_name, r.call_recording_path, r.call_recording_transcription, r.call_recording_length, ";
$sql .= "r.caller_id_name, r.caller_id_number, r.caller_destination, r.destination_number, ";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, \n";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted \n";
$sql .= "from view_call_recordings as r, v_domains as d ";
//$sql .= "from v_call_recordings as r, v_domains as d ";
$sql .= "where true ";
if ($show != "all" || !permission_exists('call_recording_all')) {
$sql .= "and r.domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$sql .= "and r.domain_uuid = d.domain_uuid ";
if (!empty($search)) {
$sql .= "and (";
$sql .= " lower(r.call_direction) like :search ";
$sql .= " or lower(r.caller_id_name) like :search ";
$sql .= " or lower(r.caller_id_number) like :search ";
$sql .= " or lower(r.caller_destination) like :search ";
$sql .= " or lower(r.destination_number) like :search ";
$sql .= " or lower(r.call_recording_name) like :search ";
$sql .= " or lower(r.call_recording_path) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'r.call_recording_date', 'desc');
$sql .= limit_offset($rows_per_page, $offset);
$call_recordings = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//detect if any transcriptions available
if ($transcribe_enabled && !empty($transcribe_engine) && !empty($call_recordings) && is_array($call_recordings)) {
$transcriptions_exists = false;
foreach ($call_recordings as $row) {
if (!empty($row['call_recording_transcription'])) { $transcriptions_exists = true; }
}
}
//limit the number of results
if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) {
$num_rows = $_SESSION['cdr']['limit']['numeric'];
}
//prepare to page the results
$param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('call_recording_all')) {
$param .= "&show=all";
}
list($paging_controls_mini, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, true, $result_count); //top
list($paging_controls, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, false, $result_count); //bottom
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-call_recordings'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-call_recordings']." </b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('call_recording_download') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'id'=>'btn_download','name'=>'btn_download','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('download'); list_form_submit('form_list');"]);
}
if (permission_exists('call_recording_transcribe') && $transcribe_enabled && !empty($transcribe_engine) && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-transcribe'],'icon'=>'quote-right','id'=>'btn_transcribe','name'=>'btn_transcribe','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('transcribe'); list_form_submit('form_list');"]);
}
if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','collapse'=>'hide-xs','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('call_recording_all')) {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.(!empty($search) ? "&search=".urlencode($search) : null)]);
}
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=\"$('#btn_reset').hide(); $('#btn_search').show();\">";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_recordings.php','style'=>(empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-call_recordings']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
$col_count = 8;
if ($show == "all" && permission_exists('call_recording_all')) {
$col_count++;
}
if (permission_exists('call_recording_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($call_recordings) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
$col_count++;
}
if ($show == "all" && permission_exists('call_recording_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='hide-sm-dn shrink'");
}
echo th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order, null, "class='pct-15'");
echo th_order_by('caller_destination', $text['label-caller_destination'], $order_by, $order, null, "class='pct-10 hide-sm-dn'");
echo th_order_by('destination_number', $text['label-destination_number'], $order_by, $order, null, "class='pct-10'");
echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order, null, "class='pct-20 hide-sm-dn'");
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo "<th class='shrink center'>".$text['label-recording']."</th>\n";
$col_count++;
}
echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order, null, "class='right hide-sm-dn shrink'");
echo th_order_by('call_recording_date', $text['label-call_recording_date'], $order_by, $order, null, "class='pct-20 center'");
echo th_order_by('call_direction', $text['label-call_direction'], $order_by, $order, null, "class='hide-sm-dn shrink'");
if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (is_array($call_recordings) && @sizeof($call_recordings) != 0) {
$x = 0;
foreach ($call_recordings as $row) {
//playback progress bar
if (permission_exists('call_recording_play')) {
echo "<tr class='list-row' id='recording_progress_bar_".escape($row['call_recording_uuid'])."' style='display: none;' onclick=\"recording_seek(event,'".escape($row['call_recording_uuid'])."')\"><td id='playback_progress_bar_background_".escape($row['call_recording_uuid'])."' class='playback_progress_bar_background' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['call_recording_uuid'])."'></span></td>".(permission_exists('xml_cdr_details') ? "<td class='action-button' style='border-bottom: none !important;'></td>" : null)."</tr>\n";
echo "<tr class='list-row' style='display: none;'><td></td></tr>\n"; // dummy row to maintain alternating background color
}
if (permission_exists('call_recording_play')) {
$list_row_url = "javascript:recording_play('".escape($row['call_recording_uuid'])."');";
}
echo "<tr class='list-row' href=\"".$list_row_url."\">\n";
if (permission_exists('call_recording_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_recordings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_recordings[$x][uuid]' value='".escape($row['call_recording_uuid'])."' />\n";
echo " </td>\n";
}
if ($show == "all" && permission_exists('call_recording_all')) {
echo " <td class='overflow hide-sm-dn shrink'>".escape($row['domain_name'])."</td>\n";
}
echo " <td class='hide-sm-dn shrink'>".escape($row['caller_id_name'])."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['caller_id_number'], 0, 20)))."</td>\n";
echo " <td class='hide-sm-dn shrink'>".escape(format_phone(substr($row['caller_destination'], 0, 20)))."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['destination_number'], 0, 20)))."</td>\n";
echo " <td class='overflow hide-sm-dn nowrap'>".escape($row['call_recording_name'])."</td>\n";
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo " <td class='middle button center no-link no-wrap'>";
if (file_exists($row['call_recording_path'].'/'.$row['call_recording_name'])) {
if (permission_exists('call_recording_play')) {
$recording_file_ext = pathinfo($row['call_recording_name'], PATHINFO_EXTENSION);
switch ($recording_file_ext) {
case "wav" : $recording_type = "audio/wav"; break;
case "mp3" : $recording_type = "audio/mpeg"; break;
case "ogg" : $recording_type = "audio/ogg"; break;
}
echo "<audio id='recording_audio_".escape($row['call_recording_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['call_recording_uuid'])."')\" onended=\"recording_reset('".escape($row['call_recording_uuid'])."');\" src='download.php?id=".urlencode($row['call_recording_uuid'])."' type='".$recording_type."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.escape($row['call_recording_uuid']),'onclick'=>"recording_play('".escape($row['call_recording_uuid'])."')"]);
}
if (permission_exists('call_recording_download')) {
echo button::create(['type'=>'button','title'=>$text['label-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'link'=>'download.php?id='.urlencode($row['call_recording_uuid']).'&binary']);
}
if (permission_exists('call_recording_transcribe') && $transcribe_enabled && !empty($transcribe_engine) && $transcriptions_exists === true) {
echo button::create(['type'=>'button','title'=>$text['label-transcription'],'icon'=>'quote-right','style'=>(empty($row['call_recording_transcription']) ? 'visibility:hidden;' : null),'onclick'=>"document.getElementById('transcription_".$row['call_recording_uuid']."').style.display = document.getElementById('transcription_".$row['call_recording_uuid']."').style.display == 'none' ? 'table-row' : 'none'; this.blur(); return false;"]);
}
}
echo " </td>\n";
}
echo " <td class='right overflow hide-sm-dn shrink'>".escape(gmdate("G:i:s", $row['call_recording_length']))."</td>\n";
echo " <td class='overflow center no-wrap'>".escape($row['call_recording_date_formatted'])." <span class='hide-sm-dn'>".escape($row['call_recording_time_formatted'])."</span></td>\n";
echo " <td class='left hide-sm-dn shrink'>".($row['call_direction'] != '' ? escape($text['label-'.$row['call_direction']]) : null)."</td>\n";
if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>PROJECT_PATH.'/app/xml_cdr/xml_cdr_details.php?id='.urlencode($row['call_recording_uuid'])]);
echo " </td>\n";
}
echo "</tr>\n";
if (permission_exists('call_recording_transcribe') && $transcribe_enabled && !empty($transcribe_engine) && !empty($row['call_recording_transcription'])) {
echo "<tr style='display: none;'><td></td></tr>\n"; // dummy row to maintain same background color for transcription row
echo "<tr id='transcription_".$row['call_recording_uuid']."' class='list-row' style='display: none;'>\n";
echo " <td style='padding: 10px 20px 15px 20px;' colspan='".$col_count."'>\n";
echo " <strong style='display: inline-block; font-size: 90%; margin-bottom: 10px;'>".$text['label-transcription']."...</strong><br />\n";
echo escape($row['call_recording_transcription'])."\n";
echo " </td>\n";
echo "</tr>\n";
}
$x++;
}
unset($call_recordings);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
<?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>
Portions created by the Initial Developer are Copyright (C) 2018-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('call_recording_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//add the settings object
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
$transcribe_enabled = $settings->get('transcribe', 'enabled', 'false');
$transcribe_engine = $settings->get('transcribe', 'engine', '');
//set additional variables
$search = $_GET["search"] ?? '';
$show = $_GET["show"] ?? '';
//get the http post data
if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$call_recordings = $_POST['call_recordings'];
}
//process the http post data by action
if (!empty($action) && is_array($call_recordings) && @sizeof($call_recordings) != 0) {
switch ($action) {
case 'download':
if (permission_exists('call_recording_download')) {
$obj = new call_recordings;
$obj->download($call_recordings);
}
break;
case 'transcribe':
if (permission_exists('call_recording_download')) {
$obj = new call_recordings;
$obj->transcribe($call_recordings);
}
break;
case 'delete':
if (permission_exists('call_recording_delete')) {
$obj = new call_recordings;
$obj->delete($call_recordings);
}
break;
}
//redirect the user
header('Location: call_recordings.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search string
if (!empty($search)) {
$search = strtolower($_GET["search"]);
}
//set the time zone
if (!empty($_SESSION['domain']['time_zone']['name'])) {
$time_zone = $_SESSION['domain']['time_zone']['name'];
}
else {
$time_zone = date_default_timezone_get();
}
$parameters['time_zone'] = $time_zone;
//get the count
//$sql = "select count(*) ";
//$sql .= "from view_call_recordings ";
//$sql .= "where true ";
//if ($_GET['show'] != "all" || !permission_exists('call_recording_all')) {
// $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
// $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
//}
//if (isset($search)) {
// $sql .= "and (";
// $sql .= " lower(call_recording_name) like :search ";
// $sql .= " or lower(call_recording_path) like :search ";
// $sql .= ") ";
// $parameters['search'] = '%'.$search.'%';
//}
//$database = new database;
//$num_rows = $database->select($sql, $parameters, 'column');
//prepare some of the paging values
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
$page = $_GET['page'] ?? '';
if (empty($page)) { $page = 0; $_GET['page'] = 0; }
$offset = $rows_per_page * $page;
//get the list
$sql = "select r.domain_uuid, d.domain_name, r.call_recording_uuid, r.call_direction, ";
$sql .= "r.call_recording_name, r.call_recording_path, r.call_recording_transcription, r.call_recording_length, ";
$sql .= "r.caller_id_name, r.caller_id_number, r.caller_destination, r.destination_number, ";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, \n";
$sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted \n";
$sql .= "from view_call_recordings as r, v_domains as d ";
//$sql .= "from v_call_recordings as r, v_domains as d ";
$sql .= "where true ";
if ($show != "all" || !permission_exists('call_recording_all')) {
$sql .= "and (r.domain_uuid = :domain_uuid or r.domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$sql .= "and r.domain_uuid = d.domain_uuid ";
if (!empty($search)) {
$sql .= "and (";
$sql .= " lower(r.call_direction) like :search ";
$sql .= " or lower(r.caller_id_name) like :search ";
$sql .= " or lower(r.caller_id_number) like :search ";
$sql .= " or lower(r.caller_destination) like :search ";
$sql .= " or lower(r.destination_number) like :search ";
$sql .= " or lower(r.call_recording_name) like :search ";
$sql .= " or lower(r.call_recording_path) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'r.call_recording_date', 'desc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$call_recordings = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//detect if any transcriptions available
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($call_recordings) && is_array($call_recordings)) {
$transcriptions_exists = false;
foreach ($call_recordings as $row) {
if (!empty($row['call_recording_transcription'])) { $transcriptions_exists = true; }
}
}
//count the results
$result_count = is_array($call_recordings) ? sizeof($call_recordings) : 0;
//limit the number of results
if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) {
$num_rows = $_SESSION['cdr']['limit']['numeric'];
}
//prepare to page the results
$param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('call_recording_all')) {
$param .= "&show=all";
}
list($paging_controls_mini, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, true, $result_count); //top
list($paging_controls, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, false, $result_count); //bottom
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-call_recordings'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-call_recordings']." </b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('call_recording_download') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'id'=>'btn_download','name'=>'btn_download','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('download'); list_form_submit('form_list');"]);
}
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-transcribe'],'icon'=>'quote-right','id'=>'btn_transcribe','name'=>'btn_transcribe','style'=>'display: none;','collapse'=>'hide-xs','onclick'=>"list_action_set('transcribe'); list_form_submit('form_list');"]);
}
if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','collapse'=>'hide-xs','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('call_recording_all')) {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.(!empty($search) ? "&search=".urlencode($search) : null)]);
}
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=\"$('#btn_reset').hide(); $('#btn_search').show();\">";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_recordings.php','style'=>(empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('call_recording_delete') && !empty($call_recordings)) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-call_recordings']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
$col_count = 8;
if ($show == "all" && permission_exists('call_recording_all')) {
$col_count++;
}
if (permission_exists('call_recording_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($call_recordings) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
$col_count++;
}
if ($show == "all" && permission_exists('call_recording_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='hide-sm-dn shrink'");
}
echo th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order, null, "class='pct-15'");
echo th_order_by('caller_destination', $text['label-caller_destination'], $order_by, $order, null, "class='pct-10 hide-sm-dn'");
echo th_order_by('destination_number', $text['label-destination_number'], $order_by, $order, null, "class='pct-10'");
echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order, null, "class='pct-20 hide-sm-dn'");
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo "<th class='shrink center'>".$text['label-recording']."</th>\n";
$col_count++;
}
echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order, null, "class='right hide-sm-dn shrink'");
echo th_order_by('call_recording_date', $text['label-call_recording_date'], $order_by, $order, null, "class='pct-20 center'");
echo th_order_by('call_direction', $text['label-call_direction'], $order_by, $order, null, "class='hide-sm-dn shrink'");
if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (is_array($call_recordings) && @sizeof($call_recordings) != 0) {
$x = 0;
foreach ($call_recordings as $row) {
//add padding to the call recording length
$call_recording_length_padding = (!empty($row['call_recording_length'])) ? str_pad($row['call_recording_length'], 2, '0', STR_PAD_LEFT) : '';
//playback progress bar
if (permission_exists('call_recording_play')) {
echo "<tr class='list-row' id='recording_progress_bar_".escape($row['call_recording_uuid'])."' style='display: none;' onclick=\"recording_play('".escape($row['call_recording_uuid'])."')\"><td id='playback_progress_bar_background_".escape($row['call_recording_uuid'])."' class='playback_progress_bar_background' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['call_recording_uuid'])."'></span></td>".(permission_exists('xml_cdr_details') ? "<td class='action-button' style='border-bottom: none !important;'></td>" : null)."</tr>\n";
echo "<tr class='list-row' style='display: none;'><td></td></tr>\n"; // dummy row to maintain alternating background color
}
if (permission_exists('call_recording_play')) {
$list_row_url = "javascript:recording_play('".escape($row['call_recording_uuid'])."');";
}
echo "<tr class='list-row' href=\"".$list_row_url."\">\n";
if (permission_exists('call_recording_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_recordings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_recordings[$x][uuid]' value='".escape($row['call_recording_uuid'])."' />\n";
echo " </td>\n";
}
if ($show == "all" && permission_exists('call_recording_all')) {
echo " <td class='overflow hide-sm-dn shrink'>".escape($row['domain_name'])."</td>\n";
}
echo " <td class='hide-sm-dn shrink'>".escape($row['caller_id_name'])."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['caller_id_number'], 0, 20)))."</td>\n";
echo " <td class='hide-sm-dn shrink'>".escape(format_phone(substr($row['caller_destination'], 0, 20)))."</td>\n";
echo " <td class='shrink'>".escape(format_phone(substr($row['destination_number'], 0, 20)))."</td>\n";
echo " <td class='overflow hide-sm-dn nowrap'>".escape($row['call_recording_name'])."</td>\n";
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo " <td class='middle button center no-link no-wrap'>";
if (file_exists($row['call_recording_path'].'/'.$row['call_recording_name'])) {
if (permission_exists('call_recording_play')) {
$recording_file_ext = pathinfo($row['call_recording_name'], PATHINFO_EXTENSION);
switch ($recording_file_ext) {
case "wav" : $recording_type = "audio/wav"; break;
case "mp3" : $recording_type = "audio/mpeg"; break;
case "ogg" : $recording_type = "audio/ogg"; break;
}
echo "<audio id='recording_audio_".escape($row['call_recording_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['call_recording_uuid'])."')\" onended=\"recording_reset('".escape($row['call_recording_uuid'])."');\" src='download.php?id=".urlencode($row['call_recording_uuid'])."' type='".$recording_type."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.escape($row['call_recording_uuid']),'onclick'=>"recording_play('".escape($row['call_recording_uuid'])."')"]);
}
if (permission_exists('call_recording_download')) {
echo button::create(['type'=>'button','title'=>$text['label-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'link'=>'download.php?id='.urlencode($row['call_recording_uuid']).'&binary']);
}
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && $transcriptions_exists === true) {
echo button::create(['type'=>'button','title'=>$text['label-transcription'],'icon'=>'quote-right','style'=>(empty($row['call_recording_transcription']) ? 'visibility:hidden;' : null),'onclick'=>"document.getElementById('transcription_".$row['call_recording_uuid']."').style.display = document.getElementById('transcription_".$row['call_recording_uuid']."').style.display == 'none' ? 'table-row' : 'none'; this.blur(); return false;"]);
}
}
echo " </td>\n";
}
echo " <td class='right overflow hide-sm-dn shrink'>".($row['call_recording_length'] <= 59 ? '0:' : null).escape($call_recording_length_padding)."</td>\n";
echo " <td class='overflow center no-wrap'>".escape($row['call_recording_date_formatted'])." <span class='hide-sm-dn'>".escape($row['call_recording_time_formatted'])."</span></td>\n";
echo " <td class='left hide-sm-dn shrink'>".($row['call_direction'] != '' ? escape($text['label-'.$row['call_direction']]) : null)."</td>\n";
if (permission_exists('xml_cdr_details')) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>PROJECT_PATH.'/app/xml_cdr/xml_cdr_details.php?id='.urlencode($row['call_recording_uuid'])]);
echo " </td>\n";
}
echo "</tr>\n";
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($row['call_recording_transcription'])) {
echo "<tr style='display: none;'><td></td></tr>\n"; // dummy row to maintain same background color for transcription row
echo "<tr id='transcription_".$row['call_recording_uuid']."' class='list-row' style='display: none;'>\n";
echo " <td style='padding: 10px 20px 15px 20px;' colspan='".$col_count."'>\n";
echo " <strong style='display: inline-block; font-size: 90%; margin-bottom: 10px;'>".$text['label-transcription']."...</strong><br />\n";
echo escape($row['call_recording_transcription'])."\n";
echo " </td>\n";
echo "</tr>\n";
}
$x++;
}
unset($call_recordings);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
+47 -47
View File
@@ -1,48 +1,48 @@
<?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>
Portions created by the Initial Developer are Copyright (C) 2016-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permisions
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
//access granted
}
else {
echo "access denied";
exit;
}
//download
if (is_uuid($_GET['id'])) {
$obj = new call_recordings;
$obj->recording_uuid = $_GET['id'];
$obj->binary = isset($_GET['binary']) ? true : false;
$obj->download();
}
<?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>
Portions created by the Initial Developer are Copyright (C) 2016-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permisions
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
//access granted
}
else {
echo "access denied";
exit;
}
//download
if (is_uuid($_GET['id'])) {
$obj = new call_recordings;
$obj->recording_uuid = $_GET['id'];
$obj->binary = isset($_GET['binary']) ? true : false;
$obj->download();
}
?>
File diff suppressed because it is too large Load Diff
+6 -33
View File
@@ -468,8 +468,8 @@ $text['label-domain']['zh-cn'] = "领域";
$text['label-domain']['ja-jp'] = "ドメイン";
$text['label-domain']['ko-kr'] = "도메인";
$text['label-destination']['en-us'] = "Destination";
$text['label-destination']['en-gb'] = "Destination";
$text['label-destination']['en-us'] = "Dest";
$text['label-destination']['en-gb'] = "Dest";
$text['label-destination']['ar-eg'] = "الوجهة";
$text['label-destination']['de-at'] = "Ziel";
$text['label-destination']['de-ch'] = "Ziel";
@@ -546,8 +546,8 @@ $text['label-codec']['zh-cn'] = "读/写编解码器";
$text['label-codec']['ja-jp'] = "読み取り/書き込みコーデック";
$text['label-codec']['ko-kr'] = "읽기/쓰기 코덱";
$text['label-cid-number']['en-us'] = "Caller Number";
$text['label-cid-number']['en-gb'] = "Caller Number";
$text['label-cid-number']['en-us'] = "CID Number";
$text['label-cid-number']['en-gb'] = "CID Number";
$text['label-cid-number']['ar-eg'] = "رقم CID";
$text['label-cid-number']['de-at'] = "Anrufer Nummer";
$text['label-cid-number']['de-ch'] = "Anrufer Nummer";
@@ -572,8 +572,8 @@ $text['label-cid-number']['zh-cn'] = "来电号码";
$text['label-cid-number']['ja-jp'] = "CID番号";
$text['label-cid-number']['ko-kr'] = "CID 번호";
$text['label-cid-name']['en-us'] = "Caller Name";
$text['label-cid-name']['en-gb'] = "Caller Name";
$text['label-cid-name']['en-us'] = "CID Name";
$text['label-cid-name']['en-gb'] = "CID Name";
$text['label-cid-name']['ar-eg'] = "اسم CID";
$text['label-cid-name']['de-at'] = "Anrufer Name";
$text['label-cid-name']['de-ch'] = "Anrufer Name";
@@ -650,33 +650,6 @@ $text['label-eavesdrop']['zh-cn'] = "窃听";
$text['label-eavesdrop']['ja-jp'] = "盗聴";
$text['label-eavesdrop']['ko-kr'] = "엿듣다";
$text['label-duration']['en-us'] = "Duration";
$text['label-duration']['en-gb'] = "Duration";
$text['label-duration']['ar-eg'] = "المدة";
$text['label-duration']['de-at'] = "Dauer";
$text['label-duration']['de-ch'] = "Dauer";
$text['label-duration']['de-de'] = "Dauer";
$text['label-duration']['el-gr'] = "Διάρκεια";
$text['label-duration']['es-cl'] = "Duración";
$text['label-duration']['es-mx'] = "Duración";
$text['label-duration']['fr-ca'] = "Durée";
$text['label-duration']['fr-fr'] = "Durée";
$text['label-duration']['he-il'] = "משך השיחה";
$text['label-duration']['it-it'] = "Durata";
$text['label-duration']['ka-ge'] = "ხანგრძლივობა";
$text['label-duration']['nl-nl'] = "Duur";
$text['label-duration']['pl-pl'] = "Czas trwania";
$text['label-duration']['pt-br'] = "Duração";
$text['label-duration']['pt-pt'] = "Duração";
$text['label-duration']['ro-ro'] = "Durată";
$text['label-duration']['ru-ru'] = "Продолжительность";
$text['label-duration']['sv-se'] = "Samtalstid";
$text['label-duration']['uk-ua'] = "Тривалість";
$text['label-duration']['tr-tr'] = "Süre";
$text['label-duration']['zh-cn'] = "期间";
$text['label-duration']['ja-jp'] = "間隔";
$text['label-duration']['ko-kr'] = "지속";
$text['description-2']['en-us'] = "Use this to view all extensions and monitor and interact with active calls.";
$text['description-2']['en-gb'] = "Use this to view all extensions and monitor and interact with active calls.";
$text['description-2']['ar-eg'] = "استخدم هذا لعرض جميع الملحقات ومراقبة المكالمات النشطة والتفاعل معها.";
+153 -176
View File
@@ -88,8 +88,10 @@
}
$num_rows = @sizeof($rows);
//if the connnection is available then run it and return the results
if (!$event_socket) {
$msg = "<div align='center'>".$text['confirm-socket']."<br /></div>";
echo "<div align='center'>\n";
echo "<table width='40%'>\n";
@@ -101,197 +103,172 @@
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
return;
}
else {
//create token
$object = new token;
$token = $object->create('/app/calls_active/calls_active_inc.php');
//create token
$object = new token;
$token = $object->create('/app/calls_active/calls_active_inc.php');
//add the style
echo "<style>\n";
echo " /* Small screens: Hide columns with class 'hide-small' */\n";
echo " @media (max-width: 600px) {\n";
echo " .hide-small {\n";
echo " display: none;\n";
echo " }\n";
echo " }\n";
echo "\n";
echo " /* Medium screens: Hide columns with class 'hide-medium' */\n";
echo "@media (max-width: 1023px) and (min-width: 601px) {\n";
echo " .hide-medium {\n";
echo " display: none;\n";
echo " }\n";
echo " }\n";
echo "\n";
echo "</style>\n";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo " <span id='refresh_state'>".button::create(['type'=>'button','title'=>$text['label-refresh_pause'],'icon'=>'sync-alt fa-spin','onclick'=>'refresh_stop()'])."</span>";
if (permission_exists('call_active_eavesdrop') && !empty($_SESSION['user']['extensions'])) {
if (sizeof($_SESSION['user']['extensions']) > 1) {
echo " <input type='hidden' id='eavesdrop_dest' value=\"".(($_REQUEST['eavesdrop_dest'] == '') ? $_SESSION['user']['extension'][0]['destination'] : escape($_REQUEST['eavesdrop_dest']))."\">\n";
echo " <i class='fas fa-headphones' style='margin-left: 15px; cursor: help;' title='".$text['description-eavesdrop_destination']."' align='absmiddle'></i>\n";
echo " <select class='formfld' style='margin-right: 5px;' align='absmiddle' onchange=\"document.getElementById('eavesdrop_dest').value = this.options[this.selectedIndex].value; refresh_start();\" onfocus='refresh_stop();'>\n";
if (is_array($_SESSION['user']['extensions'])) {
foreach ($_SESSION['user']['extensions'] as $user_extension) {
echo " <option value='".escape($user_extension)."' ".(($_REQUEST['eavesdrop_dest'] == $user_extension) ? "selected" : null).">".escape($user_extension)."</option>\n";
//show content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo " <span id='refresh_state'>".button::create(['type'=>'button','title'=>$text['label-refresh_pause'],'icon'=>'sync-alt fa-spin','onclick'=>'refresh_stop()'])."</span>";
if (permission_exists('call_active_eavesdrop') && !empty($_SESSION['user']['extensions'])) {
if (sizeof($_SESSION['user']['extensions']) > 1) {
echo " <input type='hidden' id='eavesdrop_dest' value=\"".(($_REQUEST['eavesdrop_dest'] == '') ? $_SESSION['user']['extension'][0]['destination'] : escape($_REQUEST['eavesdrop_dest']))."\">\n";
echo " <i class='fas fa-headphones' style='margin-left: 15px; cursor: help;' title='".$text['description-eavesdrop_destination']."' align='absmiddle'></i>\n";
echo " <select class='formfld' style='margin-right: 5px;' align='absmiddle' onchange=\"document.getElementById('eavesdrop_dest').value = this.options[this.selectedIndex].value; refresh_start();\" onfocus='refresh_stop();'>\n";
if (is_array($_SESSION['user']['extensions'])) {
foreach ($_SESSION['user']['extensions'] as $user_extension) {
echo " <option value='".escape($user_extension)."' ".(($_REQUEST['eavesdrop_dest'] == $user_extension) ? "selected" : null).">".escape($user_extension)."</option>\n";
}
}
echo " </select>\n";
}
else if (sizeof($_SESSION['user']['extensions']) == 1) {
echo " <input type='hidden' id='eavesdrop_dest' value=\"".escape($_SESSION['user']['extension'][0]['destination'])."\">\n";
}
}
echo " </select>\n";
}
else if (sizeof($_SESSION['user']['extensions']) == 1) {
echo " <input type='hidden' id='eavesdrop_dest' value=\"".escape($_SESSION['user']['extension'][0]['destination'])."\">\n";
}
}
if (permission_exists('call_active_hangup') && $rows) {
echo button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'phone-slash','id'=>'btn_delete','onclick'=>"refresh_stop(); modal_open('modal-hangup','btn_hangup');"]);
}
if (permission_exists('call_active_all')) {
if ($show == "all") {
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'calls_active.php','onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'calls_active.php?show=all','onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('call_active_hangup') && $rows) {
echo modal::create(['id'=>'modal-hangup','type'=>'general','message'=>$text['confirm-hangups'],'actions'=>button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'check','id'=>'btn_hangup','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('hangup'); list_form_submit('form_list');"])]);
}
echo $text['description']."\n";
echo "<br /><br />\n";
//show the results
echo "<div id='cmd_reponse'></div>\n";
echo "<form id='form_list' method='post' action='calls_exec.php'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<div class='card'>\n";
echo " <table class='list'>\n";
echo " <tr class='list-header'>\n";
if (permission_exists('call_active_hangup')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='if (this.checked) { refresh_stop(); } else { refresh_start(); } list_all_toggle();' ".(empty($rows) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
}
echo " <th class='hide-small'>".$text['label-profile']."</th>\n";
//echo" <th>".$text['label-created']."</th>\n";
echo " <th>".$text['label-duration']."</th>\n";
if ($show == 'all') {
echo " <th>".$text['label-domain']."</th>\n";
}
//echo " <th>".$text['label-number']."</th>\n";
echo " <th class='hide-small'>".$text['label-cid-name']."</th>\n";
echo " <th>".$text['label-cid-number']."</th>\n";
echo " <th>".$text['label-destination']."</th>\n";
echo " <th class='hide-small hide-medium'>".$text['label-app']."</th>\n";
echo " <th class='hide-small hide-medium'>".$text['label-codec']."</th>\n";
echo " <th class='hide-small hide-medium'>".$text['label-secure']."</th>\n";
if (permission_exists('call_active_eavesdrop') || permission_exists('call_active_hangup')) {
echo " <th>&nbsp;</th>\n";
}
echo " </tr>\n";
if (is_array($rows)) {
$x = 0;
foreach ($rows as $row) {
//set the php variables
foreach ($row as $key => $value) {
$$key = $value;
if (permission_exists('call_active_hangup') && $rows) {
echo button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'phone-slash','id'=>'btn_delete','onclick'=>"refresh_stop(); modal_open('modal-hangup','btn_hangup');"]);
}
if (permission_exists('call_active_all')) {
if ($show == "all") {
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'calls_active.php','onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
//get the sip profile
$name_array = explode("/", $name);
$sip_profile = $name_array[1];
$sip_uri = $name_array[2];
//get the number
//$temp_array = explode("@", $sip_uri);
//$tmp_number = $temp_array[0];
//$tmp_number = str_replace("sip:", "", $tmp_number);
//remove the '+' because it breaks the call recording
$cid_num = str_replace("+", "", $cid_num);
//replace gateway uuid with name
if (is_array($_SESSION['gateways']) && sizeof($_SESSION['gateways']) > 0) {
foreach ($_SESSION['gateways'] as $gateway_uuid => $gateway_name) {
$application_data = str_replace($gateway_uuid, $gateway_name, $application_data);
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'calls_active.php?show=all','onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
//calculate elapsed seconds
$elapsed_seconds = time() - $created_epoch;
if (permission_exists('call_active_hangup') && $rows) {
echo modal::create(['id'=>'modal-hangup','type'=>'general','message'=>$text['confirm-hangups'],'actions'=>button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'check','id'=>'btn_hangup','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('hangup'); list_form_submit('form_list');"])]);
}
//convert seconds to hours, minutes, and seconds
$hours = floor($elapsed_seconds / 3600);
$minutes = floor(($elapsed_seconds % 3600) / 60);
$seconds = $elapsed_seconds % 60;
echo $text['description']."\n";
echo "<br /><br />\n";
//format the elapsed time as HH:MM:SS
$elapsed_time = sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
//show the results
echo "<div id='cmd_reponse'></div>\n";
//reduce too long app data
if(strlen($application_data) > 80) {
$application_data = substr($application_data, 0, 80) . '...';
echo "<form id='form_list' method='post' action='calls_exec.php'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('call_active_hangup')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='if (this.checked) { refresh_stop(); } else { refresh_start(); } list_all_toggle();' ".(empty($rows) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
}
echo " <th>".$text['label-profile']."</th>\n";
echo " <th>".$text['label-created']."</th>\n";
if ($show == 'all') {
echo " <th>".$text['label-domain']."</th>\n";
}
echo " <th>".$text['label-number']."</th>\n";
echo " <th>".$text['label-cid-name']."</th>\n";
echo " <th>".$text['label-cid-number']."</th>\n";
echo " <th>".$text['label-destination']."</th>\n";
echo " <th>".$text['label-app']."</th>\n";
echo " <th>".$text['label-codec']."</th>\n";
echo " <th>".$text['label-secure']."</th>\n";
if (permission_exists('call_active_eavesdrop') || permission_exists('call_active_hangup')) {
echo " <th>&nbsp;</th>\n";
}
echo "</tr>\n";
if (is_array($rows)) {
$x = 0;
foreach ($rows as $row) {
//set the php variables
foreach ($row as $key => $value) {
$$key = $value;
}
//get the sip profile
$name_array = explode("/", $name);
$sip_profile = $name_array[1];
$sip_uri = $name_array[2];
//get the number
$temp_array = explode("@", $sip_uri);
$tmp_number = $temp_array[0];
$tmp_number = str_replace("sip:", "", $tmp_number);
//remove the '+' because it breaks the call recording
$cid_num = str_replace("+", "", $cid_num);
//replace gateway uuid with name
if (is_array($_SESSION['gateways']) && sizeof($_SESSION['gateways']) > 0) {
foreach ($_SESSION['gateways'] as $gateway_uuid => $gateway_name) {
$application_data = str_replace($gateway_uuid, $gateway_name, $application_data);
}
}
// reduce too long app data
if(strlen($application_data) > 512) {
$application_data = substr($application_data, 0, 512) . '...';
}
//send the html
echo "<tr class='list-row'>\n";
if (permission_exists('call_active_hangup')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='calls[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (this.checked) { refresh_stop(); } else { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='calls[$x][uuid]' value='".escape($uuid)."' />\n";
echo " </td>\n";
}
echo " <td>".escape($sip_profile)."&nbsp;</td>\n";
echo " <td>".escape($created)."&nbsp;</td>\n";
if ($show == 'all') {
echo " <td>".escape($domain_name)."&nbsp;</td>\n";
}
echo " <td>".escape($tmp_number)."&nbsp;</td>\n";
echo " <td>".escape($cid_name)."&nbsp;</td>\n";
echo " <td>".escape($cid_num)."&nbsp;</td>\n";
echo " <td>".escape($dest)."&nbsp;</td>\n";
echo " <td>".(!empty($application) ? escape($application).":".escape($application_data) : null)."&nbsp;</td>\n";
echo " <td>".escape($read_codec).":".escape($read_rate)." / ".escape($write_codec).":".escape($write_rate)."&nbsp;</td>\n";
echo " <td>".escape($secure)."&nbsp;</td>\n";
if (permission_exists('call_active_eavesdrop') || permission_exists('call_active_hangup')) {
echo " <td class='button right' style='padding-right: 0;'>\n";
//eavesdrop
if (permission_exists('call_active_eavesdrop') && $callstate == 'ACTIVE' && !empty($_SESSION['user']['extensions']) && !in_array($cid_num, $_SESSION['user']['extensions'])) {
echo button::create(['type'=>'button','label'=>$text['label-eavesdrop'],'icon'=>'headphones','collapse'=>'hide-lg-dn','onclick'=>"if (confirm('".$text['confirm-eavesdrop']."')) { eavesdrop_call('".escape($cid_num)."','".escape($uuid)."'); } else { this.blur(); return false; }",'onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
//hangup
if (permission_exists('call_active_hangup')) {
echo button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'phone-slash','collapse'=>'hide-lg-dn','onclick'=>"if (confirm('".$text['confirm-hangup']."')) { list_self_check('checkbox_".$x."'); list_action_set('hangup'); list_form_submit('form_list'); } else { this.blur(); return false; }",'onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
echo "</td>\n";
}
echo "</tr>\n";
//unset the domain name
unset($domain_name);
//increment counter
$x++;
}
unset($rows);
}
//send the html
echo " <tr class='list-row'>\n";
if (permission_exists('call_active_hangup')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='calls[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (this.checked) { refresh_stop(); } else { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='calls[$x][uuid]' value='".escape($uuid)."' />\n";
echo " </td>\n";
}
echo " <td class='hide-small'>".escape($sip_profile)."&nbsp;</td>\n";
//echo " <td>".escape($created)."&nbsp;</td>\n";
echo " <td>".escape($elapsed_time)."</td>\n";
if ($show == 'all') {
echo " <td>".escape($domain_name)."&nbsp;</td>\n";
}
//echo " <td>".escape($tmp_number)."&nbsp;</td>\n";
echo " <td class='hide-small'>".escape($cid_name)."&nbsp;</td>\n";
echo " <td>".escape($cid_num)."&nbsp;</td>\n";
echo " <td>".escape($dest)."&nbsp;</td>\n";
echo " <td class='hide-small hide-medium' style='max-width: 200px; word-wrap: break-word;'>".(!empty($application) ? escape($application).":".escape($application_data) : null)."&nbsp;</td>\n";
echo " <td class='hide-small hide-medium'>".escape($read_codec).":".escape($read_rate)." / ".escape($write_codec).":".escape($write_rate)."&nbsp;</td>\n";
echo " <td class='hide-small hide-medium'>".escape($secure)."&nbsp;</td>\n";
if (permission_exists('call_active_eavesdrop') || permission_exists('call_active_hangup')) {
echo " <td class='button right' style='padding-right: 0;'>\n";
//eavesdrop
if (permission_exists('call_active_eavesdrop') && $callstate == 'ACTIVE' && !empty($_SESSION['user']['extensions']) && !in_array($cid_num, $_SESSION['user']['extensions'])) {
echo button::create(['type'=>'button','label'=>$text['label-eavesdrop'],'icon'=>'headphones','collapse'=>'hide-lg-dn','onclick'=>"if (confirm('".$text['confirm-eavesdrop']."')) { eavesdrop_call('".escape($cid_num)."','".escape($uuid)."'); } else { this.blur(); return false; }",'onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
//hangup
if (permission_exists('call_active_hangup')) {
echo button::create(['type'=>'button','label'=>$text['label-hangup'],'icon'=>'phone-slash','collapse'=>'hide-lg-dn','onclick'=>"if (confirm('".$text['confirm-hangup']."')) { list_self_check('checkbox_".$x."'); list_action_set('hangup'); list_form_submit('form_list'); } else { this.blur(); return false; }",'onmouseover'=>'refresh_stop()','onmouseout'=>'refresh_start()']);
}
echo " </td>\n";
}
echo " </tr>\n";
echo "</table>\n";
echo "</div>\n";
//unset the domain name
unset($domain_name);
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//increment counter
$x++;
}
}
echo " </table>\n";
echo "</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
?>
@@ -164,7 +164,7 @@
$array['dialplans'][0]["app_uuid"] = "b81412e8-7253-91f4-e48e-42fc2c9a38d9";
//add the dialplan permission
$p = permissions::new();
$p = new permissions;
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
@@ -188,7 +188,7 @@
$array['conference_room_users'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
//un-assigne the users from the conference room
$p = permissions::new();
$p = new permissions;
$p->add('conference_room_user_delete', 'temp');
$database->app_name = 'conference_centers';
@@ -358,7 +358,7 @@
$array['conference_room_users'][0]['conference_room_uuid'] = $conference_room_uuid;
$array['conference_room_users'][0]['user_uuid'] = $_SESSION["user_uuid"];
$p = permissions::new();
$p = new permissions;
$p->add('conference_room_user_add', 'temp');
$database->app_name = 'conference_centers';
@@ -440,7 +440,7 @@
$array['conference_room_users'][0]['conference_room_uuid'] = $conference_room_uuid;
$array['conference_room_users'][0]['user_uuid'] = $user_uuid;
$p = permissions::new();
$p = new permissions;
$p->add('conference_room_user_add', 'temp');
$database->app_name = 'conference_centers';
@@ -349,7 +349,7 @@ if (!class_exists('conference_centers')) {
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_detail_delete', 'temp');
$p->add('dialplan_delete', 'temp');
@@ -425,7 +425,7 @@ if (!class_exists('conference_centers')) {
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('conference_room_user_delete', 'temp');
$p->add('conference_room_delete', 'temp');
@@ -489,7 +489,7 @@ if (!class_exists('conference_centers')) {
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('conference_session_detail_delete', 'temp');
$p->add('conference_user_delete', 'temp');
@@ -578,7 +578,7 @@ if (!class_exists('conference_centers')) {
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add("dialplan_edit", "temp");
//save the array
+2 -2
View File
@@ -65,7 +65,7 @@
$array['conference_controls'][0]['control_name'] = $control_name;
$array['conference_controls'][0]['control_enabled'] = 'true';
$p = permissions::new();
$p = new permissions;
$p->add('conference_control_add', 'temp');
$database->app_name = 'conference_controls';
@@ -96,7 +96,7 @@
}
$array['conference_control_details'][0]['control_enabled'] = $control_enabled;
$p = permissions::new();
$p = new permissions;
$p->add('conference_control_detail_add', 'temp');
$database->app_name = 'conference_controls';
@@ -103,7 +103,7 @@ if (!class_exists('conference_controls')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('conference_control_detail_delete', 'temp');
//execute delete
+2 -2
View File
@@ -65,7 +65,7 @@
$array['conference_profiles'][0]['profile_name'] = $profile_name;
$array['conference_profiles'][0]['profile_enabled'] = 'true';
$p = permissions::new();
$p = new permissions;
$p->add('conference_profile_add', 'temp');
$database->app_name = 'conference_profiles';
@@ -91,7 +91,7 @@
$array['conference_profile_params'][0]['profile_param_value'] = $profile_param_value;
$array['conference_profile_params'][0]['profile_param_enabled'] = $profile_param_enabled;
$p = permissions::new();
$p = new permissions;
$p->add('conference_profile_param_add', 'temp');
$database->app_name = 'conference_profiles';
@@ -103,7 +103,7 @@ if (!class_exists('conference_profiles')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('conference_profile_param_delete', 'temp');
//execute delete
@@ -410,7 +410,7 @@ if (!class_exists('conference_profiles')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('conference_profile_param_add', 'temp');
//save the array
+3 -3
View File
@@ -91,7 +91,7 @@
$user_uuid = $_REQUEST["user_uuid"];
$conference_uuid = $_REQUEST["id"];
$p = permissions::new();
$p = new permissions;
$p->add('conference_user_delete', 'temp');
$array['conference_users'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
@@ -124,7 +124,7 @@
$array['conference_users'][0]['conference_uuid'] = $conference_uuid;
$array['conference_users'][0]['user_uuid'] = $user_uuid;
$p = permissions::new();
$p = new permissions;
$p->add('conference_user_add', 'temp');
$database = new database;
@@ -239,7 +239,7 @@
$array['dialplans'][0]['dialplan_enabled'] = $conference_enabled;
$array['dialplans'][0]['dialplan_description'] = $conference_description;
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_add', 'temp');
$p->add('dialplan_edit', 'temp');
@@ -108,7 +108,7 @@ if (!class_exists('conferences')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('conference_user_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
$p->add('dialplan_delete', 'temp');
@@ -203,7 +203,7 @@ if (!class_exists('conferences')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
//save the array
@@ -341,7 +341,7 @@ if (!class_exists('conferences')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('conference_user_add', 'temp');
$p->add('dialplan_add', 'temp');
+1 -1
View File
@@ -131,7 +131,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = permissions::new();
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -545,7 +545,7 @@
//save the data
if (!empty($array)) {
//add the permission object
$p = permissions::new();
$p = new permissions;
$p->add('contact_add', 'temp');
$p->add('contact_phone_add', 'temp');
$p->add('contact_address_add', 'temp');
+1 -1
View File
@@ -112,7 +112,7 @@ if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = permissions::new();
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -107,7 +107,7 @@ if ($_POST['a'] == 'import') {
unset($duplicate_contact_uuid);
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('contact_delete', 'temp');
//delete duplicate contact
+1 -1
View File
@@ -102,7 +102,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = permissions::new();
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -132,7 +132,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = permissions::new();
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -110,7 +110,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = permissions::new();
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -129,7 +129,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = permissions::new();
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -102,7 +102,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = permissions::new();
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -115,7 +115,7 @@
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = permissions::new();
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
+1 -1
View File
@@ -108,7 +108,7 @@ if (!class_exists('contacts')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temp permissions
$p = permissions::new();
$p = new permissions;
$database = new database;
foreach ($this->tables as $table) {
$p->add(database::singular($table).'_delete', 'temp');
+2 -2
View File
@@ -83,7 +83,7 @@ if ($domains_processed == 1) {
//save to the data
if (!empty($array)) {
//add temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('destination_edit', 'temp');
//create the database object and save the data
@@ -109,7 +109,7 @@ if ($domains_processed == 1) {
if (!empty($array)) {
//add temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('destination_edit', 'temp');
//create the database object and save the data
+1
View File
@@ -73,3 +73,4 @@
$y++;
?>
+21 -42
View File
@@ -41,13 +41,10 @@
$language = new text;
$text = $language->get();
//initialize the database object
$database = database::new();
//initialize the database
$database = new database;
//initialize the settings object
$settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]);
//initialize the destination object
//initialize the destinations object
$destination = new destinations;
//initialize the ringbacks object
@@ -71,20 +68,17 @@
default: $destination_type = 'inbound';
}
//get the call recording extension
$record_extension = $settings->get('call_recordings', 'record_extension', 'mp3');
//get total destination count from the database, check limit, if defined
if (!permission_exists('destination_domain')) {
if ($action == 'add') {
if (!empty($settings->get('limit', 'destinations', ''))) {
if (!empty($_SESSION['limit']['destinations']['numeric'])) {
$sql = "select count(*) from v_destinations where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$total_destinations = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
if ($total_destinations >= $settings->get('limit', 'destinations', '')) {
message::add($text['message-maximum_destinations'].' '.$settings->get('limit', 'destinations', ''), 'negative');
if ($total_destinations >= $_SESSION['limit']['destinations']['numeric']) {
message::add($text['message-maximum_destinations'].' '.$_SESSION['limit']['destinations']['numeric'], 'negative');
header('Location: destinations.php');
exit;
}
@@ -204,7 +198,7 @@
if (empty($destination_enabled)) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."<br>\n"; }
//check for duplicates
if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $settings->get('destinations', 'unique', '')) {
if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $_SESSION['destinations']['unique']['boolean'] == 'true') {
$sql = "select count(*) from v_destinations ";
$sql .= "where (destination_number = :destination_number or destination_prefix || destination_number = :destination_number) ";
$sql .= "and destination_type = 'inbound' ";
@@ -450,15 +444,15 @@
if (!empty($destination_condition_field)) {
$dialplan_detail_type = $destination_condition_field;
}
elseif (!empty($settings->get('dialplan', 'destination', ''))) {
$dialplan_detail_type = $settings->get('dialplan', 'destination', '');
elseif (!empty($_SESSION['dialplan']['destination']['text'])) {
$dialplan_detail_type = $_SESSION['dialplan']['destination']['text'];
}
else {
$dialplan_detail_type = "destination_number";
}
//authorized specific dialplan_detail_type that are safe, sanitize all other values
$dialplan_detail_type = $settings->get('dialplan', 'destination', '');
$dialplan_detail_type = $_SESSION['dialplan']['destination']['text'];
switch ($dialplan_detail_type) {
case 'destination_number':
break;
@@ -536,11 +530,10 @@
}
if (!empty($destination_record) && $destination_record == 'true') {
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_path=\${recordings_dir}/\${domain_name}/archive/\${strftime(%Y)}/\${strftime(%b)}/\${strftime(%d)}\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_name=\${uuid}.".$record_extension."\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_name=\${uuid}.\${record_ext}\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_append=true\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_in_progress=true\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"recording_follow_transfer=true\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_stereo_swap=true\" inline=\"true\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"record_session\" data=\"\${record_path}/\${record_name}\" inline=\"false\"/>\n";
}
if (!empty($destination_hold_music)) {
@@ -599,7 +592,7 @@
$dialplan["dialplan_xml"] .= "</extension>\n";
//dialplan details
if ($settings->get('destinations', 'dialplan_details', '')) {
if ($_SESSION['destinations']['dialplan_details']['boolean'] == "true") {
//set initial value of the row id
$y=0;
@@ -640,8 +633,8 @@
if (!empty($destination_condition_field)) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field;
}
elseif (!empty($settings->get('dialplan', 'destination', ''))) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination', '');
elseif (!empty($_SESSION['dialplan']['destination']['text'])) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text'];
}
else {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "regex";
@@ -700,8 +693,8 @@
if (!empty($destination_condition_field)) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field;
}
elseif (!empty($settings->get('dialplan', 'destination', ''))) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination', '');
elseif (!empty($_SESSION['dialplan']['destination']['text'])) {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text'];
}
else {
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
@@ -949,7 +942,7 @@
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_name=\${uuid}.".$record_extension;
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_name=\${uuid}.\${record_ext}";
$dialplan["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = $dialplan_detail_group;
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
@@ -986,20 +979,6 @@
//increment the dialplan detail order
$dialplan_detail_order = $dialplan_detail_order + 10;
//add a variable
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_stereo_swap=true";
$dialplan["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = $dialplan_detail_group;
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$y++;
//increment the dialplan detail order
$dialplan_detail_order = $dialplan_detail_order + 10;
//add a variable
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
@@ -1160,7 +1139,7 @@
}
//add the dialplan permission
$p = permissions::new();
$p = new permissions;
$p->add("dialplan_add", 'temp');
$p->add("dialplan_detail_add", 'temp');
$p->add("dialplan_edit", 'temp');
@@ -1180,10 +1159,10 @@
//clear the cache
$cache = new cache;
if ($settings->get('destinations', 'dialplan_mode', '') == 'multiple') {
if ($_SESSION['destinations']['dialplan_mode']['text'] == 'multiple') {
$cache->delete("dialplan:".$destination_context);
}
if ($settings->get('destinations', 'dialplan_mode', '') == 'single') {
if ($_SESSION['destinations']['dialplan_mode']['text'] == 'single') {
if (isset($destination_prefix) && is_numeric($destination_prefix) && isset($destination_number) && is_numeric($destination_number)) {
$cache->delete("dialplan:".$destination_context.":".$destination_prefix.$destination_number);
$cache->delete("dialplan:".$destination_context.":+".$destination_prefix.$destination_number);
@@ -2067,7 +2046,7 @@
echo " ".$text['label-destination_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') {
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='destination_enabled' name='destination_enabled' value='true' ".($destination_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
File diff suppressed because it is too large Load Diff
@@ -402,7 +402,7 @@ if (!class_exists('destinations')) {
}
}
//application: hangup
if (!empty($data['application']) && $data['application'] === 'hangup') {
if (!empty($data['application'])) {
$select_value = str_replace("transfer", $data['application'], $select_value);
}
}
@@ -1081,7 +1081,7 @@ if (!class_exists('destinations')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -1134,9 +1134,6 @@ if (!class_exists('destinations')) {
$time_zone = date_default_timezone_get();
}
//set the time zone for php
date_default_timezone_set($time_zone);
//build the date range
if (!empty($this->start_stamp_begin) || !empty($this->start_stamp_end)) {
unset($this->quick_select);
@@ -1239,7 +1236,6 @@ if (!class_exists('destinations')) {
}
$sql .= " and direction = 'inbound' \n";
$sql .= " and caller_destination is not null \n";
$sql .= " and leg = 'a' \n";
$sql .= $sql_date_range ?? '';
$sql .= ") as c \n";
+4 -4
View File
@@ -62,7 +62,7 @@ if ($domains_processed == 1) {
$array['device_keys'][$index]['device_key_vendor'] = $row["device_vendor"];
}
if (is_array($array) && @sizeof($array)) {
$p = permissions::new();
$p = new permissions;
$p->add('device_key_edit', 'temp');
$database->app_name = 'devices';
@@ -106,7 +106,7 @@ if ($domains_processed == 1) {
//save the array
if (!empty($array)) {
$p = permissions::new();
$p = new permissions;
$p->add('device_profile_key_add', 'temp');
$database->app_name = 'devices';
@@ -144,7 +144,7 @@ if ($domains_processed == 1) {
//save the array
if (!empty($array)) {
$p = permissions::new();
$p = new permissions;
$p->add('device_profile_setting_add', 'temp');
$database->app_name = 'devices';
@@ -225,7 +225,7 @@ if ($domains_processed == 1) {
//execute
if (!empty($array)) {
$p = permissions::new();
$p = new permissions;
$p->add('device_vendor_add', 'temp');
$p->add('device_vendor_function_add', 'temp');
$p->add('device_vendor_function_group_add', 'temp');
+1
View File
@@ -7364,3 +7364,4 @@ $text['label-required']['ja-jp'] = "必要";
$text['label-required']['ko-kr'] = "필수의";
?>
+89 -81
View File
@@ -44,9 +44,8 @@
$device_firmware_version = '';
$device_template ='';
//get the domain values
//get the domain uuid
$domain_uuid = $_SESSION['domain_uuid'] ?? '';
$domain_name = $_SESSION['domain_name'] ?? '';
//initialize the database object
$database = database::new();
@@ -65,12 +64,12 @@
//get the total device count from the database, check the limit, if defined
if ($action == 'add') {
if (!empty($settings->get('limit', 'devices', ''))) {
if (!empty($_SESSION['limit']['devices']['numeric']) && $_SESSION['limit']['devices']['numeric']) {
$sql = "select count(*) from v_devices where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$total_devices = $database->select($sql, $parameters, 'column');
if ($total_devices >= $settings->get('limit', 'devices', '')) {
message::add($text['message-maximum_devices'].' '.$settings->get('limit', 'devices', ''), 'negative');
if ($total_devices >= $_SESSION['limit']['devices']['numeric']) {
message::add($text['message-maximum_devices'].' '.$_SESSION['limit']['devices']['numeric'], 'negative');
header('Location: devices.php');
exit;
}
@@ -229,14 +228,14 @@
$sql .= " and d1.device_uuid <> :device_uuid ";
}
$parameters['device_address'] = $device_address;
$device_domain_name = $database->select($sql, $parameters, 'column');
if ($device_domain_name != '') {
$message = $text['message-duplicate'].($device_domain_name != $domain_name ? ": ".$device_domain_name : null);
$domain_name = $database->select($sql, $parameters, 'column');
if ($domain_name != '') {
$message = $text['message-duplicate'].(if_group("superadmin") && $_SESSION["domain_name"] != $domain_name ? ": ".$domain_name : null);
message::add($message,'negative');
header('Location: devices.php');
exit;
}
unset($sql, $parameters, $device_domain_name);
unset($sql, $parameters, $domain_name);
}
//add or update the database
@@ -305,7 +304,6 @@
$device_line_uuid = uuid();
$new_line = true;
}
$array['devices'][0]['device_lines'][$y]['domain_uuid'] = $domain_uuid;
$array['devices'][0]['device_lines'][$y]['device_uuid'] = $device_uuid;
$array['devices'][0]['device_lines'][$y]['device_line_uuid'] = $device_line_uuid;
@@ -313,23 +311,23 @@
$array['devices'][0]['device_lines'][$y]['server_address'] = $row["server_address"];
if (permission_exists('device_line_outbound_proxy_primary')) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $row["outbound_proxy_primary"];
} else if ($new_line && !empty($settings->get('provision', 'outbound_proxy_primary'))) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $settings->get('provision', 'outbound_proxy_primary', '');
} else if ($new_line && isset($_SESSION['provision']['outbound_proxy_primary'])) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $_SESSION['provision']['outbound_proxy_primary']['text'];
}
if (permission_exists('device_line_outbound_proxy_secondary')) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $row["outbound_proxy_secondary"];
} else if ($new_line && !empty($settings->get('provision', 'outbound_proxy_secondary'))) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $settings->get('provision', 'outbound_proxy_secondary', '');
} else if ($new_line && isset($_SESSION['provision']['outbound_proxy_secondary'])) {
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $_SESSION['provision']['outbound_proxy_secondary']['text'];
}
if (permission_exists('device_line_server_address_primary')) {
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $row["server_address_primary"];
} else if ($new_line && !empty($settings->get('provision', 'server_address_primary'))) {
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $settings->get('provision', 'server_address_primary', '');
} else if ($new_line && isset($_SESSION['provision']['server_address_primary'])) {
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $_SESSION['provision']['server_address_primary']['text'];
}
if (permission_exists('device_line_server_address_secondary')) {
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $row["server_address_secondary"];
} else if ($new_line && !empty($settings->get('provision', 'server_address_secondary'))) {
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $settings->get('provision', 'server_address_secondary', '');
} else if ($new_line && isset($_SESSION['provision']['server_address_secondary'])) {
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $_SESSION['provision']['server_address_secondary']['text'];
}
if (permission_exists('device_line_label')) {
$array['devices'][0]['device_lines'][$y]['label'] = $row["label"];
@@ -353,7 +351,7 @@
}
else {
if ($action == "add") {
$array['devices'][0]['device_lines'][$y]['sip_port'] = $settings->get('provision', 'line_sip_port', '5060');
$array['devices'][0]['device_lines'][$y]['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric'];
}
}
if (permission_exists('device_line_transport')) {
@@ -361,7 +359,7 @@
}
else {
if ($action == "add") {
$array['devices'][0]['device_lines'][$y]['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp');
$array['devices'][0]['device_lines'][$y]['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text'];
}
}
if (permission_exists('device_line_register_expires')) {
@@ -369,7 +367,7 @@
}
else {
if ($action == "add") {
$array['devices'][0]['device_lines'][$y]['register_expires'] = $settings->get('provision', 'line_register_expires', '120');
$array['devices'][0]['device_lines'][$y]['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric'];
}
}
$y++;
@@ -482,7 +480,7 @@
}
//write the provision files
if (!empty($settings->get('provision', 'path'))) {
if (!empty($_SESSION['provision']['path']['text'])) {
$prov = new provision(['settings' => $settings]);
$prov->domain_uuid = $domain_uuid;
$response = $prov->write();
@@ -511,6 +509,7 @@
$sql = "select * from v_devices ";
$sql .= "where device_uuid = :device_uuid ";
$parameters['device_uuid'] = $device_uuid;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$device_address = $row["device_address"];
@@ -534,13 +533,6 @@
unset($sql, $parameters, $row);
}
//get device lines
$sql = "select * ";
$sql .= "from v_domains ";
$sql .= "order by domain_name asc ";
$domains = $database->select($sql, null, 'all');
unset($sql, $parameters);
//set the defaults
if (empty($device_enabled)) { $device_enabled = 'true'; }
@@ -571,22 +563,20 @@
}
//get device lines
$sql = "select l.*, d.domain_name ";
$sql .= "from v_device_lines as l, v_domains as d ";
$sql = "select * from v_device_lines ";
$sql .= "where device_uuid = :device_uuid ";
$sql .= "and l.domain_uuid = d.domain_uuid ";
$sql .= "order by cast(line_number as int) asc ";
$parameters['device_uuid'] = $device_uuid ?? null;
$device_lines = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//set the new line defaults
$device_lines[$x]['line_number'] = '';
$device_lines[$x]['server_address'] = '';
$device_lines[$x]['outbound_proxy_primary'] = $settings->get('provision', 'outbound_proxy_primary', null);
$device_lines[$x]['outbound_proxy_secondary'] = $settings->get('provision', 'outbound_proxy_secondary', null);
$device_lines[$x]['server_address_primary'] = $settings->get('provision', 'server_address_primary', null);
$device_lines[$x]['server_address_secondary'] = $settings->get('provision', 'server_address_secondary', null);
$device_lines[$x]['outbound_proxy_primary'] = $_SESSION['provision']['outbound_proxy_primary']['text'] ?? null;
$device_lines[$x]['outbound_proxy_secondary'] = $_SESSION['provision']['outbound_proxy_secondary']['text'] ?? null;
$device_lines[$x]['server_address_primary'] = $_SESSION['provision']['server_address_primary']['text'] ?? null;
$device_lines[$x]['server_address_secondary'] = $_SESSION['provision']['server_address_secondary']['text'] ?? null;
$device_lines[$x]['label'] = '';
$device_lines[$x]['display_name'] = '';
$device_lines[$x]['user_id'] = '';
@@ -594,9 +584,9 @@
$device_lines[$x]['password'] = '';
$device_lines[$x]['shared_line'] = '';
$device_lines[$x]['enabled'] = '';
$device_lines[$x]['sip_port'] = $settings->get('provision', 'line_sip_port', '5060');
$device_lines[$x]['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp');
$device_lines[$x]['register_expires'] = $settings->get('provision', 'line_register_expires', '120');
$device_lines[$x]['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric'];
$device_lines[$x]['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text'];
$device_lines[$x]['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric'];
//get device keys
$sql = "select * from v_device_keys ";
@@ -622,11 +612,11 @@
//add empty device key row(s)
if (!is_uuid($device_uuid)) {
$rows = $settings->get('devices', 'key_add_rows', '10');
$rows = $_SESSION['devices']['key_add_rows']['numeric'] ?? 1;
$id = 0;
}
else {
$rows = $settings->get('devices', 'key_edit_rows', '3');
$rows = $_SESSION['devices']['key_edit_rows']['numeric'] ?? 1;
$id = count($device_keys) + 1;
}
for ($x = 0; $x < $rows; $x++) {
@@ -648,6 +638,7 @@
$sql .= "from v_device_vendors ";
$sql .= "where enabled = 'true' ";
$sql .= "order by name asc ";
$device_vendors = $database->select($sql, null, 'all');
unset($sql);
@@ -671,11 +662,11 @@
//add empty device setting row(s)
if (!is_uuid($device_uuid)) {
$rows = $settings->get('devices', 'key_add_rows', '10');
$rows = $_SESSION['devices']['setting_add_rows']['numeric'] ?? 1;
$id = 0;
}
else {
$rows = $settings->get('devices', 'key_edit_rows', '3');
$rows = $_SESSION['devices']['setting_edit_rows']['numeric'] ?? 1;
$id = count($device_settings) + 1;
}
for ($x = 0; $x < $rows; $x++) {
@@ -703,7 +694,12 @@
//get the first device line info (found on the local server) for the provision button
foreach ($device_lines as $row) {
if ($row['server_address'] == $row['domain_name'] && !empty($row['user_id']) && !empty($row['server_address'])) {
if (
array_key_exists($row['domain_uuid'], $_SESSION['domains']) &&
$row['server_address'] == $_SESSION['domains'][$row['domain_uuid']]['domain_name'] &&
!empty($row['user_id']) &&
!empty($row['server_address'])
) {
$user_id = $row['user_id'];
$server_address = $row['server_address'];
break;
@@ -735,13 +731,14 @@
echo " $('#target_file').fadeOut(fade_speed);\n";
echo " document.getElementById('target_file').selectedIndex = 0;\n";
echo " }\n";
echo " function download(d) {\n";
echo " if (d == '".$text['label-download']."') return;\n";
if ($settings->get('provision', 'http_domain_filter', true)) {
$provision_domain_name = $domain_name;
if ($_SESSION['provision']['http_domain_filter']['boolean'] == "false") {
$domain_name = $_SERVER["HTTP_HOST"];
}
else {
$provision_domain_name = $_SERVER["HTTP_HOST"];
$domain_name = $_SESSION['domain_name'];
}
if (!isset($_SERVER['HTTP_PROTOCOL'])) {
@@ -750,7 +747,7 @@
if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
}
echo " window.location = '".$_SERVER['HTTP_PROTOCOL']."://".$provision_domain_name.PROJECT_PATH."/app/provision/index.php?address=".escape($device_address ?? '')."&file=' + d + '&content_type=application/octet-stream';\n";
echo " window.location = '".$_SERVER['HTTP_PROTOCOL']."://".$domain_name.PROJECT_PATH."/app/provision/index.php?address=".escape($device_address ?? '')."&file=' + d + '&content_type=application/octet-stream';\n";
echo " }\n";
echo "\n";
@@ -796,11 +793,16 @@
//add the QR code
if (permission_exists("device_line_password") && !empty($device_template) && $qr_code_enabled) {
//set the mode
if (!empty($settings->get('theme', 'qr_image', ''))) {
$mode = '4';
if (isset($_SESSION['theme']['qr_image'])) {
if (!empty($_SESSION['theme']['qr_image'])) {
$mode = '4';
}
else {
$mode = '0';
}
}
else {
$mode = '0';
$mode = '4';
}
//get the device line settings
@@ -920,10 +922,15 @@
//build content for linphone
if ($device_template == "linphone/default") {
$auth_string = '';
if ($settings->get('provision', 'http_auth_enabled', true) && !empty($settings->get('provision', 'http_auth_username', '')) && !empty($settings->get('provision', 'http_auth_password', ''))) {
$auth_string = $settings->get('provision', 'http_auth_username', '').':'.$settings->get('provision', 'http_auth_password', '').'@';
if (
!empty($_SESSION['provision']['http_auth_enabled']['boolean']) &&
$_SESSION['provision']['http_auth_enabled']['boolean'] == 'true' &&
!empty($_SESSION['provision']['http_auth_username']['text']) &&
!empty($_SESSION['provision']['http_auth_password'][0])
) {
$auth_string = $_SESSION['provision']['http_auth_username']['text'].':'.$_SESSION['provision']['http_auth_password'][0].'@';
}
$content = "https://".$auth_string.$provision_domain_name.'/app/provision/index.php?address='.$device_address;
$content = "https://".$auth_string.$_SESSION['domain_name'].'/app/provision/index.php?address='.$device_address;
}
//stream the file
@@ -994,16 +1001,16 @@
echo " <img id='qr_code' src='data:image/jpeg;base64,".base64_encode($image)."'>\n";
echo "</div>\n";
}
/*
if (!empty($settings->get('theme', 'qr_image', ''))) {
echo "<img id='img-buffer' src='".$settings->get('theme', 'qr_image', '')."' style='display: none;'>";
if (isset($_SESSION['theme']['qr_image'])) {
echo "<img id='img-buffer' src='".$_SESSION["theme"]["qr_image"]["text"]."' style='display: none;'>";
}
else {
echo "<img id='img-buffer' src='".PROJECT_PATH."/themes/".$settings->get('domain', 'template', '')."/images/qr_code.png' style='display: none;'>";
echo "<img id='img-buffer' src='".PROJECT_PATH."/themes/".$_SESSION["domain"]["template"]["name"]."/images/qr_code.png' style='display: none;'>";
}
*/
}
//show the content
@@ -1013,7 +1020,7 @@
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-device']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back', ''),'id'=>'btn_back','link'=>'devices.php']);
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'devices.php']);
if ($action == 'update') {
$button_margin = 'margin-left: 15px;';
if (permission_exists("device_line_password") && $qr_code_enabled) {
@@ -1031,7 +1038,7 @@
$template_dir = $prov->template_dir;
$files = glob($template_dir.'/'.$device_template.'/*');
//add file buttons and the file list
echo button::create(['type'=>'button','id'=>'button_files','label'=>$text['button-files'],'icon'=>$settings->get('theme', 'button_icon_download', ''),'style'=>($button_margin ?? ''),'onclick'=>'show_files()']);
echo button::create(['type'=>'button','id'=>'button_files','label'=>$text['button-files'],'icon'=>$_SESSION['theme']['button_icon_download'],'style'=>($button_margin ?? ''),'onclick'=>'show_files()']);
echo "<select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n";
echo " <option value=''>".$text['label-download']."</option>\n";
foreach ($files as $file) {
@@ -1047,7 +1054,7 @@
unset($button_margin);
}
if (permission_exists('device_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy', ''),'style'=>($button_margin ?? ''),'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','new_address');"]);
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'style'=>($button_margin ?? ''),'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','new_address');"]);
unset($button_margin);
}
if (
@@ -1056,11 +1063,11 @@
permission_exists('device_key_delete') ||
permission_exists('device_setting_delete')
) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete', ''),'style'=>($button_margin ?? ''),'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'style'=>($button_margin ?? ''),'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
unset($button_margin);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save', ''),'id'=>'btn_save','style'=>'margin-left: 15px;','onclick'=>'submit_form();']);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px;','onclick'=>'submit_form();']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
@@ -1282,11 +1289,11 @@
//set the defaults
if (!permission_exists('device_line_server_address')) {
if (empty($row['server_address'])) { $row['server_address'] = $domain_name; }
if (empty($row['server_address'])) { $row['server_address'] = $_SESSION['domain_name']; }
}
if (empty($row['sip_transport'])) { $row['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp'); }
if (!isset($row['sip_port'])) { $row['sip_port'] = $settings->get('provision', 'line_sip_port', '5060'); } //used !isset to support a value of 0 as empty the empty function considers a value of 0 as empty.
if (empty($row['register_expires'])) { $row['register_expires'] = $settings->get('provision', 'line_register_expires', '120'); }
if (empty($row['sip_transport'])) { $row['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; }
if (!isset($row['sip_port'])) { $row['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; } //used !isset to support a value of 0 as empty the empty function considers a value of 0 as empty.
if (empty($row['register_expires'])) { $row['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; }
//add the primary key uuid
if (!empty($row['device_line_uuid']) && is_uuid($row['device_line_uuid'])) {
@@ -1316,10 +1323,10 @@
if (permission_exists('device_line_server_address_primary')) {
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
if (!empty($settings->get('provision', 'server_address_primary', '')) && is_array($settings->get('provision', 'server_address_primary', ''))) {
if (isset($_SESSION['provision']['server_address_primary']) && !isset($_SESSION['provision']['server_address_primary']['text'])) {
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][server_address_primary]'>\n";
echo " <option value=''></option>\n";
foreach($settings->get('provision', 'server_address_primary', '') as $field) {
foreach($_SESSION['provision']['server_address_primary'] as $field) {
echo " <option value='".$field."' ".(($row['server_address_primary'] == $field) ? "selected" : null).">".$field."</option>\n";
}
echo " </select>\n";
@@ -1332,10 +1339,10 @@
if (permission_exists('device_line_server_address_secondary')) {
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
if (!empty($settings->get('provision', 'server_address_secondary', '')) && is_array($settings->get('provision', 'server_address_secondary', ''))) {
if (isset($_SESSION['provision']['server_address_secondary']) && !isset($_SESSION['provision']['server_address_secondary']['text'])) {
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][server_address_secondary]'>\n";
echo " <option value=''></option>\n";
foreach($settings->get('provision', 'server_address_secondary', '') as $field) {
foreach($_SESSION['provision']['server_address_secondary'] as $field) {
echo " <option value='".$field."' ".(($row['server_address_secondary'] == $field) ? "selected" : null).">".$field."</option>\n";
}
echo " </select>\n";
@@ -1348,10 +1355,10 @@
if (permission_exists('device_line_outbound_proxy_primary')) {
echo " <td align='left'>\n";
if (!empty($settings->get('provision', 'outbound_proxy_primary', ''))) {
if (isset($_SESSION['provision']['outbound_proxy_primary']) && !isset($_SESSION['provision']['outbound_proxy_primary']['text'])) {
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][outbound_proxy_primary]'>\n";
echo " <option value=''></option>\n";
foreach($settings->get('provision', 'outbound_proxy_primary', '') as $field) {
foreach($_SESSION['provision']['outbound_proxy_primary'] as $field) {
echo " <option value='".$field."' ".(($row['outbound_proxy_primary'] == $field) ? "selected" : null).">".$field."</option>\n";
}
echo " </select>\n";
@@ -1364,10 +1371,10 @@
if (permission_exists('device_line_outbound_proxy_secondary')) {
echo " <td align='left'>\n";
if (!empty($settings->get('provision', 'outbound_proxy_secondary', ''))) {
if (isset($_SESSION['provision']['outbound_proxy_secondary']) && !isset($_SESSION['provision']['outbound_proxy_secondary']['text'])) {
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][outbound_proxy_secondary]'>\n";
echo " <option value=''></option>\n";
foreach($settings->get('provision', 'outbound_proxy_secondary', '') as $field) {
foreach($_SESSION['provision']['outbound_proxy_secondary'] as $field) {
echo " <option value='".$field."' ".(($row['outbound_proxy_secondary'] == $field) ? "selected" : null).">".$field."</option>\n";
}
echo " </select>\n";
@@ -1488,7 +1495,7 @@
foreach($device_profiles as $row) {
echo " <option value='".escape($row['device_profile_uuid'])."' ".(!empty($device_profile_uuid) && $row['device_profile_uuid'] == $device_profile_uuid ? "selected='selected'" : null).">".escape($row['device_profile_name'])." ".(($row['domain_uuid'] == '') ? "&nbsp;&nbsp;(".$text['select-global'].")" : null)."</option>\n";
}
echo " </select>\n";
echo " </select>\n";
}
else {
foreach($device_profiles as $row) {
@@ -1956,7 +1963,7 @@
else {
echo " <option value=''>".$text['select-global']."</option>\n";
}
foreach ($domains as $row) {
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";
}
@@ -1971,7 +1978,7 @@
echo "</tr>\n";
}
else {
echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value=\"".$domain_uuid."\"/>\n";
echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value=\"".$_SESSION['domain_uuid']."\"/>\n";
}
if (permission_exists('device_enable')) {
@@ -1980,7 +1987,7 @@
echo " ".$text['label-device_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') {
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='device_enabled' name='device_enabled' value='true' ".($device_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
@@ -2047,3 +2054,4 @@
require_once "resources/footer.php";
?>
+1
View File
@@ -226,3 +226,4 @@
require_once "resources/footer.php";
?>
+3 -2
View File
@@ -44,7 +44,7 @@
//delete the device vendor function group
$array['device_vendor_function_groups'][0]['device_vendor_function_group_uuid'] = $device_vendor_function_group_uuid;
$p = permissions::new();
$p = new permissions;
$p->add('device_vendor_function_group_delete', 'temp');
$database = new database;
@@ -183,7 +183,7 @@
$array['device_vendor_function_groups'][0]['group_name'] = $group_name;
$array['device_vendor_function_groups'][0]['group_uuid'] = $group_uuid;
$p = permissions::new();
$p = new permissions;
$p->add('device_vendor_function_group_add', 'temp');
$database = new database;
@@ -403,3 +403,4 @@
require_once "resources/footer.php";
?>
+2 -1
View File
@@ -129,7 +129,7 @@
}
//assign temp permissions
$p = permissions::new();
$p = new permissions;
$p->add('device_vendor_add', 'temp');
$p->add('device_vendor_function_add', 'temp');
$p->add('device_vendor_function_group_add', 'temp');
@@ -157,3 +157,4 @@
exit;
?>
+61 -36
View File
@@ -48,6 +48,18 @@
$database = database::new();
$settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]);
//set all permissions
$has_device_import = permission_exists('device_import');
$has_device_edit = permission_exists('device_edit');
$has_device_all = permission_exists('device_all');
$has_device_delete = permission_exists('device_delete');
$has_device_domain_all = permission_exists('device_domain_all');
$has_device_export = permission_exists('device_export');
$has_device_vendor_view = permission_exists('device_vendor_view');
$has_device_profile_view = permission_exists('device_profile_view');
$has_device_add = permission_exists('device_add');
$has_show_all = &$has_device_domain_all;
//add multi-lingual support
$language = new text;
$text = $language->get();
@@ -66,13 +78,13 @@
if (!empty($action) && !empty($devices) && is_array($devices) && @sizeof($devices) != 0) {
switch ($action) {
case 'toggle':
if (permission_exists('device_edit')) {
if ($has_device_edit) {
$obj = new device;
$obj->toggle($devices);
}
break;
case 'delete':
if (permission_exists('device_delete')) {
if ($has_device_delete) {
$obj = new device;
$obj->delete($devices);
}
@@ -93,7 +105,7 @@
//get total devices count from the database
$sql = "select count(*) from v_devices ";
$sql .= "where domain_uuid = :domain_uuid ";
if (!permission_exists('device_all') && !permission_exists('device_domain_all')) {
if (!$has_device_all && !$has_device_domain_all) {
$sql .= "and device_user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
}
@@ -101,6 +113,23 @@
$total_devices = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//update the has_device_add permission if the total device count is greater then set limit
$device_limit = $settings->get('limit', 'devices', null);
if ($has_device_add && $device_limit !== null) {
$has_device_add = $total_devices > $device_limit;
}
//get the domains if user has permission for show all
$domains = [];
if ($has_device_domain_all) {
$rows = $database->select("select domain_uuid, domain_name from v_domains where domain_enabled = 'true'");
if (!empty($rows)) {
foreach ($rows as $row) {
$domains[$row['domain_uuid']] = $row['domain_name'];
}
}
}
//get the devices profiles
$sql = "select * from v_device_profiles ";
$sql .= "where true ";
@@ -113,7 +142,7 @@
//prepare to page the results
$sql = "select count(*) from v_devices as d ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
if (isset($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
if (!empty($search)) {
$sql .= "where ";
}
@@ -121,7 +150,7 @@
else {
$sql .= "where (";
$sql .= " d.domain_uuid = :domain_uuid ";
if (permission_exists('device_all')) {
if ($has_device_all) {
$sql .= " or d.domain_uuid is null ";
}
$sql .= ") ";
@@ -176,7 +205,7 @@
$param = "&search=".$search;
$param .= "&fields=".$fields;
}
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
if (!empty($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
$param .= "&show=all";
}
$page = $_GET['page'] ?? 0;
@@ -185,15 +214,11 @@
$offset = $rows_per_page * $page;
//get the list
$sql = "select ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
$sql .= "d3.domain_name, ";
}
$sql .="d.*, d2.device_label as alternate_label, ";
$sql = "select d.*, d2.device_label as alternate_label, ";
$sql .= "to_char(timezone(:time_zone, d.device_provisioned_date), 'DD Mon YYYY') as provisioned_date_formatted, \n";
$sql .= "to_char(timezone(:time_zone, d.device_provisioned_date), 'HH12:MI:SS am') as provisioned_time_formatted \n";
$sql .= "from v_devices as d, v_devices as d2 ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
if (isset($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
$sql .= ", v_domains as d3 ";
}
$sql .= "where ( ";
@@ -203,19 +228,19 @@
$sql .= " d.device_uuid = d2.device_uuid ";
$sql .= " ) ";
$sql .= ") ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
if (isset($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
$sql .= " and d.domain_uuid = d3.domain_uuid ";
}
else {
$sql .= "and (";
$sql .= " d.domain_uuid = :domain_uuid ";
if (permission_exists('device_all')) {
if ($has_device_all) {
$sql .= " or d.domain_uuid is null ";
}
$sql .= ") ";
$parameters['domain_uuid'] = $domain_uuid;
}
if (!permission_exists('device_all') && !permission_exists('device_domain_all')) {
if (!$has_device_all && !$has_device_domain_all) {
$sql .= "and d.device_user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
}
@@ -289,33 +314,33 @@
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-devices']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('device_import')) {
if ($has_device_import) {
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$settings->get('theme', 'button_icon_import'),'link'=>'device_imports.php']);
}
if (permission_exists('device_export')) {
if ($has_device_export) {
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$settings->get('theme', 'button_icon_export'),'link'=>'device_download.php']);
}
if (permission_exists('device_vendor_view')) {
if ($has_device_vendor_view) {
echo button::create(['type'=>'button','label'=>$text['button-vendors'],'icon'=>'fax','link'=>'device_vendors.php']);
}
if (permission_exists('device_profile_view')) {
if ($has_device_profile_view) {
echo button::create(['type'=>'button','label'=>$text['button-profiles'],'icon'=>'clone','link'=>'device_profiles.php']);
}
$margin_left = permission_exists('device_import') || permission_exists('device_export') || permission_exists('device_vendor_view') || permission_exists('device_profile_view') ? "margin-left: 15px;" : null;
if (permission_exists('device_add') && (empty($_SESSION['limit']['devices']['numeric']) || ($total_devices < $_SESSION['limit']['devices']['numeric']))) {
$margin_left = $has_device_import || $has_device_export || $has_device_vendor_view || $has_device_profile_view ? "margin-left: 15px;" : null;
if ($has_device_add) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>$margin_left,'link'=>'device_edit.php']);
unset($margin_left);
}
if (permission_exists('device_edit') && $devices) {
if ($has_device_edit && $devices) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$settings->get('theme', 'button_icon_toggle'),'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none; '.($margin_left ?? null),'onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
unset($margin_left);
}
if (permission_exists('device_delete') && $devices) {
if ($has_device_delete && $devices) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; '.($margin_left ?? null),'onclick'=>"modal_open('modal-delete','btn_delete');"]);
unset($margin_left);
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('device_all')) {
if ($has_device_all) {
if (!empty($_GET['show']) && $_GET['show'] == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
@@ -344,10 +369,10 @@
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('device_edit') && $devices) {
if ($has_device_edit && $devices) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('device_delete') && $devices) {
if ($has_device_delete && $devices) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
@@ -362,12 +387,12 @@
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('device_edit') || permission_exists('device_delete')) {
if ($has_device_edit || $has_device_delete) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($devices) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
}
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
if (!empty($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $param);
}
echo th_order_by('device_address', $text['label-device_address'], $order_by, $order, null, null, $param ?? null);
@@ -381,7 +406,7 @@
echo th_order_by('device_enabled', $text['label-device_enabled'], $order_by, $order, null, "class='center'", $param ?? null);
echo th_order_by('device_provisioned_date', $text['label-device_status'], $order_by, $order, null, null, $param ?? null);
echo th_order_by('device_description', $text['label-device_description'], $order_by, $order, null, "class='hide-sm-dn'", $param ?? null);
if (permission_exists('device_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
if ($has_device_edit && $settings->get('theme', 'list_row_edit_button', 'false') === 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -397,7 +422,7 @@
}
}
if (permission_exists('device_edit')) {
if ($has_device_edit) {
$list_row_url = "device_edit.php?id=".urlencode($row['device_uuid']);
}
@@ -412,17 +437,17 @@
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('device_edit') || permission_exists('device_delete')) {
if ($has_device_edit || $has_device_delete) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='devices[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='devices[$x][uuid]' value='".escape($row['device_uuid'])."' />\n";
echo " </td>\n";
}
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
echo " <td>".escape($row['domain_name'])."</td>\n";
if (!empty($_GET['show']) && $_GET['show'] == "all" && $has_device_all) {
echo " <td>".escape($domains[$row['domain_uuid']])."</td>\n";
}
echo " <td class='no-wrap'>";
echo permission_exists('device_edit') ? "<a href='".$list_row_url."'>".escape(format_device_address($row['device_address']))."</a>" : escape(format_device_address($row['device_address']));
echo $has_device_edit ? "<a href='".$list_row_url."'>".escape(format_device_address($row['device_address']))."</a>" : escape(format_device_address($row['device_address']));
echo " </td>\n";
echo " <td>".escape($row['device_label'])."&nbsp;</td>\n";
if ($device_alternate) {
@@ -438,7 +463,7 @@
echo " <td>".escape($row['device_vendor'])."&nbsp;</td>\n";
echo " <td>".escape($row['device_template'])."&nbsp;</td>\n";
echo " <td>".escape($device_profile_name)."&nbsp;</td>\n";
if (permission_exists('device_edit')) {
if ($has_device_edit) {
echo " <td class='no-link center'>";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['device_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
@@ -449,7 +474,7 @@
echo " </td>\n";
echo " <td class='no-link'><a title='".escape($row['device_provisioned_agent'])."' href='javascript:void(0)'>".escape($row['provisioned_date_formatted'])." ".escape($row['provisioned_time_formatted'])."</a> &nbsp; ".escape($device_provisioned_method)." &nbsp; <a href='".escape($device_provisioned_method)."://".escape($row['device_provisioned_ip'])."' target='_blank'>".escape($row['device_provisioned_ip'])."</a>&nbsp;</td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['device_description'])."&nbsp;</td>\n";
if (permission_exists('device_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
if ($has_device_edit && $settings->get('theme', 'list_row_edit_button', 'false') === 'true') {
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$settings->get('theme','button_icon_edit'),'link'=>$list_row_url]);
echo " </td>\n";
+6 -6
View File
@@ -512,7 +512,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('device_setting_delete', 'temp');
$p->add('device_line_delete', 'temp');
$p->add('device_key_delete', 'temp');
@@ -722,7 +722,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('device_vendor_function_delete', 'temp');
$p->add('device_vendor_function_group_delete', 'temp');
@@ -784,7 +784,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('device_vendor_function_group_delete', 'temp');
//execute delete
@@ -845,7 +845,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('device_profile_key_delete', 'temp');
$p->add('device_profile_setting_delete', 'temp');
@@ -1370,13 +1370,13 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('device_profile_key_add', 'temp');
$p->add('device_profile_setting_add', 'temp');
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->databasee->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -77,3 +77,4 @@ $array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'admin';
$y++;
?>
@@ -259,7 +259,7 @@
}
if ($save) {
//add the temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('device_keys_add', 'temp');
$p->add('device_key_edit', 'temp');
@@ -402,7 +402,7 @@
//update the destination dialplan_uuid
if (is_uuid($destination_uuid)) {
$p = permissions::new();
$p = new permissions;
$p->add('destination_edit', 'temp');
$array['destinations'][0]['destination_uuid'] = $destination_uuid;
+2
View File
@@ -1648,3 +1648,5 @@ $text['description-accountcode']['ja-jp'] = "アカウントコードを入力
$text['description-accountcode']['ko-kr'] = "계정코드를 입력하세요.";
?>
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2025
Portions created by the Initial Developer are Copyright (C) 2008-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -70,37 +70,30 @@
$toll_allow = $_POST["toll_allow"] ?? '';
$pin_numbers_enable = $_POST["pin_numbers_enabled"] ?? null;
if (empty($pin_numbers_enable)) { $pin_numbers_enable = "false"; }
//set the default type
$gateway_type = 'gateway';
$gateway_2_type = 'gateway';
$gateway_3_type = 'gateway';
//set the gateway type to bridge
if (strtolower(substr($gateway, 0, 6)) == "bridge") {
$gateway_type = 'bridge';
}
//set the type to enum
if (strtolower(substr($gateway, 0, 4)) == "enum") {
$gateway_type = 'enum';
}
//set the type to freetdm
if (strtolower(substr($gateway, 0, 7)) == "freetdm") {
$gateway_type = 'freetdm';
}
//set the type to transfer
if (strtolower(substr($gateway, 0, 8)) == "transfer") {
$gateway_type = 'transfer';
}
//set the type to dingaling
if (strtolower(substr($gateway, 0, 4)) == "xmpp") {
$gateway_type = 'xmpp';
}
//set the gateway_uuid and gateway_name
if ($gateway_type == "gateway") {
$gateway_array = explode(":",$gateway);
@@ -114,32 +107,26 @@
//set the gateway_2 variable
$gateway_2 = $_POST["gateway_2"];
//set the type to bridge
if (strtolower(substr($gateway_2, 0, 6)) == "bridge") {
$gateway_2_type = 'bridge';
}
//set type to enum
if (strtolower(substr($gateway_2, 0, 4)) == "enum") {
$gateway_2_type = 'enum';
}
//set the type to freetdm
if (strtolower(substr($gateway_2, 0, 7)) == "freetdm") {
$gateway_2_type = 'freetdm';
}
//set the type to transfer
if (strtolower(substr($gateway_2, 0, 8)) == "transfer") {
$gateway_type = 'transfer';
}
//set the type to dingaling
if (strtolower(substr($gateway_2, 0, 4)) == "xmpp") {
$gateway_2_type = 'xmpp';
}
//set the gateway_2_id and gateway_2_name
if ($gateway_2_type == "gateway" && !empty($_POST["gateway_2"])) {
$gateway_2_array = explode(":",$gateway_2);
@@ -153,32 +140,26 @@
//set the gateway_3 variable
$gateway_3 = $_POST["gateway_3"];
//set the type to bridge
if (strtolower(substr($gateway_3, 0, 6)) == "bridge") {
$gateway_3_type = 'bridge';
}
//set the type to enum
if (strtolower(substr($gateway_3, 0, 4)) == "enum") {
$gateway_3_type = 'enum';
}
//set the type to freetdm
if (strtolower(substr($gateway_3, 0, 7)) == "freetdm") {
$gateway_3_type = 'freetdm';
}
//set the type to dingaling
if (strtolower(substr($gateway_3, 0, 4)) == "xmpp") {
$gateway_3_type = 'xmpp';
}
//set the type to transfer
if (strtolower(substr($gateway_3, 0, 8)) == "transfer") {
$gateway_type = 'transfer';
}
//set the gateway_3_id and gateway_3_name
if ($gateway_3_type == "gateway" && !empty($_POST["gateway_3"])) {
$gateway_3_array = explode(":",$gateway_3);
@@ -189,7 +170,6 @@
$gateway_3_id = '';
$gateway_3_name = '';
}
//set additional variables
$dialplan_enabled = $_POST["dialplan_enabled"] ?? 'false';
$dialplan_description = $_POST["dialplan_description"];
@@ -338,7 +318,7 @@
$tmp_prefix == $dialplan_expression
? $outbound_prefix = ""
: $outbound_prefix = $tmp_prefix;
if ($gateway_type == "gateway") {
$dialplan_name = $gateway_name.".".$abbrv;
if ($abbrv == "988") {
@@ -835,7 +815,7 @@
}
//add the dialplan permission
$p = permissions::new();
$p = new permissions;
$p->add("dialplan_add", "temp");
$p->add("dialplan_detail_add", "temp");
@@ -883,7 +863,7 @@
}
else {
$sql .= "and domain_uuid = :domain_uuid ";
}
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
@@ -901,9 +881,6 @@
unset($sql, $parameters);
}
//set defaults
if (empty($dialplan_enabled)) { $dialplan_enabled = "true"; }
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
@@ -962,7 +939,6 @@ function type_onchange(dialplan_detail_type) {
echo $text['description-outbound-routes']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap>\n";
@@ -1370,18 +1346,17 @@ function type_onchange(dialplan_detail_type) {
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br><br>\n";
echo "</table>";
echo "<br><br>";
if (!empty($action) && $action == "update") {
echo "<input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
echo "</form>";
//show the footer
require_once "resources/footer.php";
?>
?>
+1 -1
View File
@@ -170,7 +170,7 @@
$array['dialplan_details'][1]['dialplan_detail_data'] = 'WARNING [inbound routes] 404 not found \${sip_network_ip}';
$array['dialplan_details'][1]['dialplan_detail_order'] = '20';
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_add', 'temp');
$p->add('dialplan_detail_add', 'temp');
@@ -111,7 +111,7 @@
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_add', 'temp');
//execute insert
@@ -144,7 +144,7 @@
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
//execute update
@@ -447,7 +447,7 @@
} //end foreach $xml_list
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_add', 'temp');
$p->add('dialplan_edit', 'temp');
$p->add('dialplan_detail_add', 'temp');
@@ -1007,7 +1007,7 @@
$array['dialplans'][$x]['dialplan_uuid'] = $key;
$array['dialplans'][$x]['dialplan_xml'] = $value;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
//execute update
$database = new database;
@@ -1160,7 +1160,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -1264,7 +1264,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_detail_delete', 'temp');
//execute delete
@@ -1371,7 +1371,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
//save the array
@@ -1525,7 +1525,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_detail_add', 'temp');
//save the array
+8 -8
View File
@@ -124,7 +124,7 @@
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_add', 'temp');
//execute insert
@@ -156,7 +156,7 @@
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
//execute update
@@ -452,7 +452,7 @@
} //end foreach $xml_list
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_add', 'temp');
$p->add('dialplan_edit', 'temp');
$p->add('dialplan_detail_add', 'temp');
@@ -1065,7 +1065,7 @@
$array['dialplans'][$x]['dialplan_xml'] = $value;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
//execute update
@@ -1188,7 +1188,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
@@ -1290,7 +1290,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_detail_delete', 'temp');
//execute delete
@@ -1395,7 +1395,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_edit', 'temp');
//save the array
@@ -1546,7 +1546,7 @@
if (!empty($array)) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_detail_add', 'temp');
//save the array
@@ -40,18 +40,6 @@
<condition field="${from_user_record}" expression="^local$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${record_session}" expression="^true$"/>
<condition field="${call_direction}" expression="^inbound" break="never">
<action application="set" data="record_stereo_swap=true" inline="true"/>
</condition>
<condition field="${record_session}" expression="^true$"/>
<condition field="${call_direction}" expression="^outbound$" break="never">
<action application="set" data="record_stereo=true" inline="true"/>
</condition>
<condition field="${record_session}" expression="^true$"/>
<condition field="${call_direction}" expression="^local$" break="never">
<action application="set" data="record_stereo=true" inline="true"/>
</condition>
<condition field="${record_session}" expression="^true$">
<action application="set" data="record_path=${recordings_dir}/${domain_name}/archive/${strftime(%Y)}/${strftime(%b)}/${strftime(%d)}" inline="true" enabled="true"/>
<action application="set" data="record_name=${uuid}.${record_ext}" inline="true" enabled="true"/>
@@ -62,8 +50,9 @@
<action application="bind_digit_action" data="local,*6,api:uuid_record,${uuid} unmask ${recordings_dir}/${domain_name}/archive/${strftime(%Y)}/${strftime(%b)}/${strftime(%d)}/${uuid}.${record_ext},both,self" enabled="true"/>
<action application="set" data="record_append=true" inline="true" enabled="true"/>
<action application="set" data="record_in_progress=true" inline="true" enabled="true"/>
<action application="set" data="api_on_answer=uuid_record ${uuid} start ${record_path}/${record_name}" inline="false" enabled="true"/>
<action application="set" data="record_answer_req=true" enabled="true"/>
<action application="record_session" data="${record_path}/${record_name}" enabled="false"/>
<action application="set" data="api_on_answer=uuid_record ${uuid} start ${record_path}/${record_name}" inline="false" enabled="false"/>
<action application="set" data="RECORD_ANSWER_REQ=true" enabled="true"/>
<action application="record_session" data="${record_path}/${record_name}" enabled="true"/>
</condition>
</extension>
@@ -1,17 +1,8 @@
<extension name="valet_park" number="park+*5901-*5999" context="${domain_name}" continue="false" app_uuid="3cc8363d-5ce3-48aa-8ac1-143cf297c4f7" enabled="true" order="470">
<condition field="destination_number" expression="^(park)?\+?\*(59(0[1-9]|[1-9][0-9]))$" break="never"/>
<condition field="${sip_refer_to}" expression="^.+$" break="never"/>
<condition field="${sip_refer_to}" expression="sip:(.*)@(.*?)(?::\d+)?\>" break="never">
<action application="set" data="referred_by_host=$2" inline="true"/>
</condition>
<condition field="${sip_h_Referred-By}" expression="sip:(.*)@(.*?)(?::\d+)?\>" break="never">
<condition field="${sip_h_Referred-By}" expression="sip:(.*)@.*" break="never">
<action application="set" data="referred_by_user=$1" inline="true"/>
</condition>
<condition field="destination_number" expression="^(park)?\+?\*(59(0[1-9]|[1-9][0-9]))$" break="never"/>
<condition field="${referred_by_user}" expression="^.+$" break="never">
<action application="set" data="valet_context=${referred_by_host}" inline="true"/>
<anti-action application="set" data="valet_context=${domain_name}" inline="true"/>
</condition>
<condition field="destination_number" expression="^(park)?\+?\*(59(0[1-9]|[1-9][0-9]))$" break="never">
<action application="set" data="park_in_use=false" inline="true"/>
<action application="set" data="park_lot=$2" inline="true"/>
@@ -19,16 +10,16 @@
</condition>
<condition field="destination_number" expression="^(park)?\+?\*(59(0[1-9]|[1-9][0-9]))$"/>
<condition field="${referred_by_user}" expression="^.+$" break="never">
<action application="set" data="valet_info_park=${valet_info park@${valet_context}}|\*${park_lot}" inline="true"/>
<action application="set" data="park_in_use=${regex ${valet_info park@${valet_context}}|\*${park_lot}}" inline="true"/>
<action application="set" data="valet_info_park=${valet_info park@${domain_name}}|\*${park_lot}" inline="true"/>
<action application="set" data="park_in_use=${regex ${valet_info park@${domain_name}}|\*${park_lot}}" inline="true"/>
</condition>
<condition field="${park_in_use}" expression="true" break="never">
<action application="transfer" data="${referred_by_user} XML ${referred_by_host}"/>
<action application="transfer" data="${referred_by_user} XML ${context}"/>
<anti-action application="set" data="effective_caller_id_name=${cond ${regex ${direction} | inbound} == true ? 'park#${caller_id_name}' : 'park#${callee_id_name}'}" inline="true"/>
<anti-action application="set" data="valet_parking_timeout=900"/>
<anti-action application="set" data="valet_hold_music=${hold_music}"/>
<anti-action application="set" data="valet_parking_orbit_exten=${cond ${regex ${referred_by_user} | ^$} == true ? ${sip_from_user} : ${referred_by_user}}"/>
<anti-action application="answer" data=""/>
<anti-action application="valet_park" data="park@${valet_context} *${park_lot}"/>
<anti-action application="valet_park" data="park@${domain_name} *${park_lot}"/>
</condition>
</extension>
@@ -1,9 +1,9 @@
<extension name="operator" number="0" context="${domain_name}" continue="false" app_uuid="0e1cd2d7-9d84-4959-8b6c-0cb23de4de59" enabled="false" order="480">
<condition field="destination_number" expression="^0$|^operator$">
<action application="export" data="transfer_context=${domain_name}" enabled="true"/>
<action application="bind_meta_app" data="4 ab s execute_extension::att_xfer XML ${domain_name}" enabled="false"/>
<action application="bind_meta_app" data="5 ab s execute_extension::xfer_vm XML ${domain_name}" enabled="false"/>
<action application="set" data="domain_name=${domain_name}" enabled="true"/>
<action application="transfer" data="${operator} XML ${domain_name}" enabled="true"/>
<action application="export" data="transfer_context={v_context}" enabled="true"/>
<action application="bind_meta_app" data="4 ab s execute_extension::att_xfer XML ${context}" enabled="false"/>
<action application="bind_meta_app" data="5 ab s execute_extension::xfer_vm XML ${context}" enabled="false"/>
<action application="set" data="domain_name={v_context}" enabled="true"/>
<action application="transfer" data="${operator} XML {v_context}" enabled="true"/>
</condition>
</extension>
@@ -1,6 +1,6 @@
<extension name="operator-forward" number="*000" context="${domain_name}" continue="false" app_uuid="a90d3639-3b82-4905-a65d-85f58b6c4a19" enabled="true" order="485">
<condition field="destination_number" expression="^\*000$" >
<action application="set" data="dial_string=loopback/operator/${domain_name}/XML" />
<action application="set" data="dial_string=loopback/operator/${context}/XML" />
<action application="set" data="direction=both" />
<action application="set" data="extension=true" />
<action application="lua" data="dial_string.lua" />
+1
View File
@@ -414,3 +414,4 @@
require_once "resources/footer.php";
?>
@@ -138,8 +138,9 @@
//process the messages
if (is_array($email_queue) && @sizeof($email_queue) != 0) {
$which_php = exec('which php');
foreach($email_queue as $row) {
$command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php ";
$command = $which_php." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php ";
$command .= "'action=send&email_queue_uuid=".$row["email_queue_uuid"]."&hostname=".$hostname."'";
if (isset($debug)) {
//run process inline to see debug info
@@ -148,7 +148,7 @@
//get the email settings
$retry_limit = $settings->get('email_queue', 'retry_limit');
$transcribe_enabled = $settings->get('transcribe', 'enabled', false);
$transcribe_enabled = $settings->get('transcribe', 'enabled');
$save_response = $settings->get('email_queue', 'save_response');
//set defaults
@@ -181,9 +181,6 @@
//$voicemail_description = $row["voicemail_description"];
//$voicemail_name_base64 = $row["voicemail_name_base64"];
//$voicemail_tutorial = $row["voicemail_tutorial"];
if (gettype($voicemail_transcription_enabled) === 'string') {
$voicemail_transcription_enabled = ($voicemail_transcription_enabled === 'true') ? true : false;
}
}
unset($parameters);
@@ -223,7 +220,7 @@
}
}
if ($transcribe_enabled && isset($voicemail_transcription_enabled) && $voicemail_transcription_enabled) {
if (isset($transcribe_enabled) && $transcribe_enabled === 'true' && isset($voicemail_transcription_enabled) && $voicemail_transcription_enabled === 'true') {
//debug message
echo "transcribe enabled: true\n";
@@ -443,7 +440,7 @@
$array['email_queue'][0]['email_status'] = 'sent';
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('email_queue_add', 'temp');
$p->add('email_queue_update', 'temp');
//execute insert
@@ -474,7 +471,7 @@
$array['email_queue'][0]['email_status'] = 'failed';
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('email_queue_add', 'temp');
//execute insert
@@ -528,7 +525,7 @@
$array['email_logs'][0]['status'] = 'failed';
$array['email_logs'][0]['email'] = str_replace("'", "''", $msg);
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('email_log_add', 'temp');
//execute insert
$database->app_name = 'v_mailto';
@@ -572,3 +569,4 @@
//fwrite($esl, $content);
//fclose($esl);
?>
@@ -141,7 +141,7 @@
$sql = "select * from v_email_queue ";
$sql .= "where (email_status = 'waiting' or email_status = 'trying') ";
$sql .= "and hostname = :hostname ";
$sql .= "order by domain_uuid, email_date desc ";
$sql .= "order by domain_uuid asc ";
$sql .= "limit :limit ";
$parameters['hostname'] = $hostname;
$parameters['limit'] = $email_queue_limit;
@@ -152,7 +152,7 @@
//process the messages
if (is_array($email_queue) && @sizeof($email_queue) != 0) {
foreach($email_queue as $row) {
$command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php ";
$command = exec('which php')." ".$_SERVER['DOCUMENT_ROOT']."/app/email_queue/resources/jobs/email_send.php ";
$command .= "'action=send&email_queue_uuid=".$row["email_queue_uuid"]."&hostname=".$hostname."'";
if (isset($debug)) {
//run process inline to see debug info
+1 -1
View File
@@ -579,7 +579,7 @@
//add the missing email templates
if (!empty($array['email_templates'])) {
//add the temporary permission
$p = permissions::new();
$p = new permissions;
$p->add("email_template_add", 'temp');
$p->add("email_template_edit", 'temp');
+2 -2
View File
@@ -27,8 +27,8 @@ $text['title-emergency_logs']['zh-cn'] = "紧急日志";
$text['title-emergency_logs']['ja-jp'] = "緊急ログ";
$text['title-emergency_logs']['ko-kr'] = "비상 기록";
$text['title_description-emergency_logs']['en-us'] = "Track emergency calls including details of the time, date, and originating extension.";
$text['title_description-emergency_logs']['en-gb'] = "Track emergency calls including details of the time, date, and originating extension.";
$text['title_description-emergency_logs']['en-us'] = "Track emergency calls includinng details of the time, date, and originating extension.";
$text['title_description-emergency_logs']['en-gb'] = "Track emergency calls includinng details of the time, date, and originating extension.";
$text['title_description-emergency_logs']['ar-eg'] = "تتبع مكالمات الطوارئ بما في ذلك تفاصيل الوقت والتاريخ والامتداد الأصلي.";
$text['title_description-emergency_logs']['de-at'] = "Verfolgen Sie Notrufe mit Angaben zu Uhrzeit, Datum und Nebenstelle des Anrufers.";
$text['title_description-emergency_logs']['de-ch'] = "Verfolgen Sie Notrufe mit Angaben zu Uhrzeit, Datum und Nebenstelle des Anrufers.";
@@ -229,11 +229,11 @@
$x++;
}
if (is_array($array)) {
$p = permissions::new();
$p = new permissions;
$p->add('event_guard_log_edit', 'temp');
$database->app_name = 'event guard';
$database->app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637';
$database->save($array, false);
$database->save($array);
//$message = $database->message;
$p->delete('event_guard_log_edit', 'temp');
unset($array);
@@ -349,11 +349,11 @@
$array['event_guard_logs'][0]['extension'] = $event['to-user'].'@'.$event['to-host'];
$array['event_guard_logs'][0]['user_agent'] = $event['user-agent'];
$array['event_guard_logs'][0]['log_status'] = 'blocked';
$p = permissions::new();
$p = new permissions;
$p->add('event_guard_log_add', 'temp');
$database->app_name = 'event guard';
$database->app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637';
$database->save($array, false);
$database->save($array);
$p->delete('event_guard_log_add', 'temp');
//send debug information to the console
+384 -384
View File
@@ -1,384 +1,384 @@
<?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>
Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$extension_uuid = '';
$extension_setting_uuid = '';
$extension_setting_name = '';
$extension_setting_value = '';
$extension_setting_description = '';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$extension_setting_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the extension id
if (!empty($_REQUEST["extension_setting_uuid"]) && is_uuid($_REQUEST["extension_setting_uuid"])) {
$extension_setting_uuid = $_REQUEST["extension_setting_uuid"];
}
if (!empty($_REQUEST["extension_uuid"]) && is_uuid($_REQUEST["extension_uuid"])) {
$extension_uuid = $_REQUEST["extension_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$domain_uuid = $_POST["domain_uuid"] ?? null;
$extension_setting_type = $_POST["extension_setting_type"];
$extension_setting_name = $_POST["extension_setting_name"];
$extension_setting_value = $_POST["extension_setting_value"];
$extension_setting_enabled = $_POST["extension_setting_enabled"] ?? 'false';
$extension_setting_description = $_POST["extension_setting_description"];
}
//process the user data and save it to the database
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php?id='.$extension_uuid);
exit;
}
//process the http post data by submitted action
if (!empty($_POST['action'])) {
//prepare the array(s)
//send the array to the database class
switch ($_POST['action']) {
case 'copy':
if (permission_exists('extension_setting_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('extension_setting_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle')) && is_uuid($id) && is_uuid($extension_uuid)) {
header('Location: extension_setting_edit.php?id='.$id.'&extension_uuid='.$extension_uuid);
exit;
}
}
//check for all required data
$msg = '';
//if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (empty($extension_setting_type)) { $msg .= $text['message-required']." ".$text['label-extension_setting_type']."<br>\n"; }
if (empty($extension_setting_name)) { $msg .= $text['message-required']." ".$text['label-extension_setting_name']."<br>\n"; }
//if (empty($extension_setting_value)) { $msg .= $text['message-required']." ".$text['label-extension_setting_value']."<br>\n"; }
if (empty($extension_setting_enabled)) { $msg .= $text['message-required']." ".$text['label-extension_setting_enabled']."<br>\n"; }
//if (empty($extension_setting_description)) { $msg .= $text['message-required']." ".$text['label-extension_setting_description']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
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;
}
//add the extension_setting_uuid
if (empty($extension_setting_uuid)) {
$extension_setting_uuid = uuid();
}
//prepare the array
$array['extension_settings'][0]['extension_setting_uuid'] = $extension_setting_uuid;
$array['extension_settings'][0]['extension_uuid'] = $extension_uuid;
$array['extension_settings'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
//$array['extension_settings'][0]['domain_uuid'] = $domain_uuid;
$array['extension_settings'][0]['extension_setting_type'] = $extension_setting_type;
$array['extension_settings'][0]['extension_setting_name'] = $extension_setting_name;
$array['extension_settings'][0]['extension_setting_value'] = $extension_setting_value;
$array['extension_settings'][0]['extension_setting_enabled'] = $extension_setting_enabled;
$array['extension_settings'][0]['extension_setting_description'] = $extension_setting_description;
//save the data
$database = new database;
$database->app_name = 'extension settings';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$database->save($array);
//clear the cache
$sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$extension = $database->select($sql, $parameters, 'row');
$cache = new cache;
$cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]);
//redirect the user
if (isset($action)) {
if ($action == "add") {
$_SESSION["message"] = $text['message-add'];
}
if ($action == "update") {
$_SESSION["message"] = $text['message-update'];
}
//header('Location: extension_settings.php');
header('Location: extension_setting_edit.php?id='.urlencode($extension_setting_uuid).'&extension_uuid='.$extension_uuid);
return;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$sql = "select ";
//$sql .= "extension_uuid, ";
//$sql .= "domain_uuid, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_setting_uuid = :extension_setting_uuid ";
//$sql .= "and domain_uuid = :domain_uuid ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['extension_setting_uuid'] = $extension_setting_uuid ?? '';
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
if (!empty($row["extension_uuid"]) && is_uuid($row["extension_uuid"])) {
$extension_uuid = $row["extension_uuid"];
}
//$domain_uuid = $row["domain_uuid"];
$extension_setting_type = $row["extension_setting_type"];
$extension_setting_name = $row["extension_setting_name"];
$extension_setting_value = $row["extension_setting_value"];
$extension_setting_enabled = $row["extension_setting_enabled"];
$extension_setting_description = $row["extension_setting_description"];
}
unset($sql, $parameters, $row);
}
//set the defaults
if (empty($extension_setting_enabled)) { $extension_setting_enabled = 'true'; }
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
$document['title'] = $text['title-extension_setting'];
require_once "resources/header.php";
//show the content
echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input class='formfld' type='hidden' name='extension_setting_uuid' value='".escape($extension_setting_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_setting']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'extension_settings.php?id='.$extension_uuid]);
if ($action == 'update') {
if (permission_exists('_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('_delete')) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n";
if ($action == 'update') {
if (permission_exists('extension_setting_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
}
if (permission_exists('extension_setting_delete')) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
}
}
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//echo "<tr>\n";
//echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-domain_uuid']."\n";
//echo "</td>\n";
//echo "<td class='vtable' style='position: relative;' align='left'>\n";
//echo " <select class='formfld' name='domain_uuid'>\n";
//if (empty($domain_uuid)) {
// echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
//}
//else {
// echo " <option value=''>".$text['label-global']."</option>\n";
//}
//foreach ($_SESSION['domains'] as $row) {
// if ($row['domain_uuid'] == $domain_uuid) {
// echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n";
// }
// else {
// echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
// }
//}
//echo " </select>\n";
//echo "<br />\n";
//echo $text['description-domain_uuid']."\n";
//echo "</td>\n";
//echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_type']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='extension_setting_type'>\n";
echo " <option value=''></option>\n";
if (!empty($extension_setting_type) && $extension_setting_type == "param") {
echo " <option value='param' selected='selected'>".$text['label-param']."</option>\n";
}
else {
echo " <option value='param'>".$text['label-param']."</option>\n";
}
if (!empty($extension_setting_type) && $extension_setting_type == "variable") {
echo " <option value='variable' selected='selected'>".$text['label-variable']."</option>\n";
}
else {
echo " <option value='variable'>".$text['label-variable']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-extension_setting_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_name']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_name' maxlength='255' value='".escape($extension_setting_name)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_value']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_value' maxlength='255' value='".escape($extension_setting_value)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_value']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='extension_setting_enabled' name='extension_setting_enabled' value='true' ".($extension_setting_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
echo " </label>\n";
}
else {
echo " <select class='formfld' id='extension_setting_enabled' name='extension_setting_enabled'>\n";
echo " <option value='true' ".($extension_setting_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($extension_setting_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
}
echo "<br />\n";
echo $text['description-extension_setting_enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_description']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_description' maxlength='255' value='".escape($extension_setting_description)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br /><br />\n";
echo "<input type='hidden' name='extension_uuid' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
<?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>
Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$extension_uuid = '';
$extension_setting_uuid = '';
$extension_setting_name = '';
$extension_setting_value = '';
$extension_setting_description = '';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$extension_setting_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the extension id
if (!empty($_REQUEST["extension_setting_uuid"]) && is_uuid($_REQUEST["extension_setting_uuid"])) {
$extension_setting_uuid = $_REQUEST["extension_setting_uuid"];
}
if (!empty($_REQUEST["extension_uuid"]) && is_uuid($_REQUEST["extension_uuid"])) {
$extension_uuid = $_REQUEST["extension_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$domain_uuid = $_POST["domain_uuid"] ?? null;
$extension_setting_type = $_POST["extension_setting_type"];
$extension_setting_name = $_POST["extension_setting_name"];
$extension_setting_value = $_POST["extension_setting_value"];
$extension_setting_enabled = $_POST["extension_setting_enabled"] ?? 'false';
$extension_setting_description = $_POST["extension_setting_description"];
}
//process the user data and save it to the database
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php?id='.$extension_uuid);
exit;
}
//process the http post data by submitted action
if (!empty($_POST['action'])) {
//prepare the array(s)
//send the array to the database class
switch ($_POST['action']) {
case 'copy':
if (permission_exists('extension_setting_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('extension_setting_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle')) && is_uuid($id) && is_uuid($extension_uuid)) {
header('Location: extension_setting_edit.php?id='.$id.'&extension_uuid='.$extension_uuid);
exit;
}
}
//check for all required data
$msg = '';
//if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (empty($extension_setting_type)) { $msg .= $text['message-required']." ".$text['label-extension_setting_type']."<br>\n"; }
if (empty($extension_setting_name)) { $msg .= $text['message-required']." ".$text['label-extension_setting_name']."<br>\n"; }
//if (empty($extension_setting_value)) { $msg .= $text['message-required']." ".$text['label-extension_setting_value']."<br>\n"; }
if (empty($extension_setting_enabled)) { $msg .= $text['message-required']." ".$text['label-extension_setting_enabled']."<br>\n"; }
//if (empty($extension_setting_description)) { $msg .= $text['message-required']." ".$text['label-extension_setting_description']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
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;
}
//add the extension_setting_uuid
if (empty($extension_setting_uuid)) {
$extension_setting_uuid = uuid();
}
//prepare the array
$array['extension_settings'][0]['extension_setting_uuid'] = $extension_setting_uuid;
$array['extension_settings'][0]['extension_uuid'] = $extension_uuid;
$array['extension_settings'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
//$array['extension_settings'][0]['domain_uuid'] = $domain_uuid;
$array['extension_settings'][0]['extension_setting_type'] = $extension_setting_type;
$array['extension_settings'][0]['extension_setting_name'] = $extension_setting_name;
$array['extension_settings'][0]['extension_setting_value'] = $extension_setting_value;
$array['extension_settings'][0]['extension_setting_enabled'] = $extension_setting_enabled;
$array['extension_settings'][0]['extension_setting_description'] = $extension_setting_description;
//save the data
$database = new database;
$database->app_name = 'extension settings';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$database->save($array);
//clear the cache
$sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$extension = $database->select($sql, $parameters, 'row');
$cache = new cache;
$cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]);
//redirect the user
if (isset($action)) {
if ($action == "add") {
$_SESSION["message"] = $text['message-add'];
}
if ($action == "update") {
$_SESSION["message"] = $text['message-update'];
}
//header('Location: extension_settings.php');
header('Location: extension_setting_edit.php?id='.urlencode($extension_setting_uuid).'&extension_uuid='.$extension_uuid);
return;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$sql = "select ";
//$sql .= "extension_uuid, ";
//$sql .= "domain_uuid, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_setting_uuid = :extension_setting_uuid ";
//$sql .= "and domain_uuid = :domain_uuid ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['extension_setting_uuid'] = $extension_setting_uuid ?? '';
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
if (!empty($row["extension_uuid"]) && is_uuid($row["extension_uuid"])) {
$extension_uuid = $row["extension_uuid"];
}
//$domain_uuid = $row["domain_uuid"];
$extension_setting_type = $row["extension_setting_type"];
$extension_setting_name = $row["extension_setting_name"];
$extension_setting_value = $row["extension_setting_value"];
$extension_setting_enabled = $row["extension_setting_enabled"];
$extension_setting_description = $row["extension_setting_description"];
}
unset($sql, $parameters, $row);
}
//set the defaults
if (empty($extension_setting_enabled)) { $extension_setting_enabled = 'true'; }
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
$document['title'] = $text['title-extension_setting'];
require_once "resources/header.php";
//show the content
echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input class='formfld' type='hidden' name='extension_setting_uuid' value='".escape($extension_setting_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_setting']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'extension_settings.php?id='.$extension_uuid]);
if ($action == 'update') {
if (permission_exists('_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('_delete')) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n";
if ($action == 'update') {
if (permission_exists('extension_setting_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
}
if (permission_exists('extension_setting_delete')) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
}
}
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//echo "<tr>\n";
//echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-domain_uuid']."\n";
//echo "</td>\n";
//echo "<td class='vtable' style='position: relative;' align='left'>\n";
//echo " <select class='formfld' name='domain_uuid'>\n";
//if (empty($domain_uuid)) {
// echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
//}
//else {
// echo " <option value=''>".$text['label-global']."</option>\n";
//}
//foreach ($_SESSION['domains'] as $row) {
// if ($row['domain_uuid'] == $domain_uuid) {
// echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n";
// }
// else {
// echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
// }
//}
//echo " </select>\n";
//echo "<br />\n";
//echo $text['description-domain_uuid']."\n";
//echo "</td>\n";
//echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_type']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='extension_setting_type'>\n";
echo " <option value=''></option>\n";
if (!empty($extension_setting_type) && $extension_setting_type == "param") {
echo " <option value='param' selected='selected'>".$text['label-param']."</option>\n";
}
else {
echo " <option value='param'>".$text['label-param']."</option>\n";
}
if (!empty($extension_setting_type) && $extension_setting_type == "variable") {
echo " <option value='variable' selected='selected'>".$text['label-variable']."</option>\n";
}
else {
echo " <option value='variable'>".$text['label-variable']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-extension_setting_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_name']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_name' maxlength='255' value='".escape($extension_setting_name)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_value']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_value' maxlength='255' value='".escape($extension_setting_value)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_value']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='extension_setting_enabled' name='extension_setting_enabled' value='true' ".($extension_setting_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
echo " </label>\n";
}
else {
echo " <select class='formfld' id='extension_setting_enabled' name='extension_setting_enabled'>\n";
echo " <option value='true' ".($extension_setting_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($extension_setting_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
}
echo "<br />\n";
echo $text['description-extension_setting_enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_description']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_description' maxlength='255' value='".escape($extension_setting_description)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br /><br />\n";
echo "<input type='hidden' name='extension_uuid' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+334 -334
View File
@@ -1,334 +1,334 @@
<?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>
Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_setting_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$search = '';
$paging_controls = '';
$id = '';
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the http post data
if (!empty($_POST['extension_settings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$extension_settings = $_POST['extension_settings'];
}
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$extension_uuid = $_REQUEST["id"];
}
//process the http post data by action
if (!empty($action) && !empty($extension_settings)) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php');
exit;
}
//prepare the database object
$obj = new extension_settings;
//send the array to the database class
switch ($action) {
case 'copy':
if (permission_exists('extension_setting_add')) {
$obj->copy($extension_settings);
}
break;
case 'toggle':
if (permission_exists('extension_setting_edit')) {
$obj->toggle($extension_settings);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$obj->extension_uuid = $extension_uuid;
$obj->delete($extension_settings);
}
break;
}
//redirect the user
header('Location: extension_settings.php?id='.urlencode($extension_uuid).'&'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search
if (isset($_GET["search"])) {
$search = strtolower($_GET["search"]);
}
//get the count
$sql = "select count(extension_setting_uuid) ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_uuid = :extension_uuid ";
if (isset($search)) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
else {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
if (isset($sql_search)) {
$sql .= "and ".$sql_search;
}
$parameters['domain_uuid'] = $domain_uuid;
}
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//get the list
$sql = "select ";
//$sql .= "d.domain_name, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings as e ";
//$sql .= ",v_domains as d ";
$sql .= "where extension_uuid = :extension_uuid ";
$sql .= "and (e.domain_uuid = :domain_uuid or e.domain_uuid is null) ";
//$sql .= "and d.domain_uuid = e.domain_uuid ";
if (isset($_GET["search"])) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'extension_setting_type', 'asc');
$sql .= limit_offset($rows_per_page ?? null, $offset ?? null);
$parameters['extension_uuid'] = $extension_uuid;
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$extension_settings = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//additional includes
$document['title'] = $text['title-extension_settings'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_settings']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_add','name'=>'btn_add','style'=>'margin-right: 15px;','link'=>'/app/extensions/extension_edit.php?id='.$extension_uuid]);
if (permission_exists('extension_setting_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'extension_setting_edit.php?extension_uuid='.$extension_uuid]);
}
if (permission_exists('extension_setting_add') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('extension_setting_edit') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
}
if (permission_exists('extension_setting_delete') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
//if (permission_exists('extension_setting_all')) {
// if ($_GET['show'] == 'all') {
// echo " <input type='hidden' name='show' value='all'>\n";
// }
// else {
// echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all&id='.$extension_uuid]);
// }
//}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'extension_settings.php?id='.$extension_uuid,'style'=>(empty($search) ? 'display: none;' : null)]);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " <input type='hidden' name='id' value='".$extension_uuid."'>\n";
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('extension_setting_add') && $extension_settings) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('extension_setting_edit') && $extension_settings) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('extension_setting_delete') && $extension_settings) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
if (!empty($extension_settings)) {
//define the variable
$previous_extension_setting_type = '';
//set the initial value
$x = 0;
//show the extension settings
foreach ($extension_settings as $row) {
$extension_setting_type = $row['extension_setting_type'];
$extension_setting_type = strtolower($extension_setting_type);
$label_extension_setting_type = $row['extension_setting_type'];
$label_extension_setting_type = str_replace("_", " ", $label_extension_setting_type);
$label_extension_setting_type = str_replace("-", " ", $label_extension_setting_type);
$label_extension_setting_type = ucwords($label_extension_setting_type);
if ($previous_extension_setting_type !== $row['extension_setting_type']) {
echo " <tr>";
echo " <td align='left' colspan='999'>&nbsp;</td>\n";
echo " </tr>";
echo " <tr>";
echo " <td align='left' colspan='999' nowrap='nowrap'><b>".escape($label_extension_setting_type)."</b></td>\n";
echo " </tr>";
echo "<tr class='list-header'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_".$extension_setting_type."' name='checkbox_all' onclick=\"list_all_toggle('".$extension_setting_type."'); checkbox_on_change(this);\">\n";
echo " </th>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
//}
//echo th_order_by('extension_setting_type', $text['label-extension_setting_type'], $order_by, $order);
//echo th_order_by('extension_setting_name', $text['label-extension_setting_name'], $order_by, $order);
//echo th_order_by('extension_setting_value', $text['label-extension_setting_value'], $order_by, $order);
//echo th_order_by('extension_setting_enabled', $text['label-extension_setting_enabled'], $order_by, $order, null, "class='center'");
echo " <th>".$text['label-extension_setting_type']."</th>\n";
echo " <th>".$text['label-extension_setting_name']."</th>\n";
echo " <th>".$text['label-extension_setting_value']."</th>\n";
echo " <th class='center'>".$text['label-extension_setting_enabled']."</th>\n";
echo " <th class='hide-sm-dn'>".$text['label-extension_setting_description']."</th>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
}
if (permission_exists('extension_setting_edit')) {
$list_row_url = "extension_setting_edit.php?id=".urlencode($row['extension_setting_uuid'])."&extension_uuid=".urlencode($extension_uuid);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='extension_settings[$x][checked]' id='checkbox_".$x."' class='checkbox_".$extension_setting_type."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all_".$extension_setting_type."').checked = false; }\">\n";
echo " <input type='hidden' name='extension_settings[$x][uuid]' value='".escape($row['extension_setting_uuid'])."' />\n";
echo " </td>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo " <td>".escape($row['domain_name'])."</td>\n";
//}
echo " <td>".escape($row['extension_setting_type'])."</td>\n";
echo " <td>".escape($row['extension_setting_name'])."</td>\n";
echo " <td>".escape($row['extension_setting_value'])."</td>\n";
if (permission_exists('extension_setting_edit')) {
echo " <td class='no-link center'>\n";
echo " <input type='hidden' name='number_translations[$x][extension_setting_enabled]' value='".escape($row['extension_setting_enabled'])."' />\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['extension_setting_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>\n";
echo $text['label-'.$row['extension_setting_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['extension_setting_description'])."</td>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
//set the previous category
$previous_extension_setting_type = $row['extension_setting_type'];
$x++;
}
unset($extension_settings);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$id."' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
<?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>
Portions created by the Initial Developer are Copyright (C) 2021-2023
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_setting_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$search = '';
$paging_controls = '';
$id = '';
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the http post data
if (!empty($_POST['extension_settings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$extension_settings = $_POST['extension_settings'];
}
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$extension_uuid = $_REQUEST["id"];
}
//process the http post data by action
if (!empty($action) && !empty($extension_settings)) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php');
exit;
}
//prepare the database object
$obj = new extension_settings;
//send the array to the database class
switch ($action) {
case 'copy':
if (permission_exists('extension_setting_add')) {
$obj->copy($extension_settings);
}
break;
case 'toggle':
if (permission_exists('extension_setting_edit')) {
$obj->toggle($extension_settings);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$obj->extension_uuid = $extension_uuid;
$obj->delete($extension_settings);
}
break;
}
//redirect the user
header('Location: extension_settings.php?id='.urlencode($extension_uuid).'&'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search
if (isset($_GET["search"])) {
$search = strtolower($_GET["search"]);
}
//get the count
$sql = "select count(extension_setting_uuid) ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_uuid = :extension_uuid ";
if (isset($search)) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
else {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
if (isset($sql_search)) {
$sql .= "and ".$sql_search;
}
$parameters['domain_uuid'] = $domain_uuid;
}
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//get the list
$sql = "select ";
//$sql .= "d.domain_name, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings as e ";
//$sql .= ",v_domains as d ";
$sql .= "where extension_uuid = :extension_uuid ";
$sql .= "and (e.domain_uuid = :domain_uuid or e.domain_uuid is null) ";
//$sql .= "and d.domain_uuid = e.domain_uuid ";
if (isset($_GET["search"])) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'extension_setting_type', 'asc');
$sql .= limit_offset($rows_per_page ?? null, $offset ?? null);
$parameters['extension_uuid'] = $extension_uuid;
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$extension_settings = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//additional includes
$document['title'] = $text['title-extension_settings'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_settings']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_add','name'=>'btn_add','style'=>'margin-right: 15px;','link'=>'/app/extensions/extension_edit.php?id='.$extension_uuid]);
if (permission_exists('extension_setting_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'extension_setting_edit.php?extension_uuid='.$extension_uuid]);
}
if (permission_exists('extension_setting_add') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('extension_setting_edit') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
}
if (permission_exists('extension_setting_delete') && $extension_settings) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
//if (permission_exists('extension_setting_all')) {
// if ($_GET['show'] == 'all') {
// echo " <input type='hidden' name='show' value='all'>\n";
// }
// else {
// echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all&id='.$extension_uuid]);
// }
//}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'extension_settings.php?id='.$extension_uuid,'style'=>(empty($search) ? 'display: none;' : null)]);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " <input type='hidden' name='id' value='".$extension_uuid."'>\n";
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('extension_setting_add') && $extension_settings) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('extension_setting_edit') && $extension_settings) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('extension_setting_delete') && $extension_settings) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-extension_settings']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
if (!empty($extension_settings)) {
//define the variable
$previous_extension_setting_type = '';
//set the initial value
$x = 0;
//show the extension settings
foreach ($extension_settings as $row) {
$extension_setting_type = $row['extension_setting_type'];
$extension_setting_type = strtolower($extension_setting_type);
$label_extension_setting_type = $row['extension_setting_type'];
$label_extension_setting_type = str_replace("_", " ", $label_extension_setting_type);
$label_extension_setting_type = str_replace("-", " ", $label_extension_setting_type);
$label_extension_setting_type = ucwords($label_extension_setting_type);
if ($previous_extension_setting_type !== $row['extension_setting_type']) {
echo " <tr>";
echo " <td align='left' colspan='999'>&nbsp;</td>\n";
echo " </tr>";
echo " <tr>";
echo " <td align='left' colspan='999' nowrap='nowrap'><b>".escape($label_extension_setting_type)."</b></td>\n";
echo " </tr>";
echo "<tr class='list-header'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_".$extension_setting_type."' name='checkbox_all' onclick=\"list_all_toggle('".$extension_setting_type."'); checkbox_on_change(this);\">\n";
echo " </th>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
//}
//echo th_order_by('extension_setting_type', $text['label-extension_setting_type'], $order_by, $order);
//echo th_order_by('extension_setting_name', $text['label-extension_setting_name'], $order_by, $order);
//echo th_order_by('extension_setting_value', $text['label-extension_setting_value'], $order_by, $order);
//echo th_order_by('extension_setting_enabled', $text['label-extension_setting_enabled'], $order_by, $order, null, "class='center'");
echo " <th>".$text['label-extension_setting_type']."</th>\n";
echo " <th>".$text['label-extension_setting_name']."</th>\n";
echo " <th>".$text['label-extension_setting_value']."</th>\n";
echo " <th class='center'>".$text['label-extension_setting_enabled']."</th>\n";
echo " <th class='hide-sm-dn'>".$text['label-extension_setting_description']."</th>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
}
if (permission_exists('extension_setting_edit')) {
$list_row_url = "extension_setting_edit.php?id=".urlencode($row['extension_setting_uuid'])."&extension_uuid=".urlencode($extension_uuid);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='extension_settings[$x][checked]' id='checkbox_".$x."' class='checkbox_".$extension_setting_type."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all_".$extension_setting_type."').checked = false; }\">\n";
echo " <input type='hidden' name='extension_settings[$x][uuid]' value='".escape($row['extension_setting_uuid'])."' />\n";
echo " </td>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo " <td>".escape($row['domain_name'])."</td>\n";
//}
echo " <td>".escape($row['extension_setting_type'])."</td>\n";
echo " <td>".escape($row['extension_setting_name'])."</td>\n";
echo " <td>".escape($row['extension_setting_value'])."</td>\n";
if (permission_exists('extension_setting_edit')) {
echo " <td class='no-link center'>\n";
echo " <input type='hidden' name='number_translations[$x][extension_setting_enabled]' value='".escape($row['extension_setting_enabled'])."' />\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['extension_setting_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>\n";
echo $text['label-'.$row['extension_setting_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['extension_setting_description'])."</td>\n";
if (permission_exists('extension_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
//set the previous category
$previous_extension_setting_type = $row['extension_setting_type'];
$x++;
}
unset($extension_settings);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$id."' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
+2 -2
View File
@@ -50,7 +50,7 @@
}
}
if (is_array($array) && @sizeof($array) != 0) {
$p = permissions::new();
$p = new permissions;
$p->add('extension_edit', 'temp');
$database->app_name = 'extensions';
@@ -69,7 +69,7 @@
$sql .= "where default_setting_category = 'security' ";
$sql .= "and default_setting_subcategory like 'password_%' ";
$p = permissions::new();
$p = new permissions;
$p->add('default_setting_edit', 'temp');
$database->execute($sql);
+1
View File
@@ -36,3 +36,4 @@
$y++;
?>
+6 -19
View File
@@ -39,7 +39,7 @@
}
//initialize the database object
$database = database::new();
$database = new database;
//add multi-lingual support
$language = new text;
@@ -261,7 +261,7 @@
$array['extension_users'][0]['user_uuid'] = $user_uuid;
//add temporary permission
$p = permissions::new();
$p = new permissions;
$p->add('extension_user_delete', 'temp');
//save the array
@@ -288,7 +288,7 @@
$array['device_lines'][0]['device_line_uuid'] = $device_line_uuid;
//add temporary permission
$p = permissions::new();
$p = new permissions;
$p->add('device_line_delete', 'temp');
//save the array
@@ -401,19 +401,6 @@
//extension exists
}
else {
//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);
}
//get the password length and strength
$password_length = $_SESSION["extension"]["password_length"]["numeric"];
@@ -671,9 +658,9 @@
$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';
$array["devices"][$j]["device_lines"][0]["sip_port"] = $_SESSION['provision']['line_sip_port']['text'];
$array["devices"][$j]["device_lines"][0]["sip_port"] = $_SESSION['provision']['line_sip_port']['numeric'];
$array["devices"][$j]["device_lines"][0]["sip_transport"] = $_SESSION['provision']['line_sip_transport']['text'];
$array["devices"][$j]["device_lines"][0]["register_expires"] = $_SESSION['provision']['line_register_expires']['text'];
$array["devices"][$j]["device_lines"][0]["register_expires"] = $_SESSION['provision']['line_register_expires']['numeric'];
$array["devices"][$j]["device_lines"][0]["enabled"] = "true";
}
@@ -1779,7 +1766,7 @@
echo " ".$text['label-voicemail_mail_to']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='voicemail_mail_to' maxlength='1024' value=\"".escape($voicemail_mail_to ?? '')."\">\n";
echo " <input class='formfld' type='text' name='voicemail_mail_to' maxlength='255' value=\"".escape($voicemail_mail_to ?? '')."\">\n";
echo "<br />\n";
echo $text['description-voicemail_mail_to']."\n";
echo "</td>\n";
+464 -464
View File
@@ -1,464 +1,464 @@
<?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>
Portions created by the Initial Developer are Copyright (C) 2018-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_import')) {
//access granted
}
else {
echo "access denied";
exit;
}
//initialize the database object
$database = new database;
//add multi-lingual support
$language = new text;
$text = $language->get();
//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher
if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
$fp = fopen("php://memory", 'r+');
fputs($fp, $input);
rewind($fp);
$data = fgetcsv($fp, null, $delimiter, $enclosure, $escape);
fclose($fp);
return $data;
}
}
//get the http get values and set them as php variables
$action = $_POST["action"] ?? null;
$from_row = $_POST["from_row"] ?? null;
$delimiter = $_POST["data_delimiter"] ?? null;
$enclosure = $_POST["data_enclosure"] ?? null;
//save the data to the csv file
if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/extensions-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file;
}
//copy the csv file
//$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('extension_import')) {
if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
$save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*');
unset($_POST['txtCommand']);
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file;
}
}
//get the schema
if (!empty($delimiter)) {
//get the first line
$line = fgets(fopen($_SESSION['file'], 'r'));
$line_fields = explode($delimiter, $line);
//get the schema
$x = 0;
include "app/extensions/app_config.php";
$i = 0;
foreach ($apps[0]['db'] as $table) {
//get the table name and parent name
$table_name = $table["table"]['name'];
$parent_name = $table["table"]['parent'];
//remove the v_ table prefix
if (substr($table_name, 0, 2) == 'v_') {
$table_name = substr($table_name, 2);
}
if (substr($parent_name, 0, 2) == 'v_') {
$parent_name = substr($parent_name, 2);
}
//filter for specific tables and build the schema array
if ($table_name == "extensions") {
$schema[$i]['table'] = $table_name;
$schema[$i]['parent'] = $parent_name;
foreach ($table['fields'] as $row) {
if (empty($row['deprecated']) || $row['deprecated'] !== 'true') {
if (is_array($row['name'])) {
$field_name = $row['name']['text'];
}
else {
$field_name = $row['name'];
}
$schema[$i]['fields'][] = $field_name;
}
}
$i++;
}
}
$i++;
$schema[$i]['table'] = 'extension_users';
$schema[$i]['parent'] = 'extensions';
$schema[$i]['fields'][] = 'username';
}
//match the column names to the field names
if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php');
exit;
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include header
$document['title'] = $text['title-extension_import'];
require_once "resources/header.php";
//form to match the fields to the column names
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extension_imports.php']);
echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//loop through user columns
$x = 0;
foreach ($line_fields as $line_field) {
$line_field = preg_replace('#[^a-zA-Z0-9_]#', '', $line_field);
echo "<tr>\n";
echo " <td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-zzz']."\n";
echo $line_field;
echo " </td>\n";
echo " <td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' style='' name='fields[$x]'>\n";
echo " <option value=''></option>\n";
foreach($schema as $row) {
echo " <optgroup label='".$row['table']."'>\n";
if (!empty($row['fields'])) {
foreach($row['fields'] as $field) {
$selected = '';
if ($field == $line_field) {
$selected = "selected='selected'";
}
if ($field !== 'domain_uuid') {
echo " <option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n";
}
}
}
echo " </optgroup>\n";
}
echo " </select>\n";
//echo "<br />\n";
//echo $text['description-zzz']."\n";
echo " </td>\n";
echo "</tr>\n";
$x++;
}
echo "</table>\n";
echo "</div>\n";
echo "<br /><br />\n";
echo "<input name='action' type='hidden' value='import'>\n";
echo "<input name='from_row' type='hidden' value='$from_row'>\n";
echo "<input name='data_delimiter' type='hidden' value='$delimiter'>\n";
echo "<input name='data_enclosure' type='hidden' value='$enclosure'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
require_once "resources/footer.php";
//normalize the column names
//$line = strtolower($line);
//$line = str_replace("-", "_", $line);
//$line = str_replace($delimiter."title".$delimiter, $delimiter."contact_title".$delimiter, $line);
//$line = str_replace("firstname", "name_given", $line);
//$line = str_replace("lastname", "name_family", $line);
//$line = str_replace("company", "organization", $line);
//$line = str_replace("company", "contact_email", $line);
//end the script
exit;
}
//get the parent table
function get_parent($schema,$table_name) {
foreach ($schema as $row) {
if ($row['table'] == $table_name) {
return $row['parent'];
}
}
}
//upload the csv
if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php');
exit;
}
//user selected fields
$fields = $_POST['fields'];
//set the domain_uuid
$domain_uuid = $_SESSION['domain_uuid'];
//get the users
$sql = "select * from v_users where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the contents of the csv file and convert them into an array
$handle = @fopen($_SESSION['file'], "r");
if ($handle) {
//set the starting identifiers
$row_id = 0;
$row_number = 1;
//loop through the array
while (($line = fgets($handle, 4096)) !== false) {
if ($from_row <= $row_number) {
//format the data
$y = 0;
foreach ($fields as $key => $value) {
//get the line
$result = str_getcsv($line, $delimiter, $enclosure);
//get the table and field name
$field_array = explode(".",$value);
$table_name = $field_array[0];
$field_name = $field_array[1] ?? null;
//echo "value: $value<br />\n";
//echo "table_name: $table_name<br />\n";
//echo "field_name: $field_name<br />\n";
//get the parent table name
$parent = get_parent($schema, $table_name);
//remove formatting from the phone number
if ($field_name == "phone_number") {
$result[$key] = preg_replace('{\D}', '', $result[$key]);
}
//set various fields to lower case
if (in_array($field_name, array('enabled','directory_visible','directory_exten_visible','call_screen_enabled','user_record','do_not_disturb','forward_all_enabled','forward_busy_enabled','forward_no_answer_enabled','forward_user_not_registered_enabled'))) {
$result[$key] = strtolower($result[$key]);
}
//build the data array
if (!empty($table_name)) {
if (empty($parent)) {
$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
$array[$table_name][$row_id][$field_name] = $result[$key];
}
elseif ($field_name != "username") {
$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
}
if ($field_name == "username") {
foreach ($users as $field) {
if ($field['username'] == $result[$key]) {
//$array[$parent][$row_id]['extension_users'][$y]['cextension_user_uuid'] = uuid();
$array[$parent][$row_id]['extension_users'][$y]['domain_uuid'] = $domain_uuid;
//$array[$parent][$row_id]['extension_users'] = $row['extension_uuid'];
$array[$parent][$row_id]['extension_users'][$y]['user_uuid'] = $field['user_uuid'];
}
}
}
}
}
//process a chunk of the array
if ($row_id === 1000) {
//save to the data
$database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array);
//clear the array
unset($array);
//set the row id back to 0
$row_id = 0;
}
} //if ($from_row <= $row_number)
$row_number++;
$row_id++;
} //end while
fclose($handle);
//save to the data
if (!empty($array) && is_array($array)) {
$database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array);
unset($array);
}
//send the redirect header
header("Location: extensions.php");
exit;
}
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-extension_import'];
require_once "resources/header.php";
//show content
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extensions.php']);
echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_data']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <textarea name='data' id='data' class='formfld' style='width: 100%; min-height: 150px;' wrap='off'>".($data ?? null)."</textarea>\n";
echo "<br />\n";
echo $text['description-import_data']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-from_row']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='from_row'>\n";
$i=2;
while($i<=99) {
$selected = ($i == $from_row) ? "selected" : null;
echo " <option value='$i' ".$selected.">$i</option>\n";
$i++;
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-from_row']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_delimiter']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_delimiter'>\n";
echo " <option value=','>,</option>\n";
echo " <option value='|'>|</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_delimiter']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_enclosure']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_enclosure'>\n";
echo " <option value='\"'>\"</option>\n";
echo " <option value=''></option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_enclosure']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_file_upload']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input name='ulfile' type='file' class='formfld fileinput' id='ulfile'>\n";
echo "<br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br><br>";
echo "<input name='type' type='hidden' value='csv'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
<?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>
Portions created by the Initial Developer are Copyright (C) 2018-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_import')) {
//access granted
}
else {
echo "access denied";
exit;
}
//initialize the database object
$database = new database;
//add multi-lingual support
$language = new text;
$text = $language->get();
//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher
if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
$fp = fopen("php://memory", 'r+');
fputs($fp, $input);
rewind($fp);
$data = fgetcsv($fp, null, $delimiter, $enclosure, $escape);
fclose($fp);
return $data;
}
}
//get the http get values and set them as php variables
$action = $_POST["action"] ?? null;
$from_row = $_POST["from_row"] ?? null;
$delimiter = $_POST["data_delimiter"] ?? null;
$enclosure = $_POST["data_enclosure"] ?? null;
//save the data to the csv file
if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/extensions-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file;
}
//copy the csv file
//$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('extension_import')) {
if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
$save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*');
unset($_POST['txtCommand']);
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file;
}
}
//get the schema
if (!empty($delimiter)) {
//get the first line
$line = fgets(fopen($_SESSION['file'], 'r'));
$line_fields = explode($delimiter, $line);
//get the schema
$x = 0;
include "app/extensions/app_config.php";
$i = 0;
foreach ($apps[0]['db'] as $table) {
//get the table name and parent name
$table_name = $table["table"]['name'];
$parent_name = $table["table"]['parent'];
//remove the v_ table prefix
if (substr($table_name, 0, 2) == 'v_') {
$table_name = substr($table_name, 2);
}
if (substr($parent_name, 0, 2) == 'v_') {
$parent_name = substr($parent_name, 2);
}
//filter for specific tables and build the schema array
if ($table_name == "extensions") {
$schema[$i]['table'] = $table_name;
$schema[$i]['parent'] = $parent_name;
foreach ($table['fields'] as $row) {
if (empty($row['deprecated']) || $row['deprecated'] !== 'true') {
if (is_array($row['name'])) {
$field_name = $row['name']['text'];
}
else {
$field_name = $row['name'];
}
$schema[$i]['fields'][] = $field_name;
}
}
$i++;
}
}
$i++;
$schema[$i]['table'] = 'extension_users';
$schema[$i]['parent'] = 'extensions';
$schema[$i]['fields'][] = 'username';
}
//match the column names to the field names
if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php');
exit;
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include header
$document['title'] = $text['title-extension_import'];
require_once "resources/header.php";
//form to match the fields to the column names
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extension_imports.php']);
echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//loop through user columns
$x = 0;
foreach ($line_fields as $line_field) {
$line_field = preg_replace('#[^a-zA-Z0-9_]#', '', $line_field);
echo "<tr>\n";
echo " <td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-zzz']."\n";
echo $line_field;
echo " </td>\n";
echo " <td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' style='' name='fields[$x]'>\n";
echo " <option value=''></option>\n";
foreach($schema as $row) {
echo " <optgroup label='".$row['table']."'>\n";
if (!empty($row['fields'])) {
foreach($row['fields'] as $field) {
$selected = '';
if ($field == $line_field) {
$selected = "selected='selected'";
}
if ($field !== 'domain_uuid') {
echo " <option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n";
}
}
}
echo " </optgroup>\n";
}
echo " </select>\n";
//echo "<br />\n";
//echo $text['description-zzz']."\n";
echo " </td>\n";
echo "</tr>\n";
$x++;
}
echo "</table>\n";
echo "</div>\n";
echo "<br /><br />\n";
echo "<input name='action' type='hidden' value='import'>\n";
echo "<input name='from_row' type='hidden' value='$from_row'>\n";
echo "<input name='data_delimiter' type='hidden' value='$delimiter'>\n";
echo "<input name='data_enclosure' type='hidden' value='$enclosure'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
require_once "resources/footer.php";
//normalize the column names
//$line = strtolower($line);
//$line = str_replace("-", "_", $line);
//$line = str_replace($delimiter."title".$delimiter, $delimiter."contact_title".$delimiter, $line);
//$line = str_replace("firstname", "name_given", $line);
//$line = str_replace("lastname", "name_family", $line);
//$line = str_replace("company", "organization", $line);
//$line = str_replace("company", "contact_email", $line);
//end the script
exit;
}
//get the parent table
function get_parent($schema,$table_name) {
foreach ($schema as $row) {
if ($row['table'] == $table_name) {
return $row['parent'];
}
}
}
//upload the csv
if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_imports.php');
exit;
}
//user selected fields
$fields = $_POST['fields'];
//set the domain_uuid
$domain_uuid = $_SESSION['domain_uuid'];
//get the users
$sql = "select * from v_users where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the contents of the csv file and convert them into an array
$handle = @fopen($_SESSION['file'], "r");
if ($handle) {
//set the starting identifiers
$row_id = 0;
$row_number = 1;
//loop through the array
while (($line = fgets($handle, 4096)) !== false) {
if ($from_row <= $row_number) {
//format the data
$y = 0;
foreach ($fields as $key => $value) {
//get the line
$result = str_getcsv($line, $delimiter, $enclosure);
//get the table and field name
$field_array = explode(".",$value);
$table_name = $field_array[0];
$field_name = $field_array[1] ?? null;
//echo "value: $value<br />\n";
//echo "table_name: $table_name<br />\n";
//echo "field_name: $field_name<br />\n";
//get the parent table name
$parent = get_parent($schema, $table_name);
//remove formatting from the phone number
if ($field_name == "phone_number") {
$result[$key] = preg_replace('{\D}', '', $result[$key]);
}
//set various fields to lower case
if (in_array($field_name, array('enabled','directory_visible','directory_exten_visible','call_screen_enabled','user_record','do_not_disturb','forward_all_enabled','forward_busy_enabled','forward_no_answer_enabled','forward_user_not_registered_enabled'))) {
$result[$key] = strtolower($result[$key]);
}
//build the data array
if (!empty($table_name)) {
if (empty($parent)) {
$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
$array[$table_name][$row_id][$field_name] = $result[$key];
}
elseif ($field_name != "username") {
$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
}
if ($field_name == "username") {
foreach ($users as $field) {
if ($field['username'] == $result[$key]) {
//$array[$parent][$row_id]['extension_users'][$y]['cextension_user_uuid'] = uuid();
$array[$parent][$row_id]['extension_users'][$y]['domain_uuid'] = $domain_uuid;
//$array[$parent][$row_id]['extension_users'] = $row['extension_uuid'];
$array[$parent][$row_id]['extension_users'][$y]['user_uuid'] = $field['user_uuid'];
}
}
}
}
}
//process a chunk of the array
if ($row_id === 1000) {
//save to the data
$database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array);
//clear the array
unset($array);
//set the row id back to 0
$row_id = 0;
}
} //if ($from_row <= $row_number)
$row_number++;
$row_id++;
} //end while
fclose($handle);
//save to the data
if (!empty($array) && is_array($array)) {
$database->app_name = 'extensions';
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$database->save($array);
unset($array);
}
//send the redirect header
header("Location: extensions.php");
exit;
}
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-extension_import'];
require_once "resources/header.php";
//show content
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extension_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'extensions.php']);
echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_data']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <textarea name='data' id='data' class='formfld' style='width: 100%; min-height: 150px;' wrap='off'>".($data ?? null)."</textarea>\n";
echo "<br />\n";
echo $text['description-import_data']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-from_row']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='from_row'>\n";
$i=2;
while($i<=99) {
$selected = ($i == $from_row) ? "selected" : null;
echo " <option value='$i' ".$selected.">$i</option>\n";
$i++;
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-from_row']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_delimiter']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_delimiter'>\n";
echo " <option value=','>,</option>\n";
echo " <option value='|'>|</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_delimiter']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_enclosure']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_enclosure'>\n";
echo " <option value='\"'>\"</option>\n";
echo " <option value=''></option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_enclosure']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_file_upload']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input name='ulfile' type='file' class='formfld fileinput' id='ulfile'>\n";
echo "<br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br><br>";
echo "<input name='type' type='hidden' value='csv'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
@@ -153,7 +153,7 @@ if (!class_exists('extension')) {
//build update array
$array['voicemails'][0]['voicemail_uuid'] = $voicemail_uuid;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('voicemail_edit', 'temp');
}
else {
@@ -161,7 +161,7 @@ if (!class_exists('extension')) {
$array['voicemails'][0]['voicemail_uuid'] = uuid();
$array['voicemails'][0]['domain_uuid'] = $this->domain_uuid;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('voicemail_add', 'temp');
}
if (is_array($array) && @sizeof($array) != 0) {
@@ -639,7 +639,7 @@ if (!class_exists('extension')) {
}
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('extension_user_delete', 'temp');
$p->add('follow_me_delete', 'temp');
$p->add('follow_me_destination_delete', 'temp');
@@ -743,7 +743,7 @@ if (!class_exists('extension')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('extension_edit', 'temp');
//save the array
@@ -798,3 +798,4 @@ if (!class_exists('extension')) {
}
?>
@@ -89,7 +89,7 @@
$array_temp = $array;
//add the dialplan permission
$p = permissions::new();
$p = new permissions;
$p->add("extension_edit", "temp");
//save to the data
+1 -1
View File
@@ -202,7 +202,7 @@
//add the missing email templates
if (!empty($array['email_templates'])) {
//add the temporary permission
$p = permissions::new();
$p = new permissions;
$p->add("email_template_add", 'temp');
$p->add("email_template_edit", 'temp');
+1 -1
View File
@@ -135,7 +135,7 @@
//execute
if (isset($array) && is_array($array)) {
//assign temp permission
$p = permissions::new();
$p = new permissions;
$p->add('fax_add', 'temp');
$p->add('fax_edit', 'temp');
+1 -1
View File
@@ -107,7 +107,7 @@
$array['fax'][0]['fax_description'] = $fax_description;
//execute insert
$p = permissions::new();
$p = new permissions;
$p->add('fax_add', 'temp');
$database = new database;
+4 -4
View File
@@ -174,7 +174,7 @@
$array['fax_users'][0]['fax_uuid'] = $fax_uuid;
$array['fax_users'][0]['user_uuid'] = $user_uuid;
$p = permissions::new();
$p = new permissions;
$p->add('fax_user_delete', 'temp');
$database = new database;
@@ -202,7 +202,7 @@
$array['fax_users'][0]['fax_uuid'] = $fax_uuid;
$array['fax_users'][0]['user_uuid'] = $user_uuid;
$p = permissions::new();
$p = new permissions;
$p->add('fax_user_add', 'temp');
$database = new database;
@@ -299,7 +299,7 @@
$array['fax'][0]['dialplan_uuid'] = $dialplan_uuid;
//assign temp permission
$p = permissions::new();
$p = new permissions;
$p->add('fax_add', 'temp');
//set the dialplan action
@@ -311,7 +311,7 @@
$array['fax'][0]['fax_uuid'] = $fax_uuid;
//assign temp permission
$p = permissions::new();
$p = new permissions;
$p->add('fax_edit', 'temp');
}
+2 -1
View File
@@ -266,7 +266,8 @@ if (!empty($result) && @sizeof($result) != 0) {
//send fax
$cwd = getcwd();
require "fax_send.php";
$included = true;
require("fax_send.php");
if($cwd){
chdir($cwd);
}
+1 -1
View File
@@ -518,7 +518,7 @@
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('fax_file_delete') || permission_exists('fax_file_edit')) {
if (permission_exists('fax_file_delete') || permission_exists['fax_file_edit']) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='fax_files[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; } checkbox_on_change(this);\">\n";
echo " <input type='hidden' name='fax_files[$x][uuid]' value='".escape($row['fax_file_uuid'])."' />\n";
+22 -26
View File
@@ -28,19 +28,14 @@
Corey Moullas <cmoullas@emak.tech>
*/
//set included to boolean
if (!isset($included)) { $included = false; }
//check if windows
if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false; }
//executed via command line
if (defined('STDIN')) {
//add multi-lingual support
$language = new text;
$text = $language->get($setting->get('domain','language','en-us'), 'app/fax');
}
//executed via browser
else {
//send email through browser
if (!$included) {
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
@@ -129,7 +124,6 @@ else {
$fax_cover_font = $setting->get('fax','cover_font') ?? null;
}
//define function correct_path
if (!function_exists('correct_path')) {
function correct_path($p) {
global $IS_WINDOWS;
@@ -212,7 +206,7 @@ if (!function_exists('fax_split_dtmf')) {
//send the fax
$continue = false;
if (!defined('STDIN')) {
if (!$included) {
if (!empty($_POST['action']) && $_POST['action'] == "send" && $domain_enabled == true) {
//get the values from the HTTP POST
$fax_numbers = $_POST['fax_numbers'];
@@ -306,10 +300,10 @@ if (!function_exists('fax_split_dtmf')) {
//process uploaded or emailed files (if any)
$fax_page_count = 0;
$_files = (!defined('STDIN')) ? $_FILES['fax_files'] : $emailed_files;
$_files = (!$included) ? $_FILES['fax_files'] : $emailed_files;
unset($tif_files);
foreach ($_files['tmp_name'] as $index => $fax_tmp_name) {
$uploaded_file = (!defined('STDIN')) ? is_uploaded_file($fax_tmp_name) : true;
$uploaded_file = (!$included) ? is_uploaded_file($fax_tmp_name) : true;
if ( $uploaded_file && $_files['error'][$index] == 0 && $_files['size'][$index] > 0 ) {
//get the file extension
$fax_file_extension = strtolower(pathinfo($_files['name'][$index], PATHINFO_EXTENSION));
@@ -329,7 +323,7 @@ if (!function_exists('fax_split_dtmf')) {
}
unset($attachment_file_name);
if (!defined('STDIN')) {
if (!$included) {
//check if directory exists
if (!is_dir($dir_fax_temp)) {
mkdir($dir_fax_temp, 0770);
@@ -496,9 +490,10 @@ if (!function_exists('fax_split_dtmf')) {
//field values
$pdf->SetFont($pdf_font, "", 12);
$pdf->SetXY($x + 2.0, $y + 1.65);
if (defined('STDIN') || ($_REQUEST['submit'] != '' && $_REQUEST['submit'] != 'preview')) {
$date = new DateTime('now', new DateTimeZone( $setting->get('domain','time_zone', date_default_timezone_get() ) ));
$pdf->Write(0.3, $date->format('d M Y @ h:i:s A'));
if ($_REQUEST['submit'] != '' && $_REQUEST['submit'] != 'preview') {
$time_zone = isset($_SESSION['domain']['time_zone']['name']) ? $_SESSION['domain']['time_zone']['name'] : date_default_timezone_get();
$date = new DateTime('now', new DateTimeZone($time_zone) );
$pdf->Write(0.3, $date->format('d M Y'));
}
$pdf->SetXY($x + 2.0, $y + 1.95);
if ($fax_recipient != '') {
@@ -629,7 +624,7 @@ if (!function_exists('fax_split_dtmf')) {
@unlink($tif_file);
}
}
elseif (!defined('STDIN')) {
elseif (!$included) {
//nothing to send, redirect the browser
message::add($text['message-invalid-fax'], 'negative', 4000);
header("Location: fax_send.php?id=".$fax_uuid);
@@ -683,10 +678,13 @@ if (!function_exists('fax_split_dtmf')) {
unset($sql, $parameters, $row);
//for email to fax send email notification back to the email sender
if (defined('STDIN')) {
if ($included) {
//use email-to-fax from address
$mail_to_address = $sender_email;
}
else {
//send fax through the browser
}
//move the generated tif (and pdf) files to the sent directory
//if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.".tif")) {
@@ -735,8 +733,6 @@ if (!function_exists('fax_split_dtmf')) {
if (!empty($provider_prefix)) {
$common_variables .= "provider_prefix='".$provider_prefix."',";
}
$common_variables .= "hangup_after_bridge=true,";
$common_variables .= "continue_on_fail=true,";
if (!empty($fax_numbers)) {
foreach ($fax_numbers as $fax_number) {
@@ -812,7 +808,7 @@ if (!function_exists('fax_split_dtmf')) {
$array['fax_queue'][0]['fax_command'] = 'originate '.$dial_string;
//add temporary permisison
$p = permissions::new();
$p = new permissions;
$p->add('fax_queue_add', 'temp');
//save the data
@@ -830,7 +826,7 @@ if (!function_exists('fax_split_dtmf')) {
}
//redirect the browser
if (!defined('STDIN') && is_uuid($fax_uuid)) {
if (!$included && is_uuid($fax_uuid)) {
header("Location: fax_files.php?id=".$fax_uuid."&box=sent");
//header("Location: fax_outbox.php?id=".$fax_uuid);
exit;
@@ -840,7 +836,7 @@ if (!function_exists('fax_split_dtmf')) {
//show content in the browser
if (!defined('STDIN')) {
if (!$included) {
//retrieve current user's assigned groups (uuids)
foreach ($_SESSION['groups'] as $group_data) {
@@ -865,7 +861,7 @@ if (!defined('STDIN')) {
$sql .= "and cp.phone_type_fax = 1 ";
$sql .= "and cp.phone_number is not null ";
$sql .= "and cp.phone_number <> '' ";
if ($setting->get('contact','permissions', false)) {
if ($setting->get('contact','permissions') == "true") {
if (is_array($user_group_uuids) && @sizeof($user_group_uuids) != 0) {
//only show contacts assigned to current user's group(s) and those not assigned to any group
$sql .= "and (";
+4 -4
View File
@@ -99,7 +99,7 @@ if (!class_exists('fax')) {
$array['dialplan_details'][0]['domain_uuid'] = $this->domain_uuid;
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('dialplan_detail_delete', 'temp');
//execute delete
@@ -166,7 +166,7 @@ if (!class_exists('fax')) {
$array['dialplans'][] = $dialplan;
//add the dialplan permission
$p = permissions::new();
$p = new permissions;
$p->add("dialplan_add", 'temp');
$p->add("dialplan_detail_add", 'temp');
$p->add("dialplan_edit", 'temp');
@@ -312,7 +312,7 @@ if (!class_exists('fax')) {
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('fax_delete', 'temp');
$p->add('fax_user_delete', 'temp');
$p->add('fax_file_delete', 'temp');
@@ -625,7 +625,7 @@ if (!class_exists('fax')) {
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('fax_add', 'temp');
$p->add('dialplan_add', 'temp');
@@ -47,11 +47,7 @@ function parse_message_decode_text($connection, &$part, $message_number, $id, $o
}
}
if($charset){
if ($charset === 'windows-1256') {
$msg = iconv('windows-1256', 'utf-8', $msg);
} else {
$msg = mb_convert_encoding($msg, $to_charset, $charset);
}
$msg = mb_convert_encoding($msg, $to_charset, $charset);
}
$msg = trim($msg);
}
-8
View File
@@ -76,14 +76,6 @@
$apps[$x]['default_settings'][$y]['default_setting_value'] = "30";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of days to retain the fax queue logs in the database for the maintenance app.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "5506cf35-e19d-4f02-ab9d-43fd0f8460f7";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "fax_queue";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "prefer_local";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Determine whether fax calls should attempt to stay local or route to the provider.";
//$y++;
//$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "afd729d9-cf69-4793-a140-21093814d314";
//$apps[$x]['default_settings'][$y]['default_setting_category'] = "fax_queue";
+2 -2
View File
@@ -324,7 +324,7 @@
echo th_order_by('fax_retry_date', $text['label-fax_retry_date'], $order_by, $order);
echo th_order_by('fax_notify_date', $text['label-fax_notify_date'], $order_by, $order);
echo th_order_by('fax_retry_count', $text['label-fax_retry_count'], $order_by, $order);
if ($permission['fax_queue_edit'] && $settings->get('theme', 'list_row_edit_button', false)) {
if ($permission['fax_queue_edit'] && $settings->get('theme', 'list_row_edit_button', 'false') == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -358,7 +358,7 @@
echo " <td>".escape($row['fax_retry_date_formatted'])." ".escape($row['fax_retry_time_formatted'])."</td>\n";
echo " <td>".escape($row['fax_notify_date_formatted'])." ".escape($row['fax_notify_time_formatted'])."</td>\n";
echo " <td>".escape($row['fax_retry_count'])."</td>\n";
if ($permission['fax_queue_edit'] && $settings->get('theme', 'list_row_edit_button', false)) {
if ($permission['fax_queue_edit'] && $settings->get('theme', 'list_row_edit_button', 'false') == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon' => $settings->get('theme', 'button_icon_edit'),'link'=>$list_row_url]);
echo " </td>\n";
+1 -1
View File
@@ -151,7 +151,7 @@
//process the messages
if (is_array($fax_queue) && @sizeof($fax_queue) != 0) {
foreach($fax_queue as $row) {
$command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
$command = exec('which php')." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
$command .= "'action=send&fax_queue_uuid=".$row["fax_queue_uuid"]."&hostname=".$hostname."&debug=true'";
if (isset($debug)) {
//run process inline to see debug info
+62 -143
View File
@@ -61,9 +61,6 @@
exit;
}
//connect to the database
$database = new database;
//shutdown call back function
function shutdown() {
//when the fax status is still sending
@@ -159,6 +156,7 @@
$sql .= "where fax_queue_uuid = :fax_queue_uuid ";
$sql .= "and q.domain_uuid = d.domain_uuid and f.fax_uuid = q.fax_uuid";
$parameters['fax_queue_uuid'] = $fax_queue_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
$fax_queue_uuid = $row['fax_queue_uuid'];
@@ -223,23 +221,6 @@
//sending the fax
if ($fax_status == 'waiting' || $fax_status == 'trying' || $fax_status == 'busy') {
//get the provider_prefix from the domain_variables dialplan
$sql = "select dialplan_detail_data from v_dialplan_details ";
$sql .= "where dialplan_uuid in ( ";
$sql .= " select dialplan_uuid from v_dialplans ";
$sql .= " where dialplan_name = 'domain-variables' ";
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= ") ";
$sql .= "and dialplan_detail_data like 'provider_prefix%' ";
$sql .= "and dialplan_detail_enabled = 'true' ";
$parameters['domain_uuid'] = $domain_uuid;
$row = $database->select($sql, $parameters, 'row');
$dialplan_detail_data = $row["dialplan_detail_data"];
unset($sql, $parameters, $row);
if (!empty($dialplan_detail_data)) {
$provider_prefix = explode('=', $dialplan_detail_data)[1];
}
//create event socket handle
$esl = event_socket::create();
if (!$esl->is_connected()) {
@@ -249,70 +230,28 @@
//fax options, first attempt use the fax variables from settings
if ($fax_retry_count == 0) {
//use default settings or domain settings (defaults to t38)
$fax_options = '';
}
if ($fax_retry_count == 1) {
$fax_options = '';
foreach($setting->get('fax','variable') as $variable) {
$fax_options .= $variable.",";
}
}
elseif ($fax_retry_count == 1) {
//send without t38 faster
$fax_options = "fax_use_ecm=true,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=false";
}
elseif ($fax_retry_count == 2) {
//use t38 passthru
$fax_options = "fax_use_ecm=false,fax_enable_t38=true,t38_passthru=true";
}
elseif ($fax_retry_count == 3) {
//send without t38 slower
$fax_options = "fax_use_ecm=true,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=true";
}
elseif ($fax_retry_count == 4) {
//send with t38 no error correction
$fax_options = "fax_use_ecm=false,fax_enable_t38=true,fax_enable_t38_request=true";
}
elseif ($fax_retry_count == 5) {
//send with t38 with error correction faster
elseif ($fax_retry_count == 3) {
$fax_options = "fax_use_ecm=true,fax_enable_t38=true,fax_enable_t38_request=true,fax_disable_v17=false";
}
elseif ($fax_retry_count == 6) {
//send with t38 with error correction slower
elseif ($fax_retry_count == 4) {
$fax_options = "fax_use_ecm=true,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=false";
}
elseif ($fax_retry_count == 5) {
$fax_options = "fax_use_ecm=true,fax_enable_t38=true,fax_enable_t38_request=true,fax_disable_v17=true";
}
else {
//try the user definable method again
$fax_options = '';
foreach($setting->get('fax','variable') as $variable) {
$fax_options .= $variable.",";
}
}
//extract fax_dtmf from the fax number
fax_split_dtmf($fax_number, $fax_dtmf);
//get the fax toll allow
if (!empty($fax_toll_allow)) {
$channel_variables["toll_allow"] = $fax_toll_allow;
}
//check to see if the destination number is local
$local_destination = false;
if ($setting->get('fax_queue','prefer_local', false)) {
$sql = "select count(destination_uuid) ";
$sql .= "from v_destinations ";
$sql .= "where (";
$sql .= " destination_number = :destination_number ";
$sql .= " or concat(destination_prefix, destination_number) = :destination_number ";
$sql .= " or concat(destination_trunk_prefix, destination_number) = :destination_number ";
$sql .= " or concat(destination_area_code, destination_number) = :destination_number ";
$sql .= " or concat(destination_prefix, destination_area_code, destination_number) = :destination_number ";
$sql .= ") ";
$parameters['destination_number'] = $fax_number;
$destination_count = $database->select($sql, $parameters, 'column');
if ($destination_count > 0) {
$local_destination = true;
$route_array[] = 'loopback/'.$fax_number.'/public';
}
elseif ($fax_retry_count == 6) {
$fax_options = "fax_use_ecm=false,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=false";
}
//define the fax file
@@ -323,61 +262,34 @@
$common_variables .= "domain_name=" . $domain_name . ",";
$common_variables .= "origination_caller_id_name='" . escape_quote($fax_caller_id_name) . "',";
$common_variables .= "origination_caller_id_number=" . $fax_caller_id_number . ",";
$common_variables .= "fax_ident='" . escape_quote($fax_caller_id_number) . "',";
$common_variables .= "fax_header='" . escape_quote($fax_caller_id_name) . "',";
$common_variables .= "fax_file='" . escape_quote($fax_file) . "',";
$common_variables .= "hangup_after_bridge=true,";
$common_variables .= "continue_on_fail=true,";
//add the fax destination number variables
if ($local_destination) {
$common_variables .= "sip_to_user=".$fax_number.",";
$common_variables .= "sip_req_user=".$fax_number.",";
}
$common_variables .= "fax_ident='" . escape_quote($fax_caller_id_number) . "',";
$common_variables .= "fax_header='" . escape_quote($fax_caller_id_name) . "',";
$common_variables .= "fax_file='" . escape_quote($fax_file) . "',";
//extract fax_dtmf from the fax number
fax_split_dtmf($fax_number, $fax_dtmf);
//prepare the fax command
$channel_variables["toll_allow"] = !empty($fax_toll_allow) ? $fax_toll_allow : null;
$route_array = outbound_route_to_bridge($domain_uuid, $fax_prefix . $fax_number, $channel_variables);
if (empty($route_array)) {
//send the internal call to the registered extension
if (count($route_array) == 0) {
//check for valid extension
$sql = "select count(extension_uuid) ";
$sql .= "from v_extensions ";
$sql .= "where extension = :fax_number ";
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['fax_number'] = $fax_number;
$extension_count = $database->select($sql, $parameters, 'column');
if ($extension_count > 0) {
//send the internal call to the registered extension
$fax_uri = "user/".$fax_number."@".$domain_name;
}
else {
$fax_uri = '';
$fax_status = 'failed';
}
}
if (!empty($fax_toll_allow)) {
$channel_variables["toll_allow"] = $fax_toll_allow;
}
else {
foreach($route_array as $key => $bridge) {
//add the bridge to the fax_uri, after first iteration add the delimiter
if ($key == 0) {
$fax_uri = $bridge;
}
else {
$fax_uri .= '|'.$bridge;
}
//add the provider_prefix
if (!empty($provider_prefix)) {
$fax_uri = preg_replace('/\${provider_prefix}/', $provider_prefix, $fax_uri);
}
//remove switch ${variables} from the bridge statement
$fax_uri = preg_replace('/\${[^}]+}/', '', $fax_uri);
$route_array = outbound_route_to_bridge($domain_uuid, $fax_prefix . $fax_number, $channel_variables);
if (count($route_array) == 0) {
//check for valid extension
$sql = "select count(extension_uuid) ";
$sql .= "from v_extensions ";
$sql .= "where extension = :fax_number ";
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['fax_number'] = $fax_number;
$database = new database;
$extension_count = $database->select($sql, $parameters, 'column');
if ($extension_count > 0) {
//send the internal call to the registered extension
$route_array[] = "user/".$fax_number."@".$domain_name;
}
else {
$fax_status = 'failed';
}
}
@@ -387,13 +299,13 @@
//build a list of fax variables
$dial_string = $common_variables;
$dial_string .= $fax_options.",";
$dial_string .= "origination_uuid=" . $origination_uuid . ",";
$dial_string .= "fax_uuid=" . $fax_uuid . ",";
$dial_string .= "fax_queue_uuid=" . $fax_queue_uuid . ",";
$dial_string .= "mailto_address='" . $fax_email_address . "',";
$dial_string .= "origination_uuid=" . $origination_uuid. ",";
$dial_string .= "fax_uuid=" . $fax_uuid. ",";
$dial_string .= "fax_queue_uuid=" . $fax_queue_uuid. ",";
$dial_string .= "mailto_address='" . $fax_email_address . "',";
$dial_string .= "mailfrom_address='" . $email_from_address . "',";
$dial_string .= "fax_retry_attempts=" . $fax_retry_count . ",";
$dial_string .= "fax_retry_limit=" . $retry_limit . ",";
$dial_string .= "fax_retry_attempts=" . $fax_retry_count . ",";
$dial_string .= "fax_retry_limit=" . $retry_limit . ",";
//$dial_string .= "fax_retry_sleep=180,";
$dial_string .= "fax_verbose=true,";
//$dial_string .= "fax_use_ecm=off,";
@@ -403,18 +315,21 @@
//connect to event socket and send the command
if ($fax_status != 'failed' && file_exists($fax_file)) {
//send the fax and try another route if the fax fails
$fax_command = "originate {" . $dial_string . ",fax_uri=".$fax_uri."}" . $fax_uri." &txfax('".$fax_file."')";
$fax_response = event_socket::api($fax_command);
$response = str_replace("\n", "", $fax_response);
$response = trim(str_replace("+OK", "", $response));
if (is_uuid($response)) {
//originate command accepted
$uuid = $response;
echo "uuid: ".$uuid."\n";
}
else {
//originate command failed (-ERR INVALID_GATEWAY or other errors)
echo "response: ".$response."\n";
foreach($route_array as $route) {
$fax_command = "originate {" . $dial_string . ",fax_uri=".$route."}" . $route." &txfax('".$fax_file."')";
$fax_response = event_socket::api($fax_command);
$response = str_replace("\n", "", $fax_response);
$response = trim(str_replace("+OK", "", $response));
if (is_uuid($response)) {
//originate command accepted
$uuid = $response;
echo "uuid: ".$uuid."\n";
break;
}
else {
//originate command failed (-ERR INVALID_GATEWAY or other errors)
echo "response: ".$response."\n";
}
}
//set the fax file name without the extension
@@ -436,10 +351,11 @@
$array['fax_queue'][0]['fax_response'] = $fax_response;
//add temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('fax_queue_edit', 'temp');
//save the data
$database = new database;
$database->app_name = 'fax queue';
$database->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
$database->save($array, false);
@@ -483,6 +399,7 @@
$parameters['template_language'] = $language_code;
$parameters['template_category'] = 'fax';
$parameters['template_type'] = 'html';
$database = new database;
$fax_templates = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
}
@@ -534,6 +451,7 @@
$sql .= "from v_fax_logs ";
$sql .= "where fax_log_uuid = :fax_log_uuid ";
$parameters['fax_log_uuid'] = $fax_log_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
$fax_success = $row['fax_success'];
@@ -651,10 +569,11 @@
$array['fax_queue'][0]['fax_notify_date'] = 'now()';
//add temporary permissions
$p = permissions::new();
$p = new permissions;
$p->add('fax_queue_edit', 'temp');
//save the data
$database = new database;
$database->app_name = 'fax queue';
$database->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
$database->save($array, false);
@@ -181,7 +181,7 @@
//process the messages
if (is_array($fax_queue) && @sizeof($fax_queue) != 0) {
foreach($fax_queue as $row) {
$command = PHP_BINARY." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
$command = exec('which php')." ".$_SERVER['DOCUMENT_ROOT']."/app/fax_queue/resources/job/fax_send.php ";
$command .= "'action=send&fax_queue_uuid=".$row["fax_queue_uuid"]."&hostname=".$hostname."'";
if (isset($debug)) {
//run process inline to see debug info
-21
View File
@@ -30,23 +30,6 @@
$apps[$x]['description']['sv-se'] = "";
$apps[$x]['description']['uk-ua'] = "";
//destination details
$y=0;
$apps[$x]['destinations'][$y]['type'] = "sql";
$apps[$x]['destinations'][$y]['label'] = "fifo";
$apps[$x]['destinations'][$y]['name'] = "fifo";
$apps[$x]['destinations'][$y]['sql'] = "select fifo_uuid as uuid, fifo_name as name, fifo_extension as extension, fifo_enabled from v_fifo ";
$apps[$x]['destinations'][$y]['where'] = "where domain_uuid = '\${domain_uuid}' and fifo_enabled = 'true' ";
$apps[$x]['destinations'][$y]['order_by'] = "natural_sort(fifo_extension) asc";
$apps[$x]['destinations'][$y]['field']['uuid'] = "uuid";
$apps[$x]['destinations'][$y]['field']['name'] = "name";
$apps[$x]['destinations'][$y]['field']['extension'] = "extension";
//$apps[$x]['destinations'][$y]['field']['context'] = "context";
$apps[$x]['destinations'][$y]['select_value']['dialplan'] = "transfer:\${extension} XML \${context}";
$apps[$x]['destinations'][$y]['select_value']['ivr'] = "menu-exec-app:transfer \${extension} XML \${context}";
$apps[$x]['destinations'][$y]['select_label'] = "\${extension} \${name}";
$y++;
//permission details
$y = 0;
$apps[$x]['permissions'][$y]['name'] = 'fifo_view';
@@ -87,10 +70,6 @@
$apps[$x]['permissions'][$y]['name'] = 'fifo_member_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_destinations';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
//queues
$y=0;
+1 -27
View File
@@ -135,33 +135,6 @@ $text['description-fifo_name']['zh-cn'] = "队列将被分配的名称。";
$text['description-fifo_name']['ja-jp'] = "キューに割り当てられる名前。";
$text['description-fifo_name']['ko-kr'] = "대기열에 할당될 이름입니다.";
$text['label-fifo']['en-us'] = "Queues";
$text['label-fifo']['en-gb'] = "Queues";
$text['label-fifo']['ar-eg'] = "الاستفسارات";
$text['label-fifo']['de-at'] = "Warteschlangen";
$text['label-fifo']['de-ch'] = "Warteschlangen";
$text['label-fifo']['de-de'] = "Warteschlangen";
$text['label-fifo']['el-gr'] = "Ουρές";
$text['label-fifo']['es-cl'] = "Colas";
$text['label-fifo']['es-mx'] = "Colas";
$text['label-fifo']['fr-ca'] = "Files d'attente";
$text['label-fifo']['fr-fr'] = "Files d'attente";
$text['label-fifo']['he-il'] = "תורים";
$text['label-fifo']['it-it'] = "Code";
$text['label-fifo']['ka-ge'] = "რიგები";
$text['label-fifo']['nl-nl'] = "Wachtrijen";
$text['label-fifo']['pl-pl'] = "Kolejki";
$text['label-fifo']['pt-br'] = "Filas";
$text['label-fifo']['pt-pt'] = "Filas";
$text['label-fifo']['ro-ro'] = "Cozi";
$text['label-fifo']['ru-ru'] = "Очереди";
$text['label-fifo']['sv-se'] = "Kö:er";
$text['label-fifo']['uk-ua'] = "Клей";
$text['label-fifo']['tr-tr'] = "Kuyruklar";
$text['label-fifo']['zh-cn'] = "尾巴";
$text['label-fifo']['ja-jp'] = "テイルス";
$text['label-fifo']['ko-kr'] = "꼬리";
$text['label-fifo_extension']['en-us'] = "Extension";
$text['label-fifo_extension']['en-gb'] = "Extension";
$text['label-fifo_extension']['ar-eg'] = "امتداد";
@@ -837,3 +810,4 @@ $text['label-member_enabled']['ja-jp'] = "有効";
$text['label-member_enabled']['ko-kr'] = "활성화됨";
?>

Some files were not shown because too many files have changed in this diff Show More