当前位置: 首页>>代码示例>>PHP>>正文


PHP Notification::error方法代码示例

本文整理汇总了PHP中Icinga\Web\Notification::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::error方法的具体用法?PHP Notification::error怎么用?PHP Notification::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Icinga\Web\Notification的用法示例。


在下文中一共展示了Notification::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createbackendAction

 /**
  * Create a new monitoring backend
  */
 public function createbackendAction()
 {
     $form = new BackendConfigForm();
     $form->setRedirectUrl('monitoring/config');
     $form->setTitle($this->translate('Create New Monitoring Backend'));
     $form->setIniConfig($this->Config('backends'));
     try {
         $form->setResourceConfig(ResourceFactory::getResourceConfigs());
     } catch (ConfigurationError $e) {
         if ($this->hasPermission('config/application/resources')) {
             Notification::error($e->getMessage());
             $this->redirectNow('config/createresource');
         }
         throw $e;
         // No permission for resource configuration, show the error
     }
     $form->setOnSuccess(function (BackendConfigForm $form) {
         try {
             $form->add(array_filter($form->getValues()));
         } catch (Exception $e) {
             $form->error($e->getMessage());
             return false;
         }
         if ($form->save()) {
             Notification::success(t('Monitoring backend successfully created'));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('form');
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:36,代码来源:ConfigController.php

示例2: onSuccess

 /**
  * 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));
         }
     }
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:20,代码来源:UserBackendReorderForm.php

示例3: onSuccess

 /**
  * 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());
         }
     }
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:22,代码来源:UserBackendReorderForm.php

示例4: removememberAction

 /**
  * Remove a group member
  */
 public function removememberAction()
 {
     $this->assertPermission('config/authentication/groups/edit');
     $this->assertHttpMethod('POST');
     $groupName = $this->params->getRequired('group');
     $backend = $this->getUserGroupBackend($this->params->getRequired('backend'), 'Icinga\\Data\\Reducible');
     $form = new Form(array('onSuccess' => function ($form) use($groupName, $backend) {
         foreach ($form->getValue('user_name') as $userName) {
             try {
                 $backend->delete('group_membership', Filter::matchAll(Filter::where('group_name', $groupName), Filter::where('user_name', $userName)));
                 Notification::success(sprintf(t('User "%s" has been removed from group "%s"'), $userName, $groupName));
             } catch (NotFoundError $e) {
                 throw $e;
             } catch (Exception $e) {
                 Notification::error($e->getMessage());
             }
         }
         $redirect = $form->getValue('redirect');
         if (!empty($redirect)) {
             $form->setRedirectUrl(htmlspecialchars_decode($redirect));
         }
         return true;
     }));
     $form->setUidDisabled();
     $form->setSubmitLabel('btn_submit');
     // Required to ensure that isSubmitted() is called
     $form->addElement('hidden', 'user_name', array('required' => true, 'isArray' => true));
     $form->addElement('hidden', 'redirect');
     try {
         $form->handleRequest();
     } catch (NotFoundError $_) {
         $this->httpNotFound(sprintf($this->translate('Group "%s" not found'), $groupName));
     }
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:37,代码来源:GroupController.php

示例5: onSuccess

 /**
  * Adjust preferences and persist them
  *
  * @see Form::onSuccess()
  */
 public function onSuccess()
 {
     $this->preferences = new Preferences($this->store ? $this->store->load() : array());
     $webPreferences = $this->preferences->get('icingaweb', array());
     foreach ($this->getValues() as $key => $value) {
         if ($value === null || $value === 'autodetect') {
             if (isset($webPreferences[$key])) {
                 unset($webPreferences[$key]);
             }
         } else {
             $webPreferences[$key] = $value;
         }
     }
     $this->preferences->icingaweb = $webPreferences;
     Session::getSession()->user->setPreferences($this->preferences);
     try {
         if ($this->store && $this->getElement('btn_submit_preferences')->isChecked()) {
             $this->save();
             Notification::success($this->translate('Preferences successfully saved'));
         } else {
             Notification::success($this->translate('Preferences successfully saved for the current session'));
         }
     } catch (Exception $e) {
         Logger::error($e);
         Notification::error($e->getMessage());
     }
 }
开发者ID:JakobGM,项目名称:icingaweb2,代码行数:32,代码来源:PreferenceForm.php

示例6: onSuccess

 /**
  * Add or edit an user backend and save the configuration
  *
  * Performs a connectivity validation using the submitted values. A checkbox is
  * added to the form to skip the check if it fails and redirection is aborted.
  *
  * @see Form::onSuccess()
  */
 public function onSuccess()
 {
     if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
         $backendForm = $this->getBackendForm($this->getElement('type')->getValue());
         if (false === $backendForm::isValidUserBackend($this)) {
             $this->addElement($this->getForceCreationCheckbox());
             return false;
         }
     }
     $authBackend = $this->request->getQuery('backend');
     try {
         if ($authBackend === null) {
             // create new backend
             $this->add($this->getValues());
             $message = $this->translate('User backend "%s" has been successfully created');
         } else {
             // edit existing backend
             $this->edit($authBackend, $this->getValues());
             $message = $this->translate('User backend "%s" has been successfully changed');
         }
     } catch (InvalidArgumentException $e) {
         Notification::error($e->getMessage());
         return;
     }
     if ($this->save()) {
         Notification::success(sprintf($message, $this->getElement('name')->getValue()));
     } else {
         return false;
     }
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:38,代码来源:UserBackendConfigForm.php

示例7: onSuccess

 /**
  * Add or edit a resource and save the configuration
  *
  * Performs a connectivity validation using the submitted values. A checkbox is
  * added to the form to skip the check if it fails and redirection is aborted.
  *
  * @see Form::onSuccess()
  */
 public function onSuccess()
 {
     $resourceForm = $this->getResourceForm($this->getElement('type')->getValue());
     if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
         $inspection = static::inspectResource($this);
         if ($inspection !== null && $inspection->hasError()) {
             $this->error($inspection->getError());
             $this->addElement($this->getForceCreationCheckbox());
             return false;
         }
     }
     $resource = $this->request->getQuery('resource');
     try {
         if ($resource === null) {
             // create new resource
             if (method_exists($resourceForm, 'beforeAdd')) {
                 if (!$resourceForm::beforeAdd($this)) {
                     return false;
                 }
             }
             $this->add(array_filter($this->getValues()));
             $message = $this->translate('Resource "%s" has been successfully created');
         } else {
             // edit existing resource
             $this->edit($resource, array_filter($this->getValues()));
             $message = $this->translate('Resource "%s" has been successfully changed');
         }
     } catch (InvalidArgumentException $e) {
         Notification::error($e->getMessage());
         return false;
     }
     if ($this->save()) {
         Notification::success(sprintf($message, $this->getElement('name')->getValue()));
     } else {
         return false;
     }
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:45,代码来源:ResourceConfigForm.php

示例8: onSuccess

 /**
  * Add or edit a monitoring backend and save the configuration
  */
 public function onSuccess()
 {
     $monitoringBackend = $this->request->getQuery('backend');
     try {
         if ($monitoringBackend === null) {
             // Create new backend
             $this->add($this->getValues());
             $message = $this->translate('Monitoring backend "%s" has been successfully created');
         } else {
             // Edit existing backend
             $this->edit($monitoringBackend, $this->getValues());
             $message = $this->translate('Monitoring backend "%s" has been successfully changed');
         }
     } catch (InvalidArgumentException $e) {
         Notification::error($e->getMessage());
         return null;
     }
     if ($this->save()) {
         Notification::success(sprintf($message, $this->getElement('name')->getValue()));
     } else {
         return false;
     }
 }
开发者ID:xert,项目名称:icingaweb2,代码行数:26,代码来源:BackendConfigForm.php

示例9: removeAction

 /**
  * Remove a role
  */
 public function removeAction()
 {
     $this->assertPermission('config/authentication/roles/remove');
     $name = $this->params->getRequired('role');
     $role = new RoleForm();
     try {
         $role->setIniConfig(Config::app('roles', true))->load($name);
     } catch (NotFoundError $e) {
         $this->httpNotFound($e->getMessage());
     }
     $confirmation = new ConfirmRemovalForm(array('onSuccess' => function (ConfirmRemovalForm $confirmation) use($name, $role) {
         try {
             $role->remove($name);
         } catch (NotFoundError $e) {
             Notification::error($e->getMessage());
             return false;
         }
         if ($role->save()) {
             Notification::success(t('Role removed'));
             return true;
         }
         return false;
     }));
     $confirmation->setSubmitLabel($this->translate('Remove Role'))->setRedirectUrl('role/list')->handleRequest();
     $this->renderForm($confirmation, $this->translate('Remove Role'));
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:29,代码来源:RoleController.php

示例10: getLdapResourceNames

 /**
  * Return the names of all configured LDAP resources
  *
  * @return  array
  */
 protected function getLdapResourceNames()
 {
     $names = array();
     foreach (ResourceFactory::getResourceConfigs() as $name => $config) {
         if (in_array(strtolower($config->type), array('ldap', 'msldap'))) {
             $names[] = $name;
         }
     }
     if (empty($names)) {
         Notification::error($this->translate('No LDAP resources available. Please configure an LDAP resource first.'));
         $this->getResponse()->redirectAndExit('config/createresource');
     }
     return $names;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:19,代码来源:LdapUserGroupBackendForm.php

示例11: removePaneAction

 public function removePaneAction()
 {
     $form = new ConfirmRemovalForm();
     $this->createTabs();
     $dashboard = $this->dashboard;
     if (!$this->_request->getParam('pane')) {
         throw new Zend_Controller_Action_Exception('Missing parameter "pane"', 400);
     }
     $pane = $this->_request->getParam('pane');
     $action = $this;
     $form->setOnSuccess(function (Form $form) use($dashboard, $pane, $action) {
         $pane = $dashboard->getPane($pane);
         $dashboard->removePane($pane->getTitle());
         $dashboardConfig = $dashboard->getConfig();
         try {
             $dashboardConfig->saveIni();
             Notification::success(t('Dashboard has been removed') . ': ' . $pane->getTitle());
             return true;
         } catch (Exception $e) {
             $action->view->error = $e;
             $action->view->config = $dashboardConfig;
             $action->render('error');
             return false;
         } catch (ProgrammingError $e) {
             Notification::error($e->getMessage());
             return false;
         }
         return false;
     });
     $form->setTitle($this->translate('Remove Dashboard'));
     $form->setRedirectUrl('dashboard/settings');
     $form->handleRequest();
     $this->view->pane = $pane;
     $this->view->form = $form;
 }
开发者ID:JakobGM,项目名称:icingaweb2,代码行数:35,代码来源:DashboardController.php

示例12: onDeleteSuccess

 /**
  * Apply mode delete on the repository
  *
  * @return  bool
  */
 protected function onDeleteSuccess()
 {
     try {
         $this->repository->delete($this->repository->getBaseTable(), $this->createFilter());
     } catch (Exception $e) {
         Notification::error($this->getDeleteMessage(false));
         $this->error($e->getMessage());
         return false;
     }
     Notification::success($this->getDeleteMessage(true));
     return true;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:17,代码来源:RepositoryForm.php

示例13: onSuccess

 /**
  * Adjust preferences and persist them
  *
  * @see Form::onSuccess()
  */
 public function onSuccess()
 {
     $this->preferences = new Preferences($this->store ? $this->store->load() : array());
     $oldTheme = $this->preferences->getValue('icingaweb', 'theme');
     $webPreferences = $this->preferences->get('icingaweb', array());
     foreach ($this->getValues() as $key => $value) {
         if ($value === '' || $value === 'autodetect' || $key === 'theme' && $value === Config::app()->get('themes', 'default', StyleSheet::DEFAULT_THEME)) {
             if (isset($webPreferences[$key])) {
                 unset($webPreferences[$key]);
             }
         } else {
             $webPreferences[$key] = $value;
         }
     }
     $this->preferences->icingaweb = $webPreferences;
     Session::getSession()->user->setPreferences($this->preferences);
     if (($theme = $this->getElement('theme')) !== null && ($theme = $theme->getValue()) !== $oldTheme) {
         $this->getResponse()->setReloadCss(true);
     }
     try {
         if ($this->store && $this->getElement('btn_submit_preferences')->isChecked()) {
             $this->save();
             Notification::success($this->translate('Preferences successfully saved'));
         } else {
             Notification::success($this->translate('Preferences successfully saved for the current session'));
         }
     } catch (Exception $e) {
         Logger::error($e);
         Notification::error($e->getMessage());
     }
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:36,代码来源:PreferenceForm.php

示例14: removeAction

 /**
  * Remove a role
  *
  * @throws Zend_Controller_Action_Exception If the required parameter 'role' is missing or the role does not exist
  */
 public function removeAction()
 {
     $this->assertPermission('config/authentication/roles/remove');
     $name = $this->_request->getParam('role');
     if (empty($name)) {
         throw new Zend_Controller_Action_Exception(sprintf($this->translate('Required parameter \'%s\' missing'), 'role'), 400);
     }
     $role = new RoleForm();
     try {
         $role->setIniConfig(Config::app('roles', true))->load($name);
     } catch (InvalidArgumentException $e) {
         throw new Zend_Controller_Action_Exception($e->getMessage(), 400);
     }
     $confirmation = new ConfirmRemovalForm(array('onSuccess' => function (ConfirmRemovalForm $confirmation) use($name, $role) {
         try {
             $role->remove($name);
         } catch (InvalidArgumentException $e) {
             Notification::error($e->getMessage());
             return false;
         }
         if ($role->save()) {
             Notification::success(t('Role removed'));
             return true;
         }
         return false;
     }));
     $confirmation->setTitle(sprintf($this->translate('Remove Role %s'), $name))->setSubmitLabel($this->translate('Remove Role'))->setRedirectUrl('role/list')->handleRequest();
     $this->view->form = $confirmation;
     $this->render('form');
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:35,代码来源:RoleController.php

示例15: notifyError

 public function notifyError($message)
 {
     Notification::error($message);
     return $this;
 }
开发者ID:dgoeger,项目名称:icingadirector,代码行数:5,代码来源:QuickForm.php


注:本文中的Icinga\Web\Notification::error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。