-
Notifications
You must be signed in to change notification settings - Fork 2
/
inc.issue.php
157 lines (124 loc) · 3.17 KB
/
inc.issue.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
class Issue extends db_generic_record {
public static function map( $issues ) {
return array_map(function($issue) {
return new Issue((array) $issue);
}, $issues);
}
/**
*
*/
public function get_transitions() {
return array();
}
/**
* Sub tasks
*/
public function get_subtasks() {
return self::map(@$this->fields->subtasks ?: array());
}
public function get_subkeys() {
return array_map(function($issue) {
return $issue->key;
}, $this->subtasks);
}
/**
* Parent issue
*/
public function get_parent() {
$parent = @$this->fields->parent;
return $parent ? new Issue((array) $parent) : null;
}
/**
* Timestamps
*/
public function get_created() {
return strtotime($this->fields->created);
}
public function get_updated() {
return strtotime($this->fields->updated);
}
/**
* Simple child objects
*/
public function get_attachments() {
$attachments = @$this->fields->attachment ?: array();
usort($attachments, function($a, $b) {
return strtotime($a->created) - strtotime($b->created);
});
return $attachments;
}
public function get_worklogs() {
return @$this->fields->worklog ?: (object) array(
'total' => 0,
'worklogs' => array(),
);
}
public function get_links() {
return @$this->fields->issuelinks ?: array();
}
public function get_comments() {
return @$this->fields->comment->comments ?: array();
}
/**
* Parent EPIC
*/
public function get_parent_epic_key() {
global $user;
return $user->cf_epic_link ? @$this->fields->{$user->cf_epic_link} : null;
}
public function get_parent_epic() {
global $user;
if ( $this->parent_epic_key && $user->config('load_epics') ) {
$parentEpic = jira_get('issue/' . $this->parent_epic_key);
if ( $parentEpic ) {
return new Issue((array) $parentEpic);
}
}
}
// public function get_parent_epic_color() {
// if ( $this->parent_epic ) {
// return @$this->parent_epic->self_epic->color;
// }
// }
/**
* Self EPIC
*/
public function get_self_epic() {
global $user;
if ( $user->cf_epic_name && $user->cf_epic_status && $user->cf_epic_link ) {
if ( @$this->fields->{$user->cf_epic_name} && @$this->fields->{$user->cf_epic_status} ) {
$epic = (object) array(
'name' => $this->fields->{$user->cf_epic_name},
'status' => $this->fields->{$user->cf_epic_status},
'color' => '',
);
if ( $user->cf_epic_color && @$this->fields->{$user->cf_epic_color} ) {
$epic->color = $this->fields->{$user->cf_epic_color};
}
return $epic;
}
}
}
public function get_self_epic_label() {
if ( $this->self_epic ) {
return '<span class="epic ' . html($this->self_epic->color) . '">' . html($this->self_epic->name) . '</span>';
}
}
public function get_self_epic_issues() {
if ( $this->self_epic ) {
$query = '"Epic Link" = ' . $this->key . ' ORDER BY Rank';
$issues = jira_get('search', array('jql' => $query), $error, $info);
if ( !$error && !empty($issues->issues) ) {
return self::map($issues->issues);
}
}
}
/**
* User story
*/
public function get_story_points() {
global $user;
return $user->cf_story_points ? (float) @$this->fields->{$user->cf_story_points} : 0;
}
}