remove dummy file
[cacert-boardvoting.git] / motions.php
1 <?php
2 require_once("database.php");
3 $db = new DB();
4 $page = is_numeric($_REQUEST['page'])?$_REQUEST['page']:1;
5 $user = $db->auth();
6
7 if ($_REQUEST['withdrawl'] && $_REQUEST['confirm'] && $_REQUEST['id']) {
8 $stmt = $db->getStatement("get decision");
9 $stmt->bindParam(":decision",$_REQUEST['id']);
10 $stmt->execute();
11 $decision=$stmt->fetch();
12
13 if (!$decision || !$user || $user['id'] != $decision['proponent']) {
14 header("HTTP/1.0 302 Redirect");
15 header("Location: denied.php");
16 exit();
17 }
18 $name = $user['name'];
19 $tag = $decision['tag'];
20 $title = $decision['title'];
21 $content = $decision['content'];
22 $body = <<<BODY
23 Dear Board,
24
25 $name has withdrawn the motion $tag that was as follows:
26
27 $title
28 $content
29
30 Kind regards,
31 the voting system
32 BODY;
33 $db->notify("Re: $tag - $title - withdrawn",$body,$tag);
34
35 $stmt = $db->getStatement("close decision");
36 $status = -2;
37 $stmt->bindParam(":status",$status);
38 $stmt->bindParam(":decision",$_REQUEST['id']);
39 $stmt->execute();
40 }
41 ?>
42 <html>
43 <head>
44 <title>CAcert Board Decisions</title>
45 <meta http-equiv="Content-Type" content="text/html; charset='UTF-8'" />
46 <link rel="stylesheet" type="text/css" href="styles.css" />
47 </head>
48 <body>
49 <?php
50 if ($user) echo '<a href="?unvoted=1">Show my outstanding votes</a><br/>';
51 ?>
52 <table class="list">
53 <tr>
54 <th>Status</th>
55 <th>Motion</th>
56 <th>Actions</th>
57 </tr>
58 <?php
59 if ($_REQUEST['motion']) {
60 $stmt = $db->getStatement("list decision");
61 $stmt->execute(array($_REQUEST['motion']));
62 } else {
63 if ($user && $_REQUEST['unvoted']) {
64 $stmt = $db->getStatement("list my unvoted decisions");
65 $stmt->bindParam(":id",$user['id']);
66 } else {
67 $stmt = $db->getStatement("list decisions");
68 }
69 $stmt->bindParam(":page",$page);
70 $stmt->execute();
71 }
72 $items = 0;
73 $id = -1;
74 while ($row = $stmt->fetch()) {
75 $items++;
76 $id = $row['id'];
77 ?><tr>
78 <td class="<?php switch($row['status']) { case 0: echo "pending"; break; case 1: echo "approved"; break; case -1: echo "declined"; break; case -2: echo "withdrawn"; break; }?>">
79 <?php
80 switch($row['status']) {
81 case 0: echo "Pending<br/><i>".$row['due']." UTC</i>"; break;
82 case 1: echo "Approved<br/><i>".$row['modified']." UTC</i>"; break;
83 case -1: echo "Declined<br/><i>".$row['modified']." UTC</i>"; break;
84 case -2: echo "Withdrawn<br/><i>".$row['modified']." UTC</i>"; break;
85 }
86 ?>
87 </td>
88 <td>
89 <i><a href="motions.php?motion=<?php echo $row['tag'].'">'.$row['tag']; ?></a></i><br/>
90 <b><?php echo htmlspecialchars($row['title']); ?></b><br/>
91 <pre><?php echo wordwrap(htmlspecialchars($row['content'])); ?></pre>
92 <br/>
93 <i>Due: <?php echo($row['due']); ?> UTC</i><br/>
94 <i>Proposed: <?php echo($row['proposer']); ?> (<?php echo($row['proposed']); ?> UTC)</i><br/>
95 <i>Vote type: <?php echo(!$row['votetype']?'motion':'veto'); ?></i><br/>
96 <i>Aye|Naye|Abstain: <?php echo($row['ayes']); ?>|<?php echo($row['nayes']); ?>|<?php echo($row['abstains']); ?></i><br/>
97 <?php
98 if ($row['status'] ==0 || $_REQUEST['showvotes']) {
99 $state = array('Naye','Abstain','Aye');
100 $vstmt = $db->getStatement("list votes");
101 $vstmt->execute(array($row['id']));
102 echo "<i>Votes:</i><br/>";
103 while ($vrow = $vstmt->fetch()) {
104 echo "<i>".$vrow['name'].": ".$state[$vrow['vote']+1]."</i><br/>";
105 }
106 } else {
107 echo '<i><a href="motions.php?motion='.$row['tag'].'&showvotes=1">Show Votes</a></i><br/>';
108 }
109 ?>
110 </td>
111 <td class="actions">
112 <?php
113 if ($row['status'] == 0 && $user ) {
114 ?>
115 <ul>
116 <li><a href="vote.php?motion=<?php echo($row['id']); ?>&amp;vote=1">Aye</a></li>
117 <li><a href="vote.php?motion=<?php echo($row['id']); ?>&amp;vote=0">Abstain</a></li>
118 <li><a href="vote.php?motion=<?php echo($row['id']); ?>&amp;vote=-1">Naye</a></li>
119 <li><a href="proxy.php?motion=<?php echo($row['id']); ?>">Proxy Vote</a></li>
120 <?php
121 if ($user && $user['id'] == $row['proponent']) {
122 ?>
123 <li><a href="motions.php?motion=<?php echo($row['tag']); ?>&amp;withdrawl=1">Withdraw</a></li>
124 <?php
125 }
126 ?>
127 </ul>
128 <?php
129 } else {
130 ?>
131 &nbsp;
132 <?php
133 }
134 ?>
135 </td>
136 </tr><?php
137 }
138 ?>
139 <tr>
140 <td colspan="2" class="navigation">
141 <?php if ($page>1) { ?><a href="?page=<?php echo($page-1); ?>">&lt;</a><?php } else { ?>&nbsp;<?php } ?>
142 &nbsp;
143 <?php if ($items>9) { ?><a href="?page=<?php echo($page+1); ?>">&gt;</a><?php } else { ?>&nbsp;<?php } ?>
144 </td>
145 <td class="actions">
146 <?php if ($user) echo('<ul><li><a href="motion.php">New Motion</a></li></ul>'); ?>
147 </td>
148 </tr>
149 <?php
150 if ($_REQUEST['withdrawl']) {
151 ?>
152 <tr>
153 <td colspan="3">
154 <?php
155 if ($_REQUEST['confirm'] && $_REQUEST['id']) {
156 ?>
157 <a href="motions.php">Motion Withdrawn</a>
158 <?php
159 } else {
160 ?>
161 <form action="?withdrawl=1&amp;confirm=1&amp;id=<?php echo $id;?>" method="post">
162 <input type="submit" value="Withdraw">
163 </form>
164 <?php
165 }
166 ?>
167 </td>
168 </tr>
169 <?php
170 }
171 ?>
172 </table>
173 </body>
174 </html>