From 1f67a6f8f48d0f46664b01bb16160ad30fe4bae2 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 4 Dec 2019 19:08:02 -0700 Subject: [PATCH] Dashboard: App list view updates, token integration, bug fixes. --- app/calls/calls.php | 11 +- app/extensions/app_languages.php | 20 ++ app/extensions/extension_dashboard.php | 323 ++++++++++++------------- app/ring_groups/ring_group_forward.php | 158 ++++++------ core/user_settings/user_dashboard.php | 12 +- themes/default/app_config.php | 8 + themes/default/css.php | 7 + 7 files changed, 286 insertions(+), 253 deletions(-) diff --git a/app/calls/calls.php b/app/calls/calls.php index 52fc61c21f..243eaf400e 100644 --- a/app/calls/calls.php +++ b/app/calls/calls.php @@ -177,12 +177,15 @@ //show the content if ($is_included) { - echo "".$text['header-call_routing']."\n"; + echo "
\n"; + echo "
".$text['header-call_routing']."
\n"; + echo "
\n"; if ($num_rows > 10) { - echo "
\n"; - echo button::create(['type'=>'button','label'=>$text['button-view_all'],'link'=>PROJECT_PATH.'/app/calls/calls.php']); - echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-view_all'],'icon'=>'project-diagram','collapse'=>false,'link'=>PROJECT_PATH.'/app/calls/calls.php']); } + echo "
\n"; + echo "
\n"; + echo "
\n"; } else { echo "
\n"; diff --git a/app/extensions/app_languages.php b/app/extensions/app_languages.php index e32f8554e8..5156e2ebf8 100644 --- a/app/extensions/app_languages.php +++ b/app/extensions/app_languages.php @@ -1541,6 +1541,26 @@ $text['label-column_name']['ru-ru'] = ""; $text['label-column_name']['sv-se'] = ""; $text['label-column_name']['uk-ua'] = ""; +$text['label-destination']['en-us'] = "Destination"; +$text['label-destination']['ar-eg'] = "جهات الأتصال"; +$text['label-destination']['de-at'] = "Ziele"; //copied from de-de +$text['label-destination']['de-ch'] = "Ziele"; //copied from de-de +$text['label-destination']['de-de'] = "Ziele"; +$text['label-destination']['es-cl'] = "Destino"; +$text['label-destination']['es-mx'] = "Destino"; //copied from es-cl +$text['label-destination']['fr-ca'] = "Destination"; //copied from fr-fr +$text['label-destination']['fr-fr'] = "Destination"; +$text['label-destination']['he-il'] = "יעדים"; +$text['label-destination']['it-it'] = "Destinazioni"; +$text['label-destination']['nl-nl'] = "Bestemmingen"; +$text['label-destination']['pl-pl'] = "Destynacje"; +$text['label-destination']['pt-br'] = "Destino"; //copied from pt-pt +$text['label-destination']['pt-pt'] = "Destino"; +$text['label-destination']['ro-ro'] = "Destinații"; +$text['label-destination']['ru-ru'] = "Направления"; +$text['label-destination']['sv-se'] = "Destinationer"; +$text['label-destination']['uk-ua'] = "Номери"; + $text['header-extensions']['en-us'] = "Extensions"; $text['header-extensions']['ar-eg'] = "الأرقام الداخلية"; $text['header-extensions']['de-at'] = "Nebenstellen"; //copied from de-de diff --git a/app/extensions/extension_dashboard.php b/app/extensions/extension_dashboard.php index 923cd40f30..9c1e9b7771 100644 --- a/app/extensions/extension_dashboard.php +++ b/app/extensions/extension_dashboard.php @@ -17,16 +17,20 @@ The Initial Developer of the Original Code is Mark J Crane - Copyright (C) 2017 All Rights Reserved. + Portions created by the Initial Developer are Copyright (C) 2017 - 2019 + the Initial Developer. All Rights Reserved. + Contributor(s): + Mark J Crane */ //includes require_once "root.php"; require_once "resources/require.php"; + require_once "resources/check_auth.php"; + //check permissions - require_once "resources/check_auth.php"; if (permission_exists('extension_caller_id')) { //access granted } @@ -40,93 +44,93 @@ $text = $language->get($_SESSION['domain']['language']['code'], 'app/extensions'); //add or update the database - if (count($_POST) > 0) { - - //add or update the database - if ($_POST["persistformvar"] != "true") { - - //build a new array to make sure it only contains what the user is allowed to change - $x=0; - foreach($_POST['extensions'] as $row) { - //loop through the extensions - $found = false; - foreach($_SESSION['user']['extension'] as $field) { - if ($field['extension_uuid'] == $row['extension_uuid']) { - //set as found - $found = true; - } - } - - //build the array on what is allowed. - if ($found) { - if (permission_exists('outbound_caller_id_select')) { - $caller_id = explode('@', $row['outbound_caller_id']); - $outbound_caller_id_name = $caller_id[0]; - $outbound_caller_id_number = $caller_id[1]; - } - else { - $outbound_caller_id_name = $row['outbound_caller_id_name']; - $outbound_caller_id_number = $row['outbound_caller_id_number']; - } - $array['extensions'][$x]['extension_uuid'] = $row['extension_uuid']; - $array['extensions'][$x]['outbound_caller_id_name'] = $outbound_caller_id_name; - if (is_numeric($outbound_caller_id_number)) { - $array['extensions'][$x]['outbound_caller_id_number'] = $outbound_caller_id_number; - } - } - - //increment the row id - $x++; - } - - //add the dialplan permission - $p = new permissions; - $p->add("extension_edit", "temp"); - - //save to the data - $database = new database; - $database->app_name = 'extensions'; - $database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3'; - $database->save($array); - $message = $database->message; - - //update the session array - foreach($array['extensions'] as $row) { - $x=0; - foreach($_SESSION['user']['extension'] as $field) { - if ($field['extension_uuid'] == $row['extension_uuid']) { - $_SESSION['user']['extension'][$x]['outbound_caller_id_name'] = $row['outbound_caller_id_name']; - $_SESSION['user']['extension'][$x]['outbound_caller_id_number'] = $row['outbound_caller_id_number']; - } - $x++; - } - } - - //remove the temporary permission - $p->delete("extension_edit", "temp"); - - //clear the cache - $cache = new cache; - foreach($_SESSION['user']['extension'] as $field) { - $cache->delete("directory:".$field['destination']."@".$field['user_context']); - } - - //set the message - message::add($text['message-update']); - - //redirect the browser - header("Location: /core/user_settings/user_dashboard.php"); - exit; + if (is_array($_POST['extensions']) && @sizeof($_POST['extensions']) != 0) { + //validate the token + $token = new token; + if (!$token->validate('/app/extensions/extension_dashboard.php')) { + message::add($text['message-invalid_token'],'negative'); + header('Location: /core/user_settings/user_dashboard.php'); + exit; } + + //build a new array to make sure it only contains what the user is allowed to change + $x=0; + foreach ($_POST['extensions'] as $row) { + //loop through the extensions + $found = false; + foreach ($_SESSION['user']['extension'] as $field) { + if ($field['extension_uuid'] == $row['extension_uuid']) { + //set as found + $found = true; + } + } + + //build the array on what is allowed. + if ($found) { + if (permission_exists('outbound_caller_id_select')) { + $caller_id = explode('@', $row['outbound_caller_id']); + $outbound_caller_id_name = $caller_id[0]; + $outbound_caller_id_number = $caller_id[1]; + } + else { + $outbound_caller_id_name = $row['outbound_caller_id_name']; + $outbound_caller_id_number = $row['outbound_caller_id_number']; + } + $array['extensions'][$x]['extension_uuid'] = $row['extension_uuid']; + $array['extensions'][$x]['outbound_caller_id_name'] = $outbound_caller_id_name; + if (is_numeric($outbound_caller_id_number)) { + $array['extensions'][$x]['outbound_caller_id_number'] = $outbound_caller_id_number; + } + } + + //increment the row id + $x++; + } + + //add the dialplan permission + $p = new permissions; + $p->add("extension_edit", "temp"); + + //save to the data + $database = new database; + $database->app_name = 'extensions'; + $database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3'; + $database->save($array); + $message = $database->message; + + //update the session array + foreach ($array['extensions'] as $row) { + $x=0; + foreach ($_SESSION['user']['extension'] as $field) { + if ($field['extension_uuid'] == $row['extension_uuid']) { + $_SESSION['user']['extension'][$x]['outbound_caller_id_name'] = $row['outbound_caller_id_name']; + $_SESSION['user']['extension'][$x]['outbound_caller_id_number'] = $row['outbound_caller_id_number']; + } + $x++; + } + } + + //remove the temporary permission + $p->delete("extension_edit", "temp"); + + //clear the cache + $cache = new cache; + foreach($_SESSION['user']['extension'] as $field) { + $cache->delete("directory:".$field['destination']."@".$field['user_context']); + } + + //set the message + message::add($text['message-update']); + + //redirect the browser + header("Location: /core/user_settings/user_dashboard.php"); + exit; } //set the sub array index $x = "999"; -//show the header - //require_once "resources/header.php"; - //get the extensions $extensions = $_SESSION['user']['extension']; @@ -140,44 +144,36 @@ $destinations = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); +//create token + $object = new token; + $token = $object->create('/app/extensions/extension_dashboard.php'); + //show the content - echo "
\n"; - - echo "
"; - echo " ".$text['label-caller_id_number']."
"; - echo "
"; + echo "
\n"; + echo "
".$text['label-caller_id_number']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"list_form_submit('form_list_extension_caller_id');"]); + echo "
\n"; + echo "
\n"; echo "
\n"; - echo "
\n"; + echo "\n"; - echo "
\n"; - echo " \n"; - echo "
\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + if (!permission_exists('outbound_caller_id_select')) { + echo " \n"; + } + echo " \n"; + echo "\n"; - echo "
".$text['label-extension']."".$text['label-caller_id']."".$text['label-destination']."".$text['label-description']."
\n"; - $x = 0; if (is_array($extensions) && @sizeof($extensions) != 0) { - foreach($extensions as $row) { - //set the variables - $extension_uuid = $row['extension_uuid']; - $user = $row['user']; - $number_alias = $row['number_alias']; - $destination = $row['destination']; - $outbound_caller_id_name = $row['outbound_caller_id_name']; - $outbound_caller_id_number = $row['outbound_caller_id_number']; - $description = $row['description']; - - //set the column names - if ($x === 0 && $previous_extension_uuid != $row['extension_uuid']) { - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - } - + $x = 0; + foreach ($extensions as $row) { //determine whether to hide the element - if (strlen($device_key_uuid) == 0) { + if (is_uuid($device_key_uuid)) { $element['hidden'] = false; $element['visibility'] = "visibility:visible;"; } @@ -186,69 +182,54 @@ $element['visibility'] = "visibility:hidden;"; } - //start the row - echo " \n"; - - //add the primary key uuid - if (strlen($row['extension_uuid']) > 0) { - echo " \n"; - } - - //show the destination - echo " \n"; - - //caller id form input - if (permission_exists('outbound_caller_id_select')) { - //caller id select - echo " \n"; + echo " \n"; + if (permission_exists('outbound_caller_id_select')) { + //caller id select + echo " \n"; + echo " \n"; } - else { - //caller id name an number input text - echo " \n"; - echo " \n"; - } - - //show the description - echo " \n"; - - //end the row - echo " \n"; - //set the previous extension_uuid - $previous_extension_uuid = $extension_uuid; - //increment the array key - $x++; - //alternate the value - $c = $c ? 0 : 1; + echo " \n"; + } + else { + //caller id name and number inputs + echo " \n"; + echo " \n"; + } + echo " \n"; + echo "\n"; + $x++; } } - unset($extensions, $row); + unset($extensions); + echo "
".$text['label-extension']."".$text['label-caller_id']."".$text['label-description']."
\n"; - echo " ".$row['destination']; - echo " \n"; - if (count($destinations) > 0) { - echo "
\n"; + echo " ".$row['destination']; + if (is_uuid($row['extension_uuid'])) { + echo " \n"; + } + echo " \n"; + if (count($destinations) > 0) { + echo " \n"; } - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " ".$row['description']; - echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " ".$row['description']; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; - - echo ""; - -?> +?> \ No newline at end of file diff --git a/app/ring_groups/ring_group_forward.php b/app/ring_groups/ring_group_forward.php index 575c9f3624..90af880f89 100644 --- a/app/ring_groups/ring_group_forward.php +++ b/app/ring_groups/ring_group_forward.php @@ -27,9 +27,10 @@ //includes require_once "root.php"; require_once "resources/require.php"; + require_once "resources/check_auth.php"; + require_once "resources/paging.php"; //check permissions - require_once "resources/check_auth.php"; if (permission_exists('ring_group_edit') || permission_exists('ring_group_forward')) { //access granted } @@ -42,10 +43,6 @@ $language = new text; $text = $language->get($_SESSION['domain']['language']['code'], 'app/ring_groups'); -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - //get variables used to control the order $order_by = $_GET["order_by"]; $order = $_GET["order"]; @@ -63,45 +60,52 @@ } //update ring group forwarding - if (sizeof($_POST) > 0) { - if (is_array($_POST['ring_groups']) && @sizeof($_POST['ring_groups']) != 0 && permission_exists('ring_group_forward')) { - $x = 0; - foreach ($_POST['ring_groups'] as $row) { - //remove non-numeric characters - $ring_group_uuid = $row['ring_group_uuid']; - $ring_group_forward_destination = preg_replace("~[^0-9]~", "", $row['ring_group_forward_destination']); - $ring_group_forward_enabled = ($row['ring_group_forward_enabled'] == 'true') ? $ring_group_forward_enabled = 'true' : $ring_group_forward_enabled = 'false'; - //build array - if (is_uuid($ring_group_uuid)) { - $array['ring_groups'][$x]['ring_group_uuid'] = $ring_group_uuid; - $array['ring_groups'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; - $array['ring_groups'][$x]['ring_group_forward_enabled'] =$ring_group_forward_enabled; - $array['ring_groups'][$x]['ring_group_forward_destination'] = $ring_group_forward_destination; - } - //increment counter - $x++; + if (is_array($_POST['ring_groups']) && @sizeof($_POST['ring_groups']) != 0 && permission_exists('ring_group_forward')) { + + //validate the token + $token = new token; + if (!$token->validate('/app/ring_groups/ring_group_forward.php')) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$validated_path); + exit; } - if (is_array($array) && sizeof($array) != 0) { - //update ring group - $p = new permissions; - $p->add('ring_group_edit', 'temp'); + $x = 0; + foreach ($_POST['ring_groups'] as $row) { + //remove non-numeric characters + $ring_group_uuid = $row['ring_group_uuid']; + $ring_group_forward_destination = preg_replace("~[^0-9]~", "", $row['ring_group_forward_destination']); + $ring_group_forward_enabled = $row['ring_group_forward_enabled'] == 'true' && is_numeric($ring_group_forward_destination) ? 'true' : 'false'; + //build array + if (is_uuid($ring_group_uuid)) { + $array['ring_groups'][$x]['ring_group_uuid'] = $ring_group_uuid; + $array['ring_groups'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['ring_groups'][$x]['ring_group_forward_enabled'] = $ring_group_forward_enabled; + $array['ring_groups'][$x]['ring_group_forward_destination'] = $ring_group_forward_destination; + } + //increment counter + $x++; + } - $database = new database; - $database->app_name = 'ring_groups'; - $database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2'; - $database->save($array); - unset($array); + if (is_array($array) && sizeof($array) != 0) { + //update ring group + $p = new permissions; + $p->add('ring_group_edit', 'temp'); - $p->delete('ring_group_edit', 'temp'); + $database = new database; + $database->app_name = 'ring_groups'; + $database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2'; + $database->save($array); + unset($array); - //set message - message::add($text['message-update']); + $p->delete('ring_group_edit', 'temp'); - //redirect the user - header("Location: ".$validated_path); - exit; - } + //set message + message::add($text['message-update']); + + //redirect the user + header("Location: ".$validated_path); + exit; } } @@ -155,68 +159,78 @@ $result = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); - echo "
\n"; - echo "
"; - echo " ".$text['header-ring-group-forward']."
"; - if (!$is_included) { - echo " ".$text['description-ring-group-forward']."
"; - } - echo "
"; - echo "
\n"; +//create token + $object = new token; + $token = $object->create('/app/ring_groups/ring_group_forward.php'); - echo "
\n"; - if ($num_rows > 10) { - echo " \n"; +//include header + require_once "resources/header.php"; + +//show content + echo "
\n"; + echo "
".$text['header-ring-group-forward']."
\n"; + echo "
\n"; + if ($is_included && $num_rows > 10) { + echo button::create(['type'=>'button','label'=>$text['button-view_all'],'icon'=>'share-square','collapse'=>'hide-xs','link'=>PROJECT_PATH.'/app/ring_groups/ring_group_forward.php']); } - echo " "; + echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"list_form_submit('form_list_ring_group_forward');"]); + echo "
\n"; + echo "
\n"; echo "
\n"; - echo "\n"; - echo "\n"; + if (!$is_included) { + echo $text['description-ring-group-forward']."\n"; + echo "

\n"; + } + + echo "\n"; + + echo "
\n"; + echo "\n"; echo th_order_by('ring_group_name', $text['label-name'], $order_by, $order); echo th_order_by('ring_group_extension', $text['label-extension'], $order_by, $order); - echo ""; + echo ""; if (!$is_included) { - echo th_order_by('ring_group_description', $text['label-description'], $order_by, $order); + echo th_order_by('ring_group_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'"); } echo "\n"; - $c = 0; $x = 0; + $x = 0; if (is_array($result) && @sizeof($result) != 0) { - foreach($result as $row) { + $x = 0; + foreach ($result as $row) { $onclick = "onclick=\"document.getElementById('".escape($row['ring_group_uuid'])."').selectedIndex = (document.getElementById('".escape($row['ring_group_uuid'])."').selectedIndex) ? 0 : 1; if (document.getElementById('".escape($row['ring_group_uuid'])."').selectedIndex) { document.getElementById('destination').focus(); }\""; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; if (!$is_included) { - echo " \n"; + echo " \n"; } echo "\n"; - $c = ($c) ? 0 : 1; $x++; } } - unset($result, $row); - - echo "
".$text['label-forwarding']."".$text['label-forwarding']."
".escape($row['ring_group_name'])." ".escape($row['ring_group_extension'])." "; - echo " "; - echo "
".escape($row['ring_group_name'])." ".escape($row['ring_group_extension'])." "; + echo " "; + echo " "; echo " "; echo " ".escape($row['ring_group_description'])." 
"; - echo ""; + unset($result); + echo "\n"; + echo "
\n"; if (!$is_included) { - echo "
".$paging_controls."
\n"; - echo "

"; + echo "
".$paging_controls."
\n"; } + echo "\n"; + echo "\n"; //include the footer if (!$is_included) { require_once "resources/footer.php"; } -?> +?> \ No newline at end of file diff --git a/core/user_settings/user_dashboard.php b/core/user_settings/user_dashboard.php index 5b30108c6d..817b4b73af 100644 --- a/core/user_settings/user_dashboard.php +++ b/core/user_settings/user_dashboard.php @@ -1232,12 +1232,12 @@ if (!is_array($selected_blocks) || in_array('caller_id', $selected_blocks)) { //caller id management if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/extension_dashboard.php")) { - if (permission_exists('extension_caller_id')) { - $is_included = true; - echo "
\n"; - require_once "app/extensions/extension_dashboard.php"; - echo "
"; - } + if (permission_exists('extension_caller_id')) { + $is_included = true; + echo "
\n"; + require_once "app/extensions/extension_dashboard.php"; + echo "
"; + } } } diff --git a/themes/default/app_config.php b/themes/default/app_config.php index 100c2270bc..edef05a727 100644 --- a/themes/default/app_config.php +++ b/themes/default/app_config.php @@ -1981,5 +1981,13 @@ $apps[$x]['default_settings'][$y]['default_setting_value'] = "fas fa-file-export"; $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "adc48491-d2df-499b-b53e-4fcaa5ef2183"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "theme"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "button_icon_save"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "fas fa-bolt"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; ?> \ No newline at end of file diff --git a/themes/default/css.php b/themes/default/css.php index 3ed5b79eee..2cb8afb1b6 100644 --- a/themes/default/css.php +++ b/themes/default/css.php @@ -2427,6 +2427,13 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false; white-space: nowrap; } + .list-row > .input { + margin: 0; + padding-top: 0; + padding-bottom: 0; + white-space: nowrap; + } + .list-row > .overflow { max-width: 50px; overflow: hidden;