case 'contactAsign': $contact = new IEContact($oPage->getRequestValue('contact_id', 'int')); if ($contact->getId()) { $host = new IEHost(); $groupMembers = $hostgroup->getMembers(); foreach ($groupMembers as $gmID => $hostName) { $host->loadFromSQL((int) $gmID); $host->addMember('contacts', $contact->getId(), $contact->getName()); if ($host->saveToMySQL()) { $host->addStatusMessage(sprintf(_('<strong>%s</strong> byl přidán mezi kontakty <strong>%s</strong>'), $contact->getName(), $host->getName()), 'success'); } else { $host->addStatusMessage(sprintf(_('<strong>%s</strong> nebyl přidán mezi kontakty <strong>%s</strong>'), $contact->getName(), $host->getName()), 'warning'); } } } else { $hostgroup->addStatusMessage(_('Chyba přiřazení kontaktu'), 'warning'); } break; default: if ($oPage->isPosted()) { $hostgroup->takeData($_POST); if (!$hostgroup->getId()) { $hostgroup->setDataValue('members', array()); } $hostgroupID = $hostgroup->saveToMySQL(); if (is_null($hostgroupID)) { $oUser->addStatusMessage(_('Skupina hostů nebyla uložena'), 'warning'); } else { $oUser->addStatusMessage(_('Skupina hostů byla uložena'), 'success'); } $hostgroup->saveMembers();
$newHostId = (int) $host->insertToMySQL(); if ($newHostId) { $host->addStatusMessage(sprintf(_('Nový host %s %s založen'), $hop, $newHostName), 'success'); $parents[$hop] = array('host_id' => $newHostId, 'address' => $hop, $host->nameColumn => $newHostName); } } if ($pos) { $parentIP = $trace[$pos - 1]; $host->addMember('parents', $parents[$parentIP][$host->myKeyColumn], $parents[$parentIP][$host->nameColumn]); } $host->addMember('contacts', $defaultContactId, $defaultContactName); $host->setDataValue('config_hash', $host->getConfigHash()); $host->setDataValue('check_command', 'check-host-alive'); $host->setDataValue('active_checks_enabled', 1); $host->setDataValue('passive_checks_enabled', 0); $oldNotes = strval($host->getDataValue('notes')); if (strstr($hostGroup->getName(), $oldNotes) == false) { $host->setDataValue('notes', $oldNotes . "\n" . $hostGroup->getName()); } $host->saveToMySQL(); $hostGroup->addMember('members', $host->getId(), $host->getName()); $listing->addItemSmart(new EaseHtmlATag('host.php?host_id=' . $host->getId(), $host->getName())); } if ($hostGroup->saveToMySQL()) { $hostGroup->addStatusMessage(sprintf(_('Hostgrupa %s naplněna'), $hostGroup->getName()), 'success'); } else { $hostGroup->addStatusMessage(sprintf(_('Hostgrupa %s nebyla naplněna'), $hostGroup->getName()), 'warning'); } } $oPage->addItem(new IEPageBottom()); $oPage->draw();