-
Notifications
You must be signed in to change notification settings - Fork 2
/
link.php
72 lines (54 loc) · 1.59 KB
/
link.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
<?php
require 'inc.bootstrap.php';
do_logincheck();
$key = @$_GET['key'];
$summary = @$_GET['summary'];
// Create link
if ( isset($_POST['type'], $_POST['issue']) ) {
$type = explode(':', $_POST['type']);
$otherIssueXward = $type[1];
$thisIssueXward = $otherIssueXward == 'inward' ? 'outward' : 'inward';
$data = array(
'type' => array('name' => $type[0]),
$thisIssueXward . 'Issue' => array('key' => $key),
$otherIssueXward . 'Issue' => array('key' => trim($_POST['issue'])),
);
$response = jira_post('issueLink', $data, $error, $info);
if ( !$error ) {
return do_redirect('issue', array('key' => $key));
}
echo '<pre>';
print_r($data);
var_dump($error);
print_r($response);
print_r($info);
exit;
}
$linkTypes = jira_get('issueLinkType');
$linkTypeOptions = array_reduce($linkTypes->issueLinkTypes, function($options, $type) {
$options[$type->name . ':inward'] = $type->inward;
if ($type->outward != $type->inward) {
$options[$type->name . ':outward'] = $type->outward;
}
return $options;
});
$_title = "Link $key";
include 'tpl.header.php';
echo '<h1><a href="issue.php?key=' . $key . '">' . $key . '</a> ' . html($summary) . '</h1>';
?>
<h2>Create link</h2>
<form autocomplete="off" method="post">
<p>This issue <select name="type"><?= html_options($linkTypeOptions, 'Relates:inward') ?></select></p>
<p>That issue: <input name="issue" placeholder="ABC-123" /></p>
<p><button>Save</button></p>
</form>
<script>
$$('input[name="issue"]').on('change', function(e) {
var key = makeUpKey(this);
if ( key ) {
this.value = key;
}
});
</script>
<?php
include 'tpl.footer.php';