|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Jitamin. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (C) Jitamin Team |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Jitamin\Model; |
|
13
|
|
|
|
|
14
|
|
|
use Jitamin\Foundation\Database\Model; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Project Task Priority Model. |
|
18
|
|
|
*/ |
|
19
|
|
|
class ProjectTaskPriorityModel extends Model |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Get Priority range from a project. |
|
23
|
|
|
* |
|
24
|
|
|
* @param array $project |
|
25
|
|
|
* |
|
26
|
|
|
* @return array |
|
27
|
|
|
*/ |
|
28
|
|
|
public function getPriorities(array $project) |
|
29
|
|
|
{ |
|
30
|
|
|
$range = range($project['priority_start'], $project['priority_end']); |
|
31
|
|
|
|
|
32
|
|
|
return array_combine($range, $range); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Get task priority settings. |
|
37
|
|
|
* |
|
38
|
|
|
* @param int $project_id |
|
39
|
|
|
* |
|
40
|
|
|
* @return array|null |
|
41
|
|
|
*/ |
|
42
|
|
|
public function getPrioritySettings($project_id) |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->db |
|
|
|
|
|
|
45
|
|
|
->table(ProjectModel::TABLE) |
|
46
|
|
|
->columns('priority_default', 'priority_start', 'priority_end') |
|
47
|
|
|
->eq('id', $project_id) |
|
48
|
|
|
->findOne(); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Get default task priority. |
|
53
|
|
|
* |
|
54
|
|
|
* @param int $project_id |
|
55
|
|
|
* |
|
56
|
|
|
* @return int |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getDefaultPriority($project_id) |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->db->table(ProjectModel::TABLE)->eq('id', $project_id)->findOneColumn('priority_default') ?: 0; |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Get priority for a destination project. |
|
65
|
|
|
* |
|
66
|
|
|
* @param int $dst_project_id |
|
67
|
|
|
* @param int $priority |
|
68
|
|
|
* |
|
69
|
|
|
* @return int |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getPriorityForProject($dst_project_id, $priority) |
|
72
|
|
|
{ |
|
73
|
|
|
$settings = $this->getPrioritySettings($dst_project_id); |
|
74
|
|
|
|
|
75
|
|
|
if ($priority >= $settings['priority_start'] && $priority <= $settings['priority_end']) { |
|
76
|
|
|
return $priority; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return $settings['priority_default']; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.