diff options
Diffstat (limited to 'app/Controller/Base.php')
-rw-r--r-- | app/Controller/Base.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/Controller/Base.php b/app/Controller/Base.php index c55ad9ad..884c439c 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -202,6 +202,36 @@ abstract class Base extends \Kanboard\Core\Base } /** + * Get Task or Project file + * + * @access protected + */ + protected function getFile() + { + $task_id = $this->request->getIntegerParam('task_id'); + $file_id = $this->request->getIntegerParam('file_id'); + $model = 'projectFile'; + + if ($task_id > 0) { + $model = 'taskFile'; + $project_id = $this->taskFinder->getProjectId($task_id); + + if ($project_id !== $this->request->getIntegerParam('project_id')) { + $this->forbidden(); + } + } + + $file = $this->$model->getById($file_id); + + if (empty($file)) { + $this->notfound(); + } + + $file['model'] = $model; + return $file; + } + + /** * Common method to get a project * * @access protected |