-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathall_codes.php
executable file
·101 lines (88 loc) · 2.36 KB
/
all_codes.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
<?php
// Require go_functions so we have access to function isSuperAdmin
require_once "go_functions.php";
require_once "header.php";
require_once "admin_nav.php";
?>
<div class="content">
<div id="response"></div>
<?php
$user = new User($_SESSION["AUTH"]->getCurrentUserId());
// If an update message was set prior to a redirect
// to this page display it and clear the message.
if (isset($_SESSION['update_message'])) {
foreach ($_SESSION['update_message'] as $message) {
print $message;
}
unset($_SESSION['update_message']);
}
print "<h2>All Codes</h2>";
// Only superadmin may admin all codes so show all
if (isSuperAdmin($user->getName())) {
$select = $connection->prepare("
SELECT
name,
institution,
aliases,
description,
url
FROM
code
LEFT JOIN
(SELECT
code,
GROUP_CONCAT(name SEPARATOR ', ') AS
aliases
FROM
alias
GROUP BY
code)
AS
grouped_alias
ON name = grouped_alias.code
ORDER BY
name");
$select->execute();
print "<table id='my_codes_table'>
<tr>
<th>Go Shortcut</th>
<th>Description</th>
<th>Aliases</th>
<th>Institution</th>
<th>Actions</th>
</tr>";
//
foreach ($select->fetchAll() as $row) {
//$codes[$row['institution'] . "/" . $row['name']] = new Code($row['name'], $row['institution']);
print "
<tr>
<td>";
if ($row['url']) {
print "<a href='" . htmlentities($row['url']) . "'>" . $row['name'] . "</a>";
} else {
print $row['name'];
}
print "</td>
<td>
" . $row['description'] . "
</td>
<td>
" . $row['aliases'] . "
</td>
<td>
" . $row['institution'] . "
</td>
<td>
<a class='edit_button' href='update.php?code=" . $row['name'] . "&institution=" . $row['institution'] . "&url=" . urlencode(curPageURL()) . "'><input type='button' value='Edit Shortcut' /></a>
<a class='edit_button' href='info.php?code=".$row['name']."'><input type='button' value='Info' /></a>
<a class='edit_button' href='details.php?code=".$row['name']."&institution=".$row['institution']."' onclick=\"var details=window.open(this.href, 'details', 'width=700,height=400,scrollbars=yes,resizable=yes'); details.focus(); return false;\"><input type='button' value='History' />
</a>
</td>
</tr>
";
}
print "</table>";
} else {
die("You are not authorized to view this page.");
}
require_once "footer.php";