svn: /pear/pearweb/trunk/include/pepr/ pepr-ppcomment.php pepr.php

[email protected] (Till Klampaeckel) Fri, 18 Mar 2011 15:42:12 +0000
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
till                                     Fri, 18 Mar 2011 15:42:12 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=309392

Log:
spin off class ppcomment

Changed paths:
    A + pear/pearweb/trunk/include/pepr/pepr-ppcomment.php
        (from pear/pearweb/trunk/include/pepr/pepr.php:r309391)
    U   pear/pearweb/trunk/include/pepr/pepr.php

Copied: pear/pearweb/trunk/include/pepr/pepr-ppcomment.php (from rev 309391, pear/pearweb/trunk/include/pepr/pepr.php)
===================================================================
--- pear/pearweb/trunk/include/pepr/pepr-ppcomment.php	                        (rev 0)
+++ pear/pearweb/trunk/include/pepr/pepr-ppcomment.php	2011-03-18 15:42:12 UTC (rev 309392)
@@ -0,0 +1,92 @@
+<?php
+/**
+ * Establishes the procedures, objects and variables used throughout PEPr.
+ *
+ *
+ * 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
+ * [email protected] so we can mail you a copy immediately.
+ *
+ * @category  pearweb
+ * @package   PEPr
+ * @author    Tobias Schlitt <[email protected]>
+ * @author    Daniel Convissor <[email protected]>
+ * @copyright Copyright (c) 1997-2005 The PHP Group
+ * @license   http://www.php.net/license/3_0.txt  PHP License
+ * @version   $Id$
+ */
+
+class ppComment
+{
+    var $pkg_prop_id;
+    var $user_handle;
+    var $timestamp;
+    var $comment;
+    var $table;
+
+    function __construct($dbhResArr, $table = 'package_proposal_changelog')
+    {
+        foreach ($dbhResArr as $name => $value) {
+            $this->$name = $value;
+        }
+        $this->table = $table;
+    }
+
+    function get($proposalId, $handle, $timestamp,
+                 $table = 'package_proposal_changelog')
+    {
+        global $dbh;
+        $sql = "SELECT *, timestamp FROM ".$table." WHERE pkg_prop_id = ".$proposalId." AND user_handle='".$handle."' AND timestamp = FROM_UNIXTIME(".$timestamp.")";
+        $res = $dbh->query($sql);
+        if (DB::isError($res)) {
+            return $res;
+        }
+        $set = $res->fetchRow(DB_FETCHMODE_ASSOC);
+        $comment = new ppComment($set);
+        return $comment;
+    }
+
+    function &getAll($proposalId, $table = 'package_proposal_changelog')
+    {
+        global $dbh;
+        $sql = "SELECT *, timestamp FROM ".$table." WHERE pkg_prop_id = ".$proposalId." ORDER BY timestamp";
+        $res = $dbh->query($sql);
+        if (DB::isError($res)) {
+            return $res;
+        }
+        $comments = array();
+        while ($set = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
+            $comments[] = new ppVote($set);
+        }
+        return $comments;
+    }
+
+    function store($proposalId)
+    {
+        global $dbh;
+        if (empty($this->user_handle)) {
+            return PEAR::raiseError("Not initialized");
+        }
+        $sql = "INSERT INTO ".$this->table." (pkg_prop_id, user_handle, comment, timestamp)
+                    VALUES (".$proposalId.", ".$dbh->quoteSmart($this->user_handle).", ".$dbh->quoteSmart($this->comment).", ".time().")";
+        $res = $dbh->query($sql);
+        return $res;
+    }
+
+    function delete()
+    {
+        global $dbh;
+        if (empty($this->table) || empty($this->user_handle) || empty($this->pkg_prop_id) || empty($this->timestamp)) {
+            return PEAR::raiseError("Inconsistant comment data. Can not delete comment.");
+        }
+        $sql = "DELETE FROM ".$this->table." WHERE user_handle = '".$this->user_handle."' AND pkg_prop_id = ".$this->pkg_prop_id." AND timestamp = ".$this->timestamp;
+        $res = $dbh->query($sql);
+        return true;
+    }
+}

Modified: pear/pearweb/trunk/include/pepr/pepr.php
===================================================================
--- pear/pearweb/trunk/include/pepr/pepr.php	2011-03-18 15:37:50 UTC (rev 309391)
+++ pear/pearweb/trunk/include/pepr/pepr.php	2011-03-18 15:42:12 UTC (rev 309392)
@@ -113,76 +113,8 @@
 }

 require_once __DIR__ . '/pepr-proposal.php';
+require_once __DIR__ . '/pepr-ppcomment.php';

-class ppComment
-{
-    var $pkg_prop_id;
-    var $user_handle;
-    var $timestamp;
-    var $comment;
-    var $table;
-
-    function __construct($dbhResArr, $table = 'package_proposal_changelog')
-    {
-        foreach ($dbhResArr as $name => $value) {
-            $this->$name = $value;
-        }
-        $this->table = $table;
-    }
-
-    function get($proposalId, $handle, $timestamp,
-                 $table = 'package_proposal_changelog')
-    {
-        global $dbh;
-        $sql = "SELECT *, timestamp FROM ".$table." WHERE pkg_prop_id = ".$proposalId." AND user_handle='".$handle."' AND timestamp = FROM_UNIXTIME(".$timestamp.")";
-        $res = $dbh->query($sql);
-        if (DB::isError($res)) {
-            return $res;
-        }
-        $set = $res->fetchRow(DB_FETCHMODE_ASSOC);
-        $comment = new ppComment($set);
-        return $comment;
-    }
-
-    function &getAll($proposalId, $table = 'package_proposal_changelog')
-    {
-        global $dbh;
-        $sql = "SELECT *, timestamp FROM ".$table." WHERE pkg_prop_id = ".$proposalId." ORDER BY timestamp";
-        $res = $dbh->query($sql);
-        if (DB::isError($res)) {
-            return $res;
-        }
-        $comments = array();
-        while ($set = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
-            $comments[] = new ppVote($set);
-        }
-        return $comments;
-    }
-
-    function store($proposalId)
-    {
-        global $dbh;
-        if (empty($this->user_handle)) {
-            return PEAR::raiseError("Not initialized");
-        }
-        $sql = "INSERT INTO ".$this->table." (pkg_prop_id, user_handle, comment, timestamp)
-                    VALUES (".$proposalId.", ".$dbh->quoteSmart($this->user_handle).", ".$dbh->quoteSmart($this->comment).", ".time().")";
-        $res = $dbh->query($sql);
-        return $res;
-    }
-
-    function delete()
-    {
-        global $dbh;
-        if (empty($this->table) || empty($this->user_handle) || empty($this->pkg_prop_id) || empty($this->timestamp)) {
-            return PEAR::raiseError("Inconsistant comment data. Can not delete comment.");
-        }
-        $sql = "DELETE FROM ".$this->table." WHERE user_handle = '".$this->user_handle."' AND pkg_prop_id = ".$this->pkg_prop_id." AND timestamp = ".$this->timestamp;
-        $res = $dbh->query($sql);
-        return true;
-    }
-}
-
 global $proposalReviewsMap;
 $proposalReviewsMap = array(
                             'cursory'   => 'Cursory source review',