From 370b5a0fd7c1dba60e3b973506ba087adba42be0 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 18 Apr 2015 18:44:45 -0400 Subject: Add Slack and Hipchat integrations for each projects --- app/Model/ProjectIntegration.php | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 app/Model/ProjectIntegration.php (limited to 'app/Model/ProjectIntegration.php') diff --git a/app/Model/ProjectIntegration.php b/app/Model/ProjectIntegration.php new file mode 100644 index 00000000..98ff8d4c --- /dev/null +++ b/app/Model/ProjectIntegration.php @@ -0,0 +1,66 @@ +db->table(self::TABLE)->eq('project_id', $project_id)->findOne() ?: array(); + } + + /** + * Save parameters for a project + * + * @access public + * @param integer $project_id + * @param array $values + * @return boolean + */ + public function saveParameters($project_id, array $values) + { + if ($this->db->table(self::TABLE)->eq('project_id', $project_id)->count() === 1) { + return $this->db->table(self::TABLE)->eq('project_id', $project_id)->update($values); + } + + return $this->db->table(self::TABLE)->insert($values + array('project_id' => $project_id)); + } + + /** + * Check if a project has the given parameter/value + * + * @access public + * @param integer $project_id + * @param string $option + * @param string $value + * @return boolean + */ + public function hasValue($project_id, $option, $value) + { + return $this->db + ->table(self::TABLE) + ->eq('project_id', $project_id) + ->eq($option, $value) + ->count() === 1; + } +} -- cgit v1.2.3