mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Use virtual paths in links (e.g. link to "/packages/" instead of "/packages.php" etc.) if the virtual path feature is enabled. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
141 lines
3.3 KiB
PHP
141 lines
3.3 KiB
PHP
<?php
|
|
|
|
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
|
|
|
|
include_once("aur.inc.php");
|
|
set_lang();
|
|
check_sid();
|
|
|
|
$title = __("Trusted User");
|
|
|
|
html_header($title);
|
|
|
|
# Default votes per page
|
|
$pp = 10;
|
|
$prev_Len = 75;
|
|
|
|
$atype = "";
|
|
if (isset($_COOKIE["AURSID"])) {
|
|
$atype = account_from_sid($_COOKIE["AURSID"]);
|
|
}
|
|
|
|
if ($atype == "Trusted User" || $atype == "Developer") {
|
|
|
|
if (isset($_GET['id'])) {
|
|
if (is_numeric($_GET['id'])) {
|
|
$row = vote_details($_GET['id']);
|
|
|
|
if (empty($row)) {
|
|
print __("Could not retrieve proposal details.");
|
|
} else {
|
|
$isrunning = $row['End'] > time() ? 1 : 0;
|
|
|
|
# List voters of a proposal.
|
|
$whovoted = voter_list($row['ID']);
|
|
|
|
$canvote = 1;
|
|
$hasvoted = 0;
|
|
$errorvote = "";
|
|
if ($isrunning == 0) {
|
|
$canvote = 0;
|
|
$errorvote = __("Voting is closed for this proposal.");
|
|
} else if ($row['User'] == username_from_sid($_COOKIE["AURSID"])) {
|
|
$canvote = 0;
|
|
$errorvote = __("You cannot vote in an proposal about you.");
|
|
} else if (tu_voted($row['ID'], uid_from_sid($_COOKIE["AURSID"]))) {
|
|
$canvote = 0;
|
|
$hasvoted = 1;
|
|
$errorvote = __("You've already voted for this proposal.");
|
|
}
|
|
|
|
if ($canvote == 1) {
|
|
if (isset($_POST['doVote']) && check_token()) {
|
|
if (isset($_POST['voteYes'])) {
|
|
$myvote = "Yes";
|
|
} else if (isset($_POST['voteNo'])) {
|
|
$myvote = "No";
|
|
} else if (isset($_POST['voteAbstain'])) {
|
|
$myvote = "Abstain";
|
|
}
|
|
|
|
cast_proposal_vote($row['ID'], uid_from_sid($_COOKIE["AURSID"]), $myvote, $row[$myvote] + 1);
|
|
|
|
# Can't vote anymore
|
|
#
|
|
$canvote = 0;
|
|
$errorvote = __("You've already voted for this proposal.");
|
|
|
|
# Update if they voted
|
|
if (tu_voted($row['ID'], uid_from_sid($_COOKIE["AURSID"]))) {
|
|
$hasvoted = 1;
|
|
}
|
|
$row = vote_details($_GET['id']);
|
|
}
|
|
}
|
|
include("tu_details.php");
|
|
}
|
|
} else {
|
|
print __("Vote ID not valid.");
|
|
}
|
|
|
|
} else {
|
|
$limit = $pp;
|
|
if (isset($_GET['off']))
|
|
$offset = $_GET['off'];
|
|
|
|
if (isset($_GET['by']))
|
|
$by = $_GET['by'];
|
|
else
|
|
$by = 'desc';
|
|
|
|
if (!empty($offset) && is_numeric($offset)) {
|
|
if ($offset >= 1) {
|
|
$off = $offset;
|
|
} else {
|
|
$off = 0;
|
|
}
|
|
} else {
|
|
$off = 0;
|
|
}
|
|
|
|
$order = ($by == 'asc') ? 'ASC' : 'DESC';
|
|
$lim = ($limit > 0) ? " LIMIT $limit OFFSET $off" : "";
|
|
$by_next = ($by == 'desc') ? 'asc' : 'desc';
|
|
|
|
$result = current_proposal_list($order);
|
|
$type = __("Current Votes");
|
|
include("tu_list.php");
|
|
?>
|
|
|
|
<?php
|
|
$result = past_proposal_list($order, $lim);
|
|
|
|
$type = __("Past Votes");
|
|
include("tu_list.php");
|
|
|
|
$nextresult = proposal_count();
|
|
?>
|
|
<div class="box">
|
|
<p><a href="<?php echo get_uri('/addvote/'); ?>"><?php print __("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='<?php echo get_uri('/tu/'); ?>?off=<?php print $back ?>&by=<?php print $by ?>'><?php print __("Back") ?></a>
|
|
<?php endif; ?>
|
|
<?php if (($off + $limit) < $nextresult):
|
|
$forw = $off + $limit; ?>
|
|
<a href="<?php echo get_uri('/tu/'); ?>?off=<?php print $forw ?>&by=<?php print $by ?>"><?php print __("Next") ?></a>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|
|
else {
|
|
header('Location: /');
|
|
}
|
|
|
|
html_footer(AUR_VERSION);
|
|
|