Example #1
0
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");
    }
}
Example #2
0
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 
}
Example #3
0
function displayTestsolveRequests($uid, $pid)
{
    $reqs = getTestsolveRequestsForPuzzle($pid);
    ?>
    <table class="testsolveInfo">
        <tr>
            <td class='testsolveInfo'>
                <strong>Active Testsolve Requests: </strong> <?php 
    echo $reqs;
    ?>
            </td>
            <td class='testsolveInfo'>
<?php 
    if (canRequestTestsolve($uid, $pid)) {
        ?>
<a href="#" class="changeLink">[Request]</a><?php 
    } else {
        ?>
<i class="smallText">[Put in testing first]</i><?php 
    }
    ?>
                <a href="#" onClick="document.getElementById('clearOneTestsolveRequest').submit(); return 0;"
                    class="smallText">[Clear one]</a>
                <a href="#" onClick="document.getElementById('clearTestsolveRequests').submit(); return 0;"
                    class="smallText">[Clear all]</a>
                <form id="clearOneTestsolveRequest" method="post" action="form-submit.php">
                    <input type="hidden" name="uid" value="<?php 
    echo $uid;
    ?>
" />
                    <input type="hidden" name="pid" value="<?php 
    echo $pid;
    ?>
" />
                    <input type="hidden" name="clearOneTestsolveRequest" />
                </form>
                <form id="clearTestsolveRequests" method="post" action="form-submit.php">
                    <input type="hidden" name="uid" value="<?php 
    echo $uid;
    ?>
" />
                    <input type="hidden" name="pid" value="<?php 
    echo $pid;
    ?>
" />
                    <input type="hidden" name="clearTestsolveRequests" />
                </form>
            </td>
        </tr>
<?php 
    if (canRequestTestsolve($uid, $pid)) {
        ?>
        <tr>
            <td colspan='3'>
            <form method="post" action="form-submit.php">
                <input type="hidden" name="uid" value="<?php 
        echo $uid;
        ?>
" />
                <input type="hidden" name="pid" value="<?php 
        echo $pid;
        ?>
" />
                <p><strong>Request Testsolve:</strong></p>
                <textarea name="notes">[Enter any notes here]</textarea>
                <input type="submit" name="requestTestsolve" value="Request Testsolve">
            </form>
            </td>
        </tr>
<?php 
    }
    ?>
    </table>
<?php 
}