Fix wrong redirect after removing a task from the task view page
This commit is contained in:
@@ -22,6 +22,7 @@ Improvements:
|
|||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
* Do not send notifications to disabled users
|
* Do not send notifications to disabled users
|
||||||
|
* Fix wrong redirect when removing a task from the task view page
|
||||||
|
|
||||||
Breaking changes:
|
Breaking changes:
|
||||||
|
|
||||||
|
|||||||
53
app/Controller/TaskSuppressionController.php
Normal file
53
app/Controller/TaskSuppressionController.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanboard\Controller;
|
||||||
|
|
||||||
|
use Kanboard\Core\Controller\AccessForbiddenException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TaskSuppressionController
|
||||||
|
*
|
||||||
|
* @package Kanboard\Controller
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class TaskSuppressionController extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Confirmation dialog box before to remove the task
|
||||||
|
*/
|
||||||
|
public function confirm()
|
||||||
|
{
|
||||||
|
$task = $this->getTask();
|
||||||
|
|
||||||
|
if (! $this->helper->user->canRemoveTask($task)) {
|
||||||
|
throw new AccessForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->response->html($this->template->render('task_suppression/remove', array(
|
||||||
|
'task' => $task,
|
||||||
|
'redirect' => $this->request->getStringParam('redirect'),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a task
|
||||||
|
*/
|
||||||
|
public function remove()
|
||||||
|
{
|
||||||
|
$task = $this->getTask();
|
||||||
|
$this->checkCSRFParam();
|
||||||
|
|
||||||
|
if (! $this->helper->user->canRemoveTask($task)) {
|
||||||
|
throw new AccessForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->task->remove($task['id'])) {
|
||||||
|
$this->flash->success(t('Task removed successfully.'));
|
||||||
|
} else {
|
||||||
|
$this->flash->failure(t('Unable to remove this task.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$redirect = $this->request->getStringParam('redirect') === '';
|
||||||
|
$this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), $redirect);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -143,34 +143,4 @@ class TaskViewController extends BaseController
|
|||||||
'transitions' => $this->transition->getAllByTask($task['id']),
|
'transitions' => $this->transition->getAllByTask($task['id']),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a task
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function remove()
|
|
||||||
{
|
|
||||||
$task = $this->getTask();
|
|
||||||
|
|
||||||
if (! $this->helper->user->canRemoveTask($task)) {
|
|
||||||
throw new AccessForbiddenException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->request->getStringParam('confirmation') === 'yes') {
|
|
||||||
$this->checkCSRFParam();
|
|
||||||
|
|
||||||
if ($this->task->remove($task['id'])) {
|
|
||||||
$this->flash->success(t('Task removed successfully.'));
|
|
||||||
} else {
|
|
||||||
$this->flash->failure(t('Unable to remove this task.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->response->html($this->template->render('task/remove', array(
|
|
||||||
'task' => $task,
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class AuthenticationProvider implements ServiceProviderInterface
|
|||||||
$acl->add('SubtaskRestrictionController', '*', Role::PROJECT_MEMBER);
|
$acl->add('SubtaskRestrictionController', '*', Role::PROJECT_MEMBER);
|
||||||
$acl->add('SubtaskStatusController', '*', Role::PROJECT_MEMBER);
|
$acl->add('SubtaskStatusController', '*', Role::PROJECT_MEMBER);
|
||||||
$acl->add('SwimlaneController', '*', Role::PROJECT_MANAGER);
|
$acl->add('SwimlaneController', '*', Role::PROJECT_MANAGER);
|
||||||
$acl->add('TaskViewController', 'remove', Role::PROJECT_MEMBER);
|
$acl->add('TaskSuppressionController', '*', Role::PROJECT_MEMBER);
|
||||||
$acl->add('TaskCreationController', '*', Role::PROJECT_MEMBER);
|
$acl->add('TaskCreationController', '*', Role::PROJECT_MEMBER);
|
||||||
$acl->add('TaskBulkController', '*', Role::PROJECT_MEMBER);
|
$acl->add('TaskBulkController', '*', Role::PROJECT_MEMBER);
|
||||||
$acl->add('TaskDuplicationController', '*', Role::PROJECT_MEMBER);
|
$acl->add('TaskDuplicationController', '*', Role::PROJECT_MEMBER);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
<?php if ($this->user->canRemoveTask($task)): ?>
|
<?php if ($this->user->canRemoveTask($task)): ?>
|
||||||
<li>
|
<li>
|
||||||
<i class="fa fa-trash-o fa-fw"></i>
|
<i class="fa fa-trash-o fa-fw"></i>
|
||||||
<?= $this->url->link(t('Remove'), 'TaskViewController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
<?= $this->url->link(t('Remove'), 'TaskSuppressionController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||||
</li>
|
</li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if (isset($task['is_active'])): ?>
|
<?php if (isset($task['is_active'])): ?>
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
<?php if ($this->user->canRemoveTask($task)): ?>
|
<?php if ($this->user->canRemoveTask($task)): ?>
|
||||||
<li>
|
<li>
|
||||||
<i class="fa fa-trash-o fa-fw"></i>
|
<i class="fa fa-trash-o fa-fw"></i>
|
||||||
<?= $this->url->link(t('Remove'), 'TaskViewController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
<?= $this->url->link(t('Remove'), 'TaskSuppressionController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'popover') ?>
|
||||||
</li>
|
</li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<?= $this->url->link(t('Yes'), 'TaskViewController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes'), true, 'btn btn-red popover-link') ?>
|
<?= $this->url->link(t('Yes'), 'TaskSuppressionController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => $redirect), true, 'btn btn-red popover-link') ?>
|
||||||
<?= t('or') ?>
|
<?= t('or') ?>
|
||||||
<?= $this->url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
<?= $this->url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user