PEPr
[ class tree: PEPr ] [ index: PEPr ] [ all elements ]

Source for file pepr-ppcomment.php

Documentation is available at pepr-ppcomment.php

  1. <?php
  2. /**
  3.  * Establishes the procedures, objects and variables used throughout PEPr.
  4.  *
  5.  *
  6.  * NOTE: Proposal constants are defined in pearweb/include/pear-config.php.
  7.  *
  8.  * This source file is subject to version 3.0 of the PHP license,
  9.  * that is bundled with this package in the file LICENSE, and is
  10.  * available through the world-wide-web at the following URI:
  11.  * http://www.php.net/license/3_0.txt.
  12.  * If you did not receive a copy of the PHP license and are unable to
  13.  * obtain it through the world-wide-web, please send a note to
  14.  * license@php.net so we can mail you a copy immediately.
  15.  *
  16.  * @category  pearweb
  17.  * @package   PEPr
  18.  * @author    Tobias Schlitt <toby@php.net>
  19.  * @author    Daniel Convissor <danielc@php.net>
  20.  * @copyright Copyright (c) 1997-2005 The PHP Group
  21.  * @license   http://www.php.net/license/3_0.txt  PHP License
  22.  * @version   $Id: pepr-ppcomment.php 309392 2011-03-18 15:42:12Z till $
  23.  */
  24.  
  25. class ppComment
  26. {
  27.     var $pkg_prop_id;
  28.     var $user_handle;
  29.     var $timestamp;
  30.     var $comment;
  31.     var $table;
  32.  
  33.     function __construct($dbhResArr$table 'package_proposal_changelog')
  34.     {
  35.         foreach ($dbhResArr as $name => $value{
  36.             $this->$name $value;
  37.         }
  38.         $this->table = $table;
  39.     }
  40.  
  41.     function get($proposalId$handle$timestamp,
  42.                  $table 'package_proposal_changelog')
  43.     {
  44.         global $dbh;
  45.         $sql "SELECT *, timestamp FROM ".$table." WHERE pkg_prop_id = ".$proposalId." AND user_handle='".$handle."' AND timestamp = FROM_UNIXTIME(".$timestamp.")";
  46.         $res $dbh->query($sql);
  47.         if (DB::isError($res)) {
  48.             return $res;
  49.         }
  50.         $set $res->fetchRow(DB_FETCHMODE_ASSOC);
  51.         $comment = new ppComment($set);
  52.         return $comment;
  53.     }
  54.  
  55.     function &getAll($proposalId$table 'package_proposal_changelog')
  56.     {
  57.         global $dbh;
  58.         $sql "SELECT *, timestamp FROM ".$table." WHERE pkg_prop_id = ".$proposalId." ORDER BY timestamp";
  59.         $res $dbh->query($sql);
  60.         if (DB::isError($res)) {
  61.             return $res;
  62.         }
  63.         $comments = array();
  64.         while ($set $res->fetchRow(DB_FETCHMODE_ASSOC)) {
  65.             $comments[= new ppVote($set);
  66.         }
  67.         return $comments;
  68.     }
  69.  
  70.     function store($proposalId)
  71.     {
  72.         global $dbh;
  73.         if (empty($this->user_handle)) {
  74.             return PEAR::raiseError("Not initialized");
  75.         }
  76.         $sql "INSERT INTO ".$this->table." (pkg_prop_id, user_handle, comment, timestamp)
  77.                     VALUES (".$proposalId.", ".$dbh->quoteSmart($this->user_handle).", ".$dbh->quoteSmart($this->comment).", ".time().")";
  78.         $res $dbh->query($sql);
  79.         return $res;
  80.     }
  81.  
  82.     function delete()
  83.     {
  84.         global $dbh;
  85.         if (empty($this->table|| empty($this->user_handle|| empty($this->pkg_prop_id|| empty($this->timestamp)) {
  86.             return PEAR::raiseError("Inconsistant comment data. Can not delete comment.");
  87.         }
  88.         $sql "DELETE FROM ".$this->table." WHERE user_handle = '".$this->user_handle."' AND pkg_prop_id = ".$this->pkg_prop_id." AND timestamp = ".$this->timestamp;
  89.         $res $dbh->query($sql);
  90.         return true;
  91.     }
  92. }

Documentation generated on Mon, 11 Mar 2019 15:44:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.