本文整理汇总了PHP中CommonDBTM::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::getID方法的具体用法?PHP CommonDBTM::getID怎么用?PHP CommonDBTM::getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::getID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showNetworkEquipmentInformation
function showNetworkEquipmentInformation(CommonDBTM $item, $options)
{
global $DB;
$id = $item->getID();
if (!($data = $this->find("`networkequipments_id`='" . $id . "'", '', 1))) {
// Add in database if not exist
$input = array();
$input['networkequipments_id'] = $id;
$_SESSION['glpi_plugins_fusinvsnmp_table'] = 'glpi_networkequipments';
$ID_tn = $this->add($input);
$this->getFromDB($ID_tn);
} else {
foreach ($data as $datas) {
$this->fields = $datas;
}
}
// Form networking informations
echo "<form name='form' method='post' action='" . $options['target'] . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<th colspan='4'>";
echo __('SNMP information', 'fusioninventory');
echo "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td align='center' rowspan='4'>";
echo __('Sysdescr', 'fusioninventory') . " :";
echo "</td>";
echo "<td rowspan='4'>";
echo "<textarea name='sysdescr' cols='45' rows='5'>";
echo $this->fields['sysdescr'];
echo "</textarea>";
echo "<td align='center'></td>";
echo "<td align='center'>";
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td align='center'>" . __('SNMP authentication', 'fusioninventory') . " :</td>";
echo "<td align='center'>";
PluginFusioninventoryConfigSecurity::auth_dropdown($this->fields['plugin_fusioninventory_configsecurities_id']);
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td align='center'>";
echo __('CPU usage (in %)', 'fusioninventory') . " :";
echo "</td>";
echo "<td>";
Html::displayProgressBar(250, $this->fields['cpu'], array('simple' => TRUE));
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td align='center'>";
echo __('Memory usage (in %)', 'fusioninventory') . " :";
echo "</td>";
echo "<td>";
$query2 = "SELECT *\n FROM `glpi_networkequipments`\n WHERE `id`='" . $id . "';";
$result2 = $DB->query($query2);
$data2 = $DB->fetch_assoc($result2);
$ram_pourcentage = 0;
if (!empty($data2["ram"]) and !empty($this->fields['memory'])) {
$ram_pourcentage = ceil(100 * ($data2["ram"] - $this->fields['memory']) / $data2["ram"]);
}
if ($data2["ram"] - $this->fields['memory'] < 0 or empty($this->fields['memory'])) {
echo "<center><strong>" . __('Datas not available', 'fusioninventory') . "</strong></center>";
} else {
Html::displayProgressBar(250, $ram_pourcentage, array('title' => " (" . ($data2["ram"] - $this->fields['memory']) . " Mo / " . $data2["ram"] . " Mo)"));
}
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_2 center'>";
echo "<td colspan='4'>";
echo "<input type='hidden' name='id' value='" . $id . "'>";
echo "<input type='submit' name='update' value=\"" . __('Update') . "\" class='submit' >";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
示例2: showForItem
/**
* Show ports for an item
*
* @param $item CommonDBTM object
* @param $withtemplate integer withtemplate param (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$rand = mt_rand();
$itemtype = $item->getType();
$items_id = $item->getField('id');
if (!Session::haveRight('networking', 'r') || !$item->can($items_id, 'r')) {
return false;
}
$netport = new self();
$netport->item = $item;
if ($itemtype == 'NetworkPort') {
$canedit = false;
} else {
$canedit = $item->can($items_id, 'w');
}
$showmassiveactions = false;
if ($withtemplate != 2) {
$showmassiveactions = $canedit;
}
// Show Add Form
if ($canedit && (empty($withtemplate) || $withtemplate != 2)) {
echo "\n<form method='get' action='" . $netport->getFormURL() . "'>\n";
echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>\n";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>\n";
echo "<div class='firstbloc'><table class='tab_cadre_fixe'>\n";
echo "<tr class='tab_bg_2'><td class='center'>\n";
_e('Network port type to be added');
echo " ";
$instantiations = array();
foreach (self::getNetworkPortInstantiations() as $inst_type) {
if (call_user_func(array($inst_type, 'canCreate'))) {
$instantiations[$inst_type] = call_user_func(array($inst_type, 'getTypeName'));
}
}
Dropdown::showFromArray('instantiation_type', $instantiations, array('value' => 'NetworkPortEthernet'));
echo "</td>\n";
echo "<td class='tab_bg_2 center' width='50%'>";
_e('Add several ports');
echo " <input type='checkbox' name='several' value='1'></td>\n";
echo "<td>\n";
echo "<input type='submit' name='create' value=\"" . _sx('button', 'Add') . "\" class='submit'>\n";
echo "</td></tr></table></div>\n";
Html::closeForm();
}
if ($showmassiveactions) {
$checkbox_column = true;
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
} else {
$checkbox_column = false;
}
$is_active_network_port = false;
Session::initNavigateListItems('NetworkPort', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
if ($itemtype == 'NetworkPort') {
$porttypes = array('NetworkPortAlias', 'NetworkPortAggregate');
} else {
$porttypes = self::getNetworkPortInstantiations();
// Manage NetworkportMigration
$porttypes[] = '';
}
$display_options = self::getDisplayOptions($itemtype);
$table = new HTMLTableMain();
$number_port = self::countForItem($item);
$table_options = array('canedit' => $canedit, 'display_options' => &$display_options);
// Make table name and add the correct show/hide parameters
$table_name = sprintf(__('%1$s: %2$d'), self::getTypeName($number_port), $number_port);
// Add the link to the popup to display the options ...
$table_namelink = self::getDisplayOptionsLink($itemtype);
$table_name = sprintf(__('%1$s - %2$s'), $table_name, $table_namelink);
$table->setTitle($table_name);
$c_main = $table->addHeader('main', self::getTypeName(2));
if ($display_options['dynamic_import'] && $item->isDynamic()) {
$table_options['display_isDynamic'] = true;
} else {
$table_options['display_isDynamic'] = false;
}
if ($display_options['characteristics']) {
$c_instant = $table->addHeader('Instantiation', __('Characteristics'));
$c_instant->setHTMLClass('center');
}
if ($display_options['internet']) {
$options = array('names' => 'NetworkName', 'aliases' => 'NetworkAlias', 'ipaddresses' => 'IPAddress', 'ipnetworks' => 'IPNetwork');
$table_options['dont_display'] = array();
foreach ($options as $option => $itemtype_for_option) {
if (!$display_options[$option]) {
$table_options['dont_display'][$itemtype_for_option] = true;
}
}
$c_network = $table->addHeader('Internet', _n(__('Internet information'), __('Internet information'), 2));
$c_network->setHTMLClass('center');
} else {
$c_network = NULL;
}
foreach ($porttypes as $portType) {
//.........这里部分代码省略.........
示例3: showForItem
/**
* Show Links for an item
*
* @param $item CommonDBTM object
* @param $withtemplate integer withtemplate param (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
if (!self::canView()) {
return false;
}
if ($item->isNewID($item->getID())) {
return false;
}
$restrict = $item->getEntityID();
if ($item->getType() == 'User') {
$restrict = Profile_User::getEntitiesForUser($item->getID());
}
$query = "SELECT `glpi_links`.`id`,\n `glpi_links`.`link` AS link,\n `glpi_links`.`name` AS name ,\n `glpi_links`.`data` AS data,\n `glpi_links`.`open_window` AS open_window\n FROM `glpi_links`\n INNER JOIN `glpi_links_itemtypes`\n ON `glpi_links`.`id` = `glpi_links_itemtypes`.`links_id`\n WHERE `glpi_links_itemtypes`.`itemtype`='" . $item->getType() . "' " . getEntitiesRestrictRequest(" AND", "glpi_links", "entities_id", $restrict, true) . "\n ORDER BY name";
$result = $DB->query($query);
echo "<div class='spaced'><table class='tab_cadre_fixe'>";
if ($DB->numrows($result) > 0) {
echo "<tr><th>" . self::getTypeName(Session::getPluralNumber()) . "</th></tr>";
while ($data = $DB->fetch_assoc($result)) {
$links = self::getAllLinksFor($item, $data);
foreach ($links as $link) {
echo "<tr class='tab_bg_2'>";
echo "<td class='center'>{$link}</td></tr>";
}
}
echo "</table></div>";
} else {
echo "<tr class='tab_bg_2'><th>" . self::getTypeName(Session::getPluralNumber()) . "</th></tr>";
echo "<tr class='tab_bg_2'><td class='center b'>" . __('No link defined') . "</td></tr>";
echo "</table></div>";
}
}
示例4: showForItem
static function showForItem(CommonDBTM $item)
{
global $DB, $LANG;
if (!$item->canView()) {
return false;
}
// if (PluginSimcardSimcard::canCreate()) {
// if ($item->canEdit($item->getField('id'))) {
// $url = Toolbox::getItemTypeFormURL('PluginSimcardSimcard');
// $url.= "?itemtype=".$item->getType()."&items_id=".$item->getID()."&id=-1";
// echo "<div class='center'><a href='$url'>".__s('New SIM card', 'simcard')."</a></div><br>";
// }
// }
$results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`items_id` = '" . $item->getID() . "' AND `itemtype`='" . get_class($item) . "'");
echo "<div class='spaced'>";
echo "<form id='items' name='items' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='6'>" . __s('Associated item') . "</th></tr>";
if (!empty($results)) {
echo "<tr><th></th>";
echo "<th>" . __s('Entity') . "</th>";
echo "<th>" . __s('Name') . "</th>";
echo "<th>" . __s('IMSI') . "</th>";
echo "<th>" . __s('Inventory number') . "</th>";
echo "</tr>";
foreach ($results as $data) {
$tmp = new PluginSimcardSimcard();
$tmp->getFromDB($data['plugin_simcard_simcards_id']);
echo "<tr>";
echo "<td>";
if (PluginSimcardSimcard::canDelete()) {
echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>";
}
echo "</td>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_entities', $tmp->fields['entities_id']);
echo "</td>";
echo "<td>";
echo $tmp->getLink();
echo "</td>";
echo "<td>";
echo $tmp->fields['serial'];
echo "</td>";
echo "<td>";
echo $tmp->fields['otherserial'];
echo "</td>";
echo "</tr>";
}
}
if (PluginSimcardSimcard::canUpdate()) {
echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
$used = array();
$query = "SELECT `id`\n FROM `glpi_plugin_simcard_simcards`\n WHERE `is_template`='0'\n AND `id` IN (SELECT `plugin_simcard_simcards_id`\n FROM `glpi_plugin_simcard_simcards_items`)";
foreach ($DB->request($query) as $use) {
$used[] = $use['id'];
}
Dropdown::show('PluginSimcardSimcard', array('name' => "plugin_simcard_simcards_id", 'entity' => $item->fields['entities_id'], 'used' => $used));
echo "</td>";
echo "<td colspan='2' class='center' class='tab_bg_2'>";
echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
echo "</td></tr>";
if (!empty($results)) {
Html::openArrowMassives('items', true);
Html::closeArrowMassives(array('delete_items' => _sx('button', 'Disconnect')));
}
}
echo "</table>";
Html::closeForm();
echo "</div>";
}
示例5: getTableGroup
/**
* Get the group of elements regarding given item.
* Two kind of item :
* - Device* feed by a link to the attached item (Computer, Printer ...)
* - Computer, Printer ...: feed by the "global" properties of the CommonDevice
* Then feed with the specificities of the Item_Device elements
* In cas of $item is an instance, then $options contains the type of the item (Computer,
* Printer ...).
*
* @param $item
* @param $table
* @param $options array
* @param $delete_all_column (default NULL)
* @param $common_column
* @param $specific_column
* @param $delete_column (default NULL)
* @param $dynamic_column
**/
function getTableGroup(CommonDBTM $item, HTMLTableMain $table, array $options, HTMLTableSuperHeader $delete_all_column = NULL, HTMLTableSuperHeader $common_column, HTMLTableSuperHeader $specific_column, HTMLTableSuperHeader $delete_column = NULL, $dynamic_column)
{
global $DB;
$is_device = $item instanceof CommonDevice;
if ($is_device) {
$peer_type = $options['itemtype'];
if (empty($peer_type)) {
$column_label = __('Dissociated devices');
$group_name = 'None';
} else {
$column_label = $peer_type::getTypeName(Session::getPluralNumber());
$group_name = $peer_type;
}
$table_group = $table->createGroup($group_name, '');
$peer_column = $table_group->addHeader('item', $column_label, $common_column, NULL);
if (!empty($peer_type)) {
//TRANS : %1$s is the type of the device
// %2$s is the type of the item
// %3$s is the name of the item (used for headings of a list),
$itemtype_nav_title = sprintf(__('%1$s of %2$s: %3$s'), $peer_type::getTypeName(Session::getPluralNumber()), $item->getTypeName(1), $item->getName());
$peer_column->setItemType($peer_type, $itemtype_nav_title);
}
} else {
$peer_type = $this->getDeviceType();
$table_group = $table->createGroup($peer_type, '');
//TRANS : %1$s is the type of the device
// %2$s is the type of the item
// %3$s is the name of the item (used for headings of a list),
$options['itemtype_title'] = sprintf(__('%1$s of %2$s: %3$s'), $peer_type::getTypeName(Session::getPluralNumber()), $item->getTypeName(1), $item->getName());
$peer_type::getHTMLTableHeader($item->getType(), $table_group, $common_column, NULL, $options);
}
$specificity_columns = array();
$link_column = $table_group->addHeader('spec_link', '', $specific_column);
$spec_column = $link_column;
foreach ($this->getSpecificities() as $field => $attributs) {
$spec_column = $table_group->addHeader('spec_' . $field, $attributs['long name'], $specific_column, $spec_column);
$specificity_columns[$field] = $spec_column;
}
$infocom_column = $table_group->addHeader('infocom', Infocom::getTypeName(Session::getPluralNumber()), $specific_column, $spec_column);
$document_column = $table_group->addHeader('document', Document::getTypeName(Session::getPluralNumber()), $specific_column, $spec_column);
if ($item->isDynamic()) {
$dynamics_column = $table_group->addHeader('one', ' ', $dynamic_column, $spec_column);
$previous_column = $dynamics_column;
} else {
$previous_column = $spec_column;
}
if ($options['canedit']) {
$group_checkbox_tag = empty($peer_type) ? '__' : $peer_type;
$content = Html::getCheckbox(array('criterion' => array('tag_for_massive' => $group_checkbox_tag)));
$delete_one = $table_group->addHeader('one', $content, $delete_column, $previous_column);
}
if ($is_device) {
$fk = 'items_id';
// Entity restrict
$leftjoin = '';
$where = "";
if (!empty($peer_type)) {
$leftjoin = "LEFT JOIN `" . getTableForItemType($peer_type) . "`\n ON (`" . $this->getTable() . "`.`items_id` = `" . getTableForItemType($peer_type) . "`.`id`\n AND `" . $this->getTable() . "`.`itemtype` = '{$peer_type}')";
$where = getEntitiesRestrictRequest(" AND", getTableForItemType($peer_type));
}
$query = "SELECT `" . $this->getTable() . "`.*\n FROM `" . $this->getTable() . "`\n {$leftjoin}\n WHERE `" . $this->getDeviceForeignKey() . "` = '" . $item->getID() . "'\n AND `" . $this->getTable() . "`.`itemtype` = '{$peer_type}'\n AND `" . $this->getTable() . "`.`is_deleted` = '0'\n {$where}\n ORDER BY `" . $this->getTable() . "`.`itemtype`, `" . $this->getTable() . "`.`{$fk}`";
} else {
$fk = $this->getDeviceForeignKey();
$query = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `itemtype` = '" . $item->getType() . "'\n AND `items_id` = '" . $item->getID() . "'\n AND `is_deleted` = '0'\n ORDER BY {$fk}";
}
if (!empty($peer_type)) {
$peer = new $peer_type();
$peer->getEmpty();
} else {
$peer = NULL;
}
foreach ($DB->request($query) as $link) {
Session::addToNavigateListItems(static::getType(), $link["id"]);
$this->getFromDB($link['id']);
if (is_null($peer) || $link[$fk] != $peer->getID()) {
if ($peer instanceof CommonDBTM) {
$peer->getFromDB($link[$fk]);
}
$current_row = $table_group->createRow();
$peer_group = $peer_type . '_' . $link[$fk] . '_' . mt_rand();
$current_row->setHTMLID($peer_group);
if ($options['canedit']) {
//.........这里部分代码省略.........
示例6: showForItem
/**
* Display form to unlock fields and links
*
* @param CommonDBTM $item the source item
**/
static function showForItem(CommonDBTM $item)
{
global $DB;
$ID = $item->getID();
$itemtype = $item->getType();
$header = false;
//If user doesn't have write right on the item, lock form must not be displayed
if (!$item->canCreate()) {
return false;
}
echo "<div width='50%'>";
echo "<form method='post' id='lock_form'\n name='lock_form' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='id' value='{$ID}'>\n";
echo "<input type='hidden' name='itemtype' value='{$itemtype}'>\n";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2''>" . __('Locked items') . "</th></tr>";
//Use a hook to allow external inventory tools to manage per field lock
$results = Plugin::doHookFunction('display_locked_fields', array('item' => $item, 'header' => $header));
$header |= $results['header'];
//Special locks for computers only
if ($itemtype == 'Computer') {
//Locks for items recorded in glpi_computers_items table
$types = array('Monitor', 'Peripheral', 'Printer');
foreach ($types as $type) {
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID, 'itemtype' => $type);
$params['FIELDS'] = array('id', 'items_id');
$first = true;
foreach ($DB->request('glpi_computers_items', $params) as $line) {
$tmp = new $type();
$tmp->getFromDB($line['items_id']);
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='Computer_Item[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $tmp->getName() . "</td>";
echo "</tr>\n";
}
}
$types = array('ComputerDisk', 'ComputerVirtualMachine');
foreach ($types as $type) {
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
$params['FIELDS'] = array('id', 'name');
$first = true;
foreach ($DB->request(getTableForItemType($type), $params) as $line) {
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='" . $type . "[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $line['name'] . "</td>";
echo "</tr>\n";
}
}
//Software versions
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
$first = true;
$query = "SELECT `csv`.`id` AS `id`,\n `sv`.`name` AS `version`,\n `s`.`name` AS `software`\n FROM `glpi_computers_softwareversions` AS csv\n LEFT JOIN `glpi_softwareversions` AS sv\n ON (`csv`.`softwareversions_id` = `sv`.`id`)\n LEFT JOIN `glpi_softwares` AS s\n ON (`sv`.`softwares_id` = `s`.`id`)\n WHERE `csv`.`is_deleted` = '1'\n AND `csv`.`is_dynamic` = '1'\n AND `csv`.`computers_id` = '{$ID}'";
foreach ($DB->request($query) as $line) {
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . Software::getTypeName(2) . "</th></tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='Computer_SoftwareVersion[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
echo "</tr>\n";
}
//Software licenses
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
$first = true;
$query = "SELECT `csv`.`id` AS `id`,\n `sv`.`name` AS `version`,\n `s`.`name` AS `software`\n FROM `glpi_computers_softwarelicenses` AS csv\n LEFT JOIN `glpi_softwarelicenses` AS sv\n ON (`csv`.`softwarelicenses_id` = `sv`.`id`)\n LEFT JOIN `glpi_softwares` AS s\n ON (`sv`.`softwares_id` = `s`.`id`)\n WHERE `csv`.`is_deleted` = '1'\n AND `csv`.`is_dynamic` = '1'\n AND `csv`.`computers_id` = '{$ID}'";
foreach ($DB->request($query) as $line) {
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . SoftwareLicense::getTypeName(2) . "</th>" . "</tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='Computer_SoftwareLicense[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
echo "</tr>\n";
}
}
$first = true;
$item = new NetworkPort();
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'items_id' => $ID, 'itemtype' => $itemtype);
$params['FIELDS'] = array('id');
foreach ($DB->request('glpi_networkports', $params) as $line) {
$item->getFromDB($line['id']);
//.........这里部分代码省略.........
示例7: getHTMLTableCellsForItem
/**
* @param $row HTMLTableRow object (default NULL)
* @param $item CommonDBTM object (default NULL)
* @param $father HTMLTableCell object (default NULL)
* @param $options array
**/
static function getHTMLTableCellsForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array())
{
global $DB, $CFG_GLPI;
if ($item !== NULL && $item->getType() == 'IPNetwork') {
$queries = array();
foreach ($CFG_GLPI["networkport_types"] as $itemtype) {
$table = getTableForItemType($itemtype);
$queries[] = "(SELECT ADDR.`binary_0` AS binary_0,\n ADDR.`binary_1` AS binary_1,\n ADDR.`binary_2` AS binary_2,\n ADDR.`binary_3` AS binary_3,\n ADDR.`name` AS ip,\n ADDR.`id` AS id,\n ADDR.`itemtype` AS addr_item_type,\n ADDR.`items_id` AS addr_item_id,\n `glpi_entities`.`completename` AS entity,\n NAME.`id` AS name_id,\n PORT.`id` AS port_id,\n ITEM.`id` AS item_id,\n '{$itemtype}' AS item_type\n FROM `glpi_ipaddresses_ipnetworks` AS LINK\n JOIN `glpi_ipaddresses` AS ADDR ON (ADDR.`id` = LINK.`ipaddresses_id`\n AND ADDR.`itemtype` = 'NetworkName'\n AND ADDR.`is_deleted` = '0')\n LEFT JOIN `glpi_entities` ON (ADDR.`entities_id` = `glpi_entities`.`id`)\n JOIN `glpi_networknames` AS NAME ON (NAME.`id` = ADDR.`items_id`\n AND NAME.`itemtype` = 'NetworkPort')\n JOIN `glpi_networkports` AS PORT ON (NAME.`items_id` = PORT.`id`\n AND PORT.`itemtype` = '{$itemtype}')\n JOIN `{$table}` AS ITEM ON (ITEM.`id` = PORT.`items_id`)\n WHERE LINK.`ipnetworks_id` = '" . $item->getID() . "')";
}
$queries[] = "(SELECT ADDR.`binary_0` AS binary_0,\n ADDR.`binary_1` AS binary_1,\n ADDR.`binary_2` AS binary_2,\n ADDR.`binary_3` AS binary_3,\n ADDR.`name` AS ip,\n ADDR.`id` AS id,\n ADDR.`itemtype` AS addr_item_type,\n ADDR.`items_id` AS addr_item_id,\n `glpi_entities`.`completename` AS entity,\n NAME.`id` AS name_id,\n PORT.`id` AS port_id,\n NULL AS item_id,\n NULL AS item_type\n FROM `glpi_ipaddresses_ipnetworks` AS LINK\n JOIN `glpi_ipaddresses` AS ADDR ON (ADDR.`id` = LINK.`ipaddresses_id`\n AND ADDR.`itemtype` = 'NetworkName'\n AND ADDR.`is_deleted` = '0')\n LEFT JOIN `glpi_entities` ON (ADDR.`entities_id` = `glpi_entities`.`id`)\n JOIN `glpi_networknames` AS NAME ON (NAME.`id` = ADDR.`items_id`\n AND NAME.`itemtype` = 'NetworkPort')\n JOIN `glpi_networkports` AS PORT\n ON (NAME.`items_id` = PORT.`id`\n AND PORT.`itemtype`\n NOT IN ('" . implode("', '", $CFG_GLPI["networkport_types"]) . "'))\n WHERE LINK.`ipnetworks_id` = '" . $item->getID() . "')";
$queries[] = "(SELECT ADDR.`binary_0` AS binary_0,\n ADDR.`binary_1` AS binary_1,\n ADDR.`binary_2` AS binary_2,\n ADDR.`binary_3` AS binary_3,\n ADDR.`name` AS ip,\n ADDR.`id` AS id,\n ADDR.`itemtype` AS addr_item_type,\n ADDR.`items_id` AS addr_item_id,\n `glpi_entities`.`completename` AS entity,\n NAME.`id` AS name_id,\n NULL AS port_id,\n NULL AS item_id,\n NULL AS item_type\n FROM `glpi_ipaddresses_ipnetworks` AS LINK\n JOIN `glpi_ipaddresses` AS ADDR ON (ADDR.`id` = LINK.`ipaddresses_id`\n AND ADDR.`itemtype` = 'NetworkName'\n AND ADDR.`is_deleted` = '0')\n LEFT JOIN `glpi_entities` ON (ADDR.`entities_id` = `glpi_entities`.`id`)\n JOIN `glpi_networknames` AS NAME ON (NAME.`id` = ADDR.`items_id`\n AND NAME.`itemtype` != 'NetworkPort')\n WHERE LINK.`ipnetworks_id` = '" . $item->getID() . "')";
$queries[] = "(SELECT ADDR.`binary_0` AS binary_0,\n ADDR.`binary_1` AS binary_1,\n ADDR.`binary_2` AS binary_2,\n ADDR.`binary_3` AS binary_3,\n ADDR.`name` AS ip,\n ADDR.`id` AS id,\n ADDR.`itemtype` AS addr_item_type,\n ADDR.`items_id` AS addr_item_id,\n `glpi_entities`.`completename` AS entity,\n NULL AS name_id,\n NULL AS port_id,\n NULL AS item_id,\n NULL AS item_type\n FROM `glpi_ipaddresses_ipnetworks` AS LINK\n JOIN `glpi_ipaddresses` AS ADDR ON (ADDR.`id` = LINK.`ipaddresses_id`\n AND ADDR.`itemtype` != 'NetworkName'\n AND ADDR.`is_deleted` = '0')\n LEFT JOIN `glpi_entities` ON (ADDR.`entities_id` = `glpi_entities`.`id`)\n WHERE LINK.`ipnetworks_id` = '" . $item->getID() . "')";
$query = implode('UNION ', $queries);
if ($options['order'] == 'ip' || $options['order'] == 'itemtype') {
$query .= " ORDER BY binary_0, binary_1, binary_2, binary_3";
}
if (isset($options['SQL_options'])) {
$query .= "\n" . $options['SQL_options'];
}
$canedit = isset($options['canedit']) && $options['canedit'];
$options['createRow'] = false;
$address = new self();
$ipaddress = new self();
$networkname = new NetworkName();
$networkport = new NetworkPort();
$item = NULL;
foreach ($DB->request($query) as $line) {
unset($row);
if ($options['order'] == 'itemtype' && !empty($line['item_type'])) {
$row = $options['group_' . $line['item_type']]->createRow();
}
if (!isset($row)) {
$row = $options['group_None']->createRow();
}
$ip_header = $row->getGroup()->getSuperHeaderByName('IP Address');
$item_header = $row->getGroup()->getHeaderByName('Item', 'Item');
$port_header = $row->getGroup()->getHeaderByName('Item', 'NetworkPort');
$name_header = $row->getGroup()->getHeaderByName('Item', 'NetworkName');
$entity_header = $row->getGroup()->getHeaderByName('Item', 'Entity');
$row->addCell($ip_header, $line['ip'], $father);
if (!empty($line['name_id'])) {
$networkname->getFromDB($line['name_id']);
$row->addCell($name_header, $networkname->getLink(), $father);
if (!empty($line['port_id'])) {
$networkport->getFromDB($line['port_id']);
$row->addCell($port_header, $networkport->getLink(), $father);
if (!empty($line['item_id']) && !empty($line['item_type'])) {
$itemtype = $line['item_type'];
$item = new $itemtype();
$item->getFromDB($line['item_id']);
$row->addCell($item_header, $item->getLink(), $father);
}
}
$row->addCell($entity_header, $line['entity'], $father);
} else {
if (!empty($line['addr_item_id']) && !empty($line['addr_item_type'])) {
$itemtype = $line['addr_item_type'];
$item = new $itemtype();
$item->getFromDB($line['addr_item_id']);
if ($item instanceof CommonDBChild) {
$items = $item->recursivelyGetItems();
$elements = array($item->getLink());
foreach ($items as $item_) {
$elements[] = $item_->getLink();
}
$row->addCell($item_header, implode(' > ', $elements), $father);
} else {
$row->addCell($item_header, $item->getLink(), $father);
}
$row->addCell($entity_header, $line['entity'], $father);
}
}
}
} else {
if (isset($options['dont_display']['IPAddress'])) {
return;
}
$header = $row->getGroup()->getHeaderByName('Internet', __CLASS__);
if (!$header) {
return;
}
if (empty($item)) {
if (empty($father)) {
return;
}
$item = $father->getItem();
}
$query = "SELECT `id`\n FROM `glpi_ipaddresses`\n WHERE `items_id` = '" . $item->getID() . "'\n AND `itemtype` = '" . $item->getType() . "'\n AND `is_deleted` = '0'";
$canedit = isset($options['canedit']) && $options['canedit'];
$createRow = isset($options['createRow']) && $options['createRow'];
$options['createRow'] = false;
$address = new self();
foreach ($DB->request($query) as $ipaddress) {
if ($address->getFromDB($ipaddress['id'])) {
//.........这里部分代码省略.........
示例8: getTableGroup
static function getTableGroup(CommonDBTM $item, HTMLTableMain $table, array $options, HTMLTableSuperHeader $delete_all_column = NULL, HTMLTableSuperHeader $common_column, HTMLTableSuperHeader $specific_column, HTMLTableSuperHeader $delete_column = NULL, $dynamic_column)
{
global $DB;
$device_type = static::getDeviceType();
$table_group = $table->createGroup($device_type, '');
//TRANS : %1$s is the type of the device
// %2$s is the type of the item
// %3$s is the name of the item (used for headings of a list),
$options['itemtype_title'] = sprintf(__('%1$s of %2$s: %3$s'), $device_type::getTypeName(2), $item->getTypeName(1), $item->getName());
$device_type::getHTMLTableHeader($item->getType(), $table_group, $common_column, NULL, $options);
$spec_column = NULL;
$specificity_columns = array();
foreach (static::getSpecificities() as $field => $attributs) {
$spec_column = $table_group->addHeader('spec_' . $field, $attributs['long name'], $specific_column, $spec_column);
$specificity_columns[$field] = $spec_column;
}
if ($item->isDynamic()) {
$dynamics_column = $table_group->addHeader('one', ' ', $dynamic_column, $spec_column);
$previous_column = $dynamics_column;
} else {
$previous_column = $spec_column;
}
if ($options['canedit']) {
$delete_one = $table_group->addHeader('one', ' ', $delete_column, $previous_column);
}
$fk = static::getDeviceForeignKey();
$query = "SELECT *\n FROM `" . static::getTable() . "`\n WHERE `itemtype` = '" . $item->getType() . "'\n AND `items_id` = '" . $item->getID() . "'\n AND `is_deleted` = '0'\n ORDER BY {$fk}";
$device = new $device_type();
$device->getEmpty();
foreach ($DB->request($query) as $link) {
if ($link[$fk] != $device->getID()) {
$device->getFromDB($link[$fk]);
$current_row = $table_group->createRow();
$device_group = $device_type . '_' . $link[$fk] . '_' . mt_rand();
$current_row->setHTMLID($device_group);
if ($options['canedit']) {
$cell_value = Html::getCheckAllAsCheckbox($device_group);
$current_row->addCell($delete_all_column, $cell_value);
}
$device->getHTMLTableCellForItem($current_row, $item, NULL, $options);
}
$spec_cell = NULL;
foreach (static::getSpecificities() as $field => $attributs) {
$content = $link[$field];
if ($options['canedit']) {
$content = "<input type='text' name='value_" . $device_type . "_" . $link['id'] . "_" . $field . "' value='{$content}' size='" . $attributs['size'] . "'>";
}
$spec_cell = $current_row->addCell($specificity_columns[$field], $content, $spec_cell);
}
if ($item->isDynamic()) {
$previous_cell = $current_row->addCell($dynamics_column, Dropdown::getYesNo($link['is_dynamic']), $spec_cell);
} else {
$previous_cell = $spec_cell;
}
if ($options['canedit']) {
$cell_value = "<input type='checkbox' name='remove_" . $device_type . "_" . $link['id'] . "' value='1'>";
$current_row->addCell($delete_one, $cell_value, $previous_cell);
}
}
}
示例9: countForItem
static function countForItem(CommonDBTM $item)
{
return countElementsInTable('glpi_plugin_webapplications_webapplications', "`suppliers_id` = '" . $item->getID() . "'");
}
示例10: array
/**
* Display the mount toolbox
*
* @param CommonDBTM $item Item referenced with the mount
* @param string $formName Name of the form
* @param string $mountAction Action to perform
* @param array $data Default data (if modified)
* @param bool $showDelete Display "Delete" action button
*/
static function rackview_mount_toolbox($item, $formName = "mountForm", $mountAction = "mount", $data = array(), $showDelete = false)
{
global $CFG_GLPI, $DB, $LANG;
print '<div>';
print '<form name="' . $formName . '" method="post" action="' . $CFG_GLPI['root_doc'] . '/plugins/rackview/front/plugin_rackview_mount.php">';
print '<table class="tab_cadre_fixe" style="width: 100%">';
print '<input type="hidden" name="mount_action" value="' . $mountAction . '" />';
print '<input type="hidden" name="object_type" ' . 'value="' . $item->getType() . '" />';
print '<input type="hidden" name="object_id" ' . 'value="' . $item->getID() . '" />';
if (isset($data['id'])) {
print '<input type="hidden" name="mount_id" ' . 'value="' . $data['id'] . '" />';
}
print '<tr class="tab_bg_1">';
$title = $LANG['plugin_rackview']['label_addmount'];
if (isset($data['rack_id'])) {
// Get rack name
$table = getTableForItemType('PluginRackviewRack');
$rack = $DB->request($table, array('id' => $data['rack_id']));
if ($rack->numrows() == 0) {
Html::displayErrorAndDie($LANG['plugin_rackview']['error_invalidrackid']);
}
$rack = $rack->next();
$rackLink = sprintf('<a href="%s?id=%s">%s</a>', Toolbox::getItemTypeFormURL('PluginRackviewRack'), $data['rack_id'], $rack['name']);
$title = sprintf($LANG['plugin_rackview']['label_mount'], $rackLink);
}
print '<th colspan="2">' . $title . '</th>';
print '</tr>';
// Rack
print '<tr>';
print '<td title="' . $LANG['plugin_rackview']['help_rack'] . '">' . $LANG['plugin_rackview']['field_rack'] . '</td>';
print '<td>';
$value = -1;
if (isset($data['rack_id'])) {
$value = $data['rack_id'];
}
$mount_id = -1;
if (isset($data['id'])) {
$mount_id = $data['id'];
}
$startuCode = 'rackview_startu_';
if (isset($data['id'])) {
$startuCode .= $data['id'];
} else {
$startuCode .= 'new';
}
$onChangeCode = sprintf('rackview_display_rack("%s", "id", "%s", "plugin_rackview_racks_id", ' . '%d, "mini=true&startu=%s", "%s")', $CFG_GLPI["root_doc"] . '/plugins/rackview/ajax/ajax_show_rack.php', $formName, $mount_id, $startuCode, $LANG['plugin_rackview']['label_selectarack']);
Dropdown::show('PluginRackviewRack', array('value' => $value, 'on_change' => $onChangeCode));
print '</td>';
print '</tr>';
// Start-U
print '<tr>';
print '<td title="' . $LANG['plugin_rackview']['help_startu'] . '">' . $LANG['plugin_rackview']['field_startu'] . '</td>';
print '<td>';
$startuId = 'new';
if (isset($data['id'])) {
$startuId = $data['id'];
}
print '<input type="text" name="startu" id="' . 'rackview_startu_' . $startuId . '" maxlength="4" ';
if (isset($data['startu'])) {
print 'value="' . $data['startu'] . '"';
}
print '/>';
print '</td>';
print '</tr>';
// Mount-Size
print '<tr>';
print '<td title="' . $LANG['plugin_rackview']['help_mount_size'] . '">' . $LANG['plugin_rackview']['field_mount_size'] . '</td>';
print '<td>';
print '<input type="checkbox" name="use_default" value="true"';
if (!isset($data['mount_size']) || is_null($data['mount_size'])) {
print ' checked="checked"';
}
$mount_size_id = 'new';
if (isset($data['id'])) {
$mount_size_id = $data['id'];
}
print sprintf('onClick = "rackview_toggle(this, \'rackview_mount_size_%s\')"', $mount_size_id);
print '/> ' . $LANG['plugin_rackview']['label_usedefault'] . ' ';
print sprintf('<input type="text" name="mount_size" id="rackview_mount_size_%s" ' . 'maxlength="4" ', $mount_size_id);
if (isset($data['mount_size']) && !is_null($data['mount_size'])) {
print 'value="' . $data['mount_size'] . '"';
} else {
print 'disabled="disabled"';
}
print '/>';
print '</td>';
print '</tr>';
// Depth
print '<tr>';
print '<td title="' . $LANG['plugin_rackview']['help_depth'] . '">' . $LANG['plugin_rackview']['field_depth'] . '</td>';
print '<td>';
//.........这里部分代码省略.........
示例11: countForItem
static function countForItem(CommonDBTM $item)
{
return countElementsInTable('glpi_plugin_databases_instances', "`plugin_databases_databases_id` = '" . $item->getID() . "'");
}
示例12: generateLinkContents
static function generateLinkContents($link, CommonDBTM $item)
{
if (strstr($link, "[EXAMPLE_ID]")) {
$link = str_replace("[EXAMPLE_ID]", $item->getID(), $link);
return array($link);
}
return parent::generateLinkContents($link, $item);
}
示例13: showForItem
static function showForItem(CommonDBTM $item)
{
global $DB, $LANG;
if (!$item->can($item->getID(), 'r')) {
return false;
}
if (Session::haveRight('simcard', 'w')) {
$url = Toolbox::getItemTypeFormURL('PluginSimcardSimcard');
$url .= "?itemtype=" . $item->getType() . "&items_id=" . $item->getID() . "&id=-1";
echo "<div class='center'><a href='{$url}'>" . $LANG['plugin_simcard'][10] . "</a></div><br>";
}
$results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`items_id` = '" . $item->getID() . "' AND `itemtype`='" . get_class($item) . "'");
echo "<div class='spaced'>";
echo "<form id='items' name='items' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='6'>" . $LANG['document'][19] . "</th></tr>";
if (!empty($results)) {
echo "<tr><th></th>";
echo "<th>" . $LANG['entity'][0] . "</th>";
echo "<th>" . $LANG['common'][16] . "</th>";
echo "<th>" . $LANG['common'][19] . "</th>";
echo "<th>" . $LANG['common'][20] . "</th>";
echo "</tr>";
foreach ($results as $data) {
$tmp = new PluginSimcardSimcard();
$tmp->getFromDB($data['plugin_simcard_simcards_id']);
echo "<tr>";
echo "<td>";
if (Session::haveRight('simcard', 'w')) {
echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>";
}
echo "</td>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_entities', $tmp->fields['entities_id']);
echo "</td>";
echo "<td>";
echo $tmp->getLink();
echo "</td>";
echo "<td>";
echo $tmp->fields['serial'];
echo "</td>";
echo "<td>";
echo $tmp->fields['otherserial'];
echo "</td>";
echo "</tr>";
}
}
if (Session::haveRight('simcard', 'w')) {
echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
$used = array();
$query = "SELECT `id`\n FROM `glpi_plugin_simcard_simcards`\n WHERE `is_template`='0'\n AND `id` IN (SELECT `plugin_simcard_simcards_id`\n FROM `glpi_plugin_simcard_simcards_items`)";
foreach ($DB->request($query) as $use) {
$used[$use['id']] = $use['id'];
}
Dropdown::show('PluginSimcardSimcard', array('name' => "plugin_simcard_simcards_id", 'entity' => $item->fields['entities_id'], 'used' => $used));
echo "</td>";
echo "<td colspan='2' class='center' class='tab_bg_2'>";
echo "<input type='submit' name='additem' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
echo "</td></tr>";
if (!empty($results)) {
Html::openArrowMassives('items');
Html::closeArrowMassives(array('delete_items' => $LANG['buttons'][10]));
}
}
echo "</table>";
Html::closeForm();
echo "</div>";
}
示例14: showChildsForItemForm
/**
* We can add several single CommonDBChild to a given Item. In such case, we display a "+"
* button and the fields already entered.
* This method display the fields
*
* @since version 0.84
*
* @todo study if we cannot use these methods for the user emails
* @see showAddChildButtonForItemForm()
*
* @param $item CommonDBTM object the item on which to add the current CommenDBChild
* @param $field_name the name of the HTML field inside Item's form
* @param $canedit (default NULL) NULL to use default behaviour
*
* @return nothing (display only)
**/
static function showChildsForItemForm(CommonDBTM $item, $field_name, $canedit = NULL)
{
global $DB, $CFG_GLPI;
$items_id = $item->getID();
if (is_null($canedit)) {
if ($item->isNewItem()) {
if (!$item->canCreate()) {
return false;
}
$canedit = $item->canUpdate();
} else {
if (!$item->can($items_id, 'r')) {
return false;
}
$canedit = $item->can($items_id, "w");
}
}
$lower_name = strtolower(get_called_class());
$div_id = "add_" . $lower_name . "_to_" . $item->getType() . "_" . $items_id;
// To be sure not to load bad datas from this table
if ($items_id == 0) {
$items_id = -99;
}
$query = "SELECT *\n FROM `" . static::getTable() . "`\n WHERE `" . static::$items_id . "` = '" . $item->getID() . "'";
if (preg_match('/^itemtype/', static::$itemtype)) {
$query .= " AND `itemtype` = '" . $item->getType() . "'";
}
$current_item = new static();
if ($current_item->maybeDeleted()) {
$query .= " AND `is_deleted` = '0'";
}
$count = 0;
foreach ($DB->request($query) as $data) {
$current_item->fields = $data;
if ($count) {
echo '<br>';
}
$count++;
$current_item->showChildForItemForm($canedit, $field_name . "[" . $current_item->getID() . "]");
}
if ($canedit) {
echo "<div id='{$div_id}'>";
// No Child display field
if ($count == 0) {
$current_item->getEmpty();
$current_item->showChildForItemForm($canedit, $field_name . "[-100]");
}
echo "</div>";
}
}
示例15: updateComputer
/**
* Update lockable fields of an item
*
* @param $item CommonDBTM object
* @param $withtemplate integer withtemplate param (default '')
*
* @return nothing
**/
static function updateComputer(CommonDBTM $item, $withtemplate = '')
{
global $DB;
// Manage changes for OCS if more than 1 element (date_mod)
// Need dohistory==1 if dohistory==2 no locking fields
if ($item->fields["is_dynamic"] && countElementsInTable('glpi_plugin_ocsinventoryng_ocslinks', "`computers_id`='" . $item->getID() . "'") && $item->dohistory == 1 && count($item->updates) > 1 && !isset($item->input["_nolock"])) {
PluginOcsinventoryngOcsServer::mergeOcsArray($item->fields["id"], $item->updates, "computer_update");
}
if (isset($item->input["_auto_update_ocs"])) {
$query = "UPDATE `glpi_plugin_ocsinventoryng_ocslinks`\n SET `use_auto_update` = '" . $item->input["_auto_update_ocs"] . "'\n WHERE `computers_id` = '" . $item->input["id"] . "'";
$DB->query($query);
}
}