示例#1
0
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);
}
示例#2
0
if (!canViewPuzzle($uid, $pid)) {
    echo "<div class='errormsg'>You do not have permission to view this puzzle.</div>";
    foot();
    exit(0);
}
// Record this user's visit (in two ways)
$lastVisit = updateLastVisit($uid, $pid);
if (!isEditorChief($uid) && !isCohesion($uid)) {
    addSpoiledUserQuietly($uid, $pid);
    if ($_GET['discuss'] && isEditorAvailable($uid, $pid) && !isEditorChief($uid)) {
        changeEditors($uid, $pid, array($uid), array());
    } else {
        if ($_GET['approve'] && isApproverAvailable($uid, $pid) && !isEditorChief($uid)) {
            changeApprovers($uid, $pid, array($uid), array());
        } else {
            if ($_GET['factcheck'] && isFactcheckerAvailable($uid, $pid) && !isEditorChief($uid)) {
                changeFactcheckers($uid, $pid, array($uid), array());
            }
        }
    }
}
// If author is a blind tester, turn page background red
if (isAnyAuthorBlind($pid)) {
    echo '<style type="text/css">html {background-color: #B00000;}</style>';
}
// Hide puzzle info from testing admins, to prevent spoilage
$hidePuzzleInfo = (isServerAdmin($uid) || isTestingAdmin($uid)) && !isAuthorOnPuzzle($uid, $pid) && !isEditorOnPuzzle($uid, $pid);
// If Testing Admin, hide answer, summary, and description
if ($hidePuzzleInfo) {
    echo '<style type="text/css">.hideFromTest {display: none;}</style>';
}