diff options
| author | Frederic Guillot <fred@kanboard.net> | 2016-05-28 19:48:22 -0400 |
|---|---|---|
| committer | Frederic Guillot <fred@kanboard.net> | 2016-05-28 19:48:22 -0400 |
| commit | 14713b0ec7ed93ca45578da069ad4e19a7d8addf (patch) | |
| tree | 79972d53f6091a1ddb17f64a6a05a5523f5d5168 /app/Model/ProjectActivity.php | |
| parent | 936376ffe74c583d3cb819e98f53a85137fdf8bc (diff) | |
Rename all models
Diffstat (limited to 'app/Model/ProjectActivity.php')
| -rw-r--r-- | app/Model/ProjectActivity.php | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/app/Model/ProjectActivity.php b/app/Model/ProjectActivity.php deleted file mode 100644 index f6bdbf92..00000000 --- a/app/Model/ProjectActivity.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php - -namespace Kanboard\Model; - -use Kanboard\Core\Base; -use PicoDb\Table; - -/** - * Project activity model - * - * @package model - * @author Frederic Guillot - */ -class ProjectActivity extends Base -{ - /** - * SQL table name - * - * @var string - */ - const TABLE = 'project_activities'; - - /** - * Maximum number of events - * - * @var integer - */ - const MAX_EVENTS = 1000; - - /** - * Add a new event for the project - * - * @access public - * @param integer $project_id Project id - * @param integer $task_id Task id - * @param integer $creator_id User id - * @param string $event_name Event name - * @param array $data Event data (will be serialized) - * @return boolean - */ - public function createEvent($project_id, $task_id, $creator_id, $event_name, array $data) - { - $values = array( - 'project_id' => $project_id, - 'task_id' => $task_id, - 'creator_id' => $creator_id, - 'event_name' => $event_name, - 'date_creation' => time(), - 'data' => json_encode($data), - ); - - $this->cleanup(self::MAX_EVENTS - 1); - return $this->db->table(self::TABLE)->insert($values); - } - - /** - * Get query - * - * @access public - * @return Table - */ - public function getQuery() - { - return $this - ->db - ->table(ProjectActivity::TABLE) - ->columns( - ProjectActivity::TABLE.'.*', - 'uc.username AS author_username', - 'uc.name AS author_name', - 'uc.email', - 'uc.avatar_path' - ) - ->join(Task::TABLE, 'id', 'task_id') - ->join(Project::TABLE, 'id', 'project_id') - ->left(User::TABLE, 'uc', 'id', ProjectActivity::TABLE, 'creator_id'); - } - - /** - * Remove old event entries to avoid large table - * - * @access public - * @param integer $max Maximum number of items to keep in the table - */ - public function cleanup($max) - { - $total = $this->db->table(self::TABLE)->count(); - - if ($total > $max) { - $ids = $this->db->table(self::TABLE)->asc('id')->limit($total - $max)->findAllByColumn('id'); - $this->db->table(self::TABLE)->in('id', $ids)->remove(); - } - } -} |
