aboutsummaryrefslogtreecommitdiff
path: root/bug/view.php
blob: 6b26860070879b7132566888987f0c8144298200 (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
<?php
require '../config.php';
require_once(TEMPLATES_PATH . "/header.php");
require_once(TEMPLATES_PATH . "/panel.php");
require_once(LIBRARY_PATH . "/functions.php");
require_once(LIBRARY_PATH . "/parsedown.php");

if(!isset($_GET['id']) || $_GET['id'] == "") {
    echo "<div id='error'>No bug selected...</div>";
    header("Refresh: 2; URL=$_SERVER[HTTP_REFERER]");
    goto footer;
}

$conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
$query = $conn->prepare("SELECT title, description, users.username AS submitter FROM bugs 
    JOIN users ON bugs.author = users.id WHERE bugs.id=:bug_id");
$query->bindParam(':bug_id', $_GET['id']);
$query->execute();
$result = $query->fetch();

$markdown = new Parsedown();

echo "<p><b>$result[title]</b></p>";
echo "<p>Submitted by $result[submitter]</p>";
echo '<p>' . $markdown->text($result['description']) . '</p>';

echo "<h2>Reports</h2>";
# reports query
$reports = $conn->prepare("SELECT reports.id AS id, title, description, users.username AS user 
    FROM reports JOIN users ON reports.author=users.id WHERE bug=:bug_id ORDER BY id");
$reports->bindParam(':bug_id', $_GET['id']);
$reports->execute();

if($reports->rowCount() > 0) {
?>

<table style='width:80%'>
<tr><th>Title</th><th>Description</th><th>Submitted by</th></tr>
<?php
foreach ($reports as $row) {
    echo "<tr><td><a href=report/view.php?id=$row[id]>$row[title]</a></td> <td>" . truncate($row['description']) . "</td> <td>$row[user]</td></tr>\n";
}
?>
</table>

<?php
} else {
    echo "<p>No reports</p>";
}

if(session_set()) {
    echo "<p><a href=edit.php?id=$_GET[id]>Edit</a> | <a href=delete.php?id=$_GET[id]>Delete</a></p>";
}

footer: require_once(TEMPLATES_PATH . "/footer.php");
?>