/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\Host $object */ $childHosts = (int) $this->getElement('child_hosts')->getValue(); $allServices = $this->getElement('all_services')->isChecked(); if ($childHosts === 0) { $hostDowntime = new ScheduleHostDowntimeCommand(); if ($allServices === true) { $hostDowntime->setForAllServices(); } } else { $hostDowntime = new PropagateHostDowntimeCommand(); if ($childHosts === 1) { $hostDowntime->setTriggered(); } if ($allServices === true) { foreach ($object->services as $service) { $serviceDowntime = new ScheduleServiceDowntimeCommand(); $serviceDowntime->setObject($service); $this->scheduleDowntime($serviceDowntime, $this->request); } } } $hostDowntime->setObject($object); $this->scheduleDowntime($hostDowntime, $this->request); } Notification::success($this->translatePlural('Scheduling host downtime..', 'Scheduling host downtimes..', count($this->objects))); return true; }
public function deployAction() { $isApiRequest = $this->getRequest()->isApiRequest(); $checksum = $this->params->get('checksum'); if ($checksum) { $config = IcingaConfig::load(Util::hex2binary($checksum), $this->db()); } else { $config = IcingaConfig::generate($this->db()); $checksum = $config->getHexChecksum(); } if ($this->api()->dumpConfig($config, $this->db())) { if ($isApiRequest) { return $this->sendJson((object) array('checksum' => $checksum)); } else { $url = Url::fromPath('director/list/deploymentlog'); Notification::success($this->translate('Config has been submitted, validation is going on')); $this->redirectNow($url); } } else { if ($isApiRequest) { return $this->sendJsonError('Config deployment failed'); } else { $url = Url::fromPath('director/config/show', array('checksum' => $checksum)); Notification::success($this->translate('Config deployment failed')); $this->redirectNow($url); } } }
public function onSuccess() { $name = $this->getValue('name'); $this->storage->deleteProcess($name); $this->setRedirectUrl('businessprocess'); Notification::success(sprintf('Process %s has been deleted', $name)); }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { $disableNotifications = new DisableNotificationsExpireCommand(); $disableNotifications->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp()); $this->getTransport($this->request)->send($disableNotifications); Notification::success($this->translate('Disabling host and service notifications..')); return true; }
public function runAction() { if ($runId = Sync::run(SyncRule::load($this->params->get('id'), $this->db()))) { Notification::success('Source has successfully been synchronized'); $this->redirectNow('director/list/syncrule'); } else { } }
/** * @see Form::onSuccess() */ public function onSuccess() { $this->config->setSection('security', $this->getValues()); if ($this->save()) { Notification::success($this->translate('New security configuration has successfully been stored')); } else { return false; } }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ $removeAck = new RemoveAcknowledgementCommand(); $removeAck->setObject($object); $this->getTransport($this->request)->send($removeAck); } Notification::success(mtp('monitoring', 'Removing problem acknowledgement..', 'Removing problem acknowledgements..', count($this->objects))); return true; }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\Service $object */ $check = new ScheduleServiceCheckCommand(); $check->setObject($object); $this->scheduleCheck($check, $this->request); } Notification::success($this->translatePlural('Scheduling service check..', 'Scheduling service checks..', count($this->objects))); return true; }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\Service $object */ $downtime = new ScheduleServiceDowntimeCommand(); $downtime->setObject($object); $this->scheduleDowntime($downtime, $this->request); } Notification::success($this->translatePlural('Scheduling service downtime..', 'Scheduling service downtimes..', count($this->objects))); return true; }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\Host $object */ $check = new ScheduleHostCheckCommand(); $check->setObject($object)->setOfAllServices($this->getElement('all_services')->isChecked()); $this->scheduleCheck($check, $this->request); } Notification::success($this->translatePlural('Scheduling host check..', 'Scheduling host checks..', count($this->objects))); return true; }
/** * {@inheritdoc} */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ $notification = new SendCustomNotificationCommand(); $notification->setObject($object)->setComment($this->getElement('comment')->getValue())->setAuthor($this->request->getUser()->getUsername())->setForced($this->getElement('forced')->isChecked())->setBroadcast($this->getElement('broadcast')->isChecked()); $this->getTransport($this->request)->send($notification); } Notification::success($this->translatePlural('Sending custom notification..', 'Sending custom notifications..', count($this->objects))); return true; }
protected function loadModifiedBpConfig() { $bp = $this->loadBpConfig(); $changes = ProcessChanges::construct($bp, $this->session()); if ($this->params->get('dismissChanges')) { Notification::success(sprintf($this->translate('%d pending change(s) have been dropped'), $changes->count())); $changes->clear(); $this->redirectNow($this->url()->without('dismissChanges')->without('unlocked')); } $bp->applyChanges($changes); return $bp; }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { $cmd = new DeleteCommentCommand(); $cmd->setIsService($this->getElement('comment_is_service')->getValue())->setCommentId($this->getElement('comment_id')->getValue()); $this->getTransport($this->request)->send($cmd); $redirect = $this->getElement('redirect')->getValue(); if (!empty($redirect)) { $this->setRedirectUrl($redirect); } Notification::success($this->translate('Deleting comment..')); return true; }
public function runAction() { $id = $this->params->get('id'); $import = new Import(ImportSource::load($id, $this->db())); if ($runId = $import->run()) { Notification::success('Import succeeded'); $this->redirectNow(Url::fromPath('director/importrun', array('id' => $runId))); } else { Notification::success('Import skipped, no changes detected'); $this->redirectNow('director/list/importrun'); } }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ $ack = new AcknowledgeProblemCommand(); $ack->setObject($object)->setComment($this->getElement('comment')->getValue())->setAuthor($this->request->getUser()->getUsername())->setPersistent($this->getElement('persistent')->isChecked())->setSticky($this->getElement('sticky')->isChecked())->setNotify($this->getElement('notify')->isChecked()); if ($this->getElement('expire')->isChecked()) { $ack->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp()); } $this->getTransport($this->request)->send($ack); } Notification::success($this->translatePlural('Acknowledging problem..', 'Acknowledging problems..', count($this->objects))); return true; }
/** * {@inheritdoc} */ public function onSuccess() { foreach ($this->downtimes as $downtime) { $delDowntime = new DeleteDowntimeCommand(); $delDowntime->setDowntimeId($downtime->id)->setIsService(isset($downtime->service_description)); $this->getTransport($this->request)->send($delDowntime); } $redirect = $this->getElement('redirect')->getValue(); if (!empty($redirect)) { $this->setRedirectUrl($redirect); } Notification::success($this->translatePlural('Deleting downtime..', 'Deleting downtimes..', count($this->downtimes))); return true; }
/** * {@inheritdoc} */ public function onSuccess() { foreach ($this->comments as $comment) { $cmd = new DeleteCommentCommand(); $cmd->setCommentId($comment->id)->setIsService(isset($comment->service_description)); $this->getTransport($this->request)->send($cmd); } $redirect = $this->getElement('redirect')->getValue(); if (!empty($redirect)) { $this->setRedirectUrl($redirect); } Notification::success($this->translatePlural('Deleting comment..', 'Deleting comments..', count($this->comments))); return true; }
/** * Show a business process tree */ public function showAction() { $this->redirectIfConfigChosen(); if ($this->params->get('unlocked')) { $bp = $this->loadModifiedBpConfig(); $bp->unlock(); } else { $bp = $this->loadBpConfig(); } $this->setTitle('Business Process "%s"', $bp->getTitle()); $this->tabsForShow()->activate('show'); // Do not lock empty configs if ($bp->isEmpty() && !$this->view->compact && $bp->isLocked()) { $this->redirectNow($this->url()->with('unlocked', true)); } if ($node = $this->params->get('node')) { // Render a specific node $this->view->nodeName = $node; $this->view->bp = $bp->getNode($node); } else { // Render a single process $this->view->bp = $bp; if ($bp->hasWarnings()) { $this->view->warnings = $bp->getWarnings(); } } $bp->retrieveStatesFromBackend(); if ($bp->isLocked()) { $this->tabs()->extend(new DashboardAction()); } else { $simulation = new Simulation($bp, $this->session()); if ($this->params->get('dismissSimulations')) { Notification::success(sprintf($this->translate('%d applied simulation(s) have been dropped'), $simulation->count())); $simulation->clear(); $this->redirectNow($this->url()->without('dismissSimulations')->without('unlocked')); } $bp->applySimulation($simulation); } if ($this->isXhr()) { $this->setAutorefreshInterval(10); } else { // This will trigger the very first XHR refresh immediately on page // load. Please not that this may hammer the server in case we would // decide to use autorefreshInterval for HTML meta-refreshes also. $this->setAutorefreshInterval(1); } if ($this->params->get('mode') === 'toplevel') { $this->render('toplevel'); } }
public function deployAction() { $checksum = $this->params->get('checksum'); $config = IcingaConfig::load(Util::hex2binary($checksum), $this->db()); if ($this->api()->dumpConfig($config, $this->db())) { $url = Url::fromPath('director/list/deploymentlog'); Notification::success($this->translate('Config has been submitted, validation is going on')); $this->redirectNow($url); } else { $url = Url::fromPath('director/config/show', array('checksum' => $checksum)); Notification::success($this->translate('Config deployment failed')); $this->redirectNow($url); } }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ $comment = new AddCommentCommand(); $comment->setObject($object); $comment->setComment($this->getElement('comment')->getValue()); $comment->setAuthor($this->request->getUser()->getUsername()); $comment->setPersistent($this->getElement('persistent')->isChecked()); $this->getTransport($this->request)->send($comment); } Notification::success($this->translatePlural('Adding comment..', 'Adding comments..', count($this->objects))); return true; }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ if ($object->getType() === $object::TYPE_HOST) { $check = new ScheduleHostCheckCommand(); } else { $check = new ScheduleServiceCheckCommand(); } $check->setObject($object)->setForced()->setCheckTime(time()); $this->getTransport($this->request)->send($check); } Notification::success(mtp('monitoring', 'Scheduling check..', 'Scheduling checks..', count($this->objects))); return true; }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { $end = $this->getValue('end')->getTimestamp(); if ($end <= $this->getValue('start')->getTimestamp()) { $endElement = $this->_elements['end']; $endElement->setValue($endElement->getValue()->format($endElement->getFormat())); $endElement->addError($this->translate('The end time must be greater than the start time')); return false; } $now = new DateTime(); if ($end <= $now->getTimestamp()) { $endElement = $this->_elements['end']; $endElement->setValue($endElement->getValue()->format($endElement->getFormat())); $endElement->addError($this->translate('A downtime must not be in the past')); return false; } foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\Host $object */ if (($childHostsEl = $this->getElement('child_hosts')) !== null) { $childHosts = (int) $childHostsEl->getValue(); } else { $childHosts = 0; } $allServices = $this->getElement('all_services')->isChecked(); if ($childHosts === 0) { $hostDowntime = new ScheduleHostDowntimeCommand(); if ($allServices === true) { $hostDowntime->setForAllServices(); } } else { $hostDowntime = new PropagateHostDowntimeCommand(); if ($childHosts === 1) { $hostDowntime->setTriggered(); } if ($allServices === true) { foreach ($object->services as $service) { $serviceDowntime = new ScheduleServiceDowntimeCommand(); $serviceDowntime->setObject($service); $this->scheduleDowntime($serviceDowntime, $this->request); } } } $hostDowntime->setObject($object); $this->scheduleDowntime($hostDowntime, $this->request); } Notification::success($this->translatePlural('Scheduling host downtime..', 'Scheduling host downtimes..', count($this->objects))); return true; }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ $command = new ProcessCheckResultCommand(); $command->setObject($object); $command->setStatus($this->getValue('status')); $command->setOutput($this->getValue('output')); if ($perfdata = $this->getValue('perfdata')) { $command->setPerformanceData($perfdata); } $this->getTransport($this->request)->send($command); } Notification::success($this->translatePlural('Processing check result..', 'Processing check results..', count($this->objects))); return true; }
/** * (non-PHPDoc) * @see \Icinga\Web\Form::onSuccess() For the method documentation. */ public function onSuccess() { $this->assertPermission('monitoring/command/feature/object'); $notifications = array(ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS => array($this->translate('Enabling active checks..'), $this->translate('Disabling active checks..')), ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS => array($this->translate('Enabling passive checks..'), $this->translate('Disabling passive checks..')), ToggleObjectFeatureCommand::FEATURE_OBSESSING => array($this->translate('Enabling obsessing..'), $this->translate('Disabling obsessing..')), ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS => array($this->translate('Enabling notifications..'), $this->translate('Disabling notifications..')), ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER => array($this->translate('Enabling event handler..'), $this->translate('Disabling event handler..')), ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION => array($this->translate('Enabling flap detection..'), $this->translate('Disabling flap detection..'))); foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ foreach ($this->getValues() as $feature => $enabled) { if ((bool) $object->{$feature} !== (bool) $enabled) { $toggleFeature = new ToggleObjectFeatureCommand(); $toggleFeature->setFeature($feature)->setObject($object)->setEnabled($enabled); $this->getTransport($this->request)->send($toggleFeature); Notification::success($notifications[$feature][$enabled ? 0 : 1]); } } } return true; }
/** * Update the user backend order and save the configuration * * @see Form::onSuccess() */ public function onSuccess() { $newPosData = $this->getValue('backend_newpos'); if ($newPosData) { $configForm = $this->getConfigForm(); list($backendName, $position) = explode('|', $newPosData, 2); try { if ($configForm->move($backendName, $position)->save()) { Notification::success($this->translate('Authentication order updated')); } else { return false; } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); } } }
/** * Update the user backend order and save the configuration */ public function onSuccess() { $newPosData = $this->getValue('backend_newpos'); if ($newPosData) { $configForm = $this->getConfigForm(); list($backendName, $position) = explode('|', $newPosData, 2); try { if ($configForm->move($backendName, $position)->save()) { Notification::success($this->translate('Authentication order updated')); } else { return false; } } catch (NotFoundError $_) { Notification::error(sprintf($this->translate('User backend "%s" not found'), $backendName)); } } }
/** * Adjust preferences and persist them * * @see Form::onSuccess() */ public function onSuccess() { /** @var Preferences $preferences */ $preferences = $this->getRequest()->getUser()->getPreferences(); $icingaweb = $preferences->get('icingaweb'); if ((bool) $preferences->getValue('icingaweb', 'auto_refresh', true) === false) { $icingaweb['auto_refresh'] = '1'; $notification = $this->translate('Auto refresh successfully enabled'); } else { $icingaweb['auto_refresh'] = '0'; $notification = $this->translate('Auto refresh successfully disabled'); } $preferences->icingaweb = $icingaweb; Session::getSession()->user->setPreferences($preferences); Notification::success($notification); $this->getResponse()->setHeader('X-Icinga-Rerender-Layout', 'yes'); $this->setRedirectUrl(Url::fromRequest()->without('renderLayout')); }
/** * @see Form::onSuccess() */ public function onSuccess() { $sections = array(); foreach ($this->getValues() as $sectionAndPropertyName => $value) { list($section, $property) = explode('_', $sectionAndPropertyName, 2); if (!isset($sections[$section])) { $sections[$section] = array(); } $sections[$section][$property] = $value; } foreach ($sections as $section => $config) { $this->config->setSection($section, $config); } if ($this->save()) { Notification::success($this->translate('New configuration has successfully been stored')); } else { return false; } }
/** * {@inheritdoc} */ public function onSuccess() { $sections = array(); foreach ($this->getValues() as $sectionAndPropertyName => $value) { if (empty($value)) { $value = null; // Causes the config writer to unset it } list($section, $property) = explode('_', $sectionAndPropertyName, 2); $sections[$section][$property] = $value; } foreach ($sections as $section => $config) { $this->config->setSection($section, $config); } if ($this->save()) { Notification::success($this->translate('New configuration has successfully been stored')); } else { return false; } }
/** * Display a confirmation form to remove a resource */ public function removeresourceAction() { $this->assertPermission('config/application/resources'); $this->getTabs()->add('resources/remove', array('label' => $this->translate('Remove Resource'), 'url' => Url::fromRequest()))->activate('resources/remove'); $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) { $configForm = new ResourceConfigForm(); $configForm->setIniConfig(Config::app('resources')); $resource = $form->getRequest()->getQuery('resource'); try { $configForm->remove($resource); } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); return false; } if ($configForm->save()) { Notification::success(sprintf(t('Resource "%s" has been successfully removed'), $resource)); } else { return false; } })); $form->setRedirectUrl('config/resource'); $form->handleRequest(); // Check if selected resource is currently used for authentication $resource = $this->getRequest()->getQuery('resource'); $authConfig = Config::app('authentication'); foreach ($authConfig as $backendName => $config) { if ($config->get('resource') === $resource) { $form->addDescription(sprintf($this->translate('The resource "%s" is currently utilized for authentication by user backend "%s". ' . 'Removing the resource can result in noone being able to log in any longer.'), $resource, $backendName)); } } $this->view->form = $form; $this->render('resource/remove'); }