|
14 | 14 | $resolution = trim(@$_POST['resolution']); |
15 | 15 | $comment = trim($_POST['comment']); |
16 | 16 |
|
17 | | - $assigneetype = trim(@$_POST['assigneetype']); |
18 | | - $assignee = trim(@$_POST['assignee']); |
19 | | - if ( $assigneetype == 'unassign' ) { |
20 | | - $assignee = null; |
21 | | - } |
22 | | - else if ( $assigneetype == 'me' ) { |
23 | | - $assignee = JIRA_USER; |
24 | | - } |
25 | | - |
26 | 17 | $update = array(); |
27 | 18 |
|
28 | | - // ASSIGN |
29 | | - if ( $status == 'assign' ) { |
30 | | - if ( $assignee === '' ) { |
31 | | - echo "Must enter assignee username."; |
32 | | - exit; |
33 | | - } |
34 | | - |
35 | | - // Add comment |
36 | | - if ( $comment ) { |
37 | | - $response = jira_post('issue/' . $key . '/comment', array('body' => $comment), $error, $info); |
38 | | - } |
39 | | - else { |
40 | | - $error = false; |
41 | | - } |
42 | | - |
43 | | - // Only move forward if that worked, since this action requires 2 API calls =( |
44 | | - if ( !$error ) { |
45 | | - // Change assignee |
46 | | - $update['name'] = $assignee === null ? null : explode('@', $assignee)[0]; |
47 | | - $response = jira_put('issue/' . $key . '/assignee', $update, $error, $info); |
48 | | - } |
| 19 | + if ( $comment ) { |
| 20 | + $update['update']['comment'][0]['add']['body'] = $comment; |
49 | 21 | } |
50 | | - |
51 | | - // TRANSITION |
52 | | - else { |
53 | | - if ( $comment ) { |
54 | | - $update['update']['comment'][0]['add']['body'] = $comment; |
55 | | - } |
56 | | - if ( $assignee !== '' ) { |
57 | | - $update['fields']['assignee']['name'] = $assignee; |
58 | | - } |
59 | | - if ( $resolution ) { |
60 | | - $update['fields']['resolution']['name'] = $resolution; |
61 | | - } |
62 | | - if ( $status ) { |
63 | | - $update['transition']['id'] = $status; |
64 | | - } |
65 | | - |
66 | | - $response = jira_post('issue/' . $key . '/transitions', $update, $error, $info); |
| 22 | + if ( $resolution ) { |
| 23 | + $update['fields']['resolution']['name'] = $resolution; |
67 | 24 | } |
| 25 | + if ( $status ) { |
| 26 | + $update['transition']['id'] = $status; |
| 27 | + } |
| 28 | + |
| 29 | + $response = jira_post('issue/' . $key . '/transitions', $update, $error, $info); |
68 | 30 |
|
69 | 31 | if ( !$error ) { |
70 | 32 | return do_redirect('issue', array('key' => $key)); |
|
84 | 46 |
|
85 | 47 | $actions = $transitionsById = array(); |
86 | 48 | $actions[''] = '-- No change'; |
87 | | -$actions['assign'] = 'Assign'; |
88 | 49 | foreach ( $transitions->transitions AS $transition ) { |
89 | 50 | $transitionsById[$transition->id] = $transition; |
90 | 51 | $actions[$transition->id] = $transition->name; |
|
112 | 73 | } |
113 | 74 | echo '<p>Comment:<br><textarea name="comment" rows="8"></textarea><br><button type="button" data-preview="textarea[name=comment]">Preview</button></p>'; |
114 | 75 |
|
115 | | -if ( $action == 'assign' || isset($transitionsById[$action]->fields->assignee) ) { |
116 | | - echo '<p>Change assignee?<br />'; |
117 | | - echo '<input type="radio" name="assigneetype" value="unassign" /> Unassign<br />'; |
118 | | - echo '<input type="radio" name="assigneetype" value="me" /> Assign to me<br />'; |
119 | | - echo '<input type="radio" name="assigneetype" value="other" checked /> No change, or assign to: <input name="assignee" style="width: 7em" placeholder="username" />'; |
120 | | - echo '</p>'; |
121 | | -} |
122 | | - |
123 | 76 | echo '<p><input type="submit" /></p>'; |
124 | 77 | echo '</form>'; |
125 | 78 | echo '</div>'; |
|
0 commit comments