appdb/ include/monitor.php unit_test/test_om_o ...

WineHQ wineowner at wine.codeweavers.com
Sun Jul 29 20:22:55 CDT 2007


ChangeSet ID:	31288
CVSROOT:	/opt/cvs-commit
Module name:	appdb
Changes by:	wineowner at winehq.org	2007/07/29 20:22:55

Modified files:
	include        : monitor.php 
	unit_test      : test_om_objects.php 

Log message:
	Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
	Add objectManager support to the monitor class

Patch: http://cvs.winehq.org/patch.py?id=31288

Old revision  New revision  Changes     Path
 1.16          1.17          +111 -10    appdb/include/monitor.php
 1.21          1.22          +2 -0       appdb/unit_test/test_om_objects.php

Index: appdb/include/monitor.php
diff -u -p appdb/include/monitor.php:1.16 appdb/include/monitor.php:1.17
--- appdb/include/monitor.php:1.16	30 Jul 2007  1:22:55 -0000
+++ appdb/include/monitor.php	30 Jul 2007  1:22:55 -0000
@@ -19,22 +19,26 @@ class Monitor {
      * Constructor.
      * If $iMonitorId is provided, fetches Monitor.
      */
-    function Monitor($iMonitorId="")
+    function Monitor($iMonitorId="", $oRow = null)
     {
-        if($iMonitorId)
+        if(!$iMonitorId && !$oRow)
+            return;
+
+        if(!$oRow)
         {
             $sQuery = "SELECT *
                        FROM appMonitors
                        WHERE monitorId = '".$iMonitorId."'";
             $hResult = query_appdb($sQuery);
             $oRow = mysql_fetch_object($hResult);
-            if($oRow)
-            {
-                $this->iMonitorId = $oRow->monitorId;
-                $this->iAppId = $oRow->appId;
-                $this->iVersionId = $oRow->versionId;
-                $this->iUserId = $oRow->userId;
-            }
+        }
+
+        if($oRow)
+        {
+            $this->iMonitorId = $oRow->monitorId;
+            $this->iAppId = $oRow->appId;
+            $this->iVersionId = $oRow->versionId;
+            $this->iUserId = $oRow->userId;
         }
     }
 
@@ -98,8 +102,12 @@ class Monitor {
         $hResult = query_parameters("DELETE FROM appMonitors WHERE monitorId = '?'", $this->iMonitorId);
         if(!$bSilent)
             $this->SendNotificationMail("delete");
-    }
 
+        if(!$hResult)
+            return FALSE;
+
+        return TRUE;
+    }
 
     function SendNotificationMail($sAction="add",$sMsg=null)
     {
@@ -139,6 +147,99 @@ class Monitor {
             mail_appdb($sEmail, $sSubject ,$sMsg);
     }
 
+    function canEdit()
+    {
+        if($_SESSION['current']->hasPriv("admin") ||
+           ($this->iUserId == $_SESSION['current']->iUserId))
+            return TRUE;
+
+        return FALSE;
+    }
+
+    function mustBeQueued()
+    {
+        return FALSE;
+    }
+
+    /* Stub */
+    function display()
+    {
+        return "";
+    }
+
+    /* Stub */
+    function getOutputEditorValues()
+    {
+        return FALSE;
+    }
+
+    /* Stub */
+    function objectGetHeader()
+    {
+        return null;
+    }
+
+    function objectGetId()
+    {
+        return $this->iMonitorId;
+    }
+
+        /* Stub */
+    function objectGetTableRow()
+    {
+        return null;
+    }
+
+    /* Stub */
+    function objectMakeLink()
+    {
+        return "";
+    }
+
+    /* Stub */
+    function objectMakeUrl()
+    {
+        return "";
+    }
+
+    /* Stub */
+    function outputEditor()
+    {
+        return "";
+    }
+
+    function objectGetEntries($bQueued, $bRejected)
+    {
+        $hResult = query_parameters("SELECT * FROM appMonitors");
+
+        if(!$hResult)
+            return FALSE;
+
+        return $hResult;
+    }
+
+    function objectGetEntriesCount($bQueued, $bRejected)
+    {
+        $hResult = query_parameters("SELECT COUNT(DISTINCT monitorId) as count
+                                    FROM appMonitors");
+
+        if(!$hResult)
+            return FALSE;
+
+        $oRow = mysql_fetch_object($hResult);
+
+        if(!$oRow)
+            return FALSE;
+
+        return $oRow->count;
+    }
+
+    function allowAnonymousSubmissions()
+    {
+        /* That makes no sense */
+        return FALSE;
+    }
+
     /* Retrieve the user's monitored versions */
     function getVersionsMonitored($oUser)
     {
Index: appdb/unit_test/test_om_objects.php
diff -u -p appdb/unit_test/test_om_objects.php:1.21 appdb/unit_test/test_om_objects.php:1.22
--- appdb/unit_test/test_om_objects.php:1.21	30 Jul 2007  1:22:55 -0000
+++ appdb/unit_test/test_om_objects.php	30 Jul 2007  1:22:55 -0000
@@ -11,6 +11,7 @@ require_once(BASE.'include/testData_queu
 require_once(BASE.'include/version_queue.php');
 require_once(BASE.'include/application_queue.php');
 require_once(BASE.'include/browse_newest_apps.php');
+require_once(BASE.'include/monitor.php');
 
 /* internal function */
 function test_class($sClassName, $aTestMethods)
@@ -252,6 +253,7 @@ function test_object_methods()
                           "distribution",
                           "downloadurl",
                           "maintainer",
+                          "monitor",
                           "note",
                           "screenshot",
                           "testData",



More information about the wine-cvs mailing list