cvs: pearweb /public_html election-info.php election.php /public_html/css style.css

From: Date: Sun, 05 Nov 2006 22:38:18 +0000
Subject: cvs: pearweb /public_html election-info.php election.php /public_html/css style.css
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-5153@lists.php.net to get a copy of this message
cellog Sun Nov 5 22:38:18 2006 UTC Added files: /pearweb/public_html election-info.php election.php Modified files: /pearweb/public_html/css style.css Log: initial secret ballot general election support. so far, only voting is supported. Votes can be retrieved with a special password that is not stored. Election results are not yet calculated or supported. Results will be calculated by a cron job to avoid server strain. This code is experimental, and will neither work on the live server or have any real effect on it. To use, run "source election.sql" from within the mysql command- line or load it in phpmyadmin and add some elections and choices both vote-for-1-thing-only and vote-for-multiple-things elections are supported, as well as the option to "abstain" which can be used to express disapproval of all choices. http://cvs.php.net/viewvc.cgi/pearweb/public_html/css/style.css?r1=1.34&r2=1.35&diff_format=u Index: pearweb/public_html/css/style.css diff -u pearweb/public_html/css/style.css:1.34 pearweb/public_html/css/style.css:1.35 --- pearweb/public_html/css/style.css:1.34 Thu Aug 24 22:47:35 2006 +++ pearweb/public_html/css/style.css Sun Nov 5 22:38:18 2006 @@ -1,4 +1,4 @@ -/* $Id: style.css,v 1.34 2006/08/24 22:47:35 pajoye Exp $ */ +/* $Id: style.css,v 1.35 2006/11/05 22:38:18 cellog Exp $ */ @import url(/css/tabs.css); @@ -245,6 +245,29 @@ border: 0px; } +/* === Voting === */ + +td.vote-active { + padding: 3px; + text-align: left; + vertical-align: top; + background-color: #ffbbaa; +} + +td.vote-complete { + padding: 3px; + text-align: left; + vertical-align: top; + background-color: #bbaaff; +} + +td.vote-inactive { + padding: 3px; + text-align: left; + vertical-align: top; + background-color: #e8e8e8; +} + /* === User Submission Responses === */ http://cvs.php.net/viewvc.cgi/pearweb/public_html/election-info.php?view=markup&rev=1.1 Index: pearweb/public_html/election-info.php +++ pearweb/public_html/election-info.php <?php if (!isset($auth_user) || !$auth_user) { if (isset($_GET['vote'])) { if (strlen($_SERVER['QUERY_STRING'])) { $query = '?' . $_SERVER['QUERY_STRING']; } else { $query = ''; } require dirname(dirname(__FILE__)) . '/templates/election-register.tpl.php'; exit; } } require 'pear-voter.php'; $voter = &new PEAR_Voter; if (isset($_POST['confirm'])) { if (isset($_POST['cancel'])) { $currentelections = $voter->listCurrentElections(); $completedelections = $voter->listCompletedElections(); $allelections = $voter->listAllElections(); require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; exit; } // display vote confirmation page if (!$voter->electionExists($_POST['election'])) { $currentelections = $voter->listCurrentElections(); $completedelections = $voter->listCompletedElections(); $allelections = $voter->listAllElections(); $error = 'No such election id: ' . htmlspecialchars($_GET['election']); require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; exit; } $info = $voter->electionInfo($_POST['election']); if (!isset($_POST['vote'])) { $_POST['vote'] = array(); } if (isset($_POST['abstain'])) { $info['abstain'] = true; $info['vote'] = array(); } else { if (!is_array($_POST['vote'])) { $_POST['vote'] = array($_POST['vote']); } if (count($_POST['vote']) < $info['minimum_choices'] || count($_POST['vote']) > $info['maximum_choices']) { $error = 'You voted for ' . count($_POST['vote']) . ' choices, but must vote ' . 'for at least ' . $info['minimum_choices'] . ' choices, and at most ' . $info['maximum_choices'] . ' choices'; require dirname(dirname(__FILE__)) . '/templates/election-dovote.tpl.php'; exit; } $info['abstain'] = false; $info['vote'] = $_POST['vote']; } require dirname(dirname(__FILE__)) . '/templates/election-confirm.tpl.php'; exit; } if (isset($_POST['finalvote'])) { // vote has been confirmed // generate salt for hash if (!$voter->electionExists($_POST['election'])) { $currentelections = $voter->listCurrentElections(); $completedelections = $voter->listCompletedElections(); $allelections = $voter->listAllElections(); $error = 'No such election id: ' . htmlspecialchars($_GET['election']); require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; exit; } if (!isset($_POST['vote']) || !is_array($_POST['vote'])) { $_POST['vote'] = array(); } if (!isset($_POST['abstain'])) { $_POST['abstain'] = false; } $info = $voter->electionInfo($_POST['election']); $info['vote'] = $_POST['vote']; $info['abstain'] = $_POST['abstain']; $salt = $voter->getVoteSalt(); if ($info['abstain']) { $success = $voter->abstain($_POST['election']); } else { $success = $voter->vote($_POST['election'], $_POST['vote']); } require dirname(dirname(__FILE__)) . '/templates/election-confirmed.tpl.php'; exit; } if (!isset($_GET['election'])) { // display summary $currentelections = $voter->listCurrentElections(); $completedelections = $voter->listCompletedElections(); $allelections = $voter->listAllElections(); require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; exit; } if (!$voter->electionExists($_GET['election'])) { // display summary $currentelections = $voter->listCurrentElections(); $completedelections = $voter->listCompletedElections(); $allelections = $voter->listAllElections(); $error = 'No such election id: ' . htmlspecialchars($_GET['election']); require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; exit; } if (isset($_GET['vote'])) { $info = $voter->electionInfo($_GET['election']); if ($voter->hasVoted($_GET['election'])) { $currentelections = $voter->listCurrentElections(); $completedelections = $voter->listCompletedElections(); $allelections = $voter->listAllElections(); $error = 'You cannot vote twice in the same election'; require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; exit; } else { require dirname(dirname(__FILE__)) . '/templates/election-dovote.tpl.php'; } } ?> http://cvs.php.net/viewvc.cgi/pearweb/public_html/election.php?view=markup&rev=1.1 Index: pearweb/public_html/election.php +++ pearweb/public_html/election.php <?php if (!isset($auth_user) || !$auth_user) { if (strlen($_SERVER['QUERY_STRING'])) { $query = '?' . $_SERVER['QUERY_STRING']; } else { $query = ''; } require dirname(dirname(__FILE__)) . '/templates/election-register.tpl.php'; } else { require 'pear-voter.php'; $voter = &new PEAR_Voter; $retrieval = false; if (isset($_POST['salt'])) { if ($vote = $voter->retrieveVote($_POST['election'], $_POST['salt'])) { $info = $voter->electionInfo($_POST['election']); $info['vote'] = $vote; } else { $error = 'No votes found, incorrect salt?'; } $retrieval = true; } $currentelections = $voter->listCurrentElections(); $completedelections = $voter->listCompletedElections(); $allelections = $voter->listAllElections(); require dirname(dirname(__FILE__)) . '/templates/election-vote.tpl.php'; } ?>

« previous php.pear.core (#5153) next »