function removeApprovers($uid, $pid, $remove) { if (!$remove) { return; } if (!canViewPuzzle($uid, $pid)) { utilsError("You do not have permission to modify puzzle {$pid}."); } $name = getUserName($uid); $comment = 'Removed '; foreach ($remove as $approver) { // Check that this approval editor is assigned to this puzzle if (!isApproverOnPuzzle($approver, $pid)) { utilsError(getUserName($approver) . " is not an approval editor on puzzle {$pid}"); } // Remove approver from puzzle $sql = sprintf("DELETE FROM approver_queue WHERE uid='%s' AND pid='%s'", mysql_real_escape_string($approver), mysql_real_escape_string($pid)); query_db($sql); // Add to comment if ($comment != 'Removed ') { $comment .= ', '; } $comment .= getUserName($approver); // Email old approver $title = getTitle($pid); $codename = getCodename($pid); $subject = "Approval on {$codename} (puzzle {$pid})"; $message = "{$name} removed you as an approval on {$title} (puzzle {$pid})."; $link = URL . "/editor.php"; sendEmail($approver, $subject, $message, $link); } $comment .= ' as approval editor'; if (count($remove) > 1) { $comment .= "s"; } addComment($uid, $pid, $comment, TRUE); }
function displayQueue($uid, $puzzles, $fields, $test, $filter = array(), $addLinkArgs = "", $hidedeadpuzzles = TRUE) { $fields = explode(" ", $fields); $showNotes = in_array("notes", $fields); $showAnswer = in_array("answer", $fields); $showSummary = in_array("summary", $fields); $showEditorNotes = in_array("editornotes", $fields); $showTags = in_array("tags", $fields); $showAuthorsAndEditors = in_array("authorsandeditors", $fields); $showNumTesters = in_array("numtesters", $fields); $showTesters = in_array("testers", $fields); $showFinalLinks = in_array("finallinks", $fields); if (!$puzzles) { echo "<span class='emptylist'>No puzzles to list</span><br/>"; return; } $statuses = getPuzzleStatuses(); $deadstatusid = getDeadStatusId(); $flaggedPuzzles = getFlaggedPuzzles($uid); ?> <table class="tablesorter"> <thead> <tr> <th class="puzzidea">ID</th> <?php if (USING_CODENAMES) { echo '<th class="puzzidea">Codename</th>'; } ?> <th class="puzzidea">Title</th> <th class="puzzidea">Puzzle Status</th> <th class="puzzidea">Round</th> <?php if ($showSummary) { echo '<th class="puzzidea">Summary</th>'; } ?> <?php if ($showEditorNotes) { echo '<th class="puzzidea">Editor Notes</th>'; } ?> <?php if ($showTags) { echo '<th class="puzzidea">Tags</th>'; } ?> <?php if ($showNotes) { echo '<th class="puzzidea">Status Notes</th>'; } ?> <?php if ($showNotes) { echo '<th class="puzzidea">Runtime Info</th>'; } ?> <?php if ($showNotes) { echo '<th class="puzzidea">Priority</th>'; } ?> <?php if ($showAnswer) { echo '<th class="puzzidea">Answer</th>'; } ?> <?php if (!$test) { echo '<th class="puzzidea">Last Commenter</th>'; } ?> <?php if (!$test) { echo '<th class="puzzidea">Last Comment</th>'; } ?> <?php if ($showAuthorsAndEditors) { echo '<th class="puzzidea">Authors</th>'; } ?> <?php if ($showAuthorsAndEditors) { echo '<th class="puzzidea">Discussion Editors</th>'; } ?> <?php if ($showAuthorsAndEditors) { echo '<th class="puzzidea">D.Eds Needed</th>'; } ?> <?php if ($showAuthorsAndEditors) { echo '<th class="puzzidea">Approval Editors</th>'; } ?> <?php if ($showAuthorsAndEditors) { echo '<th class="puzzidea">Approvals</th>'; } ?> <?php if ($showNumTesters) { echo '<th class="puzzidea"># Testers</th>'; } ?> <?php if ($showTesters) { echo '<th class="puzzidea">Testers</th>'; } ?> <?php if ($showTesters) { echo '<th class="puzzidea">Last Test Report</th>'; } ?> <?php if ($showTesters && USING_TESTSOLVE_REQUESTS) { echo '<th class="puzzidea">Testsolve requests</th>'; } ?> <?php if ($showFinalLinks) { echo '<th class="puzzidea">Final Links</th>'; } ?> </tr> </thead> <tbody> <?php foreach ($puzzles as $pid) { $puzzleInfo = getPuzzleInfo($pid); $tags = getTagsAsList($pid); // This is totally the wrong way to do this. The right way involves // writing SQL. if ($filter) { if ($filter[0] == "status" && $filter[1] != $puzzleInfo["pstatus"]) { continue; } if ($filter[0] == "author" && !isAuthorOnPuzzle($filter[1], $pid)) { continue; } if ($filter[0] == "editor" && !isEditorOnPuzzle($filter[1], $pid)) { continue; } if ($filter[0] == "approver" && !isApproverOnPuzzle($filter[1], $pid)) { continue; } if ($filter[0] == "tag" && !isTagOnPuzzle($filter[1], $pid)) { continue; } if ($filter[0] != "status" && $hidedeadpuzzles && $puzzleInfo["pstatus"] == $deadstatusid) { continue; } } else { if ($hidedeadpuzzles && $puzzleInfo["pstatus"] == $deadstatusid) { continue; } } $title = $puzzleInfo["title"]; if ($title == NULL) { $title = '(untitled)'; } $codename = getCodename($pid); $lastComment = getLastCommentDate($pid); $lastCommenter = getLastCommenter($pid); $lastVisit = getLastVisit($uid, $pid); $flagged = in_array($pid, $flaggedPuzzles); if ($lastVisit == NULL || strtotime($lastVisit) < strtotime($lastComment) || $test) { echo '<tr class="puzz-new">'; } else { if ($flagged) { echo '<tr class="puzz-flag">'; } else { echo '<tr class="puzz">'; } } if ($test) { echo "<td class='puzzidea'><a href='test.php?pid={$pid}{$addLinkArgs}'>{$pid}</a></td>"; } else { echo "<td class='puzzidea'><a href='puzzle.php?pid={$pid}{$addLinkArgs}'>{$pid}</a></td>"; } ?> <?php if (USING_CODENAMES) { echo '<td class="puzzidea">' . $codename . '</th>'; } ?> <td class='puzzidea'><?php echo $title; ?> </td> <td class='puzzidea'><?php echo $statuses[$puzzleInfo["pstatus"]]; ?> </td> <td class='puzzidea'><?php echo getPuzzleRound($pid); ?> </td> <?php if ($showSummary) { echo "<td class='puzzideasecure'>" . $puzzleInfo["summary"] . "</td>"; } ?> <?php if ($showEditorNotes) { echo "<td class='puzzideasecure'>" . $puzzleInfo["editor_notes"] . "</td>"; } ?> <?php if ($showTags) { echo "<td class='puzzidea'>" . $tags . "</td>"; } ?> <?php if ($showNotes) { echo "<td class='puzzidea'>" . $puzzleInfo["notes"] . "</td>"; } ?> <?php if ($showNotes) { echo "<td class='puzzidea'>" . $puzzleInfo["runtime_info"] . "</td>"; } ?> <?php if ($showNotes) { echo "<td class='puzzidea'>" . getPriorityWord($puzzleInfo["priority"]) . "</td>"; } if ($showAnswer) { if (getAnswersForPuzzleAsList($pid) != "") { echo "<td class='puzzideasecure'>"; } else { echo "<td class='puzzidea'>"; } echo getAnswersForPuzzleAsList($pid) . "</td>"; } ?> <?php if (!$test) { echo "<td class='puzzidea'>{$lastCommenter}</td>"; } ?> <?php if (!$test) { echo "<td class='puzzidea'>{$lastComment}</td>"; } ?> <?php if ($showAuthorsAndEditors) { echo "<td class='puzzidea'>" . getAuthorsAsList($pid) . "</td>"; } ?> <?php if ($showAuthorsAndEditors) { $est = getEditorStatus($pid); echo "<td class='puzzidea'>" . $est[0] . "</td>"; echo "<td class='puzzidea'>" . $est[1] . "</td>"; } ?> <?php if ($showAuthorsAndEditors) { echo "<td class='puzzidea'>" . getApproversAsList($pid) . "</td>"; } ?> <?php if ($showAuthorsAndEditors) { echo "<td class='puzzidea'>" . countPuzzApprovals($pid) . "</td>"; } ?> <?php if ($showNumTesters) { echo "<td class='puzzidea'>" . getNumTesters($pid) . "</td>"; } ?> <?php if ($showTesters) { echo "<td class='puzzidea'>" . getCurrentTestersAsList($pid) . "</td>"; } ?> <?php if ($showTesters) { echo "<td class='puzzidea'>" . getLastTestReportDate($pid) . "</td>"; } ?> <?php if ($showTesters && USING_TESTSOLVE_REQUESTS) { echo "<td class='puzzidea'>" . getTestsolveRequestsForPuzzle($pid) . "</td>"; } ?> <?php if ($showFinalLinks) { echo "<td class='puzzidea'><a href='" . getBetaLink($title) . "'>beta</a> <a href='" . getFinalLink($title) . "'.>final</a></td>"; } ?> </tr> <?php } ?> </tbody> </table> <?php }
function displayPuzzApproval($uid, $pid) { $approvals = getPuzzApprovals($pid); ?> <b>Editor approval (required to change puzzle status):</b> <br/> <table> <?php //only display approval form itself if you are an editor/approver on this puzzle if (isEditorOnPuzzle($uid, $pid) && !USING_APPROVERS || isApproverOnPuzzle($uid, $pid) && USING_APPROVERS) { ?> <tr> <form action="form-submit.php" method="post"> <td> <input type="radio" name="puzzApprove" value="1" checked />Approve </td> <td> <input type="radio" name="puzzApprove" value="0" />Revise </td> <td> <input type="hidden" name="uid" value='<?php echo $uid; ?> ' /> <input type="hidden" name="pid" value='<?php echo $pid; ?> ' /> <input type="submit" name="setPuzzApprove" value="Submit" /> </td> </form> </tr> <?php } //everyone gets to see approval table if ($approvals == NULL) { echo "<tr><td colspan=3>No existing editor feedback at this stage yet.</td></tr><br>"; } else { if (!isEditorOnPuzzle($uid, $pid)) { echo "<tr><td>Approve</td><td>Revise</td></td>"; } } foreach ($approvals as $fullname => $approve) { echo "<tr><td align=center>"; //check if approved if ($approve == 1) { echo "<b>X</b>"; } echo "</td><td align=center>"; //check if notapproved if ($approve == 0) { echo "<b>X</b>"; } printf("</td><td>%s</td></tr>", $fullname); } ?> </table> <?php }