/** * 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); }
/** * Editor k přidávání členů skupiny * * @param IEHost $host */ public function __construct($host) { parent::__construct(); $fieldName = $host->getmyKeyColumn(); $initialContent = new EaseTWBPanel(_('rodiče hostu')); $addparentForm = $initialContent->addItem(new EaseTWBForm('addparent')); $addparentForm->addItem(new EaseTWBFormGroup(_('IP nebo Hostname'), new EaseHtmlInputTextTag('newparent'))); $addparentForm->addItem(new EaseHtmlInputHiddenTag($fieldName, $host->getId())); $addparentForm->addItem(new EaseTWSubmitButton(_('Přidat rodiče'), 'success')); $initialContent->setTagCss(array('width' => '100%')); if (is_null($host->getMyKey())) { $initialContent->addItem(_('Nejprve je potřeba uložit záznam')); } else { $allParents = $host->getListing(); unset($allParents[$host->getID()]); //Nenabízet sám sebe jako rodiče foreach ($allParents as $parentID => $parentInfo) { if ($parentInfo['register'] != 1) { unset($allParents[$parentID]); } } $parentsAssigned = array(); foreach ($host->getDataValue('parents') as $parentAssigned) { $parentID = EaseShared::myDbLink()->queryToValue('SELECT `' . $host->myKeyColumn . '` FROM ' . $host->myTable . ' WHERE `' . $host->nameColumn . '` = \'' . addSlashes($parentAssigned) . '\''); $parentsAssigned[$parentID][$host->nameColumn] = $parentAssigned; $parentsAssigned[$parentID][$host->myKeyColumn] = $parentID; unset($allParents[$parentID]); } if (count($allParents)) { foreach ($allParents as $parentID => $parentInfo) { $initialContent->addItem($this->parentButton($parentInfo, 'plus', $host)); } } if (count($parentsAssigned)) { $initialContent->addItem('</br>'); foreach ($parentsAssigned as $parentID => $parentInfo) { $initialContent->addItem($this->parentButton($parentInfo, 'remove', $host)); } } } $this->addItem($initialContent); }
/** * Editor k přidávání členů skupiny * * @param IEHost $host */ public function __construct($host) { parent::__construct(); $fieldName = $this->getmyKeyColumn(); if ($host->getDataValue('platform') == 'generic') { $note = '<small><span class="label label-info">Tip:</span> ' . _('Další sledovatelné služby budou nabídnuty po nastavení platformy hosta a vzdáleného senzoru.') . '</small>'; } else { $note = array(); } $initialContent = new EaseTWBPanel(_('Sledované služby'), 'default', null, $note); $initialContent->setTagCss(array('width' => '100%')); if (is_null($host->getMyKey())) { $initialContent->addItem(_('Nejprve je potřeba uložit záznam')); } else { $hostName = $host->getName(); $service = new IEService(); $parentServUsed = array(); $host_active = (bool) $host->getCfgValue('active_checks_enabled'); $host_passive = (bool) $host->getCfgValue('passive_checks_enabled'); $servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',display_name,' . $service->nameColumn . ' FROM ' . $service->myTable . ' WHERE ' . $fieldName . ' LIKE \'%"' . $host->getName() . '"%\'', $service->myKeyColumn); $allServices = $service->getListing(null, true, array('platform', 'parent_id', 'passive_checks_enabled', 'active_checks_enabled', 'display_name')); foreach ($allServices as $serviceID => $serviceInfo) { $servicePassive = (bool) $serviceInfo['passive_checks_enabled']; $serviceActive = (bool) $serviceInfo['active_checks_enabled']; if ($serviceInfo['register'] != 1) { unset($allServices[$serviceID]); continue; } if ($serviceInfo['platform'] != 'generic' && $serviceInfo['platform'] != $host->getDataValue('platform')) { unset($allServices[$serviceID]); continue; } if ((!$host_passive || !$servicePassive) && (!$host_active || !$serviceActive)) { unset($allServices[$serviceID]); continue; } } foreach ($servicesAssigned as $serviceID => $serviceInfo) { if (isset($allServices[$serviceID]) && isset($parentServUsed[$allServices[$serviceID]['parent_id']])) { $parentServUsed[$allServices[$serviceID]['parent_id']] = $allServices[$serviceID]['parent_id']; } unset($allServices[$serviceID]); } if (count($allServices)) { foreach ($allServices as $serviceID => $serviceInfo) { if (isset($parentServUsed[$serviceInfo['parent_id']])) { continue; } $unchMenu = array(); if (intval($serviceInfo['parent_id'])) { $unchMenu[] = new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')); } $unchMenu[] = new EaseHtmlATag('?addservice=' . $serviceInfo[$service->nameColumn] . '&service_id=' . $serviceID . '&' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít sledovat')); if (strlen($serviceInfo['display_name'])) { $serviceName = $serviceInfo['display_name']; } else { $serviceName = $serviceInfo[$service->nameColumn]; } $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'inverse', 'xs', $unchMenu)); } } if (count($servicesAssigned)) { $saveAsTemplateButton = new EaseTWBLinkButton('stemplate.php?action=copyhost&host_id=' . $host->getId(), _('Uložit jako předlohu'), 'success'); $initialContent->footer($saveAsTemplateButton); $initialContent->addItem('</br>'); foreach ($servicesAssigned as $serviceID => $serviceInfo) { if (strlen($serviceInfo['display_name'])) { $serviceName = $serviceInfo['display_name']; } else { $serviceName = $serviceInfo[$service->nameColumn]; } $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'success', 'xs', array(new EaseHtmlATag('?delservice=' . $serviceInfo[$service->nameColumn] . '&service_id=' . $serviceID . '&' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat sledovat')), new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID . '&host_id=' . $host->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace'))))); } } else { $presetSelForm = new EaseTWBForm('presetSelForm'); $presetSelForm->addItem(new EaseHtmlInputHiddenTag($host->getmyKeyColumn(), $host->getId())); $presetSelForm->addItem(new EaseHtmlInputHiddenTag('action', 'applystemplate')); $presetSelForm->addItem(new IEStemplateSelect('stemplate_id')); $presetSelForm->addItem(new EaseTWSubmitButton(_('Aplikovat předlohu'), 'success')); $presetSelForm->setTagClass('form-inline'); $initialContent->footer($presetSelForm); } } $this->addItem($initialContent); }