function amplifyCell(&$record, $dummy = NULL) { switch ($record['realm']) { case 'object': $record['ports'] = getObjectPortsAndLinks($record['id']); $record['ipv4'] = getObjectIPv4Allocations($record['id']); $record['ipv6'] = getObjectIPv6Allocations($record['id']); $record['nat4'] = getNATv4ForObject($record['id']); $record['files'] = getFilesOfEntity($record['realm'], $record['id']); break; case 'file': $record['links'] = getFileLinks($record['id']); break; case 'location': $record['locations'] = getLocations($record['id']); $record['rows'] = getRows($record['id']); break; case 'row': $record['racks'] = getRacks($record['id']); case 'rack': $record['mountedObjects'] = array(); // start with default rackspace for ($i = $record['height']; $i > 0; $i--) { for ($locidx = 0; $locidx < 3; $locidx++) { $record[$i][$locidx]['state'] = 'F'; } } // load difference $query = "select unit_no, atom, state, object_id " . "from RackSpace where rack_id = ? and " . "unit_no between 1 and ? order by unit_no"; $result = usePreparedSelectBlade($query, array($record['id'], $record['height'])); global $loclist; $mounted_objects = array(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $record[$row['unit_no']][$loclist[$row['atom']]]['state'] = $row['state']; $record[$row['unit_no']][$loclist[$row['atom']]]['object_id'] = $row['object_id']; if ($row['state'] == 'T' and $row['object_id'] != NULL) { $mounted_objects[$row['object_id']] = TRUE; } } $record['mountedObjects'] = array_keys($mounted_objects); unset($result); break; case 'vst': $record['rules'] = array(); $record['switches'] = array(); $result = usePreparedSelectBlade('SELECT rule_no, port_pcre, port_role, wrt_vlans, description ' . 'FROM VLANSTRule WHERE vst_id = ? ORDER BY rule_no', array($record['id'])); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $record['rules'][$row['rule_no']] = $row; } unset($result); $result = usePreparedSelectBlade('SELECT object_id, domain_id FROM VLANSwitch WHERE template_id = ?', array($record['id'])); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $record['switches'][$row['object_id']] = $row; } break; default: } }
function renderFilesForEntity($entity_id) { global $pageno, $etype_by_pageno; // Now derive entity_type from pageno. $entity_type = $etype_by_pageno[$pageno]; startPortlet('Upload and link new'); echo "<table border=0 cellspacing=0 cellpadding='5' align='center' class='widetable'>\n"; echo "<tr><th>File</th><th>Comment</th><th></th></tr>\n"; printOpFormIntro('addFile', array(), TRUE); echo "<tr>"; echo "<td class=tdleft><input type='file' size='10' name='file' tabindex=100></td>\n"; echo "<td class=tdleft><textarea tabindex=101 name=comment rows=10 cols=80></textarea></td><td>\n"; printImageHREF('CREATE', 'Upload file', TRUE, 102); echo "</td></tr></form>"; echo "</table><br>\n"; finishPortlet(); $files = getAllUnlinkedFiles($entity_type, $entity_id); if (count($files)) { startPortlet('Link existing (' . count($files) . ')'); printOpFormIntro('linkFile'); echo "<table border=0 cellspacing=0 cellpadding='5' align='center'>\n"; echo '<tr><td class=tdleft>'; printSelect($files, array('name' => 'file_id')); echo '</td><td class=tdleft>'; printImageHREF('ATTACH', 'Link file', TRUE); echo '</td></tr></table>'; echo "</form>\n"; finishPortlet(); } $filelist = getFilesOfEntity($entity_type, $entity_id); if (count($filelist)) { startPortlet('Manage linked (' . count($filelist) . ')'); echo "<table border=0 cellspacing=0 cellpadding='5' align='center' class='widetable'>\n"; echo "<tr><th>File</th><th>Comment</th><th>Unlink</th></tr>\n"; foreach ($filelist as $file_id => $file) { echo "<tr valign=top><td class=tdleft>"; renderCell(spotEntity('file', $file_id)); echo "</td><td class=tdleft>{$file['comment']}</td><td class=tdcenter>"; echo getOpLink(array('op' => 'unlinkFile', 'link_id' => $file['link_id']), '', 'CUT', 'Unlink file'); echo "</td></tr>\n"; } echo "</table><br>\n"; finishPortlet(); } }