blob: 98ff8d4c7d3816e5b9979f8c580640d04bc36e5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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;
}
}
|