Make node removal working as expected

refs #132
This commit is contained in:
Alexander A. Klimov 2017-11-29 16:38:00 +01:00
parent 00e2f1886a
commit e4e651cbe8
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;