From 506483fcfaeaf0cbbf55cf660503be58c8a6d875 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 30 Jul 2016 10:25:34 -0600 Subject: [PATCH] Update device_dashboard.php If the device_uuid does not have a value then get it. --- app/devices/device_dashboard.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/devices/device_dashboard.php b/app/devices/device_dashboard.php index 36a3e796ef..ac975e102d 100644 --- a/app/devices/device_dashboard.php +++ b/app/devices/device_dashboard.php @@ -112,13 +112,24 @@ } } - //sql update + //sql add or update if (strlen($device_key_uuid) == 0) { if (permission_exists('device_key_add') && strlen($device_key_type) > 0 && strlen($device_key_value) > 0) { //create the primary keys $device_key_uuid = uuid(); + //if the device_uuid is not in the array then get the device_uuid from the database + if (strlen($device_uuid) == 0) { + $sql = "SELECT device_uuid, device_profile_uuid FROM v_devices "; + $sql .= "WHERE device_user_uuid = '".$_SESSION['user_uuid']."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_NAMED); + $device_uuid = $row['device_uuid']; + unset($row); + } + //insert the keys $sql = "insert into v_device_keys "; $sql .= "("; @@ -145,7 +156,6 @@ $sql .= "'".$device_key_category."', "; $sql .= "'".$device_key_vendor."' "; $sql .= ");"; - //echo $sql; //action add or update $action = "add";