appdb/ ./distributionView.php include/distribu ...
WineHQ
wineowner at wine.codeweavers.com
Fri Jan 26 18:30:00 CST 2007
ChangeSet ID: 30910
CVSROOT: /opt/cvs-commit
Module name: appdb
Changes by: wineowner at winehq.org 2007/01/26 18:30:00
Modified files:
. : distributionView.php
include : distribution.php
Log message:
Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Add distribution functions and use them. Based on a patch by Chris Morgan
Patch: http://cvs.winehq.org/patch.py?id=30910
Old revision New revision Changes Path
1.23 1.24 +8 -29 appdb/distributionView.php
1.5 1.6 +71 -1 appdb/include/distribution.php
Index: appdb/distributionView.php
diff -u -p appdb/distributionView.php:1.23 appdb/distributionView.php:1.24
--- appdb/distributionView.php:1.23 27 Jan 2007 0:30: 0 -0000
+++ appdb/distributionView.php 27 Jan 2007 0:30: 0 -0000
@@ -25,46 +25,25 @@ if ($aClean['sSub'])
}
$oDistribution = new distribution($aClean['iDistributionId']);
-//exit with error if no distribution
+/* Display distribution list if no id given */
if(!$oDistribution->iDistributionId)
{
apidb_header("View Distributions");
//get available Distributions
- $hResult = query_parameters("SELECT distributionId FROM distributions ORDER BY name, distributionId;");
+ $hResult = distribution::ObjectGetEntries(false);
// 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($oRow = mysql_fetch_object($hResult))
+ distribution::ObjectOutputHeader("color4");
+
+ for($c = 1; $oRow = mysql_fetch_object($hResult); $c++)
{
- if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
- $oDistribution = new distribution($oRow->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 " [<a href='".$_SERVER['PHP_SELF']."?sSub=delete&iDistributionId=".$oDistribution->iDistributionId."'>delete</a>]";
- echo " </td>\n";
- }
- echo "</tr>\n";
- $c++;
+ $oDistribution = distribution::ObjectGetInstanceFromRow($oRow);
+
+ $oDistribution->display(($c % 2) ? "color0" : "color1");
}
echo "</table>\n\n";
echo html_frame_end(" ");
Index: appdb/include/distribution.php
diff -u -p appdb/include/distribution.php:1.5 appdb/include/distribution.php:1.6
--- appdb/include/distribution.php:1.5 27 Jan 2007 0:30: 0 -0000
+++ appdb/include/distribution.php 27 Jan 2007 0:30: 0 -0000
@@ -7,7 +7,7 @@ require_once(BASE."include/util.php");
// Test class for handling Distributions.
-class distribution{
+class distribution {
var $iDistributionId;
var $sName;
var $sDescription;
@@ -422,6 +422,76 @@ class distribution{
}
echo "</select>\n";
}
+
+ function ObjectOutputHeader($sClass = "")
+ {
+ $aCells = array(
+ "Distribution name",
+ "Distribution url",
+ array("Linked Tests", "align=\"right\""));
+
+ if(distribution::canEdit())
+ $aCells[3] = array("Action", "align=\"center\"");
+
+ echo html_tr($aCells, $sClass);
+ }
+
+ function ObjectGetEntries($bQueued)
+ {
+ if($bQueued)
+ {
+ if(distribution::canEdit())
+ {
+ /* Only users with edit privileges are allowed to view queued
+ items, so return NULL in that case */
+ $sQuery = "SELECT distributionId FROM distributions
+ WHERE queued = '?' ORDER BY name";
+ return query_parameters($sQuery, $bQueued ? "true" : "false");
+ } else
+ return NULL;
+ } else
+ {
+ $sQuery = "SELECT distributionId FROM distributions
+ WHERE queued = '?' ORDER BY name";
+ return query_parameters($sQuery, "false");
+ }
+ }
+
+ function ObjectGetInstanceFromRow($oRow)
+ {
+ return new distribution($oRow->distributionId);
+ }
+
+ function display($sClass = "")
+ {
+ $aCells = array(
+ "<a href=\"".BASE."distributionView.php?iDistributionId=".
+ $this->iDistributionId."\">$this->sName.</a>",
+ "<a href=\"$this->sUrl\">$this->sUrl</a>",
+ array(sizeof($this->aTestingIds), "align=\"right\""));
+
+ if($this->canEdit())
+ {
+ $aCells[3] = array(
+ "[<a href='".BASE."admin/editDistribution.php?iDistributionId=".
+ $this->iDistributionId."'>edit</a>]".
+ (!sizeof($this->aTestingIds)) ?
+ " [<a href='".$_SERVER['PHP_SELF']."?sSub=delete&".
+ "iDistributionId=$this->iDistributionId'>delete</a>]" : "",
+ "align=\"center\"");
+ }
+
+ echo html_tr($aCells, $sClass);
+ }
+
+ // Whether the user has permission to edit distributions
+ function canEdit()
+ {
+ if($_SESSION['current']->hasPriv("admin"))
+ return TRUE;
+
+ return FALSE;
+ }
}
?>
More information about the wine-cvs
mailing list