From 8936792f6f7a408dae7e0a6a41274202822acd9c Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 16 Feb 2016 21:12:43 -0500 Subject: Add file attachements to projects --- app/Controller/Base.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'app/Controller/Base.php') 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 @@ -201,6 +201,36 @@ abstract class Base extends \Kanboard\Core\Base return $task; } + /** + * 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 * -- cgit v1.2.3