This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
testadmin.php
199 lines (169 loc) · 6.11 KB
/
testadmin.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php // vim:set ts=4 sw=4 sts=4 et:
require_once "config.php";
require_once "html.php";
require_once "db-func.php";
require_once "utils.php";
// Redirect to the login page, if not logged in
$uid = isLoggedIn();
// Start HTML
head("testadmin", "Test Admin");
// Check for permissions
if (!hasTestAdminPermission($uid)) {
echo "<div class='errormsg'>Sorry, you're not a testing admin.</div>";
foot();
exit(1);
}
echo "<h2>Test Queue</h2>";
?>
<form action="form-submit.php" method="post">
<input type="hidden" name="uid" value="<?php echo $uid; ?>" />
Enter Puzzle ID to testadmin: <input type="text" name="pid" />
<input type="submit" name="TestAdminPuzzle" value="Go" />
</form>
<br />
<?php
$inTesting = count(getPuzzlesInTesting());
$numNeedAdmin = count(getPuzzlesNeedTestAdmin());
echo "There are currently <strong>$inTesting puzzles</strong> in testing<br/>";
echo "<strong>$numNeedAdmin puzzles</strong> need a testing admin</strong>";
echo "<br /><br />";
if (hasTestAdminPermission($uid)) {
if (getPuzzleForTestAdminQueue($uid) == FALSE) {
echo '<div class="emptylist">No Puzzles To Add</div><br/>';
} else {
?>
<form action="form-submit.php" method="post">
<input type="hidden" name="uid" value="<?php echo $uid; ?>" />
<input type="submit" name="getTestAdminPuzz" value="Get Puzzle" />
</form>
<?php
}
displayTestQueue($uid);
}
echo "<h2>Puzzles needing testadmin</h2>";
$testPuzzles = getPuzzlesNeedTestAdmin();
// Should we show "testers" identities? No,
// but we've gotten lazy about using the testadmin system, which means
// I need to see testers for puzzles that have no testadmin.
displayQueue($uid, $testPuzzles, "notes summary testers", FALSE);
echo "<h2>Current Testers</h2>";
displayCurrentTesters();
echo "<h2>Testing Feed</h2>";
echo "<table>";
echo "<div class='comments'>";
displayTestingFeed();
echo "</div>";
echo "</table>";
echo "<h2>Testing Summary</h2>";
displayTestingSummary();
// End HTML
foot();
//------------------------------------------------------------------------
function displayCurrentTesters() {
$sql = 'SELECT uid, pid, created_at FROM tester_links ORDER BY created_at ASC';
$testers = get_row_dicts($sql);
?>
<table class="tablesorter">
<thead>
<tr>
<th class="puzzidea">PID</th>
<th class="puzzidea">Title</th>
<th class="puzzidea">Tester</th>
<th class="puzzidea">Started at</th>
</tr>
</thead>
<?php
foreach ($testers as $tester) {
?>
<tr class="puzz-new">
<td class="puzzidea"><a href="puzzle.php?pid=<?php echo $tester['pid']; ?>"><?php echo $tester['pid']; ?></a></td>
<td class="puzzidea"><?php echo getTitle($tester['pid']); ?></td>
<td class="puzzidea"><?php echo getUserName($tester['uid']); ?></td>
<td class="puzzidea"><?php echo $tester['created_at']; ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
function displayTestQueue($uid) {
$puzzles = getInTestAdminQueue($uid);
$puzzles = sortByLastCommentDate($puzzles);
if (!$puzzles) {
echo '<h3>No Puzzles Currently In Queue</h3>';
} else {
displayQueue($uid, $puzzles, "notes answer summary testers currentpuzzletestercount", FALSE);
}
}
function displayTestingSummary() {
$sql = sprintf("SELECT uid, pid from tester_links");
$result = get_rows($sql);
if (!$result) {
echo "<span class='emptylist'>No puzzles in test queue</span>";
return;
}
echo '<style type="text/css">';
echo '.testingtable, .testingtable a { color: #999999; }';
echo '.testingtable .name, .testingtable .current, .testingtable .past { color: #000000; font-weight: bold; }';
$currqueue = array();
foreach ($result as $r) {
$currclass = NULL;
$uid = $r['uid'];
$pid = $r['pid'];
if (isset($currqueue[$uid])) {
$currqueue[$uid] .= "$pid ";
} else {
$currqueue[$uid] = "$pid ";
}
$currclass = ".a$uid-$pid";
echo ".testingtable $currclass, .testingtable $currclass a {color: #000000; }\n";
}
echo "</style>\n";
$sql = sprintf("SELECT users.uid, users.username, comments.id, type, timestamp, pid FROM comments
LEFT JOIN users on comments.uid = users.uid WHERE comments.type = 5
ORDER BY users.username, comments.pid");
$result = query_db($sql);
$r = mysql_fetch_assoc($result);
$arr = array();
while ($r) {
$uid = $r['uid'];
$pid = $r['pid'];
$id = $r['id'];
$timestamp = $r['timestamp'];
$name = getUserName($uid);
$arr[$uid] = "<tr><td class='name'>$name</td><td>";
if (!isset($currqueue[$uid])) {
$currqueue[$uid] = "";
}
$arr[$uid] .= '<span class="current">Current queue: ' . print_r($currqueue[$uid], true) . '</span><br />';
$arr[$uid] .= '<span class="past">Past comments: </span><br />';
$arr[$uid] .= "<span class='a$uid-$pid'>";
$puzzlink = URL . "/puzzle.php?pid=$pid";
$arr[$uid] .= "<a href='$puzzlink'>$pid</a>: ";
$arr[$uid] .= "<a href='$puzzlink#comm$id'>$timestamp</a> ";
$r = mysql_fetch_assoc($result);
while ($r) {
if ($uid != $r['uid']) {
$arr[$uid] .= "</td></tr>";
break;
}
if ($pid != $r['pid']) {
$pid = $r['pid'];
$arr[$uid] .= "</span><br />\n" . "<span class=\"a" . $r['uid'] . "-" . $pid . "\">";
$puzzlink = URL . "/puzzle.php?pid=" . $pid;
$arr[$uid] .= "<a href=\"" . $puzzlink . "\">" . $pid . "</a>: ";
}
$arr[$uid] .= "<a href=\"" . $puzzlink . "#comm" . $r['id'] . "\">" . $r['timestamp'] . "</a> ";
$r = mysql_fetch_assoc($result);
}
}
if (!$arr) {
echo "<div class='emptylist'>No comments</div>";
}
echo "<table class=\"testingtable\">\n";
foreach ($arr as $key => $value) {
echo $value . "\n";
}
echo "</table>\n\n";
}