Merge pull request #152 from Icinga/bugfix/cannot-remove-a-node-132

Make node removal working as expected
This commit is contained in:
Eric Lippmann 2018-07-02 17:23:32 +02:00 committed by GitHub
commit 28bed2859b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -133,9 +133,10 @@ class DeleteNodeForm extends QuickForm
{
$changes = ProcessChanges::construct($this->bp, $this->session);
switch ($this->getValue('confirm')) {
$confirm = $this->getValue('confirm');
switch ($confirm) {
case 'yes':
$changes->deleteNode($this->node, $this->parentNode->getName());
$changes->deleteNode($this->node, $this->parentNode === null ? null : $this->parentNode->getName());
break;
case 'all':
$changes->deleteNode($this->node);
@ -143,6 +144,17 @@ class DeleteNodeForm extends QuickForm
case 'no':
$this->setSuccessMessage($this->translate('Well, maybe next time'));
}
switch ($confirm) {
case 'yes':
case 'all':
if ($this->successUrl === null) {
$this->successUrl = clone $this->getRequest()->getUrl();
}
$this->successUrl->getParams()->remove(array('action', 'deletenode'));
}
// Trigger session desctruction to make sure it get's stored.
// TODO: figure out why this is necessary, might be an unclean shutdown on redirect
unset($changes);

View file

@ -44,6 +44,9 @@ abstract class QuickForm extends QuickBaseForm
*/
protected $request;
/**
* @var Url
*/
protected $successUrl;
protected $successMessage;