function UpdateDeviceCustomAttribute() { global $dbh; $this->MakeSafe(); if (!$this->CheckInput()) { return false; } $old = new DeviceCustomAttribute(); $old->AttributeID = $this->AttributeID; $old->GetDeviceCustomAttribute(); $sql = "UPDATE fac_DeviceCustomAttribute SET Label=\"{$this->Label}\",\r\n\t\t\tAttributeType=\"{$this->AttributeType}\", Required={$this->Required},\r\n\t\t\tAllDevices={$this->AllDevices},DefaultValue=\"{$this->DefaultValue}\"\r\n\t\t\tWHERE AttributeID={$this->AttributeID};"; if (!$dbh->query($sql)) { $info = $dbh->errorInfo(); error_log("UpdateDeviceCustomAttribute::PDO Error: {$info[2]} SQL={$sql}"); return false; } class_exists('LogActions') ? LogActions::LogThis($this, $old) : ''; return true; }
// $app->get('/device/:deviceid', function ($deviceid) { $dev = new Device(); $dev->DeviceID = intval($deviceid); if (!$dev->GetDevice()) { $response['error'] = true; $response['errorcode'] = 404; $response['message'] = __("No device found with DeviceID") . $deviceid; echoResponse(200, $response); } else { if (is_array($dev->CustomValues)) { $cattr = new DeviceCustomAttribute(); $newList = array(); foreach ($dev->CustomValues as $key => $val) { $cattr->AttributeID = $key; $cattr->GetDeviceCustomAttribute(); $newList[$cattr->Label] = $val; } $dev->CustomValues = $newList; } $response['error'] = false; $response['errorcode'] = 200; $response['device'] = $dev; echoResponse(200, $response); } }); // // URL: /api/v1/device/:deviceid/getpicture // Method: GET // Params: // required: deviceid (passed in URL)
} else { $dca->AllDevices = 0; } if ($dca->AttributeType == "checkbox") { if (trim($_POST['dcav']) == "true") { $dca->DefaultValue = "1"; } else { $dca->DefaultValue = "0"; } } else { $dca->DefaultValue = trim($_POST['dcav']); } if (isset($_POST['dcaid'])) { $dca->AttributeID = $_POST['dcaid']; if (isset($_POST['original'])) { $dca->GetDeviceCustomAttribute(); header('Content-Type: application/json'); echo json_encode($dca); exit; } if (isset($_POST['clear'])) { if ($dca->RemoveDeviceCustomAttribute()) { echo 'u'; } else { echo 'f'; } exit; } if (isset($_POST['removeuses'])) { if ($dca->RemoveFromTemplatesAndDevices()) { echo 'u';