function changeStatus($uid, $pid, $status) { //make permission exception if we're killing -- for kill puzzle button if (!(canViewPuzzle($uid, $pid) && (canChangeStatus($uid) || $status == getDeadStatusId()))) { utilsError("You do not have permission to modify the status of this puzzle."); } $sql = sprintf("SELECT pstatus.inTesting FROM puzzle_idea LEFT JOIN pstatus ON puzzle_idea.pstatus =\n pstatus.id WHERE puzzle_idea.id='%s'", mysql_real_escape_string($pid)); query_db($sql); $inTesting_before = get_element($sql); // echo "<br>inTesting_before is $inTesting_before<br>"; mysql_query('START TRANSACTION'); $old = getStatusForPuzzle($pid); if ($old == $status) { mysql_query('COMMIT'); return; } $sql = sprintf("UPDATE puzzle_idea SET pstatus='%s' WHERE id='%s'", mysql_real_escape_string($status), mysql_real_escape_string($pid)); query_db($sql); $oldName = getPuzzleStatusName($old); $newName = getPuzzleStatusName($status); $comment = "Puzzle status changed from {$oldName} to {$newName}. <br />"; addComment($uid, $pid, $comment, TRUE); if (isStatusInTesting($old)) { emailTesters($pid, $status); } mysql_query('COMMIT'); $sql = sprintf("SELECT pstatus.inTesting FROM puzzle_idea LEFT JOIN pstatus ON puzzle_idea.pstatus =\n pstatus.id WHERE puzzle_idea.id='%s'", mysql_real_escape_string($pid)); query_db($sql); $inTesting_after = get_element($sql); // echo "<br>inTesting_after is $inTesting_after<br>"; if ($inTesting_before == "1" && $inTesting_after == "0") { // echo "<br>inTesting changed from yes to no<br>"; // For every user that was testing this puzzle, mark the puzzle as doneTesting $sql = sprintf("SELECT uid FROM test_queue WHERE pid = '%s'", mysql_real_escape_string($pid)); query_db($sql); $users = get_elements($sql); foreach ($users as $user) { // echo "<br>Setting puzzle $pid done for user $user<br>"; doneTestingPuzzle($user, $pid); } // Now, reset the number-of-testers count for the puzzle. resetPuzzleTesterCount($pid); } if ($inTesting_before == "0" && $inTesting_after == "1") { // Status changed into testing; file an automatic testsolve // request. if (getTestsolveRequestsForPuzzle($pid) == 0) { requestTestsolve($uid, $pid, "Automatic testsolve request."); } if (getWikiPage($pid) == "" || getWikiPage($pid) == NULL) { $newpage = defaultWikiPageForPuzzle($pid); updateWikiPage($uid, $pid, "", $newpage); } } $fcs = getFactcheckersForPuzzle($pid); if (isStatusInFactchecking($status) && !empty($fcs)) { // Let existing factcheckers know that we've gone back into // factchecking. emailFactcheckers($pid); } // reset approval status on puzz status change flushPuzzApprovals($pid); if ($status == getDeadStatusId()) { //return answer words to pool if we're killing a puzzle foreach (getAnswersForPuzzle($pid) as $akey => $answer) { //echo "removing answer id $akey<br>"; removeAnswerKill($uid, $pid, $akey); } //remove editors from puzzle if we're killing it foreach (getEditorsForPuzzle($pid) as $ekey => $editor) { //echo "removing editor id $ekey<br>"; removeEditorKill($uid, $pid, $ekey); } //utilsError("Debug Breakpoint"); } }
function displayPuzzPriority($uid, $pid) { $priority = getPriority($pid); //only display approval form itself if you are an editor/approver on this puzzle if (canChangeStatus($uid)) { ?> <b>Testsolving Priority:</b> <br/> <table> <tr> <form action="form-submit.php" method="post"> <td> <input type="radio" name="puzzPriority" value="1" <?php if ($priority == 1) { echo "checked"; } ?> />Very high <input type="radio" name="puzzPriority" value="2" <?php if ($priority == 2) { echo "checked"; } ?> />High <input type="radio" name="puzzPriority" value="3" <?php if ($priority == 3) { echo "checked"; } ?> />Normal <input type="radio" name="puzzPriority" value="4" <?php if ($priority == 4) { echo "checked"; } ?> />Low <input type="radio" name="puzzPriority" value="5" <?php if ($priority == 5) { echo "checked"; } ?> />Very low </td> <td></td> <td> <input type="hidden" name="uid" value='<?php echo $uid; ?> ' /> <input type="hidden" name="pid" value='<?php echo $pid; ?> ' /> <input type="submit" name="setPuzzPriority" value="Submit" /> </td> </form> </tr> </table> <?php } }