本文整理汇总了PHP中NetworkPort::updateInDB方法的典型用法代码示例。如果您正苦于以下问题:PHP NetworkPort::updateInDB方法的具体用法?PHP NetworkPort::updateInDB怎么用?PHP NetworkPort::updateInDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkPort
的用法示例。
在下文中一共展示了NetworkPort::updateInDB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NetworkPort
function post_addItem()
{
global $DB, $LANG;
// Get netpoint for $sport and $dport
$sport = $this->fields['networkports_id_1'];
$dport = $this->fields['networkports_id_2'];
$ps = new NetworkPort();
if (!$ps->getFromDB($sport)) {
return false;
}
$pd = new NetworkPort();
if (!$pd->getFromDB($dport)) {
return false;
}
// Check netpoint for copy
$source = "";
$destination = "";
if (isset($ps->fields['netpoints_id']) && $ps->fields['netpoints_id'] != 0) {
$source = $ps->fields['netpoints_id'];
}
if (isset($pd->fields['netpoints_id']) && $pd->fields['netpoints_id'] != 0) {
$destination = $pd->fields['netpoints_id'];
}
// Update Item
$updates[0] = 'netpoints_id';
if (empty($source) && !empty($destination)) {
$ps->fields['netpoints_id'] = $destination;
$ps->updateInDB($updates);
addMessageAfterRedirect($LANG['connect'][15] . " : " . $LANG['networking'][51]);
} else {
if (!empty($source) && empty($destination)) {
$pd->fields['netpoints_id'] = $source;
$pd->updateInDB($updates);
addMessageAfterRedirect($LANG['connect'][15] . " : " . $LANG['networking'][51]);
} else {
if ($source != $destination) {
addMessageAfterRedirect($LANG['connect'][16] . " : " . $LANG['networking'][51]);
}
}
}
// Manage VLAN : use networkings one as defaults
$npnet = -1;
$npdev = -1;
if ($ps->fields["itemtype"] != 'NetworkEquipment' && $pd->fields["itemtype"] == 'NetworkEquipment') {
$npnet = $dport;
$npdev = $sport;
}
if ($pd->fields["itemtype"] != 'NetworkEquipment' && $ps->fields["itemtype"] == 'NetworkEquipment') {
$npnet = $sport;
$npdev = $dport;
}
if ($npnet > 0 && $npdev > 0) {
// Get networking VLAN
// Unset MAC and IP from networking device
$query = "SELECT *\n FROM `glpi_networkports_vlans`\n WHERE `networkports_id` = '{$npnet}'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) > 0) {
// Found VLAN : clean vlan device and add found ones
$query = "DELETE\n FROM `glpi_networkports_vlans`\n WHERE `networkports_id` = '{$npdev}' ";
$DB->query($query);
while ($data = $DB->fetch_array($result)) {
$query = "INSERT INTO `glpi_networkports_vlans`\n (`networkports_id`, `vlans_id`)\n VALUES ('{$npdev}', '" . $data['vlans_id'] . "')";
$DB->query($query);
}
}
}
}
// end manage VLAN
// Manage History
$sourcename = NOT_AVAILABLE;
$destname = NOT_AVAILABLE;
$sourcehistory = false;
$desthistory = false;
if (class_exists($ps->fields['itemtype'])) {
$sourceitem = new $ps->fields['itemtype']();
if ($sourceitem->getFromDB($ps->fields['items_id'])) {
$sourcename = $sourceitem->getName();
$sourcehistory = $sourceitem->dohistory;
}
}
if (class_exists($pd->fields['itemtype'])) {
$destitem = new $pd->fields['itemtype']();
if ($destitem->getFromDB($pd->fields['items_id'])) {
$destname = $destitem->getName();
$desthistory = $destitem->dohistory;
}
}
$changes[0] = 0;
$changes[1] = "";
if ($sourcehistory) {
$changes[2] = $destname;
if ($ps->fields["itemtype"] == 'NetworkEquipment') {
$changes[2] = "#" . $ps->fields["name"] . " > " . $changes[2];
}
if ($pd->fields["itemtype"] == 'NetworkEquipment') {
$changes[2] = $changes[2] . " > #" . $pd->fields["name"];
}
Log::history($ps->fields["items_id"], $ps->fields["itemtype"], $changes, $pd->fields["itemtype"], HISTORY_CONNECT_DEVICE);
}
if ($desthistory) {
//.........这里部分代码省略.........