mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add a vote type to the TU proposal form
There are only four valid reasons for starting a TU vote, so instead of letting the user choose a vote length, let her pick a reason and set vote length and quorum based on that selection. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
64bfa6e828
commit
d41e40d9d6
2 changed files with 38 additions and 15 deletions
|
@ -37,16 +37,34 @@ if ($atype == "Trusted User" || $atype == "Developer") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['length'])) {
|
if (!empty($_POST['type'])) {
|
||||||
if (!is_numeric($_POST['length'])) {
|
switch ($_POST['type']) {
|
||||||
$error.= __("Length must be a number.") ;
|
case "add_tu":
|
||||||
} else if ($_POST['length'] < 1) {
|
/* Addition of a TU */
|
||||||
$error.= __("Length must be at least 1.");
|
$len = 7 * 24 * 60 * 60;
|
||||||
} else {
|
$quorum = 0.66;
|
||||||
$len = (60*60*24)*$_POST['length'];
|
break;
|
||||||
|
case "remove_tu":
|
||||||
|
/* Removal of a TU */
|
||||||
|
$len = 7 * 24 * 60 * 60;
|
||||||
|
$quorum = 0.75;
|
||||||
|
break;
|
||||||
|
case "remove_inactive_tu":
|
||||||
|
/* Removal of a TU (undeclared inactivity) */
|
||||||
|
$len = 5 * 24 * 60 * 60;
|
||||||
|
$quorum = 0.66;
|
||||||
|
break;
|
||||||
|
case "bylaws":
|
||||||
|
/* Amendment of Bylaws */
|
||||||
|
$len = 7 * 24 * 60 * 60;
|
||||||
|
$quorum = 0.75;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$error.= __("Invalid type.") ;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$len = 60*60*24*7;
|
$error.= __("Invalid type.") ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($_POST['agenda'])) {
|
if (empty($_POST['agenda'])) {
|
||||||
|
@ -55,7 +73,7 @@ if ($atype == "Trusted User" || $atype == "Developer") {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['addVote']) && empty($error)) {
|
if (!empty($_POST['addVote']) && empty($error)) {
|
||||||
add_tu_proposal($_POST['agenda'], $_POST['user'], $len, $uid);
|
add_tu_proposal($_POST['agenda'], $_POST['user'], $len, $quorum, $uid);
|
||||||
|
|
||||||
print "<p class=\"pkgoutput\">" . __("New proposal submitted.") . "</p>\n";
|
print "<p class=\"pkgoutput\">" . __("New proposal submitted.") . "</p>\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,9 +93,13 @@ if ($atype == "Trusted User" || $atype == "Developer") {
|
||||||
<?= __("(empty if not applicable)") ?>
|
<?= __("(empty if not applicable)") ?>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="id_length"><?= __("Length in days") ?></label>
|
<label for="id_type"><?= __("Type") ?></label>
|
||||||
<input type="text" name="length" id="id_length" value="<?php if (!empty($_POST['length'])) { print htmlentities($_POST['length'], ENT_QUOTES); } ?>" />
|
<select name="type" id="id_type">
|
||||||
<?= __("(defaults to 7 if empty)") ?>
|
<option value="add_tu"><?= __("Addition of a TU") ?></option>
|
||||||
|
<option value="remove_tu"><?= __("Removal of a TU") ?></option>
|
||||||
|
<option value="remove_inactive_tu"><?= __("Removal of a TU (undeclared inactivity)") ?></option>
|
||||||
|
<option value="bylaws"><?= __("Amendment of Bylaws") ?></option>
|
||||||
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="id_agenda"><?= __("Proposal") ?></label><br />
|
<label for="id_agenda"><?= __("Proposal") ?></label><br />
|
||||||
|
|
|
@ -615,7 +615,7 @@ function open_user_proposals($user) {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function add_tu_proposal($agenda, $user, $votelength, $submitteruid) {
|
function add_tu_proposal($agenda, $user, $votelength, $quorum, $submitteruid) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
|
|
||||||
$q = "SELECT COUNT(*) FROM Users WHERE AccountTypeID = 2";
|
$q = "SELECT COUNT(*) FROM Users WHERE AccountTypeID = 2";
|
||||||
|
@ -623,11 +623,12 @@ function add_tu_proposal($agenda, $user, $votelength, $submitteruid) {
|
||||||
$row = $result->fetch(PDO::FETCH_NUM);
|
$row = $result->fetch(PDO::FETCH_NUM);
|
||||||
$active_tus = $row[0];
|
$active_tus = $row[0];
|
||||||
|
|
||||||
$q = "INSERT INTO TU_VoteInfo (Agenda, User, Submitted, End, ";
|
$q = "INSERT INTO TU_VoteInfo (Agenda, User, Submitted, End, Quorum, ";
|
||||||
$q.= "SubmitterID, ActiveTUs) VALUES ";
|
$q.= "SubmitterID, ActiveTUs) VALUES ";
|
||||||
$q.= "(" . $dbh->quote($agenda) . ", " . $dbh->quote($user) . ", ";
|
$q.= "(" . $dbh->quote($agenda) . ", " . $dbh->quote($user) . ", ";
|
||||||
$q.= "UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + " . $dbh->quote($votelength);
|
$q.= "UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + " . $dbh->quote($votelength);
|
||||||
$q.= ", " . $submitteruid . ", " . $active_tus . ")";
|
$q.= ", " . $dbh->quote($quorum) . ", " . $submitteruid . ", ";
|
||||||
|
$q.= $active_tus . ")";
|
||||||
$result = $dbh->exec($q);
|
$result = $dbh->exec($q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue