$hosts[] = $r["hostname"]; //rtrim($r[1],"."); $types[] = $r["type"]; $values[] = getRecordValueDescription($zone, $r["type"], $r["value"]); $params[] = array("zone" => $zone, "reverse" => $reverse, "id" => $r["id"], "serial" => $serial); $actionsMod[] = $editAction; if ($r["hostname"] === $curzone . "." && $r["type"] === "TXT" || $r["type"] == "SOA") { $actionsDel[] = $emptyAction; } else { $actionsDel[] = $delAction; } } //print_r($values); $typeAsc = $sortby == "type" ? intval(!$asc) : "1"; $hostnameAsc = $sortby == "hostname" ? intval(!$asc) : "1"; $typeUrl = urlStr("network/network/zonerecords", array("zone" => $zone, "reverse" => $reverse, "sortby" => "type", "asc" => $typeAsc)); $hostnameUrl = urlStr("network/network/zonerecords", array("zone" => $zone, "reverse" => $reverse, "sortby" => "hostname", "asc" => $hostnameAsc)); $n = new OptimizedListInfos($hosts, "<a href='" . $hostnameUrl . "'>" . _T("Host name", "network") . "</a>"); $n->setTableHeaderPadding(1); $n->setNavBar(new AjaxNavBar(count($records), $filter)); $n->setItemCount(count($records)); $n->start = 0; $n->end = count($recordsatpage) - 1; $n->addExtraInfo($types, "<a href='" . $typeUrl . "'>" . _T("Record type", "network")) . "</a>"; $n->addExtraInfo($values, _T("Record parameters", "network")); $n->setName(_T("Host", "network")); $n->setParamInfo($params); $n->disableFirstColumnActionLink(); $n->addActionItemArray($actionsMod); $n->addActionItemArray($actionsDel); $n->display();
function display_part($part, $get, $simpleTableParts, $displayNavBar = True, $partTitle = null) { $uuid = ''; if (isset($get['uuid'])) { $uuid = $get['uuid']; } elseif (isset($get['objectUUID'])) { $uuid = $get['objectUUID']; } $maxperpage = isset($get['maxperpage']) ? $get['maxperpage'] : 0; $filter = isset($get["filter"]) ? $get['filter'] : ''; if (isset($get["start"])) { $start = $get["start"]; } else { $start = 0; } $end = $start + $maxperpage; $hide_win_updates = isset($get['hide_win_updates']) ? $get['hide_win_updates'] : False; $hide_win_updates = strtolower($hide_win_updates) == 'true' ? True : False; $history_delta = isset($get['history_delta']) ? $get['history_delta'] : False; $options = array('hide_win_updates' => $hide_win_updates, 'history_delta' => $history_delta); // Get current part inventory $inv = getLastMachineGlpiPart($uuid, $part, $start, $end, $filter, $options); $itemCount = countLastMachineGlpiPart($uuid, $part, $filter, $options); if (!is_array($inv)) { $inv = array(); } // this piece of code re-format inventory array // $all variable will contain part's inventory $all = array(); $i = 0; foreach ($inv as $line) { foreach ($line as $vals) { /* * If $vals[1] is an empty string or an array, don't use the _T() function * Empty fields are replaced by a trademark text by transifex * if it's an array, it's an editable field */ $vals[1] = str_replace('@@FALSE_POSITIVE@@', _T(' (Not an antivirus)', 'glpi'), $vals[1]); $all[$vals[0]][$i] = ''; if (!is_array($vals[1]) && $vals[1] != '') { // translatable fields $all[$vals[0]][$i] = _T($vals[1]); } elseif (is_array($vals[1])) { // editable fields $all[$vals[0]][$i] = $vals[1]; } } $i++; } /* * simpleTableParts are parts who are *not* displayed * in a multi-line table */ // Simple table if (in_array($part, $simpleTableParts)) { $key = array(); $val = array(); foreach (array_keys($all) as $k) { $key[] = _T($k, 'glpi'); if ($k == 'Serial Number') { $val[] = str_replace('@@WARRANTY_LINK_TEXT@@', _T('Click here to see this computer on manufacturer website', 'glpi'), $all[$k][0]); } else { /* * if $all[$k][0] is an array, it's an editable value * $editable = array(uniquename, type, value) */ if (is_array($all[$k][0])) { $editable = $all[$k][0]; $val[] = sprintf('<label class="editableField" name="%s" data="%s" style="height:1em;">%s</label>', $editable[0], $editable[1], $editable[2]) . sprintf('<input type="text" class="editableField" name="%s" value="%s" style="display:none" />', $editable[0], $editable[2]); } else { $val[] = $all[$k][0]; } } } $n = new ListInfos($key, _T("Properties", "glpi")); $n->addExtraInfo($val, _T("Value", "glpi")); /* * $_GET['maxperpage'] is set to 10 by default * If there is more than 10 elements, they don't be displayed * So setRowsPerPage equal to number of elements to display */ $n->setRowsPerPage(count($all)); $n->drawTable(0); } else { $n = null; // If nothing found, display a "nothing found" message // except on Hardware tab (identified by $partTitle == null) => display nothing if (count($all) == 0 && $partTitle == null) { switch ($part) { case 'History': printf('<p>%s</p>', _T('No record found for this period.', 'glpi')); break; case 'Antivirus': printf('<p>%s</p>', _T('Unable to detect any Antivirus software on this machine.', 'glpi')); printf('<p>%s</p>', _T('Please ensure you are running GLPI with FusionInventory plugin and FusionInventory Agent on this client.', 'glpi')); break; default: printf('<p>%s</p>', _T('No record found.', 'glpi')); } } // Put datas in a ListInfos object foreach ($all as $k => $v) { if ($n == null) { $n = new OptimizedListInfos($v, _T($k, 'glpi')); } else { $n->addExtraInfo($v, _T($k, 'glpi')); } } // display table if ($n) { $n->setItemCount($itemCount); $n->setNavBar(new AjaxNavBar($itemCount, $filter)); $n->disableFirstColumnActionLink(); $n->setTableHeaderPadding(1); $n->start = 0; $n->end = $itemCount; // Display a title (it happens in Hardware tab) if ($partTitle) { printf("<h2>%s</h2>", $partTitle); } // Display table with (or not) NavBar $n->display($displayNavBar, $displayNavBar); if ($partTitle) { echo "<br />"; } } } }
$a_create[] = $script['fk_boot_service'] ? $bsCreatedAction : $createAction; } else { $url = '<img src="modules/imaging/graph/images/postinst-action-ro.png" style="vertical-align: middle" /> '; $a_edit[] = $emptyAction; $a_delete[] = $emptyAction; // Don't display "Create Boot Service" icon if a Boot Service already created // from this PostInstall entry $a_create[] = $script['fk_boot_service'] ? $bsCreatedAction : $createAction; } $a_label[] = sprintf("%s%s", $url, $script['default_name']); $a_desc[] = $script["default_desc"]; $l_params = array(); $l_params["itemid"] = $script['imaging_uuid']; $l_params["itemlabel"] = $script["default_name"]; $list_params[] = $l_params; } // show scripts list $l = new OptimizedListInfos($a_label, _T("Name", "imaging")); $l->addExtraInfo($a_desc, _T("Description", "imaging")); $l->setParamInfo($list_params); $l->addActionItemArray($a_edit); $l->addActionItem($a_create); $l->addActionItem(new ActionItem(_T("Duplicate", "imaging"), "postinstall_duplicate", "duplicatescript", "image", "imaging", "manage")); $l->addActionItemArray($a_delete); $l->setTableHeaderPadding(19); $l->disableFirstColumnActionLink(); $l->setItemCount($count); $l->setNavBar(new AjaxNavBar($count, $filter, "updateSearchParamformLevel2")); $l->start = 0; $l->end = $maxperpage; $l->display();
// Create an array with the inventory dates $inventories = array(); // Create an array with the "new_machine" booleans $new_machines = array(); // Create an array with $params needed for cliquable first column $params = array(); foreach ($incoming as $inc) { $machines[] = $inc[0]; $inventories[] = _toDate($inc[1]); $new_machines[] = $inc[2]; $params[] = array('hostname' => $inc[0], 'uuid' => $inc[3]); } // Create the listinfos widget, the first column is the machine name $l = new OptimizedListInfos($machines, _T("Computer name")); // Add the second column, which is the inventory date $l->addExtraInfo($inventories, _T("Inventory date")); // Add the third column, which is the boolean "new_machine" $l->addExtraInfo($new_machines, _T("New computer")); // Add actions item, to make first column cliquable $l->addActionItem(new ActionItem(_T("View", "inventory"), "invtabs", "display", "inventory", "base", "computers")); $l->addActionItem(new ActionPopupItem(_T("Information", "inventory"), "infos", "info", "inventory", "inventory", "inventory")); $l->setParamInfo($params); // Navbar for an Ajax widget $l->setItemCount($count); $l->setNavBar(new AjaxNavBar($count, $filter)); // Item counter label $l->setName(_T("Elements")); $l->setTableHeaderPadding(0); $l->start = 0; $l->end = count($machines); $l->display();