diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-02-08 18:36:13 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-02-08 18:36:13 -0500 |
commit | 73dce1279760434e1d1b7a903a0a7500462d6f9c (patch) | |
tree | 59a4fa8b6aa0215c658d339e6a31a0ba32b10036 /app/Api | |
parent | d3650eaa2582f6224eb5f5549829b7a84cda1ea4 (diff) |
Prevent people to remove columns that contains tasks
Diffstat (limited to 'app/Api')
-rw-r--r-- | app/Api/Procedure/ColumnProcedure.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/Api/Procedure/ColumnProcedure.php b/app/Api/Procedure/ColumnProcedure.php index ab9d173b..3ffe12ba 100644 --- a/app/Api/Procedure/ColumnProcedure.php +++ b/app/Api/Procedure/ColumnProcedure.php @@ -4,6 +4,7 @@ namespace Kanboard\Api\Procedure; use Kanboard\Api\Authorization\ColumnAuthorization; use Kanboard\Api\Authorization\ProjectAuthorization; +use Kanboard\Model\TaskModel; /** * Column API controller @@ -40,6 +41,15 @@ class ColumnProcedure extends BaseProcedure public function removeColumn($column_id) { ColumnAuthorization::getInstance($this->container)->check($this->getClassName(), 'removeColumn', $column_id); + + $projectId = $this->columnModel->getProjectId($column_id); + $nbTasks = $this->taskFinderModel->countByColumnId($projectId, $column_id, array(TaskModel::STATUS_OPEN, TaskModel::STATUS_CLOSED)); + + if ($nbTasks > 0) { + $this->logger->error(__METHOD__.': This column cannot be removed because it contains '.$nbTasks.' tasks'); + return false; + } + return $this->columnModel->remove($column_id); } |