function addFactcheckers($uid, $pid, $add) { if (!$add) { return; } if (!validPuzzleId($pid)) { utilsError("Invalid puzzle ID."); } if (!canViewPuzzle($uid, $pid)) { utilsError("You do not have permission to modify this puzzle."); } $name = getUserName($uid); $comment = 'Added '; foreach ($add as $fc) { // Check that this factchecker is available for this puzzle if (!isFactcheckerAvailable($fc, $pid)) { utilsError(getUserName($fc) . ' is not available.'); } // Add factchecker to puzzle $sql = sprintf("INSERT INTO factcheck_queue (pid, uid) VALUE ('%s', '%s')", mysql_real_escape_string($pid), mysql_real_escape_string($fc)); query_db($sql); // Add to comment if ($comment != 'Added ') { $comment .= ', '; } $comment .= getUserName($fc); // Email new factchecker $title = getTitle($pid); $codename = getCodename($pid); $subject = "Factchecker on {$codename} (puzzle {$pid})"; $message = "{$name} added you as a factchecker on {$title} (puzzle {$pid})."; $link = URL . "/puzzle?pid={$pid}"; sendEmail($fc, $subject, $message, $link); // Subscribe factcheckers to comments on their puzzles subscribe($fc, $pid); } $comment .= ' as factchecker'; if (count($add) > 1) { $comment .= "s"; } addComment($uid, $pid, $comment, TRUE); }
$pid = $_POST['pid']; addFactcheckers($uid, $pid, array($uid)); header("Location: " . URL . "/factcheck.php"); exit(0); } if (isset($_POST['TestAdminPuzzle'])) { $pid = $_POST['pid']; if (!addToTestAdminQueue($uid, $pid)) { $_SESSION['failedToAdd'] = TRUE; } header("Location: " . URL . "/testadmin.php"); exit(0); } if (isset($_POST['getTestId'])) { $pid = $_POST['pid']; if (!validPuzzleId($pid)) { utilsError("Invalid puzzle ID."); } if (isTestingAdmin($uid)) { header("Location: " . URL . "/test.php?pid=" . $pid); exit(0); } if (canTestPuzzle($uid, $pid, TRUE) && !isTesterOnPuzzle($uid, $pid)) { addPuzzleToTestQueue($uid, $pid); header("Location: " . URL . "/test.php?pid=" . $pid); } else { if (isTesterOnPuzzle($uid, $pid)) { header("Location: " . URL . "/test.php?pid=" . $pid); } else { if (!isset($_SESSION['testError'])) { $_SESSION['testError'] = "Could not add Puzzle {$pid} to your queue";