From 28ff8dad91c9e3c25f6a3b5398ae15f2a1ef95cd Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 10 Sep 2014 16:21:47 +0200 Subject: Add subtasks and comments history --- app/Model/BaseHistory.php | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 app/Model/BaseHistory.php (limited to 'app/Model/BaseHistory.php') diff --git a/app/Model/BaseHistory.php b/app/Model/BaseHistory.php new file mode 100644 index 00000000..31578a3b --- /dev/null +++ b/app/Model/BaseHistory.php @@ -0,0 +1,70 @@ +db->table($this->table)->count() > $max) { + + $this->db->execute(' + DELETE FROM '.$this->table.' + WHERE id <= ( + SELECT id FROM ( + SELECT id FROM '.$this->table.' ORDER BY id DESC LIMIT 1 OFFSET '.$max.' + ) foo + )'); + } + } + + /** + * Get all events for a given project + * + * @access public + * @return array + */ + public function getAllByProjectId($project_id) + { + return $this->db->table($this->table) + ->eq('project_id', $project_id) + ->desc('id') + ->findAll(); + } + + /** + * Get the event html content + * + * @access public + * @param array $params Event properties + * @return string + */ + public function getContent(array $params) + { + $tpl = new Template; + return $tpl->load('event_'.str_replace('.', '_', $params['event_name']), $params); + } +} -- cgit v1.2.3