diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Core/Helper.php | 2 | ||||
-rw-r--r-- | app/Model/File.php | 64 | ||||
-rw-r--r-- | app/Schema/Mysql.php | 9 | ||||
-rw-r--r-- | app/Schema/Postgres.php | 9 | ||||
-rw-r--r-- | app/Schema/Sqlite.php | 9 | ||||
-rw-r--r-- | app/Template/file/show.php | 6 |
6 files changed, 86 insertions, 13 deletions
diff --git a/app/Core/Helper.php b/app/Core/Helper.php index 29003416..76f90755 100644 --- a/app/Core/Helper.php +++ b/app/Core/Helper.php @@ -755,7 +755,7 @@ class Helper return 'fa-file-powerpoint-o'; case 'zip': case 'rar': - return 'fa-archive-o'; + return 'fa-file-archive-o'; case 'mp3': return 'fa-audio-o'; case 'avi': 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] ); } } diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index e5269d93..626f7b84 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,14 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 61; +const VERSION = 62; + +function version_62($pdo) +{ + $pdo->exec('ALTER TABLE files ADD COLUMN date VARCHAR(10) NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE files ADD COLUMN user_id INT NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE files ADD COLUMN size FLOAT NOT NULL DEFAULT 0'); +} function version_61($pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index 2c5e0f28..4b9752eb 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,14 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 42; +const VERSION = 43; + +function version_43($pdo) +{ + $pdo->exec('ALTER TABLE files ADD COLUMN date VARCHAR(10) NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE files ADD COLUMN user_id INT NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE files ADD COLUMN size FLOAT NOT NULL DEFAULT 0'); +} function version_42($pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index b9c264bc..52a37d25 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -6,7 +6,14 @@ use Core\Security; use PDO; use Model\Link; -const VERSION = 60; +const VERSION = 61; + +function version_61($pdo) +{ + $pdo->exec('ALTER TABLE files ADD COLUMN date VARCHAR(10) NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE files ADD COLUMN user_id INT NOT NULL DEFAULT 0'); + $pdo->exec('ALTER TABLE files ADD COLUMN size FLOAT NOT NULL DEFAULT 0'); +} function version_60($pdo) { diff --git a/app/Template/file/show.php b/app/Template/file/show.php index 66e1afd9..8615079a 100644 --- a/app/Template/file/show.php +++ b/app/Template/file/show.php @@ -16,6 +16,9 @@ <?php endif ?> <p> <?= $this->e($file['name']) ?> + <span class="column-tooltip" title='<?= $this->e(t('uploaded by').': '.$this->e($file['user_name'] ?: $file['username']).'<br>'.t('uploaded on').': '.dt('%B %e, %Y at %k:%M %p', $file['date']).'<br>'.t('size').': '.round($file['size']/1024/1024,2)).' MB' ?>'> + <i class="fa fa-info-circle"></i> + </span> </p> <span class="task-show-file-actions task-show-image-actions"> <i class="fa fa-eye"></i> <?= $this->a(t('open'), 'file', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id']), false, 'popover') ?> @@ -35,6 +38,9 @@ <td><i class="fa <?= $this->getFileIcon($file['name']) ?> fa-fw"></i></td> <td> <?= $this->e($file['name']) ?> + <span class="column-tooltip" title='<?= $this->e(t('uploaded by').': '.$this->e($file['user_name'] ?: $file['username']).'<br>'.t('uploaded on').': '.dt('%B %e, %Y at %k:%M %p', $file['date']).'<br>'.t('size').': '.round($file['size']/1024/1024,2)).' MB' ?>'> + <i class="fa fa-info-circle"></i> + </span> </td> <td> <span class="task-show-file-actions"> |