Exemplo n.º 1
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 
}
Exemplo n.º 2
0
function setPuzzPriority($uid, $pid, $priority)
{
    $sql = sprintf("UPDATE puzzle_idea SET priority='%s' WHERE id='%s'", mysql_real_escape_string($priority), mysql_real_escape_string($pid));
    $result = query_db($sql);
    $name = getUserName($uid);
    $title = getTitle($pid);
    //add comment noting this approval or disapproval
    $comment = sprintf("%s changed testsolving priority of puzzle %s to %s", $name, $title, getPriorityWord($priority));
    addComment($uid, $pid, $comment, TRUE);
}