[AppDB] Let users view distributions (3rd time lucky?)

Tony Lambregts tony.lambregts at gmail.com
Thu Oct 20 20:59:18 CDT 2005


(this time it should apply cleanly)

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 04:54:11 -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.2
diff -u -r1.2 distributionView.php
--- distributionView.php	18 Oct 2005 02:04:16 -0000	1.2
+++ distributionView.php	20 Oct 2005 04:54:11 -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
 {
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 04:54:11 -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: admin/editVendor.php
===================================================================
RCS file: /home/wine/appdb/admin/editVendor.php,v
retrieving revision 1.7
diff -u -r1.7 editVendor.php
--- admin/editVendor.php	30 Jan 2005 23:12:49 -0000	1.7
+++ admin/editVendor.php	20 Oct 2005 04:54:11 -0000
@@ -1,41 +1,44 @@
 <?php
-
 include("path.php");
-include(BASE."include/"."incl.php");
-include(BASE."include/"."tableve.php");
+require(BASE."include/incl.php");
+require(BASE."include/vendor.php");
 
 if(!$_SESSION['current']->hasPriv("admin"))
 {
     errorpage();
     exit;
 }
-else
-{
-    global $admin_mode;
-    $admin_mode = 1;
-}
-
-$vendorId = $_REQUEST['vendorId'];
-apidb_header("Edit Vendor Information");
-
-$t = new TableVE("edit");
-
-
-if($_POST)
+$oVendor = new Vendor($_REQUEST['vendorId']);
+if($_REQUEST['submit'])
 {
-    $t->update($_POST);
+    $oVendor->update($_REQUEST['name'],$_REQUEST['webpage']);
+    redirect(apidb_fullurl("admin/adminVendors.php"));
 }
 else
 {
-    $table = "vendor";
-    $query = "SELECT * FROM $table WHERE vendorId = $vendorId";
-
-    if(debugging())
-	echo "$query <br><br>\n";
-
-    $t->edit($query);
+    apidb_header("Edit Vendor");
+    echo "<form method=\"post\" action=\"addVendor.php\">
+          <input type=\"hidden\" name=\"vendorId\" value=\"".$oVendor->iVendorId."\" /> 
+          <table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
+            <tr>
+              <td width=\"15%\" class=\"box-label\"><b>Vendor name</b></td>
+              <td class=\"box-body\">
+                <input type=\"text\" size=\"50\" name=\"name\" value=\"".$oVendor->sName."\" /> 
+              </td>
+            </tr>
+            <tr>
+              <td width=\"15%\" class=\"box-label\"><b>Vendor URL</b></td>
+              <td class=\"box-body\">
+                <input type=\"text\" size=\"50\" name=\"webpage\" value=\"".$oVendor->sWebpage."\" /> 
+              </td>
+            </tr>
+            <tr>
+              <td colspan=\"2\" class=\"box-body\">
+                <input type=\"submit\" name=\"submit\" value=\"Submit\" />
+              </td>
+            </tr>
+          </table>
+          </form>";
+    apidb_footer();
 }
-
-apidb_footer();
-
 ?>
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 04:54:11 -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 04:54:11 -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