function addPuzzleToEditorQueue($uid, $pid) { mysql_query('START TRANSACTION'); $sql = sprintf("INSERT INTO editor_queue (uid, pid) VALUES ('%s', '%s')", mysql_real_escape_string($uid), mysql_real_escape_string($pid)); query_db($sql); $comment = "Added to " . getUserName($uid) . "'s queue"; addComment($uid, $pid, $comment, TRUE); mysql_query('COMMIT'); // Subscribe editors to comments on the puzzles they edit if (isAutoSubEditor($uid)) { subscribe($uid, $pid); } }
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"; } header("Location: " . URL . "/testsolving.php"); } } exit(0); } if (isset($_POST['getPuzz'])) { $pid = $_POST['pid']; if ($pid && isEditorAvailable($uid, $pid)) { addPuzzleToEditorQueue($uid, $pid); if (isAutoSubEditor($uid)) { subscribe($uid, $pid); } } else { $_SESSION['failedToAdd'] = TRUE; $_SESSION['failedToAddEdit'] = TRUE; } header("Location: " . URL . "/editor.php"); exit(0); } if (isset($_POST['checkAns'])) { $pid = $_POST['pid']; $answer = $_POST['ans']; $_SESSION['answer'] = $answer; makeAnswerAttempt($uid, $pid, $answer); header("Location: " . URL . "/test.php?pid={$pid}");