Add file attachements to projects

This commit is contained in:
Frederic Guillot
2016-02-16 21:12:43 -05:00
parent 5bbc903dca
commit 8936792f6f
20 changed files with 449 additions and 194 deletions

View File

@@ -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
*