diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-04-18 18:44:45 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-04-18 18:44:45 -0400 |
commit | 370b5a0fd7c1dba60e3b973506ba087adba42be0 (patch) | |
tree | 8da109b4fc90062d6eebb69d4ae2efca4da1bac3 /app/Model/ProjectIntegration.php | |
parent | f53bb88d10836e5c31efb958683d8bf3829eecbf (diff) |
Add Slack and Hipchat integrations for each projects
Diffstat (limited to 'app/Model/ProjectIntegration.php')
-rw-r--r-- | app/Model/ProjectIntegration.php | 66 |
1 files changed, 66 insertions, 0 deletions
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 @@ +<?php + +namespace Model; + +/** + * Project integration + * + * @package model + * @author Frederic Guillot + */ +class ProjectIntegration extends Base +{ + /** + * SQL table name + * + * @var string + */ + const TABLE = 'project_integrations'; + + /** + * Get all parameters for a project + * + * @access public + * @param integer $project_id + * @return array + */ + public function getParameters($project_id) + { + return $this->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; + } +} |