diff options
| author | Nala Ginrut <nalaginrut@gmail.com> | 2014-06-19 15:18:13 +0800 |
|---|---|---|
| committer | Nala Ginrut <nalaginrut@gmail.com> | 2014-06-19 15:18:13 +0800 |
| commit | bfd1db41367f7931016931a94cf1b67396481c79 (patch) | |
| tree | 2d696f2d8eca9ed2e4561c61c16584952d9f7b0b /app/Model/File.php | |
| parent | d0944e682d5a3491f72c5b566248b87fbaff032a (diff) | |
| parent | efdc959c555872677e599d2ff12e1263d719f3f2 (diff) | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'app/Model/File.php')
| -rw-r--r-- | app/Model/File.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/app/Model/File.php b/app/Model/File.php index 41ecfba1..e5aa527e 100644 --- a/app/Model/File.php +++ b/app/Model/File.php @@ -55,6 +55,22 @@ class File extends Base } /** + * Remove all files for a given task + * + * @access public + * @param integer $task_id Task id + * @return bool + */ + public function removeAll($task_id) + { + $files = $this->getAll($task_id); + + foreach ($files as $file) { + $this->remove($file['id']); + } + } + + /** * Create a file entry in the database * * @access public @@ -144,6 +160,7 @@ class File extends Base public function upload($project_id, $task_id, $form_name) { $this->setup(); + $result = array(); if (! empty($_FILES[$form_name])) { @@ -159,7 +176,7 @@ class File extends Base if (@move_uploaded_file($uploaded_filename, self::BASE_PATH.$destination_filename)) { - $this->create( + $result[] = $this->create( $task_id, $original_filename, $destination_filename, @@ -169,5 +186,7 @@ class File extends Base } } } + + return count(array_unique($result)) === 1; } } |
