summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcommunity.cacert.org <community.cacert.org@d4452222-2f33-11de-9270-010000000000>2009-05-26 03:19:11 +0000
committercommunity.cacert.org <community.cacert.org@d4452222-2f33-11de-9270-010000000000>2009-05-26 03:19:11 +0000
commit2877a513fed891d90878f0f672b67f2582ab48e8 (patch)
tree82c828513c2f140e8696e68a31ec3a887fadb186
parent91afc1bbad9621364b92ae83f9d1c0a2bc7a1594 (diff)
downloadcacert-boardvoting-2877a513fed891d90878f0f672b67f2582ab48e8.tar.gz
cacert-boardvoting-2877a513fed891d90878f0f672b67f2582ab48e8.tar.xz
cacert-boardvoting-2877a513fed891d90878f0f672b67f2582ab48e8.zip
add showvotes functionality and remove notification when people vote
git-svn-id: http://svn.cacert.cl/Software/Voting/vote@40 d4452222-2f33-11de-9270-010000000000
-rw-r--r--database.php3
-rw-r--r--motions.php11
-rw-r--r--vote.php2
3 files changed, 14 insertions, 2 deletions
diff --git a/database.php b/database.php
index a522bd8..33a8130 100644
--- a/database.php
+++ b/database.php
@@ -5,7 +5,7 @@
function __construct() {
$this->dbh = new PDO("sqlite:".dirname(__FILE__)."/database.sqlite");
$this->statement = array();
- $this->statement['list decisions'] = $this->dbh->prepare("SELECT decisions.id, decisions.tag, voters.name AS proposer, decisions.proposed, decisions.title, decisions.content, decisions.quorum, decisions.majority, decisions.status, decisions.due, decisions.modified, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=1) AS ayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=-1) AS nayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=0) AS abstains FROM decisions, voters WHERE decisions.proponent=voters.id ORDER BY proposed DESC LIMIT 10 OFFSET 10 * (:page - 1);");
+ $this->statement['list decisions'] = $this->dbh->prepare("SELECT decisions.id AS id, decisions.tag, voters.name AS proposer, decisions.proposed, decisions.title, decisions.content, decisions.quorum, decisions.majority, decisions.status, decisions.due, decisions.modified, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=1) AS ayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=-1) AS nayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=0) AS abstains FROM decisions, voters WHERE decisions.proponent=voters.id ORDER BY proposed DESC LIMIT 10 OFFSET 10 * (:page - 1);");
$this->statement['closed decisions'] = $this->dbh->prepare("SELECT decisions.id, decisions.tag, voters.name AS proposer, decisions.proposed, decisions.title, decisions.content, decisions.quorum, decisions.majority, decisions.status, decisions.due, decisions.modified, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=1) AS ayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=-1) AS nayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=0) AS abstains FROM decisions, voters WHERE decisions.proponent=voters.id AND decisions.status=0 AND datetime('now','utc') > datetime(due);");
$this->statement['get decision'] = $this->dbh->prepare("SELECT decisions.id, decisions.tag, decisions.proponent, voters.name AS proposer, decisions.proposed, decisions.title, decisions.content, decisions.quorum, decisions.majority, decisions.status, decisions.due, decisions.modified, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=1) AS ayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=-1) AS nayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=0) AS abstains FROM decisions, voters WHERE decisions.proponent=voters.id AND decisions.id=:decision;");
$this->statement['get new decision'] = $this->dbh->prepare("SELECT decisions.id, decisions.tag, decisions.proponent, voters.name AS proposer, decisions.proposed, decisions.title, decisions.content, decisions.quorum, decisions.majority, decisions.status, decisions.due, decisions.modified, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=1) AS ayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=-1) AS nayes, (SELECT COUNT(*) FROM votes WHERE decision=decisions.id AND vote=0) AS abstains FROM decisions, voters WHERE decisions.proponent=voters.id AND decisions.id=last_insert_rowid();");
@@ -15,6 +15,7 @@
$this->statement['del vote'] = $this->dbh->prepare("DELETE FROM votes WHERE decision=:decision AND voter=:voter;");
$this->statement['do vote'] = $this->dbh->prepare("INSERT INTO votes (decision, voter, vote, voted, notes) VALUES (:decision, :voter, :vote, datetime('now','utc'), :notes);");
$this->statement['stats'] = $this->dbh->prepare("SELECT COUNT(*) AS voters FROM voters WHERE enabled=1;");
+ $this->statement['list votes'] = $this->dbh->prepare("SELECT voters.name AS name, votes.vote AS vote FROM voters,votes WHERE voters.id=votes.voter AND votes.decision=:id;");
$this->statement['create decision'] = $this->dbh->prepare("INSERT INTO decisions (proposed, proponent, title, content, quorum, majority, status, due, modified) VALUES (datetime('now','utc'), :proponent, :title, :content, :quorum, :majority, 0, datetime('now','utc', :due), datetime('now','utc'));");
$this->statement['post create'] = $this->dbh->prepare(" UPDATE decisions SET tag='m' || strftime('%Y%m%d','now') || '.' || id WHERE id=last_insert_rowid();");
$this->statement['update decision'] = $this->dbh->prepare("UPDATE decisions SET proposed=datetime('now','utc'), proponent=:proponent, title=:title, content=:content, quorum=:quorum, majority=:majority, status=0, due=datetime('now','utc',:due), modified=datetime('now','utc') WHERE id=:id;");
diff --git a/motions.php b/motions.php
index 27d1632..bbf1825 100644
--- a/motions.php
+++ b/motions.php
@@ -43,6 +43,17 @@
<i>Required Votes: <?php echo($row['quorum']); ?></i><br/>
<i>Majority: <?php echo($row['majority']); ?>%</i><br/>
<i>Aye|Naye|Abstain: <?php echo($row['ayes']); ?>|<?php echo($row['nayes']); ?>|<?php echo($row['abstains']); ?></i><br/>
+ <?php
+ if ($row['status'] ==0 || $_REQUEST['showvotes']) {
+ $state = array('Naye','Abstain','Aye');
+ $vstmt = $db->getStatement("list votes");
+ $vstmt->execute(array($row['id']));
+ echo "<i>Votes:</i><br/>";
+ while ($vrow = $vstmt->fetch()) {
+ echo "<i>".$vrow['name']." ".$state[$vrow['vote']+1]."</i><br/>";
+ }
+ }
+ ?>
</td><?php
?><td class="actions">
<?php
diff --git a/vote.php b/vote.php
index 819f03a..7908413 100644
--- a/vote.php
+++ b/vote.php
@@ -67,7 +67,7 @@ Kind regards,
the vote system
BODY;
- $db->notify("Re: $tag - $title",$body);
+ //$db->notify("Re: $tag - $title",$body);
} else {
?>
<b>Your vote has NOT been registered.</b><br/>