[AppDB] Let users view distributions

Tony Lambregts tony.lambregts at gmail.com
Wed Oct 19 21:27:29 CDT 2005


This is a bit of clean up that lets normal users view all the 
distributions. in order to not duplicate code I got rid of 
adminDistributions. and removed the distributions entries from the admin 
menu.

Also bronze and garbage were not displaying properly under firefox in 
windows so fix it up (apidb.css)

Change log: Let users view distributions.

Files Changed: apidb.css distributionView.php admin/editDistribution.php 
include/sidebar.php include/sidebar_admin.php

Files Removed: admin/adminDistributions.php
-------------- next part --------------
Index: apidb.css
===================================================================
RCS file: /home/wine/appdb/apidb.css,v
retrieving revision 1.12
diff -u -r1.12 apidb.css
--- apidb.css	15 Oct 2005 15:18:19 -0000	1.12
+++ apidb.css	20 Oct 2005 02:14:00 -0000
@@ -135,6 +135,8 @@
 /* App Support status */
 .gold               { background-color: #fff600; }
 .silver             { background-color: silver; }
+.bronze             { background-color: #fcba0a; }
+.Garbage            { background-color: #999966; }
 
 
 /*******************************************************************/
Index: distributionView.php
===================================================================
RCS file: /home/wine/appdb/distributionView.php,v
retrieving revision 1.1
diff -u -r1.1 distributionView.php
--- distributionView.php	17 Oct 2005 03:59:24 -0000	1.1
+++ distributionView.php	20 Oct 2005 02:14:00 -0000
@@ -11,13 +11,70 @@
 require(BASE."include/distributions.php");
 require(BASE."include/testResults.php");
 
+if ($_REQUEST['sub'])
+{
+    if(!$_SESSION['current']->hasPriv("admin"))
+    {
+    errorpage("Insufficient privileges.");
+    exit;
+    }
+
+    if($_REQUEST['sub'] == 'delete')
+    {
+        $oDistribution = new distribution($_REQUEST['iDistributionId']);
+        $oDistribution->delete();
+        redirect($_SERVER['PHP_SELF']);
+    }
+} 
 $oDistribution = new distribution($_REQUEST['iDistributionId']);
 
 //exit with error if no vendor
 if(!$oDistribution->iDistributionId) 
 {
-    errorpage("No Distribution ID specified!");
-    exit;
+    apidb_header("View Distributions");
+
+    //get available Distributions
+    $sQuery = "SELECT distributionId FROM distributions ORDER BY name, distributionId;";
+    $hResult = query_appdb($sQuery);
+
+    // show Distribution list
+    echo html_frame_start("","90%","",0);
+    echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
+
+    echo "<tr class=color4>\n";
+    echo "    <td>Distribution name</td>\n";
+    echo "    <td>Distribution url</td>\n";
+    echo "    <td align=\"right\">Linked Tests</td>\n";
+    if ($_SESSION['current']->hasPriv("admin"))
+        echo "    <td align=\"center\">Action</td>\n";
+    echo "</tr>\n\n";
+       
+    $c = 1;
+    while($ob = mysql_fetch_object($hResult))
+    {
+        if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
+        $oDistribution = new distribution($ob->distributionId);
+        echo "<tr class=\"$bgcolor\">\n";
+        echo "    <td><a href=\"".BASE."distributionView.php?iDistributionId=".$oDistribution->iDistributionId."\">","\n";
+        echo $oDistribution->sName."</a></td>\n";
+        echo "    <td><a href=\"".$oDistribution->sUrl."\">".$oDistribution->sUrl."</a></td>\n";
+        echo "    <td align=\"right\">".sizeof($oDistribution->aTestingIds)."</td>\n";
+        if ($_SESSION['current']->hasPriv("admin"))
+        {
+            echo "    <td align=\"center\">";
+            echo "[<a href='".BASE."admin/editDistribution.php?iDistributionId=".$oDistribution->iDistributionId."'>edit</a>]";
+            if(!sizeof($oDistribution->aTestingIds))
+                echo " &nbsp; [<a href='".$_SERVER['PHP_SELF']."?sub=delete&iDistributionId=".$oDistribution->iDistributionId."'>delete</a>]";
+            echo "        </td>\n";
+        }
+        echo "</tr>\n";
+         $c++;
+    }
+    echo "</table>\n\n";
+    echo html_frame_end("&nbsp;");
+    if ($_SESSION['current']->hasPriv("admin"))
+        echo "[<a href='".BASE."admin/editDistribution.php'>Add New Distribution</a>]";
+    apidb_footer();
 } 
 else
 {
@@ -33,18 +90,21 @@
     echo $oDistribution->sName;
 
     if ($oDistribution->sUrl) 
+    {
         echo " (".$oDistribution->sUrl.")";
         echo "</a> <br />\n";
-
-    echo "<br />\n";
+    }
+    else 
+        echo "<br />\n";
 
     if($oDistribution->aTestingIds)
     {
-        echo "<br />Testing results for ".$oDistribution->sName."<br /><ol>\n";
-        echo '<p><span class="title">Testing Results</span><br />',"\n";
+//        echo "<br />Testing results for ".$oDistribution->sName."<br /><ol>\n";
+        echo '<p><span class="title">Testing Results for '.$oDistribution->sName.'</span><br />',"\n";
         echo '<table width="100%" border="1">',"\n";
         echo '<thead class="historyHeader">',"\n";
         echo '<tr>',"\n";
+        echo '<td>Application Version</td>',"\n";
         echo '<td>Submitter</td>',"\n";
         echo '<td>Date Submitted</td>',"\n";
         echo '<td>Wine version</td>',"\n";
@@ -60,16 +120,19 @@
             $oSubmitter = new User($oTest->iSubmitterId);
             $bgcolor = $oTest->sTestedRating;
             echo '<tr class='.$bgcolor.'>',"\n";
-            echo '    <td>',"\n";
+            echo '<td><a href="'.BASE.'appview.php?versionId='.$oTest->iVersionId.'&iTestingId='.$oTest->iTestingId.'">',"\n";
+            echo $oApp->sName.' '.$oVersion->sName.'</a></td>',"\n";
+            echo '<td>',"\n";
             echo $oSubmitter->sEmail ? "<a href=\"mailto:".$oSubmitter->sEmail."\">":"";
             echo $oSubmitter->sRealname;
             echo $oSubmitter->sEmail ? "</a>":"";
-            echo '    </td>',"\n";
-            echo '    <td>'.date("M d Y", mysqldatetime_to_unixtimestamp($oTest->sSubmitTime)).'</td>',"\n";
-            echo '    <td>'.$oTest->sTestedRelease.'&nbsp</td>',"\n";
-            echo '    <td>'.$oTest->sInstalls.'&nbsp</td>',"\n";
-            echo '    <td>'.$oTest->sRuns.'&nbsp</td>',"\n";
-            echo '    <td>'.$oTest->sTestedRating.'&nbsp</td>',"\n";
+            echo '</td>',"\n";
+            echo '<td>'.date("M d Y", mysqltimestamp_to_unixtimestamp($oTest->sSubmitTime)).'</td>',"\n";
+            echo '<td>'.$oTest->sTestedRelease.'&nbsp</td>',"\n";
+            echo '<td>'.$oTest->sInstalls.'&nbsp</td>',"\n";
+            echo '<td>'.$oTest->sRuns.'&nbsp</td>',"\n";
+            echo '<td>'.$oTest->sTestedRating.'&nbsp</td>',"\n";
+
             echo '</tr>',"\n";
         }
         echo '</table>',"\n";
Index: admin/editDistribution.php
===================================================================
RCS file: /home/wine/appdb/admin/editDistribution.php,v
retrieving revision 1.1
diff -u -r1.1 editDistribution.php
--- admin/editDistribution.php	17 Oct 2005 03:59:24 -0000	1.1
+++ admin/editDistribution.php	20 Oct 2005 02:14:00 -0000
@@ -5,7 +5,7 @@
 
 if(!$_SESSION['current']->hasPriv("admin"))
 {
-    errorpage();
+    errorpage("Insufficient privileges.");
     exit;
 }
 
@@ -22,7 +22,7 @@
        $oDistribution->create();
     } 
   
-    redirect(apidb_fullurl("admin/adminDistributions.php"));
+    redirect(apidb_fullurl("distributionView.php"));
     exit;
 }
 else

Index: include/sidebar.php
===================================================================
RCS file: /home/wine/appdb/include/sidebar.php,v
retrieving revision 1.13
diff -u -r1.13 sidebar.php
--- include/sidebar.php	25 Sep 2005 23:55:06 -0000	1.13
+++ include/sidebar.php	20 Oct 2005 02:14:00 -0000
@@ -2,6 +2,7 @@
 /***********/
 /* SideBar */
 /***********/
+require_once(BASE."include/distributions.php");
   
 function global_sidebar_menu() {
   
@@ -17,6 +18,8 @@
     $g->add("Submit Application", BASE."appsubmit.php?apptype=1");
     $g->add("Help &amp; Documentation", BASE."help/");
     $g->add("AppDB Stats", BASE."appdbStats.php");
+    $g->add("View Distributions (".getNumberOfDistributions().")", BASE."distributionView.php");
+
     $g->add("Email your suggestions for improving the AppDB", "mailto:appdb at winehq.org");
     $g->done();    
 
Index: include/sidebar_admin.php
===================================================================
RCS file: /home/wine/appdb/include/sidebar_admin.php,v
retrieving revision 1.18
diff -u -r1.18 sidebar_admin.php
--- include/sidebar_admin.php	17 Oct 2005 03:59:24 -0000	1.18
+++ include/sidebar_admin.php	20 Oct 2005 02:14:00 -0000
@@ -11,7 +11,6 @@
     
     $g->add("Add Category", BASE."admin/addCategory.php");
     $g->add("Add Vendor", BASE."admin/addVendor.php");
-    $g->add("Add Distribution", BASE."admin/editDistribution.php");
     
     $g->addmisc("&nbsp;");
     $g->add("View App Queue (".$_SESSION['current']->getQueuedAppCount()."/".$_SESSION['current']->getQueuedVersionCount().")", BASE."admin/adminAppQueue.php");
@@ -21,7 +20,6 @@
     $g->add("View Vendors (".getVendorCount().")", BASE."admin/adminVendors.php");
     $g->add("View Bug Links (".getNumberOfQueuedBugLinks()."/".getNumberOfBugLinks().")", BASE."admin/adminBugs.php");
     $g->add("View Test Results Queue (".getNumberOfQueuedTests().")", BASE."admin/adminTestResults.php");
-    $g->add("View Distributions (".getNumberOfDistributions().")", BASE."admin/adminDistributions.php");
 
     $g->addmisc("&nbsp;");
     $g->add("Users Management", BASE."admin/adminUsers.php");


More information about the wine-patches mailing list