From 5b1fef316ae757bbd159168fb5af654459a39a09 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 4 Dec 2015 21:09:25 +0300 Subject: [PATCH 1/6] Fix. send fax by user listed in fax server list --- app/fax/fax_send.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index b5491287a0..6307d28f68 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -58,13 +58,17 @@ if (!$included) { $fax_uuid = check_str($_REQUEST["id"]); if (if_group("superadmin") || if_group("admin")) { //show all fax extensions - $sql = "select * from v_fax "; + $sql = "select fax_uuid, fax_extension, fax_caller_id_name, fax_caller_id_number, "; + $sql .= "accountcode, fax_send_greeting "; + $sql .= "from v_fax "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and fax_uuid = '$fax_uuid' "; } else { //show only assigned fax extensions - $sql = "select * from v_fax as f, v_fax_users as u "; + $sql = "select f.fax_uuid, f.fax_extension, f.fax_caller_id_name, f.fax_caller_id_number, "; + $sql .= "f.accountcode, f.fax_send_greeting "; + $sql .= "from v_fax as f, v_fax_users as u "; $sql .= "where f.fax_uuid = u.fax_uuid "; $sql .= "and f.domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and f.fax_uuid = '$fax_uuid' "; @@ -101,7 +105,7 @@ if (!$included) { } //set the fax directory - $fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.((count($_SESSION["domains"]) > 1) ? '/'.$_SESSION['domain_name'] : null); + $fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; // set fax cover font to generate pdf $fax_cover_font = $_SESSION['fax']['cover_font']['text']; @@ -703,6 +707,7 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ foreach ($fax_numbers as $fax_number) { $dial_string = $common_dial_string; + fax_split_dtmf($fax_number, $fax_dtmf); //prepare the fax command From 7e715879f853075d1836349f847d979db6d9c668 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 8 Dec 2015 16:16:54 +0300 Subject: [PATCH 2/6] Add. Web UI to monitor for fax queue. --- app/fax/app_config.php | 7 ++ app/fax/app_languages.php | 21 ++++ app/fax/fax.php | 3 + app/fax/fax_active.php | 136 +++++++++++++++++++++++ app/fax/fax_active_inc.php | 222 +++++++++++++++++++++++++++++++++++++ 5 files changed, 389 insertions(+) create mode 100644 app/fax/fax_active.php create mode 100644 app/fax/fax_active_inc.php diff --git a/app/fax/app_config.php b/app/fax/app_config.php index 83fe88019d..838ecf936f 100644 --- a/app/fax/app_config.php +++ b/app/fax/app_config.php @@ -146,6 +146,13 @@ $apps[$x]['permissions'][$y]['name'] = 'fax_file_delete'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'fax_active_view'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'fax_active_all'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; //schema details $y = 0; //table array index diff --git a/app/fax/app_languages.php b/app/fax/app_languages.php index 5ab3463d98..2cb1bbd38d 100644 --- a/app/fax/app_languages.php +++ b/app/fax/app_languages.php @@ -330,6 +330,17 @@ $text['label-log']['de-at'] = "Log"; $text['label-log']['ro'] = "Log"; $text['label-log']['he'] = ""; +$text['label-active']['en-us'] = "Active"; +$text['label-active']['es-cl'] = ""; +$text['label-active']['pt-pt'] = ""; +$text['label-active']['fr-fr'] = ""; +$text['label-active']['pt-br'] = ""; +$text['label-active']['pl'] = ""; +$text['label-active']['sv-se'] = ""; +$text['label-active']['de-at'] = ""; +$text['label-active']['ro'] = ""; +$text['label-active']['he'] = ""; + $text['label-location']['en-us'] = "Location"; $text['label-location']['es-cl'] = "Localización"; $text['label-location']['pt-pt'] = "Localização"; @@ -2068,4 +2079,14 @@ $text['button-add']['de-at'] = "Hinzufügen"; $text['button-add']['ro'] = "Adaugă"; $text['button-add']['he'] = "הוספה"; +$text['button-show_all']['en-us'] = "Show All"; +$text['button-show_all']['es-cl'] = "Mostrar Todos"; +$text['button-show_all']['pt-pt'] = "Mostrar Todos"; +$text['button-show_all']['fr-fr'] = "Montrer Tout"; +$text['button-show_all']['pt-br'] = "Mostrar Todos"; +$text['button-show_all']['pl'] = "Pokaż Wszystkie"; +$text['button-show_all']['uk'] = "Показати всі"; +$text['button-show_all']['de-at'] = "Alle anzeigen"; +$text['button-show_all']['he'] = ""; + ?> \ No newline at end of file diff --git a/app/fax/fax.php b/app/fax/fax.php index 81af0c8441..5fb50ed436 100644 --- a/app/fax/fax.php +++ b/app/fax/fax.php @@ -170,6 +170,9 @@ else { if (permission_exists('fax_log_view')) { echo " ".$text['label-log'].""; } + if (permission_exists('fax_active_view')) { + echo " ".$text['label-active'].""; + } echo " \n"; echo " ".$row['fax_description']." \n"; echo " "; diff --git a/app/fax/fax_active.php b/app/fax/fax_active.php new file mode 100644 index 0000000000..a70bcc8eb6 --- /dev/null +++ b/app/fax/fax_active.php @@ -0,0 +1,136 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('fax_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the HTTP values and set as variables + $show = trim($_REQUEST["show"]); + if ($show != "all") { $show = ''; } + +// + $fax_uuid = false; + if(isset($_REQUEST['id'])) { + $fax_uuid = check_str($_REQUEST["id"]); + } + +//show the header + $document['title'] = $text['title']; + require_once "resources/header.php"; + +//ajax for refresh + ?> + +\n"; +echo "\n"; +echo "


"; + +require_once "resources/footer.php"; + +/* +// deprecated functions for this page + + function get_park_cmd(uuid, context) { + cmd = \"uuid_transfer \"+uuid+\" -bleg *6000 xml \"+context; + return escape(cmd); + } + + function get_record_cmd(uuid, prefix, name) { + cmd = \"uuid_record \"+uuid+\" start ".$_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/\"+uuid+\".wav\"; + return escape(cmd); + } +*/ +?> \ No newline at end of file diff --git a/app/fax/fax_active_inc.php b/app/fax/fax_active_inc.php new file mode 100644 index 0000000000..17bac8604b --- /dev/null +++ b/app/fax/fax_active_inc.php @@ -0,0 +1,222 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('fax_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if ((!permission_exists('fax_active_all')) && ($show == 'all')) { + echo "access denied"; + exit; +} + +$fax_uuid = false; +if(isset($_REQUEST['id'])) { + $fax_uuid = check_str($_REQUEST["id"]); +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the HTTP values and set as variables + $show = trim($_REQUEST["show"]); + if ($show != "all") { $show = ''; } + +//include theme config for button images + include_once("themes/".$_SESSION['domain']['template']['name']."/config.php"); + +$where = 'where (1 = 1)'; + +if($show !== 'all'){ + $where .= 'and (t3.domain_name = \'' . check_str($_SESSION['domain_name']) . '\')'; +} +else if($fax_uuid){ + if(!permission_exists('fax_active_all')){ + $where .= 'and (t3.domain_name = \'' . check_str($_SESSION['domain_name']) . '\')'; + } + $where .= 'and (t1.fax_uuid =\'' . check_str($fax_uuid) . '\')'; +} + + $sql = <<prepare(check_sql($sql)); + if ($prep_statement) { + if($prep_statement->execute()) { + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + } + } + unset($prep_statement, $sql, $where); + +//if the connnection is available then run it and return the results + if ($result === false) { + var_dump($db->errorInfo()); + $msg = "
".$text['confirm-socket']."
"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
".$text['label-message']."
$msg
\n"; + echo "
\n"; + } + else { + //define js function call var + $onhover_pause_refresh = " onmouseover='refresh_stop();' onmouseout='refresh_start();'"; + + //show buttons + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo " \"".$text['label-refresh_pause']."\""; + echo " "; + if (permission_exists('fax_active_all')) { + if ($show == "all") { + echo " \n"; + } + else { + echo " \n"; + } + } + echo "
"; + + // show title + echo "".'Fax queue'.""; + echo "

\n"; + echo 'Current status of fax queue' . "\n"; + echo "

\n"; + + //set the alternating color for each row + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + //show the results + echo "
\n"; + + //show headers + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + + foreach ($result as &$row) { + $fax_uri = $row['uri']; + $domain_name = $row['domain_name']; + $task_enabled = ($row['interrupted'] == 'true') ? 'Disable': 'Enable'; + $task_status = 'Wait'; + $task_next_time = $row['next_time']; + + if($row['status'] > 0){ + if($row['status'] <= 3){ + $task_status = 'Execute'; + } + else if($row['status'] == 10){ + $task_status = 'Success'; + } + else{ + $task_status = 'Fail'; + } + } + + $fax_server = $row['fax_server_name']; + if ($show == 'all') { + $fax_server .= '@' . $domain_name; + } + + $task_files = ''; + if(!empty($row['fax_file'])){ + $task_files .= ' ' . basename($row['fax_file']); + } + if(!empty($row['wav_file'])){ + $task_files .= '
 ' . basename($row['wav_file']); + } else if(!empty($row['greeting'])){ + $task_files .= '
 ' . basename($row['greeting']); + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + echo "\n"; + echo "\n"; + echo "
". 'Fax' . "". 'Enabled' . "". 'Status' . "". 'Next time' . "". 'Files' . "". 'URI' . "
" . $fax_server . " " . $task_enabled . " " . $task_status . " " . $task_next_time . " " . $task_files . " " . $fax_uri . " ".$v_link_label_delete."
\n"; + } +?> \ No newline at end of file From 66d0f060cebdd1120ccdacdee817a10e6c91bdd7 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 8 Dec 2015 16:42:13 +0300 Subject: [PATCH 3/6] Add. Ability to delete fax queue element --- app/fax/fax_active.php | 2 +- app/fax/fax_active_exec.php | 74 +++++++++++++++++++++++++++++++++++++ app/fax/fax_active_inc.php | 2 +- 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 app/fax/fax_active_exec.php diff --git a/app/fax/fax_active.php b/app/fax/fax_active.php index a70bcc8eb6..4729e91ab8 100644 --- a/app/fax/fax_active.php +++ b/app/fax/fax_active.php @@ -95,7 +95,7 @@ else { //call controls function hangup(uuid) { if (confirm("")) { - send_cmd('fax_active_exec.php?cmd=uuid_kill%20'+uuid); + send_cmd('fax_active_exec.php?cmd=delete&id='+uuid); } } diff --git a/app/fax/fax_active_exec.php b/app/fax/fax_active_exec.php new file mode 100644 index 0000000000..24b38ac2d0 --- /dev/null +++ b/app/fax/fax_active_exec.php @@ -0,0 +1,74 @@ +0) { + $cmd = trim(check_str($_GET['cmd'])); + $fax_uuid = trim(check_str($_GET['id'])); + } + +//authorized commands + if ($cmd == 'delete') { + //authorized; + } else { + //not found. this command is not authorized + echo "access denied"; + exit; + } + +//Command + if ($cmd == 'delete') { + if($fax_uuid){ + $sql = <<exec($sql); + // if($result === false){ + // var_dump($db->errorInfo()); + // } + } + } +?> \ No newline at end of file diff --git a/app/fax/fax_active_inc.php b/app/fax/fax_active_inc.php index 17bac8604b..b8b791c5eb 100644 --- a/app/fax/fax_active_inc.php +++ b/app/fax/fax_active_inc.php @@ -210,7 +210,7 @@ HERE; echo "" . $task_files . " \n"; echo "" . $fax_uri . " \n"; - echo "".$v_link_label_delete."\n"; + echo "".$v_link_label_delete."\n"; echo "\n"; $c = ($c) ? 0 : 1; } From df8da0f5ce324865bfd4a2d75d95855dec7b59b0 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 9 Dec 2015 13:00:42 +0300 Subject: [PATCH 4/6] Change. `Send` button redirect to `Active` page. --- app/fax/fax_send.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index 1d016b4171..35b17e5a2b 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -768,7 +768,12 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ if (!$included) { //redirect the browser $_SESSION["message"] = $response; - header("Location: fax_files.php?id=".$fax_uuid."&box=sent"); + if (permission_exists('fax_active_view')) { + header("Location: fax_active.php?id=".$fax_uuid); + } + else { + header("Location: fax_files.php?id=".$fax_uuid."&box=sent"); + } exit; } From b638967f0157b076507a5d6a13fcb281d4fdf9df Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 9 Dec 2015 13:37:32 +0300 Subject: [PATCH 5/6] Fix. Use `Test` interface to translate UI. --- app/fax/app_languages.php | 24 ++++++++++++++++++++++++ app/fax/fax_active_inc.php | 26 +++++++++++++------------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/app/fax/app_languages.php b/app/fax/app_languages.php index 2cb1bbd38d..3531c78fec 100644 --- a/app/fax/app_languages.php +++ b/app/fax/app_languages.php @@ -2089,4 +2089,28 @@ $text['button-show_all']['uk'] = "Показати всі"; $text['button-show_all']['de-at'] = "Alle anzeigen"; $text['button-show_all']['he'] = ""; +$text['fax-active_title']['en-us'] = "Fax queue"; + +$text['fax-active_description']['en-us'] = "Current status of fax queue"; + +$text['fax-active_title_fax_server']['en-us'] = "Fax"; + +$text['fax-active_title_enabled']['en-us'] = "Enabled"; + +$text['fax-active_title_status']['en-us'] = "Status"; + +$text['fax-active_title_next_time']['en-us'] = "Next time"; + +$text['fax-active_title_files']['en-us'] = "Files"; + +$text['fax-active_title_uri']['en-us'] = "URI"; + +$text['fax-active_status_wait']['en-us'] = "Wait"; + +$text['fax-active_status_execute']['en-us'] = "Execute"; + +$text['fax-active_status_success']['en-us'] = "Success"; + +$text['fax-active_status_fail']['en-us'] = "Fail"; + ?> \ No newline at end of file diff --git a/app/fax/fax_active_inc.php b/app/fax/fax_active_inc.php index b8b791c5eb..9e13e1cc6a 100644 --- a/app/fax/fax_active_inc.php +++ b/app/fax/fax_active_inc.php @@ -106,7 +106,7 @@ HERE; //if the connnection is available then run it and return the results if ($result === false) { var_dump($db->errorInfo()); - $msg = "
".$text['confirm-socket']."
"; + $msg = "
".$text['message-fail']."
"; echo "
\n"; echo "\n"; echo "\n"; @@ -142,9 +142,9 @@ HERE; echo "
"; // show title - echo "".'Fax queue'.""; + echo "".$text['fax-active_title'].""; echo "

\n"; - echo 'Current status of fax queue' . "\n"; + echo $text['fax-active_description']."\n"; echo "

\n"; //set the alternating color for each row @@ -158,12 +158,12 @@ HERE; //show headers echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; @@ -172,18 +172,18 @@ HERE; $fax_uri = $row['uri']; $domain_name = $row['domain_name']; $task_enabled = ($row['interrupted'] == 'true') ? 'Disable': 'Enable'; - $task_status = 'Wait'; + $task_status = $text['fax-active_status_wait']; $task_next_time = $row['next_time']; if($row['status'] > 0){ if($row['status'] <= 3){ - $task_status = 'Execute'; + $task_status = $text['fax-active_status_execute']; } else if($row['status'] == 10){ - $task_status = 'Success'; + $task_status = $text['fax-active_status_success']; } else{ - $task_status = 'Fail'; + $task_status = $text['fax-active_status_fail']; } } From ed781fc8c3d3323155af982a8dca4afc10eb2be9 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 9 Dec 2015 13:51:25 +0300 Subject: [PATCH 6/6] Fix. forgotten images. --- app/fax/resources/images/refresh_active.gif | Bin 0 -> 1079 bytes app/fax/resources/images/refresh_paused.png | Bin 0 -> 501 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/fax/resources/images/refresh_active.gif create mode 100644 app/fax/resources/images/refresh_paused.png diff --git a/app/fax/resources/images/refresh_active.gif b/app/fax/resources/images/refresh_active.gif new file mode 100644 index 0000000000000000000000000000000000000000..305457831c3f47939d634650660e859f50f18224 GIT binary patch literal 1079 zcmZ?wbhEHb6krfw_{_lY|NsA0U~uKimGkG%KYaM`#fum3-o5+$`SYz?x4wP*cIM0( z1|*>PpWDwhB-q(8z|~04fSC~}rT9$q3n zO>tew&yZDRa$!Y@S0^yIF#{CID4C^TqZC^&!;E6k-dQ&1{8}lV<;)-2jBdSFW47#` z1vIJ`t5L{)gBT?kmRz|^`|7L}S{*99_jCT;vIy5ToB7wlqaU~5kYZS7nL_(UfrqBk z(zDj8X?3K$2`jK(z145C(S#4nG^P4aV2xolq_Ej0;4GAuT$!{|vttSOYJI8o;oR@$ zJ^Oz^L6r$xSRh*s)EXo~qSeR&uoa}AU5JbTK#mcJDN5wV2$E5AwtyYvL~c4k^4lFJ R9?wLX4uT2S8kB9p001&weI)<@ literal 0 HcmV?d00001 diff --git a/app/fax/resources/images/refresh_paused.png b/app/fax/resources/images/refresh_paused.png new file mode 100644 index 0000000000000000000000000000000000000000..38937ec1f222094efb05cd3d3c634f752f84deb2 GIT binary patch literal 501 zcmVwBx2>F4R;%NMVn_aJxg_miiOUzd`-l3gn!7VkA&I7c*+DB!%r3QpAguz80Ve)s0dLW`~5+e4hT7Q6`Q>6PhY?hE(21}udC6bM0N(*gquPL7X19qhk(2T)25%jM!% r*LBxEygxiz%}l?3`LprpRloCJ0R6KCvd?rv00000NkvXXu0mjfpda3S literal 0 HcmV?d00001
". 'Fax' . "". 'Enabled' . "". 'Status' . "". 'Next time' . "". 'Files' . "". 'URI' . "" . $text['fax-active_title_fax_server'] . "" . $text['fax-active_title_enabled'] . "" . $text['fax-active_title_status'] . "" . $text['fax-active_title_next_time'] . "" . $text['fax-active_title_files'] . "" . $text['fax-active_title_uri'] . "