Prevents users to convert subtaks to tasks when custom role does not allow it

Fixes #5069
This commit is contained in:
Frédéric Guillot 2023-04-04 19:30:05 -07:00 committed by Frédéric Guillot
parent 4c40fe1931
commit 022b106d2d
2 changed files with 8 additions and 0 deletions

View File

@ -26,6 +26,12 @@ class SubtaskConverterController extends BaseController
$task = $this->getTask();
$subtask = $this->getSubtask($task);
if (! $this->helper->projectRole->canCreateTaskInColumn($task['project_id'], $task['column_id'])) {
$this->flash->failure(t('You cannot create tasks in this column.'));
$this->response->redirect($this->helper->url->to('TaskViewController', 'show', ['task_id' => $task['id']]));
return;
}
$task_id = $this->subtaskTaskConversionModel->convertToTask($task['project_id'], $subtask['id']);
if ($task_id !== false) {

View File

@ -7,8 +7,10 @@
<li>
<?= $this->modal->confirm('trash-o', t('Remove'), 'SubtaskController', 'confirm', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
</li>
<?php if ($this->projectRole->canCreateTaskInColumn($task['project_id'], $task['column_id'])): ?>
<li>
<?= $this->modal->confirm('clone', t('Convert to task'), 'SubtaskConverterController', 'show', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
</li>
<?php endif ?>
</ul>
</div>