Update device_dashboard.php

This commit is contained in:
FusionPBX 2017-11-17 14:01:40 -07:00 committed by GitHub
parent eb095469cc
commit 21b282857c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 411 additions and 385 deletions

View File

@ -109,6 +109,7 @@
}
//create a list of protected keys - device keys
if (is_array($device_keys)) {
foreach($device_keys as $row) {
//determine if the key is allowed
$device_key_authorized = false;
@ -126,23 +127,29 @@
$protected_keys[$row['device_key_id']] = 'true';
}
}
}
//create a list of protected keys - device proile keys
if (is_array($device_profile_keys)) {
foreach($device_profile_keys as $row) {
//determine if the key is allowed
$device_key_authorized = false;
if (is_array($vendor_functions)) {
foreach($vendor_functions as $function) {
if ($function['vendor_name'] == $row['device_key_vendor'] && $function['value'] == $row['device_key_type']) {
$device_key_authorized = true;
}
}
}
//add the protected keys
if (!$device_key_authorized) {
$protected_keys[$row['device_key_id']] = 'true';
}
}
}
//remove the keys the user is not allowed to edit based on the authorized vendor keys
$x=0;
if (is_array($_POST['device_keys'])) {
foreach($_POST['device_keys'] as $row) {
//loop through the authorized vendor functions
if ($protected_keys[$row['device_key_id']] == "true") {
@ -151,8 +158,10 @@
//increment the row id
$x++;
}
}
//add or update the device keys
if (is_array($_POST['device_keys'])) {
foreach ($_POST['device_keys'] as &$row) {
//validate the data
@ -270,6 +279,7 @@
//echo "invalid: ".$sql."\n";
}
}
}
//write the provision files
if (strlen($_SESSION['provision']['path']['text']) > 0) {
@ -302,13 +312,16 @@
unset($row);
//get device lines
if (isset($device_uuid)) {
$sql = "SELECT * from v_device_lines ";
$sql .= "WHERE device_uuid = '".$device_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$device_lines = $prep_statement->fetchAll(PDO::FETCH_NAMED);
}
//get the user
if (is_array($device_lines)) {
foreach ($device_lines as $row) {
if ($_SESSION['domain_name'] == $row['server_address']) {
$user_id = $row['user_id'];
@ -316,11 +329,13 @@
break;
}
}
}
//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
if (isset($device_uuid)) {
$sql = "SELECT * FROM v_device_keys ";
$sql .= "WHERE (";
$sql .= "device_uuid = '".$device_uuid."' ";
@ -347,8 +362,10 @@
$prep_statement->execute();
$keys = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($sql,$prep_statement);
}
//override profile keys with device keys
if (is_array($device_keys)) {
foreach($keys as $row) {
$id = $row['device_key_id'];
$device_keys[$id] = $row;
@ -360,8 +377,10 @@
}
}
unset($keys);
}
//get the vendor count and last and device information
if (is_array($device_keys)) {
$vendor_count = 0;
foreach($device_keys as $row) {
if ($previous_vendor != $row['device_key_vendor']) {
@ -374,6 +393,7 @@
$vendor_count++;
}
}
}
//add a new key
if (permission_exists('device_key_add')) {
@ -389,9 +409,11 @@
}
//remove the keys the user is not allowed to edit based on the authorized vendor keys
if (is_array($device_keys)) {
foreach($device_keys as $row) {
//loop through the authorized vendor functions
$device_key_authorized = false;
if (is_array($vendor_functions)) {
foreach($vendor_functions as $function) {
if (strlen($row['device_key_type'] == 0)) {
$device_key_authorized = true;
@ -402,6 +424,7 @@
}
}
}
}
//unset vendor functions the is not allowed to edit
if (!$device_key_authorized) {
unset($device_keys[$row['device_key_id']]);
@ -411,6 +434,7 @@
unset($device_keys[$row['device_key_id']]);
}
}
}
//show the header
//require_once "resources/header.php";
@ -437,6 +461,7 @@
if (permission_exists('device_key_edit')) {
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
$x = 0;
if (is_array($device_keys)) {
foreach($device_keys as $row) {
//set the variables
$device_key_vendor = $row['device_key_vendor'];
@ -564,6 +589,7 @@
echo " <option value=''></option>\n";
$previous_vendor = '';
$i=0;
if (is_array($vendor_functions)) {
foreach ($vendor_functions as $function) {
if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) {
if ($i > 0) { echo " </optgroup>\n"; }
@ -578,11 +604,10 @@
}
if (strlen($row['device_key_vendor']) > 0 && $row['device_key_vendor'] == $function['vendor_name']) {
echo " <option value='".$function['value']."' $selected >".$text['label-'.$function['name']]."</option>\n";
}
$previous_vendor = $function['vendor_name'];
$i++;
}
}
if (strlen($row['device_key_vendor']) == 0) {
echo " </optgroup>\n";
@ -630,6 +655,7 @@
//alternate the value
$c = ($c) ? 0 : 1;
}
}
echo " </table>\n";
//if (strlen($text['description-keys']) > 0) {
// echo " <br>".$text['description-keys']."\n";