$response['errorcode'] = 200; // Verify the userids are real foreach (array('peopleid', 'newpeopleid') as $var) { $p = new People(); $p->UserID = ${$var}; if (!$p->GetPerson() && ($var != 'newpeopleid' && ${$var} == 0)) { $response['error'] = true; $response['message'] = "{$var} is not valid"; continue; } } // If we error above don't attempt to make changes if (!$response['error']) { $dev = new Device(); $dev->PrimaryContact = $peopleid; foreach ($dev->Search() as $d) { $d->PrimaryContact = $newpeopleid; if (!$d->UpdateDevice()) { // If we encounter an error stop immediately $response['error'] = true; $response['message'] = __("Device update has failed"); continue; } } } echoResponse(200, $response); }); // // URL: /api/v1/powerport/:deviceid // Method: POST // Params:
$d = new Device($port->DeviceID); // These should all be valid but just in case, skip it if ($d->GetDevice()) { $devList[$d->DeviceID] = $d; } } } } $resultcount = count($devList) + count($cabList); $title = __("Notes search results for") . " "{$searchTerm}""; } elseif ($searchKey = "dev") { // This is gonna be a generic catch all foreach ($dev as $prop => $val) { $dev->{$prop} = isset($_GET[$prop]) ? $_GET[$prop] : $val; } $devList = $dev->Search(true); $resultcount = count($devList); } else { $devList = array(); } $x = 0; $temp = array(); // Store all devices for display $cabtemp = array(); // List of all cabinet ids for outerloop $childList = array(); // List of all blade devices $dctemp = array(); // List of datacenters involved with result set $pduList = array(); // List of CDUs
$audit->AuditStamp = __("Never"); $audit->GetLastAudit(); if ($audit->UserID != "") { $tmpUser = new People(); $tmpUser->UserID = $audit->UserID; $tmpUser->GetUserRights(); $AuditorName = $tmpUser->FirstName . " " . $tmpUser->LastName; } $pdu->CabinetID = $cab->CabinetID; $PDUList = $pdu->GetPDUbyCabinet(); $dev->Cabinet = $cab->CabinetID; $devList = $dev->ViewDevicesByCabinet(); $search = new Device(); $search->Cabinet = $cab->CabinetID; $search->DeviceType = "Sensor"; $SensorList = $search->Search(); $stats = $cab->getStats($cab->CabinetID); $totalWatts = $stats->Wattage; $totalWeight = $stats->Weight; $totalMoment = 0; if ($config->ParameterArray["ReservedColor"] != "#FFFFFF" || $config->ParameterArray["FreeSpaceColor"] != "#FFFFFF") { $head .= "\t\t<style type=\"text/css\">\n\t\t\t.reserved {background-color: {$config->ParameterArray['ReservedColor']} !important;}\n\t\t\t.freespace {background-color: {$config->ParameterArray['FreeSpaceColor']};}\n"; // Only show reserved in the legend if the color is something other than white if ($config->ParameterArray["ReservedColor"] != "#FFFFFF") { $legend .= "\t\t<div class=\"legenditem hide\"><span class=\"reserved colorbox border\"></span> - " . __("Reservation") . "</div>\n"; } if ($config->ParameterArray["FreeSpaceColor"] != "#FFFFFF") { $legend .= '<div class="legenditem"><span class="freespace colorbox border"></span> - ' . __("Free Space") . '</div>' . "\n"; } } $noOwnerFlag = false;
function BuildCabinet($cabid, $face = "front") { $cab = new Cabinet($cabid); $cab->GetCabinet(); $order = $cab->U1Position == "Top" ? false : true; $dev = new Device(); $dev->Cabinet = $cab->CabinetID; $dev->ParentDevice = 0; $bounds = array('max' => array('position' => 0, 'height' => 0), 'min' => array('position' => 0, 'height' => 0)); // Read in all the devices and make sure they fit the cabinet. If not expand it foreach ($dev->Search() as $device) { if ($device->Position == 0) { continue; } $pos = $order ? $device->Position : $device->Position - $device->Height; if ($device->Position > $bounds['max']['position']) { $bounds['max']['position'] = $device->Position; $bounds['max']['height'] = $device->Height; } if ($pos < $bounds['min']['position']) { $bounds['min']['position'] = $pos; $bounds['min']['height'] = 1; } } if ($order) { $top = max($cab->CabinetHeight, $bounds['max']['position'] + $bounds['max']['height'] - 1); $bottom = min(0, $bounds['min']['position']); } else { // Reverse order $top = min(1, $bounds['min']['position'] - $bounds['min']['height']); $bottom = max($cab->CabinetHeight, $bounds['max']['position']); } // Build cabinet HTML switch ($face) { case "rear": $cab->Location = "{$cab->Location} (" . __("Rear") . ")"; break; case "side": $cab->Location = "{$cab->Location} (" . __("Side") . ")"; break; default: // Leave the location alone } // helper function to print the rows of the cabinet table if (!function_exists("printrow")) { function printrow($i, $top, $bottom, $order, $face, &$htmlcab, $cabobject) { $error = $i > $cabobject->CabinetHeight || $i <= 0 && $order || $i < 0 && !$order ? ' error' : ''; if ($order) { $x = $i <= 0 ? $i - 1 : $i; } else { $x = $i >= 0 ? $i + 1 : $i; } if ($i == $top) { if ($face == "rear") { $rs = "-rear"; } elseif ($face == "side") { $rs = "-side"; } else { $rs = ""; } $rowspan = abs($top) + abs($bottom); $height = (abs($top) + abs($bottom)) * ceil(220 * (1.75 / 19)) . "px"; $htmlcab .= "\t<tr id=\"pos{$x}\"><td class=\"pos{$error}\">{$x}</td><td rowspan={$rowspan}><div id=\"servercontainer{$rs}\" class=\"freespace\" style=\"width: 220px; height: {$height}\" data-face=\"{$face}\"></div></td></tr>\n"; } else { $htmlcab .= "\t<tr id=\"pos{$x}\"><td class=\"pos{$error}\">{$x}</td></tr>\n"; } } } // If they have rights to the device then make the picture clickable $clickable = $cab->Rights != "None" ? "\t\t<a href=\"cabnavigator.php?cabinetid={$cab->CabinetID}\">\n\t" : ""; $clickableend = $cab->Rights != "None" ? "\n\t\t</a>\n" : ""; $htmlcab = "<table class=\"cabinet\" id=\"cabinet{$cab->CabinetID}\">\n\t<tr><th colspan=2>{$clickable}{$cab->Location}{$clickableend}</th></tr>\n\t<tr><td>Pos</td><td>Device</td></tr>\n"; // loop here for the height // numbered high to low, top to bottom if ($order) { for ($i = $top; $i > $bottom; $i--) { printrow($i, $top, $bottom, $order, $face, $htmlcab, $cab); } } else { // numbered low to high, top to bottom for ($i = $top; $bottom > $i; $i++) { printrow($i, $top, $bottom, $order, $face, $htmlcab, $cab); } } $htmlcab .= "</table>\n"; // Wrap it in a nice div $htmlcab = '<div class="cabinet">' . $htmlcab . '</div>'; // debug information // print "Cabinet: $cab->CabinetID Top: $top Bottom: $bottom<br>\n"; return $htmlcab; }