mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-22 13:24:24 +02:00
Remove $request parameter from Form::onSuccess and Form::onRequest
fixes #7552
This commit is contained in:
parent
0e050fa29c
commit
ddf2ef5cc9
@ -7,7 +7,6 @@ namespace Icinga\Forms\Config\Authentication;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Authentication\Backend\DbUserBackend;
|
use Icinga\Authentication\Backend\DbUserBackend;
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ class DbBackendForm extends Form
|
|||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
if (false === static::isValidAuthenticationBackend($this)) {
|
if (false === static::isValidAuthenticationBackend($this)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,7 +7,6 @@ namespace Icinga\Forms\Config\Authentication;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Exception\AuthenticationException;
|
use Icinga\Exception\AuthenticationException;
|
||||||
use Icinga\Authentication\Backend\LdapUserBackend;
|
use Icinga\Authentication\Backend\LdapUserBackend;
|
||||||
@ -119,7 +118,7 @@ class LdapBackendForm extends Form
|
|||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
if (false === static::isValidAuthenticationBackend($this)) {
|
if (false === static::isValidAuthenticationBackend($this)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
namespace Icinga\Forms\Config;
|
namespace Icinga\Forms\Config;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Forms\ConfigForm;
|
use Icinga\Forms\ConfigForm;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
@ -192,7 +191,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
|
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
|
||||||
$backendForm = $this->getBackendForm($this->getElement('type')->getValue());
|
$backendForm = $this->getBackendForm($this->getElement('type')->getValue());
|
||||||
@ -202,7 +201,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$authBackend = $request->getQuery('auth_backend');
|
$authBackend = $this->request->getQuery('auth_backend');
|
||||||
try {
|
try {
|
||||||
if ($authBackend === null) { // create new backend
|
if ($authBackend === null) { // create new backend
|
||||||
$this->add($this->getValues());
|
$this->add($this->getValues());
|
||||||
@ -230,9 +229,9 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||||||
*
|
*
|
||||||
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
|
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
|
||||||
*/
|
*/
|
||||||
public function onRequest(Request $request)
|
public function onRequest()
|
||||||
{
|
{
|
||||||
$authBackend = $request->getQuery('auth_backend');
|
$authBackend = $this->request->getQuery('auth_backend');
|
||||||
if ($authBackend !== null) {
|
if ($authBackend !== null) {
|
||||||
if ($authBackend === '') {
|
if ($authBackend === '') {
|
||||||
throw new ConfigurationError(t('Authentication backend name missing'));
|
throw new ConfigurationError(t('Authentication backend name missing'));
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
namespace Icinga\Forms\Config;
|
namespace Icinga\Forms\Config;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Forms\ConfigForm;
|
use Icinga\Forms\ConfigForm;
|
||||||
|
|
||||||
@ -30,17 +29,26 @@ class AuthenticationBackendReorderForm extends ConfigForm
|
|||||||
return $this->config->keys();
|
return $this->config->keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Form::createElements()
|
||||||
|
*/
|
||||||
|
public function createElements(array $formData)
|
||||||
|
{
|
||||||
|
// This adds just a dummy element to be able to utilize Form::getValue as part of onSuccess()
|
||||||
|
$this->addElement('hidden', 'backend_newpos');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the authentication backend order and save the configuration
|
* Update the authentication backend order and save the configuration
|
||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
$formData = $this->getRequestData($request);
|
$newPosData = $this->getValue('backend_newpos');
|
||||||
if (isset($formData['backend_newpos'])) {
|
if ($newPosData) {
|
||||||
$configForm = $this->getConfigForm();
|
$configForm = $this->getConfigForm();
|
||||||
list($backendName, $position) = explode('|', $formData['backend_newpos'], 2);
|
list($backendName, $position) = explode('|', $newPosData, 2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($configForm->move($backendName, $position)->save()) {
|
if ($configForm->move($backendName, $position)->save()) {
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
namespace Icinga\Forms\Config;
|
namespace Icinga\Forms\Config;
|
||||||
|
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Forms\ConfigForm;
|
use Icinga\Forms\ConfigForm;
|
||||||
use Icinga\Forms\Config\General\LoggingConfigForm;
|
use Icinga\Forms\Config\General\LoggingConfigForm;
|
||||||
@ -38,7 +37,7 @@ class GeneralConfigForm extends ConfigForm
|
|||||||
/**
|
/**
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
$sections = array();
|
$sections = array();
|
||||||
foreach ($this->getValues() as $sectionAndPropertyName => $value) {
|
foreach ($this->getValues() as $sectionAndPropertyName => $value) {
|
||||||
@ -62,7 +61,7 @@ class GeneralConfigForm extends ConfigForm
|
|||||||
/**
|
/**
|
||||||
* @see Form::onRequest()
|
* @see Form::onRequest()
|
||||||
*/
|
*/
|
||||||
public function onRequest(Request $request)
|
public function onRequest()
|
||||||
{
|
{
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($this->config as $section => $properties) {
|
foreach ($this->config as $section => $properties) {
|
||||||
|
@ -7,7 +7,6 @@ namespace Icinga\Forms\Config\Resource;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Application\Platform;
|
use Icinga\Application\Platform;
|
||||||
|
|
||||||
@ -113,7 +112,7 @@ class DbResourceForm extends Form
|
|||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
if (false === static::isValidResource($this)) {
|
if (false === static::isValidResource($this)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,7 +7,6 @@ namespace Icinga\Forms\Config\Resource;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +93,7 @@ class LdapResourceForm extends Form
|
|||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
if (false === static::isValidResource($this)) {
|
if (false === static::isValidResource($this)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,7 +7,6 @@ namespace Icinga\Forms\Config\Resource;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ class LivestatusResourceForm extends Form
|
|||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
if (false === static::isValidResource($this)) {
|
if (false === static::isValidResource($this)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
namespace Icinga\Forms\Config;
|
namespace Icinga\Forms\Config;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Forms\ConfigForm;
|
use Icinga\Forms\ConfigForm;
|
||||||
use Icinga\Forms\Config\Resource\DbResourceForm;
|
use Icinga\Forms\Config\Resource\DbResourceForm;
|
||||||
@ -128,7 +127,7 @@ class ResourceConfigForm extends ConfigForm
|
|||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
|
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
|
||||||
$resourceForm = $this->getResourceForm($this->getElement('type')->getValue());
|
$resourceForm = $this->getResourceForm($this->getElement('type')->getValue());
|
||||||
@ -138,7 +137,7 @@ class ResourceConfigForm extends ConfigForm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$resource = $request->getQuery('resource');
|
$resource = $this->request->getQuery('resource');
|
||||||
try {
|
try {
|
||||||
if ($resource === null) { // create new resource
|
if ($resource === null) { // create new resource
|
||||||
$this->add($this->getValues());
|
$this->add($this->getValues());
|
||||||
@ -166,9 +165,9 @@ class ResourceConfigForm extends ConfigForm
|
|||||||
*
|
*
|
||||||
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
|
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
|
||||||
*/
|
*/
|
||||||
public function onRequest(Request $request)
|
public function onRequest()
|
||||||
{
|
{
|
||||||
$resource = $request->getQuery('resource');
|
$resource = $this->request->getQuery('resource');
|
||||||
if ($resource !== null) {
|
if ($resource !== null) {
|
||||||
if ($resource === '') {
|
if ($resource === '') {
|
||||||
throw new ConfigurationError(t('Resource name missing'));
|
throw new ConfigurationError(t('Resource name missing'));
|
||||||
|
@ -12,10 +12,8 @@ use Icinga\User\Preferences;
|
|||||||
use Icinga\User\Preferences\PreferencesStore;
|
use Icinga\User\Preferences\PreferencesStore;
|
||||||
use Icinga\Util\TimezoneDetect;
|
use Icinga\Util\TimezoneDetect;
|
||||||
use Icinga\Util\Translator;
|
use Icinga\Util\Translator;
|
||||||
use Icinga\Web\Controller\ControllerTabCollector;
|
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Web\Session;
|
use Icinga\Web\Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +84,7 @@ class PreferenceForm extends Form
|
|||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
$this->preferences = new Preferences($this->store->load());
|
$this->preferences = new Preferences($this->store->load());
|
||||||
|
|
||||||
@ -122,7 +120,7 @@ class PreferenceForm extends Form
|
|||||||
*
|
*
|
||||||
* @see Form::onRequest()
|
* @see Form::onRequest()
|
||||||
*/
|
*/
|
||||||
public function onRequest(Request $request)
|
public function onRequest()
|
||||||
{
|
{
|
||||||
$auth = Manager::getInstance();
|
$auth = Manager::getInstance();
|
||||||
$values = $auth->getUser()->getPreferences()->get('icingaweb');
|
$values = $auth->getUser()->getPreferences()->get('icingaweb');
|
||||||
|
@ -37,6 +37,13 @@ class Form extends Zend_Form
|
|||||||
*/
|
*/
|
||||||
protected $created = false;
|
protected $created = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The request associated with this form
|
||||||
|
*
|
||||||
|
* @var Request
|
||||||
|
*/
|
||||||
|
protected $request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The callback to call instead of Form::onSuccess()
|
* The callback to call instead of Form::onSuccess()
|
||||||
*
|
*
|
||||||
@ -112,7 +119,7 @@ class Form extends Zend_Form
|
|||||||
* Create a new form
|
* Create a new form
|
||||||
*
|
*
|
||||||
* Accepts an additional option `onSuccess' which is a callback that is called instead of this
|
* Accepts an additional option `onSuccess' which is a callback that is called instead of this
|
||||||
* form's method. It is called using the following signature: (Request $request, Form $form).
|
* form's method. It is called using the following signature: (Form $form).
|
||||||
*
|
*
|
||||||
* @see Zend_Form::__construct()
|
* @see Zend_Form::__construct()
|
||||||
*
|
*
|
||||||
@ -356,11 +363,9 @@ class Form extends Zend_Form
|
|||||||
*
|
*
|
||||||
* Intended to be implemented by concrete form classes. The base implementation returns always FALSE.
|
* Intended to be implemented by concrete form classes. The base implementation returns always FALSE.
|
||||||
*
|
*
|
||||||
* @param Request $request The valid request used to process this form
|
|
||||||
*
|
|
||||||
* @return null|bool Return FALSE in case no redirect should take place
|
* @return null|bool Return FALSE in case no redirect should take place
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -369,10 +374,8 @@ class Form extends Zend_Form
|
|||||||
* Perform actions when no form dependent data was sent
|
* Perform actions when no form dependent data was sent
|
||||||
*
|
*
|
||||||
* Intended to be implemented by concrete form classes.
|
* Intended to be implemented by concrete form classes.
|
||||||
*
|
|
||||||
* @param Request $request The current request
|
|
||||||
*/
|
*/
|
||||||
public function onRequest(Request $request)
|
public function onRequest()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -552,15 +555,17 @@ class Form extends Zend_Form
|
|||||||
{
|
{
|
||||||
if ($request === null) {
|
if ($request === null) {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
} else {
|
||||||
|
$this->request = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
$formData = $this->getRequestData($request);
|
$formData = $this->getRequestData();
|
||||||
if ($this->getUidDisabled() || $this->wasSent($formData)) {
|
if ($this->getUidDisabled() || $this->wasSent($formData)) {
|
||||||
$this->populate($formData); // Necessary to get isSubmitted() to work
|
$this->populate($formData); // Necessary to get isSubmitted() to work
|
||||||
if (! $this->getSubmitLabel() || $this->isSubmitted()) {
|
if (! $this->getSubmitLabel() || $this->isSubmitted()) {
|
||||||
if ($this->isValid($formData)
|
if ($this->isValid($formData)
|
||||||
&& (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $request, $this))
|
&& (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $this))
|
||||||
|| ($this->onSuccess === null && false !== $this->onSuccess($request)))) {
|
|| ($this->onSuccess === null && false !== $this->onSuccess()))) {
|
||||||
$this->getResponse()->redirectAndExit($this->getRedirectUrl());
|
$this->getResponse()->redirectAndExit($this->getRedirectUrl());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -568,7 +573,7 @@ class Form extends Zend_Form
|
|||||||
$this->isValidPartial($formData);
|
$this->isValidPartial($formData);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->onRequest($request);
|
$this->onRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
@ -694,29 +699,19 @@ class Form extends Zend_Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the request data based on this form's request method
|
* Return the request associated with this form
|
||||||
*
|
*
|
||||||
* @param Request $request The request to fetch the data from
|
* Returns the global request if none has been set for this form yet.
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getRequestData(Request $request)
|
|
||||||
{
|
|
||||||
if (strtolower($request->getMethod()) === $this->getMethod()) {
|
|
||||||
return $request->{'get' . ($request->isPost() ? 'Post' : 'Query')}();
|
|
||||||
}
|
|
||||||
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the current request
|
|
||||||
*
|
*
|
||||||
* @return Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function getRequest()
|
public function getRequest()
|
||||||
{
|
{
|
||||||
return Icinga::app()->getFrontController()->getRequest();
|
if ($this->request === null) {
|
||||||
|
$this->request = Icinga::app()->getFrontController()->getRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->request;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -729,6 +724,20 @@ class Form extends Zend_Form
|
|||||||
return Icinga::app()->getFrontController()->getResponse();
|
return Icinga::app()->getFrontController()->getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the request data based on this form's request method
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getRequestData()
|
||||||
|
{
|
||||||
|
if (strtolower($this->request->getMethod()) === $this->getMethod()) {
|
||||||
|
return $this->request->{'get' . ($this->request->isPost() ? 'Post' : 'Query')}();
|
||||||
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new element located in the Icinga Web 2 library
|
* Create a new element located in the Icinga Web 2 library
|
||||||
*
|
*
|
||||||
|
@ -207,7 +207,7 @@ class Wizard
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->setupPage($page, $request);
|
$this->setupPage($page, $request);
|
||||||
$requestData = $page->getRequestData($request);
|
$requestData = $this->getRequestData($page, $request);
|
||||||
if ($page->wasSent($requestData)) {
|
if ($page->wasSent($requestData)) {
|
||||||
if (($requestedPage = $this->getRequestedPage($requestData)) !== null) {
|
if (($requestedPage = $this->getRequestedPage($requestData)) !== null) {
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
@ -238,6 +238,23 @@ class Wizard
|
|||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the request data based on given form's request method
|
||||||
|
*
|
||||||
|
* @param Form $page The page to fetch the data for
|
||||||
|
* @param Request $request The request to fetch the data from
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getRequestData(Form $page, Request $request)
|
||||||
|
{
|
||||||
|
if (strtolower($request->getMethod()) === $page->getMethod()) {
|
||||||
|
return $request->{'get' . ($request->isPost() ? 'Post' : 'Query')}();
|
||||||
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the requested page
|
* Return the name of the requested page
|
||||||
*
|
*
|
||||||
@ -269,7 +286,7 @@ class Wizard
|
|||||||
$request = $currentPage->getRequest();
|
$request = $currentPage->getRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
$requestData = $currentPage->getRequestData($request);
|
$requestData = $this->getRequestData($currentPage, $request);
|
||||||
if (isset($requestData[static::BTN_NEXT])) {
|
if (isset($requestData[static::BTN_NEXT])) {
|
||||||
return static::FORWARD;
|
return static::FORWARD;
|
||||||
} elseif (isset($requestData[static::BTN_PREV])) {
|
} elseif (isset($requestData[static::BTN_PREV])) {
|
||||||
|
@ -9,7 +9,6 @@ use DateInterval;
|
|||||||
use Icinga\Module\Monitoring\Command\Instance\DisableNotificationsExpireCommand;
|
use Icinga\Module\Monitoring\Command\Instance\DisableNotificationsExpireCommand;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\CommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\CommandForm;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for disabling host and service notifications w/ an optional expire date and time on an Icinga instance
|
* Form for disabling host and service notifications w/ an optional expire date and time on an Icinga instance
|
||||||
@ -60,12 +59,12 @@ class DisableNotificationsExpireCommandForm extends CommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
$disableNotifications = new DisableNotificationsExpireCommand();
|
$disableNotifications = new DisableNotificationsExpireCommand();
|
||||||
$disableNotifications
|
$disableNotifications
|
||||||
->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp());
|
->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp());
|
||||||
$this->getTransport($request)->send($disableNotifications);
|
$this->getTransport($this->request)->send($disableNotifications);
|
||||||
Notification::success(mt('monitoring', 'Disabling host and service notifications..'));
|
Notification::success(mt('monitoring', 'Disabling host and service notifications..'));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ namespace Icinga\Module\Monitoring\Forms\Command\Instance;
|
|||||||
use Icinga\Module\Monitoring\Command\Instance\ToggleInstanceFeatureCommand;
|
use Icinga\Module\Monitoring\Command\Instance\ToggleInstanceFeatureCommand;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\CommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\CommandForm;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for enabling or disabling features of Icinga objects, i.e. hosts or services
|
* Form for enabling or disabling features of Icinga objects, i.e. hosts or services
|
||||||
@ -190,14 +189,14 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->getValues() as $feature => $enabled) {
|
foreach ($this->getValues() as $feature => $enabled) {
|
||||||
$toggleFeature = new ToggleInstanceFeatureCommand();
|
$toggleFeature = new ToggleInstanceFeatureCommand();
|
||||||
$toggleFeature
|
$toggleFeature
|
||||||
->setFeature($feature)
|
->setFeature($feature)
|
||||||
->setEnabled($enabled);
|
->setEnabled($enabled);
|
||||||
$this->getTransport($request)->send($toggleFeature);
|
$this->getTransport($this->request)->send($toggleFeature);
|
||||||
}
|
}
|
||||||
Notification::success(mt('monitoring', 'Toggling feature..'));
|
Notification::success(mt('monitoring', 'Toggling feature..'));
|
||||||
return true;
|
return true;
|
||||||
|
@ -8,7 +8,6 @@ use DateTime;
|
|||||||
use DateInterval;
|
use DateInterval;
|
||||||
use Icinga\Module\Monitoring\Command\Object\AcknowledgeProblemCommand;
|
use Icinga\Module\Monitoring\Command\Object\AcknowledgeProblemCommand;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for acknowledging host or service problems
|
* Form for acknowledging host or service problems
|
||||||
@ -143,7 +142,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
@ -151,14 +150,14 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
|
|||||||
$ack
|
$ack
|
||||||
->setObject($object)
|
->setObject($object)
|
||||||
->setComment($this->getElement('comment')->getValue())
|
->setComment($this->getElement('comment')->getValue())
|
||||||
->setAuthor($request->getUser()->getUsername())
|
->setAuthor($this->request->getUser()->getUsername())
|
||||||
->setPersistent($this->getElement('persistent')->isChecked())
|
->setPersistent($this->getElement('persistent')->isChecked())
|
||||||
->setSticky($this->getElement('sticky')->isChecked())
|
->setSticky($this->getElement('sticky')->isChecked())
|
||||||
->setNotify($this->getElement('notify')->isChecked());
|
->setNotify($this->getElement('notify')->isChecked());
|
||||||
if ($this->getElement('expire')->isChecked()) {
|
if ($this->getElement('expire')->isChecked()) {
|
||||||
$ack->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp());
|
$ack->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp());
|
||||||
}
|
}
|
||||||
$this->getTransport($request)->send($ack);
|
$this->getTransport($this->request)->send($ack);
|
||||||
}
|
}
|
||||||
Notification::success(mtp(
|
Notification::success(mtp(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
|
@ -6,7 +6,6 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
|||||||
|
|
||||||
use Icinga\Module\Monitoring\Command\Object\AddCommentCommand;
|
use Icinga\Module\Monitoring\Command\Object\AddCommentCommand;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for adding host or service comments
|
* Form for adding host or service comments
|
||||||
@ -76,16 +75,16 @@ class AddCommentCommandForm extends ObjectsCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
$comment = new AddCommentCommand();
|
$comment = new AddCommentCommand();
|
||||||
$comment->setObject($object);
|
$comment->setObject($object);
|
||||||
$comment->setComment($this->getElement('comment')->getValue());
|
$comment->setComment($this->getElement('comment')->getValue());
|
||||||
$comment->setAuthor($request->getUser()->getUsername());
|
$comment->setAuthor($this->request->getUser()->getUsername());
|
||||||
$comment->setPersistent($this->getElement('persistent')->isChecked());
|
$comment->setPersistent($this->getElement('persistent')->isChecked());
|
||||||
$this->getTransport($request)->send($comment);
|
$this->getTransport($this->request)->send($comment);
|
||||||
}
|
}
|
||||||
Notification::success(mtp(
|
Notification::success(mtp(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
|
@ -7,7 +7,6 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
|||||||
use Icinga\Module\Monitoring\Command\Object\ScheduleHostCheckCommand;
|
use Icinga\Module\Monitoring\Command\Object\ScheduleHostCheckCommand;
|
||||||
use Icinga\Module\Monitoring\Command\Object\ScheduleServiceCheckCommand;
|
use Icinga\Module\Monitoring\Command\Object\ScheduleServiceCheckCommand;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for immediately checking hosts or services
|
* Form for immediately checking hosts or services
|
||||||
@ -54,7 +53,7 @@ class CheckNowCommandForm extends ObjectsCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
@ -67,7 +66,7 @@ class CheckNowCommandForm extends ObjectsCommandForm
|
|||||||
->setObject($object)
|
->setObject($object)
|
||||||
->setForced()
|
->setForced()
|
||||||
->setCheckTime(time());
|
->setCheckTime(time());
|
||||||
$this->getTransport($request)->send($check);
|
$this->getTransport($this->request)->send($check);
|
||||||
}
|
}
|
||||||
Notification::success(mtp(
|
Notification::success(mtp(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
|
@ -6,7 +6,6 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
|||||||
|
|
||||||
use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand;
|
use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for deleting host or service comments
|
* Form for deleting host or service comments
|
||||||
@ -67,7 +66,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
@ -75,7 +74,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm
|
|||||||
$delComment
|
$delComment
|
||||||
->setObject($object)
|
->setObject($object)
|
||||||
->setCommentId($this->getElement('comment_id')->getValue());
|
->setCommentId($this->getElement('comment_id')->getValue());
|
||||||
$this->getTransport($request)->send($delComment);
|
$this->getTransport($this->request)->send($delComment);
|
||||||
}
|
}
|
||||||
$redirect = $this->getElement('redirect')->getValue();
|
$redirect = $this->getElement('redirect')->getValue();
|
||||||
if (! empty($redirect)) {
|
if (! empty($redirect)) {
|
||||||
|
@ -6,7 +6,6 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
|||||||
|
|
||||||
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
|
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for deleting host or service downtimes
|
* Form for deleting host or service downtimes
|
||||||
@ -67,7 +66,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
@ -75,7 +74,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
|
|||||||
$delDowntime
|
$delDowntime
|
||||||
->setObject($object)
|
->setObject($object)
|
||||||
->setDowntimeId($this->getElement('downtime_id')->getValue());
|
->setDowntimeId($this->getElement('downtime_id')->getValue());
|
||||||
$this->getTransport($request)->send($delDowntime);
|
$this->getTransport($this->request)->send($delDowntime);
|
||||||
}
|
}
|
||||||
$redirect = $this->getElement('redirect')->getValue();
|
$redirect = $this->getElement('redirect')->getValue();
|
||||||
if (! empty($redirect)) {
|
if (! empty($redirect)) {
|
||||||
|
@ -6,7 +6,6 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
|||||||
|
|
||||||
use Icinga\Module\Monitoring\Command\Object\RemoveAcknowledgementCommand;
|
use Icinga\Module\Monitoring\Command\Object\RemoveAcknowledgementCommand;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for removing host or service problem acknowledgements
|
* Form for removing host or service problem acknowledgements
|
||||||
@ -37,13 +36,13 @@ class RemoveAcknowledgementCommandForm extends ObjectsCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
$removeAck = new RemoveAcknowledgementCommand();
|
$removeAck = new RemoveAcknowledgementCommand();
|
||||||
$removeAck->setObject($object);
|
$removeAck->setObject($object);
|
||||||
$this->getTransport($request)->send($removeAck);
|
$this->getTransport($this->request)->send($removeAck);
|
||||||
}
|
}
|
||||||
Notification::success(mtp(
|
Notification::success(mtp(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
|
@ -6,7 +6,6 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
|||||||
|
|
||||||
use Icinga\Module\Monitoring\Command\Object\ScheduleHostCheckCommand;
|
use Icinga\Module\Monitoring\Command\Object\ScheduleHostCheckCommand;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for scheduling host checks
|
* Form for scheduling host checks
|
||||||
@ -40,7 +39,7 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\Host $object */
|
/** @var \Icinga\Module\Monitoring\Object\Host $object */
|
||||||
@ -48,7 +47,7 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm
|
|||||||
$check
|
$check
|
||||||
->setObject($object)
|
->setObject($object)
|
||||||
->setOfAllServices($this->getElement('all_services')->isChecked());
|
->setOfAllServices($this->getElement('all_services')->isChecked());
|
||||||
$this->scheduleCheck($check, $request);
|
$this->scheduleCheck($check, $this->request);
|
||||||
}
|
}
|
||||||
Notification::success(mtp(
|
Notification::success(mtp(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
|
@ -59,7 +59,7 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\Host $object */
|
/** @var \Icinga\Module\Monitoring\Object\Host $object */
|
||||||
@ -79,12 +79,12 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm
|
|||||||
foreach ($object->services as $service) {
|
foreach ($object->services as $service) {
|
||||||
$serviceDowntime = new ScheduleServiceDowntimeCommand();
|
$serviceDowntime = new ScheduleServiceDowntimeCommand();
|
||||||
$serviceDowntime->setObject($service);
|
$serviceDowntime->setObject($service);
|
||||||
$this->scheduleDowntime($serviceDowntime, $request);
|
$this->scheduleDowntime($serviceDowntime, $this->request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$hostDowntime->setObject($object);
|
$hostDowntime->setObject($object);
|
||||||
$this->scheduleDowntime($hostDowntime, $request);
|
$this->scheduleDowntime($hostDowntime, $this->request);
|
||||||
}
|
}
|
||||||
Notification::success(mtp(
|
Notification::success(mtp(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
|
@ -90,13 +90,13 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\Service $object */
|
/** @var \Icinga\Module\Monitoring\Object\Service $object */
|
||||||
$check = new ScheduleServiceCheckCommand();
|
$check = new ScheduleServiceCheckCommand();
|
||||||
$check->setObject($object);
|
$check->setObject($object);
|
||||||
$this->scheduleCheck($check, $request);
|
$this->scheduleCheck($check, $this->request);
|
||||||
}
|
}
|
||||||
Notification::success(mtp(
|
Notification::success(mtp(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
|
@ -201,13 +201,13 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\Service $object */
|
/** @var \Icinga\Module\Monitoring\Object\Service $object */
|
||||||
$downtime = new ScheduleServiceDowntimeCommand();
|
$downtime = new ScheduleServiceDowntimeCommand();
|
||||||
$downtime->setObject($object);
|
$downtime->setObject($object);
|
||||||
$this->scheduleDowntime($downtime, $request);
|
$this->scheduleDowntime($downtime, $this->request);
|
||||||
}
|
}
|
||||||
Notification::success(mtp(
|
Notification::success(mtp(
|
||||||
'monitoring',
|
'monitoring',
|
||||||
|
@ -7,7 +7,6 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
|||||||
use Icinga\Module\Monitoring\Command\Object\ToggleObjectFeatureCommand;
|
use Icinga\Module\Monitoring\Command\Object\ToggleObjectFeatureCommand;
|
||||||
use Icinga\Module\Monitoring\Object\MonitoredObject;
|
use Icinga\Module\Monitoring\Object\MonitoredObject;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for enabling or disabling features of Icinga objects, i.e. hosts or services
|
* Form for enabling or disabling features of Icinga objects, i.e. hosts or services
|
||||||
@ -106,7 +105,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
@ -117,7 +116,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
|
|||||||
->setFeature($feature)
|
->setFeature($feature)
|
||||||
->setObject($object)
|
->setObject($object)
|
||||||
->setEnabled($enabled);
|
->setEnabled($enabled);
|
||||||
$this->getTransport($request)->send($toggleFeature);
|
$this->getTransport($this->request)->send($toggleFeature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
namespace Icinga\Module\Monitoring\Forms\Config;
|
namespace Icinga\Module\Monitoring\Forms\Config;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Forms\ConfigForm;
|
use Icinga\Forms\ConfigForm;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
@ -135,9 +134,9 @@ class BackendConfigForm extends ConfigForm
|
|||||||
*
|
*
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
$monitoringBackend = $request->getQuery('backend');
|
$monitoringBackend = $this->request->getQuery('backend');
|
||||||
try {
|
try {
|
||||||
if ($monitoringBackend === null) { // create new backend
|
if ($monitoringBackend === null) { // create new backend
|
||||||
$this->add($this->getValues());
|
$this->add($this->getValues());
|
||||||
@ -165,9 +164,9 @@ class BackendConfigForm extends ConfigForm
|
|||||||
*
|
*
|
||||||
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
|
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
|
||||||
*/
|
*/
|
||||||
public function onRequest(Request $request)
|
public function onRequest()
|
||||||
{
|
{
|
||||||
$monitoringBackend = $request->getQuery('backend');
|
$monitoringBackend = $this->request->getQuery('backend');
|
||||||
if ($monitoringBackend !== null) {
|
if ($monitoringBackend !== null) {
|
||||||
if ($monitoringBackend === '') {
|
if ($monitoringBackend === '') {
|
||||||
throw new ConfigurationError(mt('monitoring', 'Monitoring backend name missing'));
|
throw new ConfigurationError(mt('monitoring', 'Monitoring backend name missing'));
|
||||||
|
@ -12,7 +12,6 @@ use Icinga\Module\Monitoring\Command\Transport\RemoteCommandFile;
|
|||||||
use Icinga\Module\Monitoring\Forms\Config\Instance\LocalInstanceForm;
|
use Icinga\Module\Monitoring\Forms\Config\Instance\LocalInstanceForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Config\Instance\RemoteInstanceForm;
|
use Icinga\Module\Monitoring\Forms\Config\Instance\RemoteInstanceForm;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for modifying/creating monitoring instances
|
* Form for modifying/creating monitoring instances
|
||||||
@ -132,9 +131,9 @@ class InstanceConfigForm extends ConfigForm
|
|||||||
* @see Form::onRequest() For the method documentation.
|
* @see Form::onRequest() For the method documentation.
|
||||||
* @throws ConfigurationError In case the instance name is missing or invalid
|
* @throws ConfigurationError In case the instance name is missing or invalid
|
||||||
*/
|
*/
|
||||||
public function onRequest(Request $request)
|
public function onRequest()
|
||||||
{
|
{
|
||||||
$instanceName = $request->getQuery('instance');
|
$instanceName = $this->request->getQuery('instance');
|
||||||
if ($instanceName !== null) {
|
if ($instanceName !== null) {
|
||||||
if (! $instanceName) {
|
if (! $instanceName) {
|
||||||
throw new ConfigurationError(mt('monitoring', 'Instance name missing'));
|
throw new ConfigurationError(mt('monitoring', 'Instance name missing'));
|
||||||
@ -153,9 +152,9 @@ class InstanceConfigForm extends ConfigForm
|
|||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see Form::onSuccess() For the method documentation.
|
* @see Form::onSuccess() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
$instanceName = $request->getQuery('instance');
|
$instanceName = $this->request->getQuery('instance');
|
||||||
try {
|
try {
|
||||||
if ($instanceName === null) { // create new instance
|
if ($instanceName === null) { // create new instance
|
||||||
$this->add($this->getValues());
|
$this->add($this->getValues());
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Forms\Config;
|
namespace Icinga\Module\Monitoring\Forms\Config;
|
||||||
|
|
||||||
use Icinga\Web\Request;
|
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Forms\ConfigForm;
|
use Icinga\Forms\ConfigForm;
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ class SecurityConfigForm extends ConfigForm
|
|||||||
/**
|
/**
|
||||||
* @see Form::onSuccess()
|
* @see Form::onSuccess()
|
||||||
*/
|
*/
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
$this->config->security = $this->getValues();
|
$this->config->security = $this->getValues();
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ class SecurityConfigForm extends ConfigForm
|
|||||||
/**
|
/**
|
||||||
* @see Form::onRequest()
|
* @see Form::onRequest()
|
||||||
*/
|
*/
|
||||||
public function onRequest(Request $request)
|
public function onRequest()
|
||||||
{
|
{
|
||||||
if (isset($this->config->security)) {
|
if (isset($this->config->security)) {
|
||||||
$this->populate($this->config->security->toArray());
|
$this->populate($this->config->security->toArray());
|
||||||
|
@ -45,7 +45,8 @@ class ModulePage extends Form
|
|||||||
|
|
||||||
public function handleRequest(Request $request = null)
|
public function handleRequest(Request $request = null)
|
||||||
{
|
{
|
||||||
if ($this->wasSent($this->getRequestData($request))) {
|
$isPost = strtolower($request->getMethod()) === 'post';
|
||||||
|
if ($isPost && $this->wasSent($request->getPost())) {
|
||||||
if (($newModule = $request->getPost('module')) !== null) {
|
if (($newModule = $request->getPost('module')) !== null) {
|
||||||
$this->setCurrentModule($newModule);
|
$this->setCurrentModule($newModule);
|
||||||
$this->getResponse()->redirectAndExit($this->getRedirectUrl());
|
$this->getResponse()->redirectAndExit($this->getRedirectUrl());
|
||||||
@ -58,7 +59,7 @@ class ModulePage extends Form
|
|||||||
$wizardPage = $wizard->getCurrentPage();
|
$wizardPage = $wizard->getCurrentPage();
|
||||||
|
|
||||||
$wizard->handleRequest($request);
|
$wizard->handleRequest($request);
|
||||||
if ($wizard->isFinished() && $wizardPage->wasSent($wizardPage->getRequestData($request))) {
|
if ($isPost && $wizard->isFinished() && $wizardPage->wasSent($request->getPost())) {
|
||||||
$wizards = $this->getWizards();
|
$wizards = $this->getWizards();
|
||||||
|
|
||||||
$newModule = null;
|
$newModule = null;
|
||||||
|
@ -11,7 +11,7 @@ use Icinga\Test\BaseTestCase;
|
|||||||
|
|
||||||
class SuccessfulForm extends Form
|
class SuccessfulForm extends Form
|
||||||
{
|
{
|
||||||
public function onSuccess(Request $request)
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -238,24 +238,6 @@ class FormTest extends BaseTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWhetherGetRequestDataOnlyReturnsFormRelevantData()
|
|
||||||
{
|
|
||||||
$form = new Form();
|
|
||||||
$form->setMethod('POST');
|
|
||||||
|
|
||||||
$expectedResult = array('expected_key' => 'expected_value');
|
|
||||||
$request = $this->getRequestMock();
|
|
||||||
$request->shouldReceive('getMethod')->andReturn('POST')
|
|
||||||
->shouldReceive('isPost')->andReturn(true)
|
|
||||||
->shouldReceive('getPost')->andReturn($expectedResult);
|
|
||||||
|
|
||||||
$this->assertEquals(
|
|
||||||
$expectedResult,
|
|
||||||
$form->getRequestData($request),
|
|
||||||
'Form::getRequestData() does not (only) return form relevant data'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException LogicException
|
* @expectedException LogicException
|
||||||
*/
|
*/
|
||||||
@ -273,7 +255,7 @@ class FormTest extends BaseTestCase
|
|||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$form = new Form(array(
|
$form = new Form(array(
|
||||||
'onSuccess' => function ($req) { $req->setParam('test', 'tset'); return false; }
|
'onSuccess' => function ($form) { $form->getRequest()->setParam('test', 'tset'); return false; }
|
||||||
));
|
));
|
||||||
$form->setTokenDisabled();
|
$form->setTokenDisabled();
|
||||||
$form->setUidDisabled();
|
$form->setUidDisabled();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user