[aur-dev] [PATCH 1/2] Add "Last Votes by TU" list
This shows a list of all Trusted Users and the vote ID of the last proposal each of the TUs voted on. This list is sorted by vote ID. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/tu.php | 2 ++ web/lib/acctfuncs.inc.php | 19 ++++++++++++++++++ web/template/tu_last_votes_list.php | 40 +++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 web/template/tu_last_votes_list.php diff --git a/web/html/tu.php b/web/html/tu.php index e2f7712..d221619 100644 --- a/web/html/tu.php +++ b/web/html/tu.php @@ -134,6 +134,8 @@ if ($atype == "Trusted User" || $atype == "Developer") { <?php endif; ?> </div> <?php + $result = last_votes_list(); + include("tu_last_votes_list.php"); } } else { diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 31cdd79..f52dfc3 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -996,6 +996,25 @@ function past_proposal_list($order, $lim) { } /** + * Get the vote ID of the last vote of all Trusted Users + * + * @return array The vote ID of the last vote of each Trusted User + */ +function last_votes_list() { + $dbh = DB::connect(); + + $q = "SELECT UserID, MAX(VoteID) AS LastVote FROM TU_Votes GROUP BY UserID ORDER BY VoteID DESC"; + $result = $dbh->query($q); + + $details = array(); + while ($row = $result->fetch(PDO::FETCH_ASSOC)) { + $details[] = $row; + } + + return $details; +} + +/** * Determine the total number of Trusted User proposals * * @return string The total number of Trusted User proposals diff --git a/web/template/tu_last_votes_list.php b/web/template/tu_last_votes_list.php new file mode 100644 index 0000000..090ce8d --- /dev/null +++ b/web/template/tu_last_votes_list.php @@ -0,0 +1,40 @@ +<div class="box"> + <h2><?= __("Last Votes by TU") ?></h2> + <table class="results"> + <thead> + <tr> + <th><?= __("User") ?></th> + <th><?= __("Last vote") ?></th> + </tr> + </thead> + + <tbody> + <?php if (empty($result)): ?> + <tr><td align="center" colspan="0"><?= __("No results found.") ?></td></tr> + <?php else: while (list($indx, $row) = each($result)): + if ($indx % 2): + $c = "even"; + else: + $c = "odd"; + endif; + $username = username_from_id($row["UserID"]); + ?> + <tr class="<?= $c ?>"> + <td> + <?php if (!$USE_VIRTUAL_URLS): ?> + <a href="<?= get_uri('/account/'); ?>?Action=AccountInfo&ID=<?= htmlspecialchars($row['UserID'], ENT_QUOTES) ?>" title="<?= __('View account information for')?> <?= htmlspecialchars($username) ?>"><?= htmlspecialchars($username) ?></a></td> + <?php else: ?> + <a href="<?= get_uri('/account/') . htmlspecialchars($username, ENT_QUOTES) ?>" title="<?= __('View account information for %s', htmlspecialchars($username)) ?>"><?= htmlspecialchars($username) ?></a> + <?php endif; ?> + </td> + <td> + <a href="<?= get_uri('/tu/'); ?>?id=<?= $row['LastVote'] ?>"><?= intval($row["LastVote"]) ?></a> + </td> + </tr> + <?php + endwhile; + endif; + ?> + </tbody> + </table> +</div> -- 1.8.4.rc3.500.gc3113b0
These are navigation links and do not belong to the action box. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/tu.php | 17 +++-------------- web/template/tu_list.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/web/html/tu.php b/web/html/tu.php index d221619..fdccdb4 100644 --- a/web/html/tu.php +++ b/web/html/tu.php @@ -107,6 +107,7 @@ if ($atype == "Trusted User" || $atype == "Developer") { $result = current_proposal_list($order); $type = __("Current Votes"); + $nextresult = 0; include("tu_list.php"); ?> @@ -114,25 +115,13 @@ if ($atype == "Trusted User" || $atype == "Developer") { $result = past_proposal_list($order, $lim); $type = __("Past Votes"); - include("tu_list.php"); - $nextresult = proposal_count(); + include("tu_list.php"); ?> <div class="box"> <p><a href="<?= get_uri('/addvote/'); ?>"><?= __("Add Proposal") ?></a></p> - - <?php if ($result): - $by = htmlentities($by, ENT_QUOTES); ?> - <?php if ($off != 0): - $back = (($off - $limit) <= 0) ? 0 : $off - $limit; ?> - <a href='<?= get_uri('/tu/'); ?>?off=<?= $back ?>&by=<?= $by ?>'><?= __("Back") ?></a> - <?php endif; ?> - <?php if (($off + $limit) < $nextresult): - $forw = $off + $limit; ?> - <a href="<?= get_uri('/tu/'); ?>?off=<?= $forw ?>&by=<?= $by ?>"><?= __("Next") ?></a> - <?php endif; ?> - <?php endif; ?> </div> + </p> <?php $result = last_votes_list(); include("tu_last_votes_list.php"); diff --git a/web/template/tu_list.php b/web/template/tu_list.php index f80d2f5..1f7280a 100644 --- a/web/template/tu_list.php +++ b/web/template/tu_list.php @@ -53,4 +53,18 @@ ?> </tbody> </table> + <div class="pkglist-stats"> + <p class="pkglist-nav"> + <?php if ($result): + $by = htmlentities($by, ENT_QUOTES); ?> + <?php if ($nextresult > 0 && $off != 0): + $back = (($off - $limit) <= 0) ? 0 : $off - $limit; ?> + <a class="page" href='<?= get_uri('/tu/'); ?>?off=<?= $back ?>&by=<?= $by ?>'>‹ <?= __("Back") ?></a> + <?php endif; ?> + <?php if (($off + $limit) < $nextresult): + $forw = $off + $limit; ?> + <a class="page" href="<?= get_uri('/tu/'); ?>?off=<?= $forw ?>&by=<?= $by ?>"><?= __("Next") ?> ›</a> + <?php endif; ?> + <?php endif; ?> + </div> </div> -- 1.8.4.rc3.500.gc3113b0
participants (1)
-
Lukas Fleischer