本文整理汇总了PHP中NetworkPort::getNetworkPortInstantiations方法的典型用法代码示例。如果您正苦于以下问题:PHP NetworkPort::getNetworkPortInstantiations方法的具体用法?PHP NetworkPort::getNetworkPortInstantiations怎么用?PHP NetworkPort::getNetworkPortInstantiations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkPort
的用法示例。
在下文中一共展示了NetworkPort::getNetworkPortInstantiations方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showMassiveActionsSubForm
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
global $CFG_GLPI;
switch ($ma->getAction()) {
case 'transform_to':
Dropdown::showItemTypes('transform_to', NetworkPort::getNetworkPortInstantiations(), array('value' => 'NetworkPortEthernet'));
echo "<br><br>";
echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')) . "</span>";
return true;
}
return parent::showMassiveActionsSubForm($ma);
}
示例2: getHTMLTableCellsForItem
/**
* @since version 0.84
*
* @see CommonDevice::getHTMLTableCellForItem()
**/
static function getHTMLTableCellsForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array())
{
$column_name = __CLASS__;
if (isset($options['dont_display'][$column_name])) {
return;
}
if (empty($item)) {
if (empty($father)) {
return;
}
$item = $father->getItem();
}
if (in_array($item->getType(), NetworkPort::getNetworkPortInstantiations())) {
$link = new Item_DeviceNetworkCard();
if ($link->getFromDB($item->fields['items_devicenetworkcards_id'])) {
$device = $link->getOnePeer(1);
if ($device) {
$row->addCell($row->getHeaderByName($column_name), $device->getLink(), $father);
}
}
}
}
示例3: showSpecificMassiveActionsParameters
/**
* @see CommonDBTM::showSpecificMassiveActionsParameters()
**/
function showSpecificMassiveActionsParameters($input = array())
{
switch ($input['action']) {
case "transform_to":
Dropdown::showItemTypes('transform_to', NetworkPort::getNetworkPortInstantiations(), array('value' => 'NetworkPortEthernet'));
echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Save') . "'>";
return true;
default:
return parent::showSpecificMassiveActionsParameters($input);
}
return false;
}
示例4: getItem
//.........这里部分代码省略.........
$fields['_softwares'] = array();
if (!Software::canView()) {
$fields['_softwares'] = self::arrayRightError();
} else {
$query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n `glpi_softwares`.`id` AS softwares_id,\n `glpi_softwareversions`.`id` AS softwareversions_id,\n `glpi_computers_softwareversions`.`is_dynamic`,\n `glpi_softwareversions`.`states_id`,\n `glpi_softwares`.`is_valid`\n FROM `glpi_computers_softwareversions`\n LEFT JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n LEFT JOIN `glpi_softwares`\n ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n WHERE `glpi_computers_softwareversions`.`computers_id` = '{$id}'\n AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n ORDER BY `glpi_softwares`.`name`, `glpi_softwareversions`.`name`";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_softwares'][] = $data;
}
}
}
}
// retrieve item connections
if (isset($params['with_connections']) && $params['with_connections'] && $itemtype == "Computer") {
$fields['_connections'] = array();
foreach ($CFG_GLPI["directconnect_types"] as $connect_type) {
$connect_item = new $connect_type();
if ($connect_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($connect_type) . ".*\n FROM `glpi_computers_items`\n LEFT JOIN `" . getTableForItemType($connect_type) . "`\n ON (`" . getTableForItemType($connect_type) . "`.`id`\n = `glpi_computers_items`.`items_id`)\n WHERE `computers_id` = '{$id}'\n AND `itemtype` = '" . $connect_type . "'\n AND `glpi_computers_items`.`is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_connections'][$connect_type][] = $data;
}
}
}
}
}
// retrieve item networkports
if (isset($params['with_networkports']) && $params['with_networkports']) {
$fields['_networkports'] = array();
if (!NetworkEquipment::canView()) {
$fields['_networkports'] = self::arrayRightError();
} else {
foreach (NetworkPort::getNetworkPortInstantiations() as $networkport_type) {
$netport_table = $networkport_type::getTable();
$query = "SELECT\n netp.`id` as netport_id,\n netp.`entities_id`,\n netp.`is_recursive`,\n netp.`logical_number`,\n netp.`name`,\n netp.`mac`,\n netp.`comment`,\n netp.`is_dynamic`,\n netp_subtable.*\n FROM glpi_networkports AS netp\n LEFT JOIN `{$netport_table}` AS netp_subtable\n ON netp_subtable.`networkports_id` = netp.`id`\n WHERE netp.`instantiation_type` = '{$networkport_type}'\n AND netp.`items_id` = '{$id}'\n AND netp.`itemtype` = '{$itemtype}'\n AND netp.`is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
if (isset($data['netport_id'])) {
// append network name
$query_netn = "SELECT\n GROUP_CONCAT(CONCAT(ipadr.`id`, '" . Search::SHORTSEP . "' , ipadr.`name`)\n SEPARATOR '" . Search::LONGSEP . "') as ipadresses,\n netn.`id` as networknames_id,\n netn.`name` as networkname,\n netn.`fqdns_id`,\n fqdn.`name` as fqdn_name,\n fqdn.`fqdn`\n FROM `glpi_networknames` AS netn\n LEFT JOIN `glpi_ipaddresses` AS ipadr\n ON ipadr.`itemtype` = 'NetworkName' AND ipadr.`items_id` = netn.`id`\n LEFT JOIN `glpi_fqdns` AS fqdn\n ON fqdn.`id` = netn.`fqdns_id`\n LEFT JOIN `glpi_ipaddresses_ipnetworks` ipadnet\n ON ipadnet.`ipaddresses_id` = ipadr.`id`\n LEFT JOIN `glpi_ipnetworks` `ipnet`\n ON ipnet.`id` = ipadnet.`ipnetworks_id`\n WHERE netn.`itemtype` = 'NetworkPort'\n AND netn.`items_id` = " . $data['netport_id'] . "\n GROUP BY netn.`id`, netn.`name`, netn.fqdns_id, fqdn.name, fqdn.fqdn";
if ($result_netn = $DB->query($query_netn)) {
$data_netn = $DB->fetch_assoc($result_netn);
$raw_ipadresses = explode(Search::LONGSEP, $data_netn['ipadresses']);
$ipadresses = array();
foreach ($raw_ipadresses as $ipadress) {
$ipadress = explode(Search::SHORTSEP, $ipadress);
//find ip network attached to these ip
$ipnetworks = array();
$query_ipnet = "SELECT\n ipnet.`id`,\n ipnet.`completename`,\n ipnet.`name`,\n ipnet.`address`,\n ipnet.`netmask`,\n ipnet.`gateway`,\n ipnet.`ipnetworks_id`,\n ipnet.`comment`\n FROM `glpi_ipnetworks` ipnet\n INNER JOIN `glpi_ipaddresses_ipnetworks` ipadnet\n ON ipnet.`id` = ipadnet.`ipnetworks_id`\n AND ipadnet.`ipaddresses_id` = " . $ipadress[0];
if ($result_ipnet = $DB->query($query_ipnet)) {
while ($data_ipnet = $DB->fetch_assoc($result_ipnet)) {
$ipnetworks[] = $data_ipnet;
}
}
$ipadresses[] = array('id' => $ipadress[0], 'name' => $ipadress[1], 'IPNetwork' => $ipnetworks);
}
$data['NetworkName'] = array('id' => $data_netn['networknames_id'], 'name' => $data_netn['networkname'], 'fqdns_id' => $data_netn['fqdns_id'], 'FQDN' => array('id' => $data_netn['fqdns_id'], 'name' => $data_netn['fqdn_name'], 'fqdn' => $data_netn['fqdn']), 'IPAddress' => $ipadresses);
}
}
$fields['_networkports'][$networkport_type][] = $data;
}
}
}
}
}
示例5: getItem
//.........这里部分代码省略.........
$fields['_softwares'] = array();
if (!Software::canView()) {
$fields['_softwares'] = self::arrayRightError();
} else {
$query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n `glpi_softwares`.`id` AS softwares_id,\n `glpi_softwareversions`.`id` AS softwareversions_id,\n `glpi_computers_softwareversions`.`is_dynamic`,\n `glpi_softwareversions`.`states_id`,\n `glpi_softwares`.`is_valid`\n FROM `glpi_computers_softwareversions`\n LEFT JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n LEFT JOIN `glpi_softwares`\n ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n WHERE `glpi_computers_softwareversions`.`computers_id` = '{$id}'\n AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n ORDER BY `glpi_softwares`.`name`, `glpi_softwareversions`.`name`";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_softwares'][] = $data;
}
}
}
}
// retrieve item connections
if (isset($params['with_connections']) && $params['with_connections'] && $itemtype == "Computer") {
$fields['_connections'] = array();
foreach ($CFG_GLPI["directconnect_types"] as $connect_type) {
$connect_item = new $connect_type();
if ($connect_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($connect_type) . ".*\n FROM `glpi_computers_items`\n LEFT JOIN `" . getTableForItemType($connect_type) . "`\n ON (`" . getTableForItemType($connect_type) . "`.`id`\n = `glpi_computers_items`.`items_id`)\n WHERE `computers_id` = '{$id}'\n AND `itemtype` = '" . $connect_type . "'\n AND `glpi_computers_items`.`is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_connections'][$connect_type][] = $data;
}
}
}
}
}
// retrieve item networkports
if (isset($params['with_networkports']) && $params['with_networkports']) {
$fields['_networkports'] = array();
if (!NetworkEquipment::canView()) {
$fields['_networkports'] = self::arrayRightError();
} else {
foreach (NetworkPort::getNetworkPortInstantiations() as $networkport_type) {
$query = "SELECT\n netp.`entities_id`,\n netp.`is_recursive`,\n netp.`logical_number`,\n netp.`name`,\n netp.`mac`,\n netp.`comment`,\n netp.`is_dynamic`,\n netp_subtable.*\n FROM glpi_networkports AS netp\n LEFT JOIN " . $networkport_type::getTable() . " AS netp_subtable\n ON netp_subtable.`networkports_id` = netp.`id`\n WHERE netp.`instantiation_type` = '{$networkport_type}'\n AND netp.`items_id` = '{$id}'\n AND netp.`itemtype` = '{$itemtype}'\n AND netp.`is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_networkports'][$networkport_type][] = $data;
}
}
}
}
}
// retrieve item infocoms
if (isset($params['with_infocoms']) && $params['with_infocoms']) {
$fields['_infocoms'] = array();
if (!Infocom::canView()) {
$fields['_infocoms'] = self::arrayRightError();
} else {
$ic = new Infocom();
if ($ic->getFromDBforDevice($itemtype, $id)) {
$fields['_infocoms'] = $ic->fields;
}
}
}
// retrieve item contracts
if (isset($params['with_contracts']) && $params['with_contracts']) {
$fields['_contracts'] = array();
if (!Contract::canView()) {
$fields['_contracts'] = self::arrayRightError();
} else {
$query = "SELECT `glpi_contracts_items`.*\n FROM `glpi_contracts_items`,\n `glpi_contracts`\n LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`\n AND `glpi_contracts_items`.`items_id` = '{$id}'\n AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n ORDER BY `glpi_contracts`.`name`";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_contracts'][] = $data;
}