Update wiki links to the new short URL
[aur.git] / web / html / addvote.php
blob3672c03153f90d38d3031c9205911f421f0540bd
1 <?php
3 set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
5 include_once("aur.inc.php");
7 $title = __("Add Proposal");
9 html_header($title);
11 if (isset($_COOKIE["AURSID"])) {
12 $uid = uid_from_sid($_COOKIE["AURSID"]);
15 if (has_credential(CRED_TU_ADD_VOTE)) {
17 if (!empty($_POST['addVote']) && !check_token()) {
18 $error = __("Invalid token for user action.");
21 if (!empty($_POST['addVote']) && check_token()) {
22 $error = "";
24 if (!empty($_POST['user'])) {
25 if (!uid_from_username($_POST['user'])) {
26 $error.= __("Username does not exist.");
27 } else {
29 if (open_user_proposals($_POST['user'])) {
30 $error.= __("%s already has proposal running for them.", htmlentities($_POST['user']));
35 if (!empty($_POST['type'])) {
36 switch ($_POST['type']) {
37 case "add_tu":
38 /* Addition of a TU */
39 $len = 7 * 24 * 60 * 60;
40 $quorum = 0.66;
41 break;
42 case "remove_tu":
43 /* Removal of a TU */
44 $len = 7 * 24 * 60 * 60;
45 $quorum = 0.75;
46 break;
47 case "remove_inactive_tu":
48 /* Removal of a TU (undeclared inactivity) */
49 $len = 5 * 24 * 60 * 60;
50 $quorum = 0.66;
51 break;
52 case "bylaws":
53 /* Amendment of Bylaws */
54 $len = 7 * 24 * 60 * 60;
55 $quorum = 0.75;
56 break;
57 default:
58 $error.= __("Invalid type.") ;
59 break;
61 } else {
62 $error.= __("Invalid type.") ;
65 if (empty($_POST['agenda'])) {
66 $error.= __("Proposal cannot be empty.");
70 if (!empty($_POST['addVote']) && empty($error)) {
71 add_tu_proposal($_POST['agenda'], $_POST['user'], $len, $quorum, $uid);
73 print "<p class=\"pkgoutput\">" . __("New proposal submitted.") . "</p>\n";
74 } else {
77 <?php if (!empty($error)): ?>
78 <p style="color: red;" class="pkgoutput"><?= $error ?></p>
79 <?php endif; ?>
81 <div class="box">
82 <h2><?= __("Submit a proposal to vote on.") ?></h2>
84 <form action="<?= get_uri('/addvote/'); ?>" method="post">
85 <p>
86 <label for="id_user"><?= __("Applicant/TU") ?></label>
87 <input type="text" name="user" id="id_user" value="<?php if (!empty($_POST['user'])) { print htmlentities($_POST['user'], ENT_QUOTES); } ?>" />
88 <?= __("(empty if not applicable)") ?>
89 </p>
90 <p>
91 <label for="id_type"><?= __("Type") ?></label>
92 <select name="type" id="id_type">
93 <option value="add_tu"><?= __("Addition of a TU") ?></option>
94 <option value="remove_tu"><?= __("Removal of a TU") ?></option>
95 <option value="remove_inactive_tu"><?= __("Removal of a TU (undeclared inactivity)") ?></option>
96 <option value="bylaws"><?= __("Amendment of Bylaws") ?></option>
97 </select>
98 </p>
99 <p>
100 <label for="id_agenda"><?= __("Proposal") ?></label><br />
101 <textarea name="agenda" id="id_agenda" rows="15" cols="80"><?php if (!empty($_POST['agenda'])) { print htmlentities($_POST['agenda']); } ?></textarea><br />
102 <input type="hidden" name="addVote" value="1" />
103 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
104 <input type="submit" class="button" value="<?= __("Submit"); ?>" />
105 </p>
106 </form>
107 </div>
108 <?php
110 } else {
111 print __("You are not allowed to access this area.");
114 html_footer(AURWEB_VERSION);