Source for file pepr-ppvote.php
Documentation is available at pepr-ppvote.php
* Establishes the procedures, objects and variables used throughout PEPr.
* The <var>$proposalReviewsMap</var> arrays is defined here.
* NOTE: Proposal constants are defined in pearweb/include/pear-config.php.
* This source file is subject to version 3.0 of the PHP license,
* that is bundled with this package in the file LICENSE, and is
* available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt.
* If you did not receive a copy of the PHP license and are unable to
* obtain it through the world-wide-web, please send a note to
* license@php.net so we can mail you a copy immediately.
* @author Tobias Schlitt <toby@php.net>
* @author Daniel Convissor <danielc@php.net>
* @copyright Copyright (c) 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License
* @version $Id: pepr-ppvote.php 312511 2011-06-27 10:33:02Z clockwerx $
global $proposalReviewsMap;
$proposalReviewsMap = array (
'cursory' => 'Cursory source review',
'deep' => 'Deep source review',
'test' => 'Run examples');
foreach ($dbhResArr as $name => $value) {
function get(&$dbh, $proposalId, $handle)
$sql = "SELECT *, UNIX_TIMESTAMP(timestamp) AS timestamp FROM package_proposal_votes WHERE pkg_prop_id = ". $dbh->quoteSmart ($proposalId) . " AND user_handle= ". $dbh->quoteSmart ($handle);
$res = $dbh->query ($sql);
$set = $res->fetchRow (DB_FETCHMODE_ASSOC );
function &getAll(&$dbh, $proposalId)
$sql = "SELECT *, UNIX_TIMESTAMP(timestamp) AS timestamp FROM package_proposal_votes WHERE pkg_prop_id = ". $dbh->quoteSmart ($proposalId) . " ORDER BY timestamp ASC";
$res = $dbh->query ($sql);
while ($set = $res->fetchRow (DB_FETCHMODE_ASSOC )) {
$votes[$set['user_handle']] = new ppVote($set);
function store($dbh, $proposalId)
return PEAR ::raiseError ("Not initialized");
$sql = "INSERT INTO package_proposal_votes (pkg_prop_id, user_handle, value, is_conditional, comment, reviews)
$res = $dbh->query ($sql);
foreach ((array) $this->reviews as $review) {
$res[] = $GLOBALS['proposalReviewsMap'][$review];
function getSum($dbh, $proposalId)
$sql = "SELECT SUM(value) FROM package_proposal_votes WHERE pkg_prop_id = ". $proposalId. " GROUP BY pkg_prop_id";
$result = $dbh->getOne ($sql);
$res['all'] = (is_numeric($result)) ? $result : 0;
$sql = "SELECT SUM(value) FROM package_proposal_votes WHERE pkg_prop_id = ". $proposalId. " AND is_conditional = 1 GROUP BY pkg_prop_id";
$result = $dbh->getOne ($sql);
$res['conditional'] = (is_numeric($result)) ? $result : 0;
$sql = "SELECT COUNT(user_handle) FROM package_proposal_votes WHERE pkg_prop_id = ". $dbh->quoteSmart ($proposalId). " GROUP BY pkg_prop_id";
$res = $dbh->getOne ($sql);
return (!empty ($res)) ? $res: " 0";
function hasVoted($dbh, $userHandle, $proposalId)
$sql = "SELECT count(pkg_prop_id) as votecount FROM package_proposal_votes
WHERE pkg_prop_id = ". $dbh->quoteSmart ($proposalId). " AND user_handle = ". $dbh->quoteSmart ($userHandle). "
$votes = $dbh->query ($sql);
return (bool) ($votes->numRows ());
Documentation generated on Mon, 11 Mar 2019 15:44:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|