/** * Editor k přidávání členů skupiny * * @param IEService|IEHost $holder */ public function __construct($holder) { $contactsAssigned = array(); parent::__construct(); $fieldName = $this->getmyKeyColumn(); $initialContent = new EaseTWBPanel(_('Cíle notifikací')); $initialContent->setTagCss(array('width' => '100%')); if (is_null($holder->getMyKey())) { $initialContent->addItem(_('Nejprve je potřeba uložit záznam')); } else { $serviceName = $holder->getName(); $contact = new IEContact(); $allContacts = $contact->getListing(null, true, array('alias', 'parent_id')); foreach ($holder->getDataValue('contacts') as $contactId => $contactName) { if (isset($allContacts[$contactId])) { $contactsAssigned[$contactId] = $allContacts[$contactId]; } } foreach ($allContacts as $contactID => $contactInfo) { if ($contactInfo['register'] != 1) { unset($allContacts[$contactID]); } if (!$contactInfo['parent_id']) { unset($allContacts[$contactID]); } } foreach ($contactsAssigned as $contactID => $contactInfo) { unset($allContacts[$contactID]); } if (count($allContacts)) { foreach ($allContacts as $contactID => $contactInfo) { $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'inverse', 'xs', array(new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addcontact=' . $contactInfo[$contact->nameColumn] . '&contact_id=' . $contactID . '&' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít obesílat'))))); } } if (count($contactsAssigned)) { $initialContent->addItem('<br/>'); foreach ($contactsAssigned as $contactID => $contactInfo) { $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'success', 'xs', array(new EaseHtmlATag('?delcontact=' . $contactInfo[$contact->nameColumn] . '&contact_id=' . $contactID . '&' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat obesílat')), new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace'))))); } } } $this->addItem($initialContent); }
/** * Smazaže kontakt i jeho subkontakty * * @return boolean */ public function rename($newname) { $oldname = $this->getName(); $this->setDataValue($this->nameColumn, $newname); if ($this->saveToMySQL()) { $childs = $this->getChilds(); $subcontact = new IEContact(); $service = new IEService(); foreach ($childs as $childID => $childInfo) { $subcontact->loadFromMySQL($childID); $type = $subcontact->getDataValue('alias'); $subcontact->setDataValue($subcontact->nameColumn, $newname . ' ' . $type); $services = $this->myDbLink->queryTo2DArray('SELECT ' . $service->getmyKeyColumn() . ' FROM ' . $service->myTable . ' WHERE contacts LIKE \'%' . $oldname . ' ' . $type . '%\''); if (count($services)) { foreach ($services as $serviceID) { $service->loadFromMySQL((int) $serviceID); if ($service->delMember('contacts', $id)) { $service->addMember('contacts', $id, $newname . ' ' . $type); $service->saveToMySQL(); } } } $subcontact->saveToMySQL(); } } else { $this->addStatusMessage(_('Kontakt nelze přejmenovat'), 'warning'); } }
/** * Vrací hash vypočítaný z aktuální konfigurace hosta */ function getConfigHash() { $configuration = array(); $service = new IEService(); $servicesAssigned = $service->myDbLink->queryToArray('SELECT `' . $service->getmyKeyColumn() . '` FROM ' . $service->myTable . ' WHERE host_name LIKE \'%"' . $this->getName() . '"%\'', $service->myKeyColumn); foreach ($servicesAssigned as $serviceAssigned) { $service->loadFromSQL((int) $serviceAssigned[$service->myKeyColumn]); $service->unsetDataValue('display_name'); //Položky které se mohou měnit bez nutnosti aktualizovat senzor $service->unsetDataValue('service_description'); $service->unsetDataValue('host_name'); $service->unsetDataValue('hostgroup_name'); $service->unsetDataValue('notes'); $service->unsetDataValue('notes_url'); $service->unsetDataValue('action_url'); $service->unsetDataValue('icon_image'); $service->unsetDataValue('icon_image_alt'); $service->unsetDataValue('public'); $service->unsetDataValue('user_id'); $service->unsetDataValue($service->myLastModifiedColumn); $configuration[] = $service->getEffectiveCfg(); } return hash('md5', $this->getName() . serialize($configuration)); }
/** * Icinga Editor služby * * @package IcingaEditor * @subpackage WebUI * @author Vitex <*****@*****.**> * @copyright 2012 Vitex@hippy.cz (G) */ require_once 'includes/IEInit.php'; $oPage->onlyForLogged(); $service = new IEService($oPage->getRequestValue('service_id', 'int')); $host = new IEHost($oPage->getRequestValue('host_id', 'int')); switch ($oPage->getRequestValue('action')) { case 'clone': $service->setDataValue('parent_id', $service->getId()); $service->unsetDataValue($service->getmyKeyColumn()); $service->addMember('host_name', $host->getId(), $host->getName()); $service->setDataValue('hostgroup_name', array()); $service->setDataValue('user_id', $oUser->getID()); $service->setDataValue($service->nameColumn, _('Klon') . ' ' . $service->getName()); if ($service->saveToMySQL()) { $oUser->addStatusMessage(_('Služba byla naklonována'), 'success'); $oPage->redirect('servicetweak.php?service_id=' . $service->getId() . '&host_id=' . $host->getId()); } else { $oUser->addStatusMessage(_('Sužba nebyla naklonována'), 'warning'); } break; case 'rename': $newname = $oPage->getRequestValue('newname'); if (strlen($newname)) { if ($service->rename($newname)) {