cvs: pearweb /include pear-election.php pear-voter.php /public_html election-new.php /sql election.sql /templates election-new-step1.tpl.php
election-new-step2.tpl.php election-new-step3.tpl.php election-showresults.tpl.php
| From: | Greg Beaver | Date: | Thu, 09 Nov 2006 05:10:18 +0000 |
| Subject: | cvs: pearweb /include pear-election.php pear-voter.php /public_html election-new.php /sql election.sql /templates election-new-step1.tpl.php election-new-step2.tpl.php election-new-step3.tpl.php election-showresults.tpl.php |
||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-5162@lists.php.net to get a copy of this message | ||
cellog Thu Nov 9 05:10:18 2006 UTC
Modified files:
/pearweb/include pear-election.php pear-voter.php
/pearweb/public_html election-new.php
/pearweb/sql election.sql
/pearweb/templates election-new-step1.tpl.php
election-new-step2.tpl.php
election-new-step3.tpl.php
election-showresults.tpl.php
Log:
fully support limiting voting to PEAR developers or to general PHP public
on an election-by-election basis.
Improve the validation of election choices
http://cvs.php.net/viewvc.cgi/pearweb/include/pear-election.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/pear-election.php diff -u pearweb/include/pear-election.php:1.1 pearweb/include/pear-election.php:1.2 --- pearweb/include/pear-election.php:1.1 Tue Nov 7 05:47:05 2006 +++ pearweb/include/pear-election.php Thu Nov 9 05:10:17 2006 @@ -20,13 +20,24 @@ if (empty($_POST['choices'])) { $error[] = 'Number of Choices is required'; } else { - if ((int) $_POST['choices'] != $_POST['choices']) { + if (!is_numeric($_POST['choices']) || + ((int) $_POST['choices'] != $_POST['choices'])) { $error[] = 'Number of Choices must be an integer'; } if ($_POST['choices'] < 2 || $_POST['choices'] > 20) { $error[] = 'Number of Choices must be between 2 and 20'; } } + if (empty($_POST['eligiblevoters'])) { + $error[] = 'Eligible Voters is required'; + } else { + if (!is_numeric($_POST['eligiblevoters'])) { + $error[] = 'Eligible Voters must be "PEAR Developers" or "General PHP Public"'; + } + if ($_POST['eligiblevoters'] != 1 && $_POST['eligiblevoters'] != 2) { + $error[] = 'Eligible Voters must be "PEAR Developers" or "General PHP Public"'; + } + } if (empty($_POST['detail'])) { $error[] = 'Election detail is required'; } @@ -100,18 +111,33 @@ if ($_POST['maximum'] < $_POST['minimum']) { $error[] = 'Maximum votes needed must be greater or the same as minimum votes needed'; } + if ($_POST['minimum'] > $_POST['choices']) { + $error[] = 'Minimum votes needed must be greater or equal to the number of choices'; + } return $error; } function validateStep2() { $error = array(); - for ($i = 1; $i <= $_POST['choices']; $i++) { - if (empty($_POST['summary' . $i])) { - $error[] = 'Summary for Choice #' . $i . ' must not be empty'; - } - if (empty($_POST['summary_link' . $i])) { - $error[] = 'Link to more info for Choice #' . $i . ' must not be empty'; + if (isset($_POST['add1choice'])) { + $error[] = 'Added one choice'; + $_POST['choices']++; + } elseif (isset($_POST['delete1choice'])) { + if ($_POST['choices'] < $_POST['minimum']) { + $error[] = 'Cannot delete, must have at least the Minimum votes needed'; + } else { + $error[] = 'Deleted last choice'; + $_POST['choices']--; + } + } else { + for ($i = 1; $i <= $_POST['choices']; $i++) { + if (empty($_POST['summary' . $i])) { + $error[] = 'Summary for Choice #' . $i . ' must not be empty'; + } + if (empty($_POST['summary_link' . $i])) { + $error[] = 'Link to more info for Choice #' . $i . ' must not be empty'; + } } } return $error; @@ -126,8 +152,8 @@ $this->dbh->query(' INSERT INTO elections (purpose, detail, votestart, voteend, creator, createdate, minimum_choices, - maximum_choices) - VALUES(?,?,?,?,?,NOW(),?,?) + maximum_choices, eligiblevoters) + VALUES(?,?,?,?,?,NOW(),?,?,?) ', array( $_POST['purpose'], $_POST['detail'], @@ -136,6 +162,7 @@ $this->user, $_POST['minimum'], $_POST['maximum'], + $_POST['eligiblevoters'] )); $id = $this->dbh->phptype == 'mysql' ? mysql_insert_id() : mysqli_insert_id($this->dbh->connection); http://cvs.php.net/viewvc.cgi/pearweb/include/pear-voter.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/include/pear-voter.php diff -u pearweb/include/pear-voter.php:1.4 pearweb/include/pear-voter.php:1.5 --- pearweb/include/pear-voter.php:1.4 Thu Nov 9 04:05:31 2006 +++ pearweb/include/pear-voter.php Thu Nov 9 05:10:17 2006 @@ -5,10 +5,12 @@ var $dbh; var $user = false; var $voteSalt; + var $damblan; function PEAR_Voter() { $this->dbh = &$GLOBALS['dbh']; $this->user = isset($GLOBALS['auth_user']) ? $GLOBALS['auth_user']->handle : false; + $this->damblan = new Damblan_Karma($this->dbh); } function listCurrentElections() @@ -217,6 +219,29 @@ // election is finished return false; } + if ($info['eligiblevoters'] == 1) { + // PEAR developers + if ($this->karma->has($this->user, 'pear.dev')) { + return true; + } + if ($this->karma->has($this->user, 'pear.admin')) { + return true; + } + return false; + } elseif ($info['eligiblevoters'] == 2) { + // general PHP public + PEAR developers + if ($this->karma->has($this->user, 'pear.dev')) { + return true; + } + if ($this->karma->has($this->user, 'pear.admin')) { + return true; + } + if ($this->karma->has($this->user, 'pear.voter')) { + return true; + } + return false; + } + return false; } function getVoteSalt() http://cvs.php.net/viewvc.cgi/pearweb/public_html/election-new.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/public_html/election-new.php diff -u pearweb/public_html/election-new.php:1.1 pearweb/public_html/election-new.php:1.2 --- pearweb/public_html/election-new.php:1.1 Tue Nov 7 05:47:05 2006 +++ pearweb/public_html/election-new.php Thu Nov 9 05:10:18 2006 @@ -14,6 +14,7 @@ 'length' => 7, 'minimum' => 1, 'maximum' => 1, + 'eligiblevoters' => 1, ); require dirname(dirname(__FILE__)) . '/templates/election-new-step1.tpl.php'; } elseif ($_POST['step'] == 2) { @@ -29,6 +30,7 @@ $info['length'] = (int) $_POST['length']; $info['minimum'] = (int) $_POST['minimum']; $info['maximum'] = (int) $_POST['maximum']; + $info['eligiblevoters'] = (int) $_POST['eligiblevoters']; if ($error) { require dirname(dirname(__FILE__)) . '/templates/election-new-step1.tpl.php'; exit; @@ -52,6 +54,7 @@ $info['length'] = (int) $_POST['length']; $info['minimum'] = (int) $_POST['minimum']; $info['maximum'] = (int) $_POST['maximum']; + $info['eligiblevoters'] = (int) $_POST['eligiblevoters']; if ($error) { // this should never happen. It will only occur // if the user manually fills POST data without going @@ -59,29 +62,8 @@ require dirname(dirname(__FILE__)) . '/templates/election-new-step1.tpl.php'; exit; } - if (isset($_POST['add1choice'])) { - $info['choices']++; - for ($i = 1; $i <= $info['choices']; $i++) { - $info['summary' . $i] = - empty($_POST['summary' . $i]) ? '' : $_POST['summary' . $i]; - $info['summary_link' . $i] = - empty($_POST['summary_link' . $i]) ? '' : $_POST['summary_link' . $i]; - } - require dirname(dirname(__FILE__)) . '/templates/election-new-step2.tpl.php'; - exit; - } - if (isset($_POST['delete1choice']) && $info['choices'] > 2) { - $info['choices']--; - for ($i = 1; $i <= $info['choices']; $i++) { - $info['summary' . $i] = - empty($_POST['summary' . $i]) ? '' : $_POST['summary' . $i]; - $info['summary_link' . $i] = - empty($_POST['summary_link' . $i]) ? '' : $_POST['summary_link' . $i]; - } - require dirname(dirname(__FILE__)) . '/templates/election-new-step2.tpl.php'; - exit; - } $error = $election->validateStep2(); + $info['choices'] = (int) $_POST['choices']; for ($i = 1; $i <= $info['choices']; $i++) { $info['summary' . $i] = empty($_POST['summary' . $i]) ? '' : $_POST['summary' . $i]; $info['summary_link' . $i] = @@ -93,6 +75,16 @@ } require dirname(dirname(__FILE__)) . '/templates/election-new-step3.tpl.php'; } elseif ($_POST['step'] == 4) { + if (isset($_POST['cancel'])) { + require 'pear-voter.php'; + $voter = new PEAR_Voter; + $currentelections = $voter->listCurrentElections(); + $completedelections = $voter->listCompletedElections(); + $allelections = $voter->listAllElections(); + $error = 'Election creation cancelled'; + require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; + exit; + } require 'pear-election.php'; $election = new PEAR_Election; $error = $election->validateStep1(); @@ -105,6 +97,7 @@ $info['length'] = (int) $_POST['length']; $info['minimum'] = (int) $_POST['minimum']; $info['maximum'] = (int) $_POST['maximum']; + $info['eligiblevoters'] = (int) $_POST['eligiblevoters']; if ($error) { // this should never happen. It will only occur // if the user manually fills POST data without going @@ -127,5 +120,11 @@ } $election->saveNewElection(); $error = ''; + require 'pear-voter.php'; + $voter = new PEAR_Voter; + $currentelections = $voter->listCurrentElections(); + $completedelections = $voter->listCompletedElections(); + $allelections = $voter->listAllElections(); + $error = 'Election saved'; require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; } \ No newline at end of file http://cvs.php.net/viewvc.cgi/pearweb/sql/election.sql?r1=1.3&r2=1.4&diff_format=u Index: pearweb/sql/election.sql diff -u pearweb/sql/election.sql:1.3 pearweb/sql/election.sql:1.4 --- pearweb/sql/election.sql:1.3 Thu Nov 9 04:05:31 2006 +++ pearweb/sql/election.sql Thu Nov 9 05:10:18 2006 @@ -35,6 +35,7 @@ createdate DATETIME NOT NULL, minimum_choices TINYINT DEFAULT '1' NOT NULL, maximum_choicse TINYINT DEFAULT '1' NOT NULL, + eligiblevoters TINYINT DEFAULT '1' NOT NULL, PRIMARY KEY (id) ); http://cvs.php.net/viewvc.cgi/pearweb/templates/election-new-step1.tpl.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/templates/election-new-step1.tpl.php diff -u pearweb/templates/election-new-step1.tpl.php:1.1 pearweb/templates/election-new-step1.tpl.php:1.2 --- pearweb/templates/election-new-step1.tpl.php:1.1 Tue Nov 7 05:47:06 2006 +++ pearweb/templates/election-new-step1.tpl.php Thu Nov 9 05:10:18 2006 @@ -16,6 +16,24 @@ <th class="form-label_left" colspan="2">(All entries are required)</th> </tr> <tr> + <th class="form-label_left">Eligible Voters</th> + <td class="form-input"> + <select name="eligiblevoters"> + <?php + if ($info['eligiblevoters'] == '1') { + $ev1 = ' selected="true"'; + $ev2 = ''; + } else { + $ev2 = ' selected="true"'; + $ev1 = ''; + } + ?> + <option value="1"<?php echo $ev1 ?>>PEAR Developers</option> + <option value="2"<?php echo $ev2 ?>>General PHP Public</option> + </select> + </td> + </tr> + <tr> <th class="form-label_left">Election Purpose (summary)</th> <td class="form-input"> <input type="text" name="purpose" size="100" maxlength="100" value="<?php http://cvs.php.net/viewvc.cgi/pearweb/templates/election-new-step2.tpl.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/templates/election-new-step2.tpl.php diff -u pearweb/templates/election-new-step2.tpl.php:1.1 pearweb/templates/election-new-step2.tpl.php:1.2 --- pearweb/templates/election-new-step2.tpl.php:1.1 Tue Nov 7 05:47:06 2006 +++ pearweb/templates/election-new-step2.tpl.php Thu Nov 9 05:10:18 2006 @@ -34,6 +34,17 @@ <th class="form-label_left" colspan="2">Entered data (can be edited later)</th> </tr> <tr> + <th class="form-label_left">Eligible Voters</th> + <td class="form-input"> + <input type="hidden" name="eligiblevoters" value="<?php echo $info['eligiblevoters'] ?>" /> + <?php if ($info['eligiblevoters'] == 1) { + echo 'PEAR Developers'; +} else { + echo 'General PHP Public'; +} ?> + </td> + </tr> + <tr> <th class="form-label_left">Election Purpose</th> <td class="form-input"> <input type="hidden" name="purpose" value="<?php echo htmlspecialchars($info['purpose']); ?>" /> http://cvs.php.net/viewvc.cgi/pearweb/templates/election-new-step3.tpl.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/templates/election-new-step3.tpl.php diff -u pearweb/templates/election-new-step3.tpl.php:1.1 pearweb/templates/election-new-step3.tpl.php:1.2 --- pearweb/templates/election-new-step3.tpl.php:1.1 Tue Nov 7 05:47:06 2006 +++ pearweb/templates/election-new-step3.tpl.php Thu Nov 9 05:10:18 2006 @@ -27,6 +27,17 @@ </tr> <?php endfor; // for ($i = 1; $i < $info['choices']; $i++): ?> <tr> + <th class="form-label_left">Eligible Voters</th> + <td class="form-input"> + <input type="hidden" name="eligiblevoters" value="<?php echo $info['eligiblevoters'] ?>" /> + <?php if ($info['eligiblevoters'] == 1) { + echo 'PEAR Developers'; +} else { + echo 'General PHP Public'; +} ?> + </td> + </tr> + <tr> <th class="form-label_left">Election Purpose</th> <td class="form-input"> <input type="hidden" name="purpose" value="<?php echo htmlspecialchars($info['purpose']); ?>" /> http://cvs.php.net/viewvc.cgi/pearweb/templates/election-showresults.tpl.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/templates/election-showresults.tpl.php diff -u pearweb/templates/election-showresults.tpl.php:1.4 pearweb/templates/election-showresults.tpl.php:1.5 --- pearweb/templates/election-showresults.tpl.php:1.4 Thu Nov 9 04:05:31 2006 +++ pearweb/templates/election-showresults.tpl.php Thu Nov 9 05:10:18 2006 @@ -6,6 +6,11 @@ <td class="form-input"><?php echo $info['detail'] ?></td> </tr> <tr> + <th class="form-label_left">Eligible Voters</td> + <td class="form-input"><?php echo $info['eligiblevoters'] == 1 ? + 'PEAR Developers' : 'General PHP Public' ?></td> + </tr> + <tr> <th class="form-label_left">Election dates</th> <td class="form-input"><?php echo $info['votestart'] . ' until ' . $info['voteend']; ?></td>
http://cvs.php.net/viewvc.cgi/pearweb/include/pear-election.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/pear-election.php diff -u pearweb/include/pear-election.php:1.1 pearweb/include/pear-election.php:1.2 --- pearweb/include/pear-election.php:1.1 Tue Nov 7 05:47:05 2006 +++ pearweb/include/pear-election.php Thu Nov 9 05:10:17 2006 @@ -20,13 +20,24 @@ if (empty($_POST['choices'])) { $error[] = 'Number of Choices is required'; } else { - if ((int) $_POST['choices'] != $_POST['choices']) { + if (!is_numeric($_POST['choices']) || + ((int) $_POST['choices'] != $_POST['choices'])) { $error[] = 'Number of Choices must be an integer'; } if ($_POST['choices'] < 2 || $_POST['choices'] > 20) { $error[] = 'Number of Choices must be between 2 and 20'; } } + if (empty($_POST['eligiblevoters'])) { + $error[] = 'Eligible Voters is required'; + } else { + if (!is_numeric($_POST['eligiblevoters'])) { + $error[] = 'Eligible Voters must be "PEAR Developers" or "General PHP Public"'; + } + if ($_POST['eligiblevoters'] != 1 && $_POST['eligiblevoters'] != 2) { + $error[] = 'Eligible Voters must be "PEAR Developers" or "General PHP Public"'; + } + } if (empty($_POST['detail'])) { $error[] = 'Election detail is required'; } @@ -100,18 +111,33 @@ if ($_POST['maximum'] < $_POST['minimum']) { $error[] = 'Maximum votes needed must be greater or the same as minimum votes needed'; } + if ($_POST['minimum'] > $_POST['choices']) { + $error[] = 'Minimum votes needed must be greater or equal to the number of choices'; + } return $error; } function validateStep2() { $error = array(); - for ($i = 1; $i <= $_POST['choices']; $i++) { - if (empty($_POST['summary' . $i])) { - $error[] = 'Summary for Choice #' . $i . ' must not be empty'; - } - if (empty($_POST['summary_link' . $i])) { - $error[] = 'Link to more info for Choice #' . $i . ' must not be empty'; + if (isset($_POST['add1choice'])) { + $error[] = 'Added one choice'; + $_POST['choices']++; + } elseif (isset($_POST['delete1choice'])) { + if ($_POST['choices'] < $_POST['minimum']) { + $error[] = 'Cannot delete, must have at least the Minimum votes needed'; + } else { + $error[] = 'Deleted last choice'; + $_POST['choices']--; + } + } else { + for ($i = 1; $i <= $_POST['choices']; $i++) { + if (empty($_POST['summary' . $i])) { + $error[] = 'Summary for Choice #' . $i . ' must not be empty'; + } + if (empty($_POST['summary_link' . $i])) { + $error[] = 'Link to more info for Choice #' . $i . ' must not be empty'; + } } } return $error; @@ -126,8 +152,8 @@ $this->dbh->query(' INSERT INTO elections (purpose, detail, votestart, voteend, creator, createdate, minimum_choices, - maximum_choices) - VALUES(?,?,?,?,?,NOW(),?,?) + maximum_choices, eligiblevoters) + VALUES(?,?,?,?,?,NOW(),?,?,?) ', array( $_POST['purpose'], $_POST['detail'], @@ -136,6 +162,7 @@ $this->user, $_POST['minimum'], $_POST['maximum'], + $_POST['eligiblevoters'] )); $id = $this->dbh->phptype == 'mysql' ? mysql_insert_id() : mysqli_insert_id($this->dbh->connection); http://cvs.php.net/viewvc.cgi/pearweb/include/pear-voter.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/include/pear-voter.php diff -u pearweb/include/pear-voter.php:1.4 pearweb/include/pear-voter.php:1.5 --- pearweb/include/pear-voter.php:1.4 Thu Nov 9 04:05:31 2006 +++ pearweb/include/pear-voter.php Thu Nov 9 05:10:17 2006 @@ -5,10 +5,12 @@ var $dbh; var $user = false; var $voteSalt; + var $damblan; function PEAR_Voter() { $this->dbh = &$GLOBALS['dbh']; $this->user = isset($GLOBALS['auth_user']) ? $GLOBALS['auth_user']->handle : false; + $this->damblan = new Damblan_Karma($this->dbh); } function listCurrentElections() @@ -217,6 +219,29 @@ // election is finished return false; } + if ($info['eligiblevoters'] == 1) { + // PEAR developers + if ($this->karma->has($this->user, 'pear.dev')) { + return true; + } + if ($this->karma->has($this->user, 'pear.admin')) { + return true; + } + return false; + } elseif ($info['eligiblevoters'] == 2) { + // general PHP public + PEAR developers + if ($this->karma->has($this->user, 'pear.dev')) { + return true; + } + if ($this->karma->has($this->user, 'pear.admin')) { + return true; + } + if ($this->karma->has($this->user, 'pear.voter')) { + return true; + } + return false; + } + return false; } function getVoteSalt() http://cvs.php.net/viewvc.cgi/pearweb/public_html/election-new.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/public_html/election-new.php diff -u pearweb/public_html/election-new.php:1.1 pearweb/public_html/election-new.php:1.2 --- pearweb/public_html/election-new.php:1.1 Tue Nov 7 05:47:05 2006 +++ pearweb/public_html/election-new.php Thu Nov 9 05:10:18 2006 @@ -14,6 +14,7 @@ 'length' => 7, 'minimum' => 1, 'maximum' => 1, + 'eligiblevoters' => 1, ); require dirname(dirname(__FILE__)) . '/templates/election-new-step1.tpl.php'; } elseif ($_POST['step'] == 2) { @@ -29,6 +30,7 @@ $info['length'] = (int) $_POST['length']; $info['minimum'] = (int) $_POST['minimum']; $info['maximum'] = (int) $_POST['maximum']; + $info['eligiblevoters'] = (int) $_POST['eligiblevoters']; if ($error) { require dirname(dirname(__FILE__)) . '/templates/election-new-step1.tpl.php'; exit; @@ -52,6 +54,7 @@ $info['length'] = (int) $_POST['length']; $info['minimum'] = (int) $_POST['minimum']; $info['maximum'] = (int) $_POST['maximum']; + $info['eligiblevoters'] = (int) $_POST['eligiblevoters']; if ($error) { // this should never happen. It will only occur // if the user manually fills POST data without going @@ -59,29 +62,8 @@ require dirname(dirname(__FILE__)) . '/templates/election-new-step1.tpl.php'; exit; } - if (isset($_POST['add1choice'])) { - $info['choices']++; - for ($i = 1; $i <= $info['choices']; $i++) { - $info['summary' . $i] = - empty($_POST['summary' . $i]) ? '' : $_POST['summary' . $i]; - $info['summary_link' . $i] = - empty($_POST['summary_link' . $i]) ? '' : $_POST['summary_link' . $i]; - } - require dirname(dirname(__FILE__)) . '/templates/election-new-step2.tpl.php'; - exit; - } - if (isset($_POST['delete1choice']) && $info['choices'] > 2) { - $info['choices']--; - for ($i = 1; $i <= $info['choices']; $i++) { - $info['summary' . $i] = - empty($_POST['summary' . $i]) ? '' : $_POST['summary' . $i]; - $info['summary_link' . $i] = - empty($_POST['summary_link' . $i]) ? '' : $_POST['summary_link' . $i]; - } - require dirname(dirname(__FILE__)) . '/templates/election-new-step2.tpl.php'; - exit; - } $error = $election->validateStep2(); + $info['choices'] = (int) $_POST['choices']; for ($i = 1; $i <= $info['choices']; $i++) { $info['summary' . $i] = empty($_POST['summary' . $i]) ? '' : $_POST['summary' . $i]; $info['summary_link' . $i] = @@ -93,6 +75,16 @@ } require dirname(dirname(__FILE__)) . '/templates/election-new-step3.tpl.php'; } elseif ($_POST['step'] == 4) { + if (isset($_POST['cancel'])) { + require 'pear-voter.php'; + $voter = new PEAR_Voter; + $currentelections = $voter->listCurrentElections(); + $completedelections = $voter->listCompletedElections(); + $allelections = $voter->listAllElections(); + $error = 'Election creation cancelled'; + require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; + exit; + } require 'pear-election.php'; $election = new PEAR_Election; $error = $election->validateStep1(); @@ -105,6 +97,7 @@ $info['length'] = (int) $_POST['length']; $info['minimum'] = (int) $_POST['minimum']; $info['maximum'] = (int) $_POST['maximum']; + $info['eligiblevoters'] = (int) $_POST['eligiblevoters']; if ($error) { // this should never happen. It will only occur // if the user manually fills POST data without going @@ -127,5 +120,11 @@ } $election->saveNewElection(); $error = ''; + require 'pear-voter.php'; + $voter = new PEAR_Voter; + $currentelections = $voter->listCurrentElections(); + $completedelections = $voter->listCompletedElections(); + $allelections = $voter->listAllElections(); + $error = 'Election saved'; require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; } \ No newline at end of file http://cvs.php.net/viewvc.cgi/pearweb/sql/election.sql?r1=1.3&r2=1.4&diff_format=u Index: pearweb/sql/election.sql diff -u pearweb/sql/election.sql:1.3 pearweb/sql/election.sql:1.4 --- pearweb/sql/election.sql:1.3 Thu Nov 9 04:05:31 2006 +++ pearweb/sql/election.sql Thu Nov 9 05:10:18 2006 @@ -35,6 +35,7 @@ createdate DATETIME NOT NULL, minimum_choices TINYINT DEFAULT '1' NOT NULL, maximum_choicse TINYINT DEFAULT '1' NOT NULL, + eligiblevoters TINYINT DEFAULT '1' NOT NULL, PRIMARY KEY (id) ); http://cvs.php.net/viewvc.cgi/pearweb/templates/election-new-step1.tpl.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/templates/election-new-step1.tpl.php diff -u pearweb/templates/election-new-step1.tpl.php:1.1 pearweb/templates/election-new-step1.tpl.php:1.2 --- pearweb/templates/election-new-step1.tpl.php:1.1 Tue Nov 7 05:47:06 2006 +++ pearweb/templates/election-new-step1.tpl.php Thu Nov 9 05:10:18 2006 @@ -16,6 +16,24 @@ <th class="form-label_left" colspan="2">(All entries are required)</th> </tr> <tr> + <th class="form-label_left">Eligible Voters</th> + <td class="form-input"> + <select name="eligiblevoters"> + <?php + if ($info['eligiblevoters'] == '1') { + $ev1 = ' selected="true"'; + $ev2 = ''; + } else { + $ev2 = ' selected="true"'; + $ev1 = ''; + } + ?> + <option value="1"<?php echo $ev1 ?>>PEAR Developers</option> + <option value="2"<?php echo $ev2 ?>>General PHP Public</option> + </select> + </td> + </tr> + <tr> <th class="form-label_left">Election Purpose (summary)</th> <td class="form-input"> <input type="text" name="purpose" size="100" maxlength="100" value="<?php http://cvs.php.net/viewvc.cgi/pearweb/templates/election-new-step2.tpl.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/templates/election-new-step2.tpl.php diff -u pearweb/templates/election-new-step2.tpl.php:1.1 pearweb/templates/election-new-step2.tpl.php:1.2 --- pearweb/templates/election-new-step2.tpl.php:1.1 Tue Nov 7 05:47:06 2006 +++ pearweb/templates/election-new-step2.tpl.php Thu Nov 9 05:10:18 2006 @@ -34,6 +34,17 @@ <th class="form-label_left" colspan="2">Entered data (can be edited later)</th> </tr> <tr> + <th class="form-label_left">Eligible Voters</th> + <td class="form-input"> + <input type="hidden" name="eligiblevoters" value="<?php echo $info['eligiblevoters'] ?>" /> + <?php if ($info['eligiblevoters'] == 1) { + echo 'PEAR Developers'; +} else { + echo 'General PHP Public'; +} ?> + </td> + </tr> + <tr> <th class="form-label_left">Election Purpose</th> <td class="form-input"> <input type="hidden" name="purpose" value="<?php echo htmlspecialchars($info['purpose']); ?>" /> http://cvs.php.net/viewvc.cgi/pearweb/templates/election-new-step3.tpl.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/templates/election-new-step3.tpl.php diff -u pearweb/templates/election-new-step3.tpl.php:1.1 pearweb/templates/election-new-step3.tpl.php:1.2 --- pearweb/templates/election-new-step3.tpl.php:1.1 Tue Nov 7 05:47:06 2006 +++ pearweb/templates/election-new-step3.tpl.php Thu Nov 9 05:10:18 2006 @@ -27,6 +27,17 @@ </tr> <?php endfor; // for ($i = 1; $i < $info['choices']; $i++): ?> <tr> + <th class="form-label_left">Eligible Voters</th> + <td class="form-input"> + <input type="hidden" name="eligiblevoters" value="<?php echo $info['eligiblevoters'] ?>" /> + <?php if ($info['eligiblevoters'] == 1) { + echo 'PEAR Developers'; +} else { + echo 'General PHP Public'; +} ?> + </td> + </tr> + <tr> <th class="form-label_left">Election Purpose</th> <td class="form-input"> <input type="hidden" name="purpose" value="<?php echo htmlspecialchars($info['purpose']); ?>" /> http://cvs.php.net/viewvc.cgi/pearweb/templates/election-showresults.tpl.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/templates/election-showresults.tpl.php diff -u pearweb/templates/election-showresults.tpl.php:1.4 pearweb/templates/election-showresults.tpl.php:1.5 --- pearweb/templates/election-showresults.tpl.php:1.4 Thu Nov 9 04:05:31 2006 +++ pearweb/templates/election-showresults.tpl.php Thu Nov 9 05:10:18 2006 @@ -6,6 +6,11 @@ <td class="form-input"><?php echo $info['detail'] ?></td> </tr> <tr> + <th class="form-label_left">Eligible Voters</td> + <td class="form-input"><?php echo $info['eligiblevoters'] == 1 ? + 'PEAR Developers' : 'General PHP Public' ?></td> + </tr> + <tr> <th class="form-label_left">Election dates</th> <td class="form-input"><?php echo $info['votestart'] . ' until ' . $info['voteend']; ?></td>