diff --git a/app/devices/resources/dashboard/device_keys.php b/app/devices/resources/dashboard/device_keys.php index 37b96aa398..1431906ee7 100644 --- a/app/devices/resources/dashboard/device_keys.php +++ b/app/devices/resources/dashboard/device_keys.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2016-2020 + Portions created by the Initial Developer are Copyright (C) 2016-2021 the Initial Developer. All Rights Reserved. */ @@ -27,15 +27,6 @@ require_once "resources/require.php"; require_once "resources/check_auth.php"; -//check permissions - if (permission_exists('device_key_add') || permission_exists('device_key_edit')) { - //access granted - } - else { - echo "access denied"; - exit; - } - //add multi-lingual support $language = new text; $text = $language->get($_SESSION['domain']['language']['code'], 'app/devices'); @@ -133,6 +124,7 @@ } } } + //create a list of protected keys - device proile keys if (is_array($device_profile_keys)) { foreach($device_profile_keys as $row) { @@ -263,10 +255,20 @@ $array['device_keys'][0]['device_key_icon'] = $device_key_icon; } if ($save) { - $database = new database; - $database->app_name = 'devices'; - $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; - $database->save($array); + //add the temporary permissions + $p = new permissions; + $p->add('device_keys_add', 'temp'); + $p->add('device_key_edit', 'temp'); + + //save the changes + $database = new database; + $database->app_name = 'devices'; + $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; + $database->save($array); + + //remove the temporary permissions + $p->delete('device_keys_add', 'temp'); + $p->delete('device_key_edit', 'temp'); } unset($array); } @@ -283,7 +285,7 @@ message::add($text["message-".$action]); //redirect the browser - header("Location: /core/user_settings/user_dashboard.php"); + header("Location: /core/dashboard/"); exit; } @@ -292,7 +294,7 @@ //set the sub array index $x = "999"; -//get device +//get the device $sql = "select device_uuid, device_profile_uuid from v_devices "; $sql .= "where device_user_uuid = :device_user_uuid "; $parameters['device_user_uuid'] = $_SESSION['user_uuid']; @@ -328,7 +330,7 @@ //set the sip profile name $sip_profile_name = 'internal'; -//get device keys in the right order where device keys are listed after the profile keys +//get the device keys in the right order where device keys are listed after the profile keys if (is_uuid($device_uuid)) { $sql = "select * from v_device_keys "; $sql .= "where ("; @@ -346,14 +348,16 @@ $sql .= $db_type == "mysql" ? "device_key_id asc " : "cast(device_key_id as numeric) asc, "; $sql .= "case when device_uuid is null then 0 else 1 end asc "; $parameters['device_uuid'] = $device_uuid; - $parameters['device_profile_uuid'] = $device_profile_uuid; + if (is_uuid($device_profile_uuid)) { + $parameters['device_profile_uuid'] = $device_profile_uuid; + } $database = new database; $keys = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); } //override profile keys with device keys - if (is_array($device_keys) && @sizeof($device_keys) != 0) { + if (is_array($keys) && @sizeof($keys) != 0) { foreach($keys as $row) { $id = $row['device_key_id']; $device_keys[$id] = $row; @@ -444,69 +448,95 @@ echo "

\n"; } - echo "
\n"; + echo "\n"; + echo "\n"; + $x = 0; + if (is_array($device_keys) && @sizeof($device_keys) != 0) { + foreach ($device_keys as $row) { - if (permission_exists('device_key_edit')) { - echo "
\n"; - $x = 0; - if (is_array($device_keys) && @sizeof($device_keys) != 0) { - foreach ($device_keys as $row) { - //set the variables - $device_key_vendor = $row['device_key_vendor']; - $device_vendor = $row['device_key_vendor']; - //set the column names - if ($previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') { - echo " \n"; - echo " \n"; - if (strlen($row['device_key_vendor']) > 0) { - echo " \n"; + //set the variables + $device_key_vendor = $row['device_key_vendor']; + $device_vendor = $row['device_key_vendor']; + + //set the column names + if ($previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') { + echo " \n"; + echo " \n"; + if (strlen($row['device_key_vendor']) > 0) { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + + //determine whether to hide the element + if (strlen($device_key_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + + //add the primary key uuid + if (strlen($row['device_key_uuid']) > 0) { + echo " \n"; + } + + //show all the rows in the array + /* + echo " \n"; + echo "\n"; + echo " \n"; + } + if ($row['device_key_category'] == "expansion-2") { + echo " \n"; + } + else { + echo " \n"; } - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - } - //determine whether to hide the element - if (strlen($device_key_uuid) == 0) { - $element['hidden'] = false; - $element['visibility'] = "visibility:visible;"; } else { - $element['hidden'] = true; - $element['visibility'] = "visibility:hidden;"; - } - //add the primary key uuid - if (strlen($row['device_key_uuid']) > 0) { - echo " \n"; - } - //show all the rows in the array - /* - echo " \n"; - echo "\n"; - */ - //output form rows - echo " \n"; - echo " \n"; + } + echo " \n"; + echo "\n"; + */ - echo " \n"; + echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - //set the previous vendor - $previous_device_key_vendor = $row['device_key_vendor']; - //increment the array key - $x++; - } - } - echo "
".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."
".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_type']."".$text['label-device_key_value']."".$text['label-device_key_label']."".$text['label-device_key_icon']."
\n"; + echo " ".$text['label-device_key_type']."".$text['label-device_key_value']."".$text['label-device_key_label']."".$text['label-device_key_icon']."
\n"; - echo " \n"; - echo "
\n"; - if (permission_exists('device_key_id') || permission_exists('device_key_add')) { - $selected = "selected='selected'"; - echo " \n"; - } - else { - echo "  ".$row['device_key_id']; - } - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; + if (permission_exists('device_key_id') || permission_exists('device_key_add')) { + $selected = "selected='selected'"; + echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - } + } + else { + echo "  ".$row['device_key_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"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + //set the previous vendor + $previous_device_key_vendor = $row['device_key_vendor']; + + //increment the array key + $x++; + } + } + echo "\n"; echo "\n"; echo "
"; -?> \ No newline at end of file +?>