本文整理汇总了PHP中Computer::can方法的典型用法代码示例。如果您正苦于以下问题:PHP Computer::can方法的具体用法?PHP Computer::can怎么用?PHP Computer::can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::can方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pdfDevice
static function pdfDevice(PluginPdfSimplePDF $pdf, Computer $computer)
{
global $DB;
$devtypes = Item_Devices::getDeviceTypes();
$ID = $computer->getField('id');
if (!$computer->can($ID, 'r')) {
return false;
}
$pdf->setColumnsSize(100);
$pdf->displayTitle('<b>' . Toolbox::ucfirst(_n('Component', 'Components', 2)) . '</b>');
$pdf->setColumnsSize(3, 14, 42, 41);
foreach ($devtypes as $itemtype) {
$devicetypes = new $itemtype();
$specificities = $devicetypes->getSpecificities();
$specif_fields = array_keys($specificities);
$specif_text = implode(',', $specif_fields);
if (!empty($specif_text)) {
$specif_text = " ," . $specif_text . " ";
}
$associated_type = str_replace('Item_', '', $itemtype);
$linktable = getTableForItemType($itemtype);
$fk = getForeignKeyFieldForTable(getTableForItemType($associated_type));
$query = "SELECT count(*) AS NB, `id`, `" . $fk . "`" . $specif_text . "\n FROM `" . $linktable . "`\n WHERE `items_id` = '" . $ID . "'\n AND `itemtype` = 'Computer'\n GROUP BY `" . $fk . "`" . $specif_text;
$device = new $associated_type();
foreach ($DB->request($query) as $data) {
if ($device->getFromDB($data[$fk])) {
$spec = $device->getAdditionalFields();
$col4 = '';
if (count($spec)) {
$colspan = 60 / count($spec);
foreach ($spec as $i => $label) {
if (isset($device->fields[$label["name"]]) && !empty($device->fields[$label["name"]])) {
if ($label["type"] == "dropdownValue" && $device->fields[$label["name"]] != 0) {
$table = getTableNameForForeignKeyField($label["name"]);
$value = Dropdown::getDropdownName($table, $device->fields[$label["name"]]);
$col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', Html::clean($value) . " ");
} else {
$value = $device->fields[$label["name"]];
$col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', $value . " ");
}
} else {
if (isset($device->fields[$label["name"] . "_default"]) && !empty($device->fields[$label["name"] . "_default"])) {
$col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', $device->fields[$label["name"] . "_default"] . " ");
}
}
}
}
$pdf->displayLine($data['NB'], $device->getTypeName(), $device->getName(), $col4);
}
}
}
$pdf->displaySpace();
}
示例2: showForComputer
/**
* Print the computers disks
*
* @param $comp Computer object
*
* @return Nothing (call to classes members)
**/
static function showForComputer(Computer $comp)
{
global $DB;
$ID = $comp->fields['id'];
if (!$comp->getFromDB($ID) || !$comp->can($ID, "r")) {
return false;
}
$canedit = $comp->can($ID, "w");
echo "<div class='spaced center'>";
$virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}' AND `is_deleted` = '0'");
echo "<table class='tab_cadre_fixe'>";
Session::initNavigateListItems('ComputerVirtualMachine', sprintf(__('%1$s = %2$s'), __('Computer'), empty($comp->fields['name']) ? "({$ID})" : $comp->fields['name']));
if (empty($virtualmachines)) {
echo "<tr><th>" . __('No virtual machine associated with the computer') . "</th></tr>";
} else {
echo "<tr><th colspan='10'>" . __('List of virtual machines') . "</th></tr>";
echo "<tr><th>" . __('Name') . "</th>";
if (Plugin::haveImport()) {
echo "<th>" . __('Automatic inventory') . "</th>";
}
echo "<th>" . __('Virtualization system') . "</th>";
echo "<th>" . __('Virtualization model') . "</th>";
echo "<th>" . __('State of the virtual machine') . "</th>";
echo "<th>" . __('UUID') . "</th>";
echo "<th>" . _x('quantity', 'Processors number') . "</th>";
echo "<th>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</th>";
echo "<th>" . __('Machine') . "</th>";
echo "</tr>";
$vm = new self();
foreach ($virtualmachines as $virtualmachine) {
$vm->getFromDB($virtualmachine['id']);
echo "<tr class='tab_bg_2'>";
echo "<td>" . $vm->getLink() . "</td>";
if (Plugin::haveImport()) {
echo "<td>";
echo Dropdown::getYesNo($vm->isDynamic());
echo "</td>";
}
echo "<td>";
echo Dropdown::getDropdownName('glpi_virtualmachinetypes', $virtualmachine['virtualmachinetypes_id']);
echo "</td>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_virtualmachinesystems', $virtualmachine['virtualmachinesystems_id']);
echo "</td>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_virtualmachinestates', $virtualmachine['virtualmachinestates_id']);
echo "</td>";
echo "<td>" . $virtualmachine['uuid'] . "</a></td>";
echo "<td>" . $virtualmachine['vcpu'] . "</td>";
echo "<td>" . $virtualmachine['ram'] . "</td>";
echo "<td>";
if ($link_computer = self::findVirtualMachine($virtualmachine)) {
$computer = new Computer();
if ($computer->can($link_computer, 'r')) {
$url = "<a href='computer.form.php?id=" . $link_computer . "'>";
$url .= $computer->fields["name"] . "</a>";
$tooltip = "<table><tr><td>" . __('Name') . "</td><td>" . $computer->fields['name'] . '</td></tr>';
$tooltip .= "<tr><td>" . __('Serial number') . "</td><td>" . $computer->fields['serial'] . '</td></tr>';
$tooltip .= "<tr><td>" . __('Comments') . "</td><td>" . $computer->fields['comment'] . '</td></tr></table>';
$url .= " " . Html::showToolTip($tooltip, array('display' => false));
} else {
$url = $computer->fields['name'];
}
echo $url;
}
echo "</td>";
echo "</tr>";
Session::addToNavigateListItems('ComputerVirtualMachine', $virtualmachine['id']);
}
}
if ($canedit) {
echo "<tr class='tab_bg_1'><td colspan='8' class='center'>";
echo "<a class='vsubmit' href='computervirtualmachine.form.php?computers_id={$ID}'>" . __('Add a virtual machine') . "</a></td></tr>";
}
echo "</table>";
echo "</div>";
}
示例3: showForComputer
/**
* Print the computers disks
*
* @param $comp Computer object
* @param $withtemplate boolean Template or basic item (default '')
*
* @return Nothing (call to classes members)
**/
static function showForComputer(Computer $comp, $withtemplate = '')
{
global $DB;
$ID = $comp->fields['id'];
if (!$comp->getFromDB($ID) || !$comp->can($ID, READ)) {
return false;
}
$canedit = $comp->canEdit($ID);
if ($canedit && !(!empty($withtemplate) && $withtemplate == 2)) {
echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='computerdisk.form.php?computers_id={$ID}&withtemplate=" . $withtemplate . "'>";
_e('Add a volume');
echo "</a></div>\n";
}
echo "<div class='center'>";
$query = "SELECT `glpi_filesystems`.`name` AS fsname,\n `glpi_computerdisks`.*\n FROM `glpi_computerdisks`\n LEFT JOIN `glpi_filesystems`\n ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n WHERE `computers_id` = '{$ID}'\n AND `is_deleted` = '0'";
if ($result = $DB->query($query)) {
echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
$colspan = 7;
if (Plugin::haveImport()) {
$colspan++;
}
echo "<tr class='noHover'><th colspan='{$colspan}'>" . self::getTypeName($DB->numrows($result)) . "</th></tr>";
if ($DB->numrows($result)) {
$header = "<tr><th>" . __('Name') . "</th>";
if (Plugin::haveImport()) {
$header .= "<th>" . __('Automatic inventory') . "</th>";
}
$header .= "<th>" . __('Partition') . "</th>";
$header .= "<th>" . __('Mount point') . "</th>";
$header .= "<th>" . __('File system') . "</th>";
$header .= "<th>" . __('Global size') . "</th>";
$header .= "<th>" . __('Free size') . "</th>";
$header .= "<th>" . __('Free percentage') . "</th>";
$header .= "</tr>";
echo $header;
Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName()));
$disk = new self();
while ($data = $DB->fetch_assoc($result)) {
$disk->getFromDB($data['id']);
echo "<tr class='tab_bg_2'>";
echo "<td>" . $disk->getLink() . "</td>";
if (Plugin::haveImport()) {
echo "<td>" . Dropdown::getYesNo($data['is_dynamic']) . "</td>";
}
echo "<td>" . $data['device'] . "</td>";
echo "<td>" . $data['mountpoint'] . "</td>";
echo "<td>" . $data['fsname'] . "</td>";
//TRANS: %s is a size
$tmp = sprintf(__('%s Mio'), Html::formatNumber($data['totalsize'], false, 0));
echo "<td class='right'>{$tmp}<span class='small_space'></span></td>";
$tmp = sprintf(__('%s Mio'), Html::formatNumber($data['freesize'], false, 0));
echo "<td class='right'>{$tmp}<span class='small_space'></span></td>";
echo "<td>";
$percent = 0;
if ($data['totalsize'] > 0) {
$percent = round(100 * $data['freesize'] / $data['totalsize']);
}
Html::displayProgressBar('100', $percent, array('simple' => true, 'forcepadding' => false));
echo "</td>";
echo "</tr>";
Session::addToNavigateListItems(__CLASS__, $data['id']);
}
echo $header;
} else {
echo "<tr class='tab_bg_2'><th colspan='{$colspan}'>" . __('No item found') . "</th></tr>";
}
echo "</table>";
}
echo "</div><br>";
}
示例4: showForComputer
/**
* Print the computers disks
*
* @param $comp Computer
*
* @return Nothing (call to classes members)
**/
static function showForComputer(Computer $comp)
{
global $DB, $LANG;
$ID = $comp->fields['id'];
if (!$comp->getFromDB($ID) || !$comp->can($ID, "r")) {
return false;
}
$canedit = $comp->can($ID, "w");
echo "<div class='spaced center'>";
$virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}'");
echo "<table class='tab_cadre_fixe'>";
if (empty($virtualmachines)) {
echo "<tr><th>" . $LANG['computers'][59] . "</th></tr>";
} else {
echo "<tr><th colspan='9'>" . $LANG['computers'][66] . "</th></tr>";
echo "<tr><th>" . $LANG['common'][16] . "</th>";
echo "<th>" . $LANG['computers'][62] . "</th>";
echo "<th>" . $LANG['computers'][60] . "</th>";
echo "<th>" . $LANG['computers'][63] . "</th>";
echo "<th>" . $LANG['computers'][58] . "</th>";
echo "<th>" . $LANG['computers'][61] . "</th>";
echo "<th>" . $LANG['computers'][24] . "</th>";
echo "<th>" . $LANG['computers'][64] . "</th>";
echo "</tr>";
initNavigateListItems('ComputerVirtualMachine', $LANG['help'][25] . " = " . (empty($comp->fields['name']) ? "({$ID})" : $comp->fields['name']));
foreach ($virtualmachines as $virtualmachine) {
$href = "<a href='computervirtualmachine.form.php?id=" . $virtualmachine['id'] . "'>";
echo "<tr class='tab_bg_2'>";
echo "<td>{$href}" . $virtualmachine['name'] . "</a></td>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_virtualmachinetypes', $virtualmachine['virtualmachinetypes_id']);
echo "</td>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_virtualmachinesystems', $virtualmachine['virtualmachinesystems_id']);
echo "</td>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_virtualmachinestates', $virtualmachine['virtualmachinestates_id']);
echo "</td>";
echo "<td>{$href}" . $virtualmachine['uuid'] . "</a></td>";
echo "<td>" . $virtualmachine['vcpu'] . "</td>";
echo "<td>" . $virtualmachine['ram'] . "</td>";
echo "<td>";
if ($link_computer = self::findVirtualMachine($virtualmachine)) {
$computer = new Computer();
if ($computer->can($link_computer, 'r')) {
$url = "<a href='computer.form.php?id=" . $link_computer . "'>";
$url .= $computer->fields["name"] . "</a>";
$tooltip = $LANG['common'][16] . " : " . $computer->fields['name'];
$tooltip .= "<br>" . $LANG['common'][19] . " : ";
$tooltip .= "<br>" . $computer->fields['serial'];
$tooltip .= "<br>" . $computer->fields['comment'];
$url .= " " . showToolTip($tooltip, array('display' => false));
} else {
$url = $computer->fields['name'];
}
echo $url;
}
echo "</td>";
echo "</tr>";
addToNavigateListItems('ComputerVirtualMachine', $virtualmachine['id']);
}
}
if ($canedit) {
echo "<tr class='tab_bg_2'><th colspan='8'>";
echo "<a href='computervirtualmachine.form.php?computers_id={$ID}'>" . $LANG['computers'][55] . "</a></th></tr>";
}
echo "</table>";
echo "</div>";
}
示例5: showForComputer
/**
* Print the computers antiviruses
*
* @param $comp Computer object
* @param $withtemplate boolean Template or basic item (default '')
*
* @return Nothing (call to classes members)
**/
static function showForComputer(Computer $comp, $withtemplate = '')
{
global $DB;
$ID = $comp->fields['id'];
if (!$comp->getFromDB($ID) || !$comp->can($ID, READ)) {
return false;
}
$canedit = $comp->canEdit($ID);
if ($canedit && !(!empty($withtemplate) && $withtemplate == 2)) {
echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='computerantivirus.form.php?computers_id={$ID}&withtemplate=" . $withtemplate . "'>";
_e('Add an antivirus');
echo "</a></div>\n";
}
echo "<div class='spaced center'>";
if ($result = $DB->request('glpi_computerantiviruses', array('computers_id' => $ID, 'is_deleted' => 0))) {
echo "<table class='tab_cadre_fixehov'>";
$colspan = 7;
if (Plugin::haveImport()) {
$colspan++;
}
echo "<tr class='noHover'><th colspan='{$colspan}'>" . self::getTypeName($result->numrows()) . "</th></tr>";
if ($result->numrows() != 0) {
$header = "<tr><th>" . __('Name') . "</th>";
if (Plugin::haveImport()) {
$header .= "<th>" . __('Automatic inventory') . "</th>";
}
$header .= "<th>" . __('Manufacturer') . "</th>";
$header .= "<th>" . __('Antivirus version') . "</th>";
$header .= "<th>" . __('Signature database version') . "</th>";
$header .= "<th>" . __('Active') . "</th>";
$header .= "<th>" . __('Up to date') . "</th>";
$header .= "<th>" . __('Expiration date') . "</th>";
$header .= "</tr>";
echo $header;
Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName()));
$antivirus = new self();
foreach ($result as $data) {
$antivirus->getFromDB($data['id']);
echo "<tr class='tab_bg_2'>";
echo "<td>" . $antivirus->getLink() . "</td>";
if (Plugin::haveImport()) {
echo "<td>" . Dropdown::getYesNo($data['is_dynamic']) . "</td>";
}
echo "<td>";
if ($data['manufacturers_id']) {
echo Dropdown::getDropdownName('glpi_manufacturers', $data['manufacturers_id']) . "</td>";
} else {
echo "</td>";
}
echo "<td>" . $data['antivirus_version'] . "</td>";
echo "<td>" . $data['signature_version'] . "</td>";
echo "<td>" . Dropdown::getYesNo($data['is_active']) . "</td>";
echo "<td>" . Dropdown::getYesNo($data['is_uptodate']) . "</td>";
echo "<td>" . Html::convDate($data['date_expiration']) . "</td>";
echo "</tr>";
Session::addToNavigateListItems(__CLASS__, $data['id']);
}
echo $header;
} else {
echo "<tr class='tab_bg_2'><th colspan='{$colspan}'>" . __('No item found') . "</th></tr>";
}
echo "</table>";
}
echo "</div>";
}
示例6: showForComputer
/**
* Print the form for devices linked to a computer or a template
*
* @param $computer Computer object
* @param $withtemplate='' boolean : template or basic computer
*
* @return Nothing (display)
**/
static function showForComputer(Computer $computer, $withtemplate = '')
{
global $DB, $LANG;
$devtypes = self::getDeviceTypes();
$ID = $computer->getField('id');
if (!$computer->can($ID, 'r')) {
return false;
}
$canedit = $withtemplate != 2 && $computer->can($ID, 'w');
echo "<div class='spaced'>";
if ($canedit) {
echo "<form name='form_device_action' action='" . getItemTypeFormURL(__CLASS__) . "' method='post'>";
echo "<input type='hidden' name='computers_id' value='{$ID}'>";
}
echo "<table class='tab_cadre_fixe' >";
echo "<tr><th colspan='63'>" . $LANG['title'][30] . "</th></tr>";
$nb = 0;
$specificity_units = array('DeviceProcessor' => $LANG['setup'][35], 'DeviceMemory' => $LANG['common'][82], 'DeviceHardDrive' => $LANG['common'][82], 'DeviceGraphicCard' => $LANG['common'][82]);
foreach ($devtypes as $itemtype) {
initNavigateListItems($itemtype, $computer->getTypeName() . " = " . $computer->getName());
$device = new $itemtype();
$specificities = $device->getSpecifityLabel();
$specif_fields = array_keys($specificities);
$specif_text = implode(',', $specif_fields);
if (!empty($specif_text)) {
$specif_text = " ," . $specif_text . " ";
}
$linktable = getTableForItemType('Computer_' . $itemtype);
$fk = getForeignKeyFieldForTable(getTableForItemType($itemtype));
$query = "SELECT COUNT(*) AS NB,\n `id`,\n `{$fk}`\n {$specif_text}\n FROM `{$linktable}`\n WHERE `computers_id` = '{$ID}'\n GROUP BY `{$fk}` {$specif_text}";
$prev = '';
foreach ($DB->request($query) as $data) {
addToNavigateListItems($itemtype, $data[$fk]);
if ($device->getFromDB($data[$fk])) {
echo "<tr class='tab_bg_2'>";
echo "<td class='center'>";
Dropdown::showInteger("quantity_" . $itemtype . "_" . $data['id'], $data['NB']);
echo "</td><td>";
if ($device->canCreate()) {
echo "<a href='" . $device->getSearchURL() . "'>" . $device->getTypeName() . "</a>";
} else {
echo $device->getTypeName();
}
echo "</td><td>" . $device->getLink() . "</td>";
$spec = $device->getFormData();
if (isset($spec['label']) && count($spec['label'])) {
$colspan = 60 / count($spec['label']);
foreach ($spec['label'] as $i => $label) {
if (isset($spec['value'][$i])) {
echo "<td colspan='{$colspan}'>" . $spec['label'][$i] . " : ";
echo $spec['value'][$i] . "</td>";
} else {
if ($canedit) {
// Specificity
echo "<td class='right' colspan='{$colspan}'>" . $spec['label'][$i] . " : ";
echo "<input type='text' name='value_" . $itemtype . "_" . $data['id'] . "' value='" . $data['specificity'] . "' size='" . $spec['size'] . "'>";
if (isset($specificity_units[$device->getType()])) {
echo ' ' . $specificity_units[$device->getType()];
}
echo "</td>";
} else {
echo "<td colspan='{$colspan}'>" . $spec['label'][$i] . " : ";
echo $data['specificity'];
if (isset($specificity_units[$device->getType()])) {
echo ' ' . $specificity_units[$device->getType()];
}
echo "</td>";
}
}
}
} else {
echo "<td colspan='60'> </td>";
}
echo "</tr>";
$nb++;
}
}
}
if ($canedit) {
if ($nb > 0) {
echo "<tr><td colspan='63' class='tab_bg_1 center'>";
echo "<input type='submit' class='submit' name='updateall' value='" . $LANG['buttons'][7] . "'></td></tr>";
}
echo "<tr><td colspan='63' class='tab_bg_1 center'>";
echo $LANG['devices'][0] . " : ";
Dropdown::showAllItems('items_id', '', 0, -1, $devtypes);
echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
echo "</tr></table></form>";
} else {
echo "</table>";
}
echo "</div>";
//.........这里部分代码省略.........
示例7: showForComputer
/**
*
* Print the form for computers or templates connections to printers, screens or peripherals
*
* @param $comp Computer object
* @param $withtemplate boolean Template or basic item (default '')
*
* @return Nothing (call to classes members)
**/
static function showForComputer(Computer $comp, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $comp->fields['id'];
$canedit = $comp->can($ID, 'w');
$rand = mt_rand();
$datas = array();
$used = array();
foreach ($CFG_GLPI["directconnect_types"] as $itemtype) {
$item = new $itemtype();
if ($item->canView()) {
$query = "SELECT `glpi_computers_items`.`id` as assoc_id,\n `glpi_computers_items`.`computers_id` as assoc_computers_id,\n `glpi_computers_items`.`itemtype` as assoc_itemtype,\n `glpi_computers_items`.`items_id` as assoc_items_id,\n `glpi_computers_items`.`is_dynamic` as assoc_is_dynamic,\n " . getTableForItemType($itemtype) . ".*\n FROM `glpi_computers_items`\n LEFT JOIN `" . getTableForItemType($itemtype) . "`\n ON (`" . getTableForItemType($itemtype) . "`.`id`\n = `glpi_computers_items`.`items_id`)\n WHERE `computers_id` = '{$ID}'\n AND `itemtype` = '" . $itemtype . "'\n AND `glpi_computers_items`.`is_deleted` = '0'";
if ($item->maybetemplate()) {
$query .= " AND NOT `" . getTableForItemType($itemtype) . "`.`is_template` ";
}
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$datas[] = $data;
$used[$itemtype][] = $data['assoc_items_id'];
}
}
}
}
$number = count($datas);
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='computeritem_form{$rand}' id='computeritem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Connect an item') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='right'>";
// Dropdown::showAllItems("items_id", 0, 0, $comp->fields['entities_id'],
// $CFG_GLPI["directconnect_types"], false, true);
if (!empty($withtemplate)) {
echo "<input type='hidden' name='_no_history' value='1'>";
}
self::dropdownAllConnect('Computer', "items_id", $comp->fields["entities_id"], $withtemplate, $used);
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Connect') . "\" class='submit'>";
echo "<input type='hidden' name='computers_id' value='" . $comp->fields['id'] . "'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
if ($number) {
echo "<div class='spaced'>";
if ($canedit) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number, 'specific_actions' => array('purge' => _x('button', 'Disconnect')));
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Type') . "</th>";
echo "<th>" . __('Name') . "</th>";
if (Plugin::haveImport()) {
echo "<th>" . __('Automatic inventory') . "</th>";
}
echo "<th>" . __('Entity') . "</th>";
echo "<th>" . __('Serial number') . "</th>";
echo "<th>" . __('Inventory number') . "</th>";
echo "</tr>";
foreach ($datas as $data) {
$linkname = $data["name"];
$itemtype = $data['assoc_itemtype'];
if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
$linkname = sprintf(__('%1$s (%2$s)'), $linkname, $data["id"]);
}
$link = Toolbox::getItemTypeFormURL($itemtype);
$name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $linkname . "</a>";
echo "<tr class='tab_bg_1'>";
if ($canedit) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assoc_id"]);
echo "</td>";
}
echo "<td class='center'>" . $data['assoc_itemtype']::getTypeName(1) . "</td>";
echo "<td " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
if (Plugin::haveImport()) {
echo "<td>";
echo Dropdown::getYesNo($data['assoc_is_dynamic']);
echo "</td>";
}
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']);
echo "</td>";
echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
echo "</tr>";
//.........这里部分代码省略.........
示例8: Computer
if (!isset($_POST["id"])) {
exit;
}
if (!isset($_POST["sort"])) {
$_POST["sort"] = "";
}
if (!isset($_POST["order"])) {
$_POST["order"] = "";
}
if (!isset($_POST["withtemplate"])) {
$_POST["withtemplate"] = "";
}
checkRight("computer", "r");
$computer = new Computer();
//show computer form to add
if ($_POST["id"] > 0 && $computer->can($_POST["id"], 'r')) {
if (!empty($_POST["withtemplate"])) {
switch ($_REQUEST['glpi_tab']) {
case 2:
Computer_SoftwareVersion::showForComputer($computer, $_POST["withtemplate"]);
break;
case 3:
Computer_Item::showForComputer($_POST['target'], $computer, $_POST["withtemplate"]);
NetworkPort::showForItem('Computer', $_POST["id"], $_POST["withtemplate"]);
break;
case 4:
Infocom::showForItem($computer, $_POST["withtemplate"]);
Contract::showAssociated($computer, $_POST["withtemplate"]);
break;
case 5:
Document::showAssociated($computer, $_POST["withtemplate"]);
示例9: showForComputer
/**
* Print the computers or template local connections form.
*
* Print the form for computers or templates connections to printers, screens or peripherals
*
*@param $target
*@param $comp Computer object
*@param $withtemplate='' boolean : Template or basic item.
*
*@return Nothing (call to classes members)
**/
static function showForComputer($target, Computer $comp, $withtemplate = '')
{
global $DB, $CFG_GLPI, $LANG;
$ID = $comp->fields['id'];
$canedit = $comp->can($ID, 'w');
$items = array('Monitor', 'Peripheral', 'Phone', 'Printer');
$datas = array();
foreach ($items as $itemtype) {
$item = new $itemtype();
if ($item->canView()) {
$query = "SELECT *\n FROM `glpi_computers_items`\n WHERE `computers_id` = '{$ID}'\n AND `itemtype` = '" . $itemtype . "'";
$result = $DB->query($query);
if ($result) {
$nb = $DB->numrows($result);
$datas[$itemtype]['result'] = $result;
$datas[$itemtype]['title'] = $item->getTypeName($nb);
}
}
}
if (count($datas)) {
echo "<div class='spaced'><table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>" . $LANG['connect'][2] . " :</th></tr>";
//echo "<tr class='tab_bg_1'>";
$items_displayed = 0;
$nbperline = 2;
foreach ($datas as $itemtype => $data) {
$used = array();
// Line change
if ($items_displayed % $nbperline == 0) {
// Begin case
if ($items_displayed != 0) {
echo "</tr>";
}
echo "<tr>";
$count = 0;
$header_displayed = 0;
foreach ($datas as $tmp_data) {
if ($count >= $items_displayed && $header_displayed < $nbperline) {
echo "<th>" . $tmp_data['title'] . " :</th>";
$header_displayed++;
}
$count++;
}
// Add header if line not complete
while ($header_displayed % $nbperline != 0) {
echo "<th> </th>";
$header_displayed++;
}
echo "</tr><tr class='tab_bg_1'>";
}
echo "<td class='center'>";
$resultnum = $DB->numrows($data['result']);
$item = new $itemtype();
if ($resultnum > 0) {
echo "<table width='100%'>";
for ($i = 0; $i < $resultnum; $i++) {
$tID = $DB->result($data['result'], $i, "items_id");
$connID = $DB->result($data['result'], $i, "id");
$item->getFromDB($tID);
$used[] = $tID;
echo "<tr " . ($item->isDeleted() ? "class='tab_bg_2_2'" : "") . ">";
echo "<td class='center'><strong>" . $item->getLink() . "</strong>";
echo " - " . Dropdown::getDropdownName("glpi_states", $item->getField('state'));
echo "</td><td>" . $item->getField('serial');
echo "</td><td>" . $item->getField('otherserial');
echo "</td><td>";
if ($canedit && (empty($withtemplate) || $withtemplate != 2)) {
echo "<td class='center'>";
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/computer.form.php?computers_id={$ID}&id={$connID}&" . "disconnect=1&withtemplate=" . $withtemplate . "\">";
echo "<strong>" . $LANG['buttons'][10] . "</strong></a></td>";
}
echo "</tr>";
}
echo "</table>";
} else {
switch ($itemtype) {
case 'Printer':
echo $LANG['computers'][38];
break;
case 'Monitor':
echo $LANG['computers'][37];
break;
case 'Peripheral':
echo $LANG['computers'][47];
break;
case 'Phone':
echo $LANG['computers'][54];
break;
}
//.........这里部分代码省略.........
示例10: showForComputer
/**
* Print the computers disks
*
* @param $comp Computer
* @param $withtemplate='' boolean : Template or basic item.
*
* @return Nothing (call to classes members)
**/
static function showForComputer(Computer $comp, $withtemplate = '')
{
global $DB, $LANG;
$ID = $comp->fields['id'];
if (!$comp->getFromDB($ID) || !$comp->can($ID, "r")) {
return false;
}
$canedit = $comp->can($ID, "w");
echo "<div class='center'>";
$query = "SELECT `glpi_filesystems`.`name` AS fsname,\n `glpi_computerdisks`.*\n FROM `glpi_computerdisks`\n LEFT JOIN `glpi_filesystems`\n ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n WHERE (`computers_id` = '{$ID}')";
if ($result = $DB->query($query)) {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='7'>";
if ($DB->numrows($result) == 1) {
echo $LANG['computers'][0];
} else {
echo $LANG['computers'][8];
}
echo "</th></tr>";
if ($DB->numrows($result)) {
echo "<tr><th>" . $LANG['common'][16] . "</th>";
echo "<th>" . $LANG['computers'][6] . "</th>";
echo "<th>" . $LANG['computers'][5] . "</th>";
echo "<th>" . $LANG['computers'][4] . "</th>";
echo "<th>" . $LANG['computers'][3] . "</th>";
echo "<th>" . $LANG['computers'][2] . "</th>";
echo "<th>" . $LANG['computers'][1] . "</th>";
echo "</tr>";
initNavigateListItems('ComputerDisk', $LANG['help'][25] . " = " . (empty($comp->fields['name']) ? "({$ID})" : $comp->fields['name']));
while ($data = $DB->fetch_assoc($result)) {
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td><a href='computerdisk.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? $data['id'] : "") . "</a></td>";
} else {
echo "<td>" . $data['name'] . (empty($data['name']) ? $data['id'] : "") . "</td>";
}
echo "<td>" . $data['device'] . "</td>";
echo "<td>" . $data['mountpoint'] . "</td>";
echo "<td>" . $data['fsname'] . "</td>";
echo "<td class='right'>" . formatNumber($data['totalsize'], false, 0) . " " . $LANG['common'][82] . "<span class='small_space'></span></td>";
echo "<td class='right'>" . formatNumber($data['freesize'], false, 0) . " " . $LANG['common'][82] . "<span class='small_space'></span></td>";
echo "<td>";
$percent = 0;
if ($data['totalsize'] > 0) {
$percent = round(100 * $data['freesize'] / $data['totalsize']);
}
displayProgressBar('100', $percent, array('simple' => true, 'forcepadding' => false));
echo "</td>";
addToNavigateListItems('ComputerDisk', $data['id']);
}
} else {
echo "<tr><th colspan='7'>" . $LANG['search'][15] . "</th></tr>";
}
if ($canedit && !(!empty($withtemplate) && $withtemplate == 2)) {
echo "<tr class='tab_bg_2'><th colspan='7'>";
echo "<a href='computerdisk.form.php?computers_id={$ID}&withtemplate=" . $withtemplate . "'>" . $LANG['computers'][7] . "</a></th></tr>";
}
echo "</table>";
}
echo "</div><br>";
}