Alexander Nicolaysen Sørnes : Move votes when merging versions

Alexander Nicolaysen Sørnes asornes at winehq.org
Thu Jul 23 09:26:09 CDT 2009


Module: appdb
Branch: master
Commit: f95f3d533a78198a5ef058bddfd17b2a9a12efb1
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=f95f3d533a78198a5ef058bddfd17b2a9a12efb1

Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date:   Thu Jul 23 16:25:36 2009 +0200

Move votes when merging versions

---

 include/version.php |    3 ++
 include/vote.php    |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/include/version.php b/include/version.php
index 94b5071..064d890 100644
--- a/include/version.php
+++ b/include/version.php
@@ -1860,6 +1860,9 @@ class version {
             $aChildren[] = $oDownload;
         }
 
+        /* Get votes, include deleted ones */
+        $aChildren += vote::getVotesForVersion($this->iVersionId);
+
         return $aChildren;
     }
 
diff --git a/include/vote.php b/include/vote.php
index c19874f..520beca 100644
--- a/include/vote.php
+++ b/include/vote.php
@@ -70,6 +70,62 @@ class vote
 
         return TRUE;
     }
+
+    public function getVotesForVersion($iVersionId)
+    {
+        $aRet = array();
+        $hResult = query_parameters("SELECT * FROM appVotes WHERE versionId = '?'", 
+                                     $iVersionId);
+
+        if(!$hResult)
+            return $aRet;
+
+        while($oRow = mysql_fetch_object($hResult))
+            $aRet[] = new vote(null, $oRow);
+
+        return $aRet;
+    }
+
+    public function objectGetId()
+    {
+        return $this->iVoteId;
+    }
+
+    public function objectGetSubmitterId()
+    {
+        return $this->iUserId;
+    }
+
+    public function objectGetParent($sClass = '')
+    {
+        return new version($this->iVersionId);
+    }
+
+    public function objectSetParent($iNewId, $sClass = '')
+    {
+        $this->iVersionId = $iNewId;
+    }
+
+    public function canEdit()
+    {
+        if($_SESSION['current']->iUserId == $this->iUserId)
+            return true;
+
+        $oVersion = new version($this->iVersionId);
+
+        return $oVersion->canEdit();
+    }
+
+    function objectGetMail($sAction, $bMailSubmitter, $bParentAction)
+    {
+        return array(null, null, null); /* No mail */
+    }
+
+    public static function objectGetMailOptions($sAction, $bMailSubmitter,
+                                                $bParentAction)
+    {
+        return new mailOptions();
+    }
 }
 
 class voteManager




More information about the wine-cvs mailing list