Implement capability to pin comments above others
[aur.git] / web / html / tu.php
blobcc77d625ab35cd8b987729dbf8da2918f6019053
1 <?php
3 set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
5 include_once("aur.inc.php");
6 set_lang();
7 check_sid();
9 $title = __("Trusted User");
11 html_header($title);
13 # Default votes per page
14 $pp = 10;
15 $prev_Len = 75;
17 if (has_credential(CRED_TU_LIST_VOTES)) {
19 if (isset($_GET['id'])) {
20 if (is_numeric($_GET['id'])) {
21 $row = vote_details($_GET['id']);
23 if (empty($row)) {
24 print __("Could not retrieve proposal details.");
25 } else {
26 $isrunning = $row['End'] > time() ? 1 : 0;
28 # List voters of a proposal.
29 $whovoted = voter_list($row['ID']);
31 $canvote = 1;
32 $hasvoted = 0;
33 $errorvote = "";
34 if ($isrunning == 0) {
35 $canvote = 0;
36 $errorvote = __("Voting is closed for this proposal.");
37 } else if (!has_credential(CRED_TU_VOTE)) {
38 $canvote = 0;
39 $errorvote = __("Only Trusted Users are allowed to vote.");
40 } else if ($row['User'] == username_from_sid($_COOKIE["AURSID"])) {
41 $canvote = 0;
42 $errorvote = __("You cannot vote in an proposal about you.");
44 if (tu_voted($row['ID'], uid_from_sid($_COOKIE["AURSID"]))) {
45 $canvote = 0;
46 $hasvoted = 1;
47 if ($isrunning) {
48 $errorvote = __("You've already voted for this proposal.");
52 if ($canvote == 1) {
53 if (isset($_POST['doVote']) && check_token()) {
54 if (isset($_POST['voteYes'])) {
55 $myvote = "Yes";
56 } else if (isset($_POST['voteNo'])) {
57 $myvote = "No";
58 } else if (isset($_POST['voteAbstain'])) {
59 $myvote = "Abstain";
62 cast_proposal_vote($row['ID'], uid_from_sid($_COOKIE["AURSID"]), $myvote, $row[$myvote] + 1);
64 # Can't vote anymore
66 $canvote = 0;
67 $errorvote = __("You've already voted for this proposal.");
69 # Update if they voted
70 if (tu_voted($row['ID'], uid_from_sid($_COOKIE["AURSID"]))) {
71 $hasvoted = 1;
73 $row = vote_details($_GET['id']);
76 include("tu_details.php");
78 } else {
79 print __("Vote ID not valid.");
82 } else {
83 $limit = $pp;
84 if (isset($_GET['off']))
85 $offset = $_GET['off'];
87 if (isset($_GET['by']))
88 $by = $_GET['by'];
89 else
90 $by = 'desc';
92 if (!empty($offset) && is_numeric($offset)) {
93 if ($offset >= 1) {
94 $off = $offset;
95 } else {
96 $off = 0;
98 } else {
99 $off = 0;
102 $order = ($by == 'asc') ? 'ASC' : 'DESC';
103 $lim = ($limit > 0) ? " LIMIT $limit OFFSET $off" : "";
104 $by_next = ($by == 'desc') ? 'asc' : 'desc';
106 $result = current_proposal_list($order);
107 $type = __("Current Votes");
108 $nextresult = 0;
109 include("tu_list.php");
111 $result = past_proposal_list($order, $lim);
112 $type = __("Past Votes");
113 $nextresult = proposal_count();
114 include("tu_list.php");
116 $result = last_votes_list();
117 include("tu_last_votes_list.php");
120 else {
121 header('Location: /');
124 html_footer(AURWEB_VERSION);