summaryrefslogtreecommitdiff
path: root/app/Model/File.php
diff options
context:
space:
mode:
authorBlueTeck <tili2@gmx.de>2015-04-09 10:08:27 +0200
committerBlueTeck <tili2@gmx.de>2015-04-09 10:08:27 +0200
commitbca1012e70db8c23a2a4b2bcf0767a36d1a719ff (patch)
tree254b6ebbde61b2a122c217c97821e7ad942159a7 /app/Model/File.php
parentc1329ac7c45baf3c824b91f043e70a2f6b072785 (diff)
#717 add size, user, date to uploaded files
Diffstat (limited to 'app/Model/File.php')
-rw-r--r--app/Model/File.php64
1 files changed, 55 insertions, 9 deletions
diff --git a/app/Model/File.php b/app/Model/File.php
index a8cce9f4..52f756c6 100644
--- a/app/Model/File.php
+++ b/app/Model/File.php
@@ -82,7 +82,7 @@ class File extends Base
* @param bool $is_image Image or not
* @return bool
*/
- public function create($task_id, $name, $path, $is_image)
+ public function create($task_id, $name, $path, $is_image, $size)
{
$this->container['dispatcher']->dispatch(
self::EVENT_CREATE,
@@ -94,6 +94,9 @@ class File extends Base
'name' => $name,
'path' => $path,
'is_image' => $is_image ? '1' : '0',
+ 'size' => $size,
+ 'user_id' => $this->userSession->getId(),
+ 'date' => time(),
));
}
@@ -106,10 +109,24 @@ class File extends Base
*/
public function getAll($task_id)
{
- return $this->db->table(self::TABLE)
+ return $this->db
+ ->table(self::TABLE)
+ ->columns(
+ self::TABLE.'.id',
+ self::TABLE.'.name',
+ self::TABLE.'.path',
+ self::TABLE.'.is_image',
+ self::TABLE.'.task_id',
+ self::TABLE.'.date',
+ self::TABLE.'.user_id',
+ self::TABLE.'.size',
+ User::TABLE.'.username',
+ User::TABLE.'.name as user_name'
+ )
+ ->join(User::TABLE, 'id', 'user_id')
->eq('task_id', $task_id)
- ->asc('name')
- ->findAll();
+ ->asc(self::TABLE.'.name')
+ ->findAll();
}
/**
@@ -121,10 +138,24 @@ class File extends Base
*/
public function getAllImages($task_id)
{
- return $this->db->table(self::TABLE)
+ return $this->db
+ ->table(self::TABLE)
+ ->columns(
+ self::TABLE.'.id',
+ self::TABLE.'.name',
+ self::TABLE.'.path',
+ self::TABLE.'.is_image',
+ self::TABLE.'.task_id',
+ self::TABLE.'.date',
+ self::TABLE.'.user_id',
+ self::TABLE.'.size',
+ User::TABLE.'.username',
+ User::TABLE.'.name as user_name'
+ )
+ ->join(User::TABLE, 'id', 'user_id')
->eq('task_id', $task_id)
->eq('is_image', 1)
- ->asc('name')
+ ->asc(self::TABLE.'.name')
->findAll();
}
@@ -137,10 +168,24 @@ class File extends Base
*/
public function getAllDocuments($task_id)
{
- return $this->db->table(self::TABLE)
+ return $this->db
+ ->table(self::TABLE)
+ ->columns(
+ self::TABLE.'.id',
+ self::TABLE.'.name',
+ self::TABLE.'.path',
+ self::TABLE.'.is_image',
+ self::TABLE.'.task_id',
+ self::TABLE.'.date',
+ self::TABLE.'.user_id',
+ self::TABLE.'.size',
+ User::TABLE.'.username',
+ User::TABLE.'.name as user_name'
+ )
+ ->join(User::TABLE, 'id', 'user_id')
->eq('task_id', $task_id)
->eq('is_image', 0)
- ->asc('name')
+ ->asc(self::TABLE.'.name')
->findAll();
}
@@ -230,7 +275,8 @@ class File extends Base
$task_id,
$original_filename,
$destination_filename,
- $this->isImage($original_filename)
+ $this->isImage($original_filename),
+ $_FILES[$form_name]['size'][$key]
);
}
}