Let users browse vendors and remove some duplicate code
This commit is contained in:
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("path.php");
|
|
||||||
require(BASE."include/incl.php");
|
|
||||||
require(BASE."include/vendor.php");
|
|
||||||
|
|
||||||
if(!$_SESSION['current']->hasPriv("admin"))
|
|
||||||
{
|
|
||||||
errorpage();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$oVendor = new Vendor($_REQUEST['vendorId']);
|
|
||||||
if($_REQUEST['submit'])
|
|
||||||
{
|
|
||||||
$oVendor->update($_REQUEST['name'],$_REQUEST['webpage']);
|
|
||||||
redirect(apidb_fullurl("admin/adminVendors.php"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
apidb_header("Add 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();
|
|
||||||
?>
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*************************************************************/
|
|
||||||
/* code to view and maintain the list of application vendors */
|
|
||||||
/*************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* application environment
|
|
||||||
*/
|
|
||||||
include("path.php");
|
|
||||||
require(BASE."include/incl.php");
|
|
||||||
require_once(BASE."include/vendor.php");
|
|
||||||
|
|
||||||
if(!$_SESSION['current']->hasPriv("admin"))
|
|
||||||
{
|
|
||||||
errorpage("Insufficient privileges.");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
if ($_REQUEST['sub'])
|
|
||||||
{
|
|
||||||
if($_REQUEST['sub'] == 'delete')
|
|
||||||
{
|
|
||||||
$oVendor = new Vendor($_REQUEST['vendorId']);
|
|
||||||
$oVendor->delete();
|
|
||||||
redirect(apidb_fullurl("admin/adminVendors.php"));
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
apidb_header("Admin Vendors");
|
|
||||||
|
|
||||||
//get available vendors
|
|
||||||
$sQuery = "SELECT vendorId FROM vendor ORDER BY vendorName, vendorId;";
|
|
||||||
$hResult = query_appdb($sQuery);
|
|
||||||
|
|
||||||
// show vendorlist
|
|
||||||
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>Vendor name</td>\n";
|
|
||||||
echo " <td>Vendor url</td>\n";
|
|
||||||
echo " <td>Linked apps</td>\n";
|
|
||||||
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'; }
|
|
||||||
$oVendor = new Vendor($ob->vendorId);
|
|
||||||
echo "<tr class=\"$bgcolor\">\n";
|
|
||||||
echo " <td><a href=\"".BASE."vendorview.php?vendorId=".$oVendor->iVendorId."\">".$oVendor->sName."</a></td>\n";
|
|
||||||
echo " <td><a href=\"".$oVendor->sWebpage."\">".$oVendor->sWebpage."</a></td>\n";
|
|
||||||
echo " <td>".sizeof($oVendor->aApplicationsIds)."</td>\n";
|
|
||||||
echo " <td align=\"center\">[<a href='addVendor.php?vendorId=".$oVendor->iVendorId."'>edit</a>] [<a href='adminVendors.php?sub=delete&vendorId=".$oVendor->iVendorId."'>delete</a>]";
|
|
||||||
echo " </td>\n";
|
|
||||||
echo "</tr>\n\n";
|
|
||||||
$c++;
|
|
||||||
}
|
|
||||||
echo "</table>\n\n";
|
|
||||||
echo html_frame_end(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
apidb_footer();
|
|
||||||
?>
|
|
||||||
@@ -1,44 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
include("path.php");
|
include("path.php");
|
||||||
require(BASE."include/incl.php");
|
require_once(BASE."include/incl.php");
|
||||||
require(BASE."include/vendor.php");
|
require_once(BASE."include/vendor.php");
|
||||||
|
|
||||||
if(!$_SESSION['current']->hasPriv("admin"))
|
if(!$_SESSION['current']->hasPriv("admin"))
|
||||||
{
|
{
|
||||||
errorpage();
|
errorpage();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$oVendor = new Vendor($_REQUEST['vendorId']);
|
|
||||||
if($_REQUEST['submit'])
|
$oVendor = new Vendor($_REQUEST['iVendorId']);
|
||||||
|
if($_REQUEST['Submit'])
|
||||||
{
|
{
|
||||||
$oVendor->update($_REQUEST['name'],$_REQUEST['webpage']);
|
$oVendor->update($_REQUEST['sName'],$_REQUEST['sWebpage']);
|
||||||
redirect(apidb_fullurl("admin/adminVendors.php"));
|
redirect(apidb_fullurl("vendorview.php"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
apidb_header("Edit Vendor");
|
if($oVendor->iVendorId)
|
||||||
echo "<form method=\"post\" action=\"addVendor.php\">
|
apidb_header("Edit Vendor");
|
||||||
<input type=\"hidden\" name=\"vendorId\" value=\"".$oVendor->iVendorId."\" />
|
else
|
||||||
<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
|
apidb_header("Add Vendor");
|
||||||
<tr>
|
|
||||||
<td width=\"15%\" class=\"box-label\"><b>Vendor name</b></td>
|
// Show the form
|
||||||
<td class=\"box-body\">
|
echo '<form name="qform" action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">',"\n";
|
||||||
<input type=\"text\" size=\"50\" name=\"name\" value=\"".$oVendor->sName."\" />
|
|
||||||
</td>
|
$oVendor->OutputEditor();
|
||||||
</tr>
|
|
||||||
<tr>
|
echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
|
||||||
<td width=\"15%\" class=\"box-label\"><b>Vendor URL</b></td>
|
echo '<input name="Submit" type="submit" value="Submit" class="button" > ',"\n";
|
||||||
<td class=\"box-body\">
|
echo '</td></tr>',"\n";
|
||||||
<input type=\"text\" size=\"50\" name=\"webpage\" value=\"".$oVendor->sWebpage."\" />
|
|
||||||
</td>
|
echo "</form>";
|
||||||
</tr>
|
echo html_frame_end(" ");
|
||||||
<tr>
|
|
||||||
<td colspan=\"2\" class=\"box-body\">
|
|
||||||
<input type=\"submit\" name=\"submit\" value=\"Submit\" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>";
|
|
||||||
apidb_footer();
|
apidb_footer();
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
/* SideBar */
|
/* SideBar */
|
||||||
/***********/
|
/***********/
|
||||||
require_once(BASE."include/distributions.php");
|
require_once(BASE."include/distributions.php");
|
||||||
|
require_once(BASE."include/vendor.php");
|
||||||
|
|
||||||
function global_sidebar_menu() {
|
function global_sidebar_menu() {
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ function global_sidebar_menu() {
|
|||||||
$g->add("Help & Documentation", BASE."help/");
|
$g->add("Help & Documentation", BASE."help/");
|
||||||
$g->add("AppDB Stats", BASE."appdbStats.php");
|
$g->add("AppDB Stats", BASE."appdbStats.php");
|
||||||
$g->add("View Distributions (".getNumberOfDistributions().")", BASE."distributionView.php");
|
$g->add("View Distributions (".getNumberOfDistributions().")", BASE."distributionView.php");
|
||||||
|
$g->add("View Vendors (".getNumberOfvendors().")", BASE."vendorview.php");
|
||||||
|
|
||||||
$g->add("Email your suggestions for improving the AppDB", "mailto:appdb@winehq.org");
|
$g->add("Email your suggestions for improving the AppDB", "mailto:appdb@winehq.org");
|
||||||
$g->done();
|
$g->done();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ function global_admin_menu() {
|
|||||||
$g = new htmlmenu("Global Admin");
|
$g = new htmlmenu("Global Admin");
|
||||||
|
|
||||||
$g->add("Add Category", BASE."admin/addCategory.php");
|
$g->add("Add Category", BASE."admin/addCategory.php");
|
||||||
$g->add("Add Vendor", BASE."admin/addVendor.php");
|
$g->add("Add Vendor", BASE."admin/editVendor.php");
|
||||||
|
|
||||||
$g->addmisc(" ");
|
$g->addmisc(" ");
|
||||||
$g->add("View App Queue (".$_SESSION['current']->getQueuedAppCount()."/".$_SESSION['current']->getQueuedVersionCount().")", BASE."admin/adminAppQueue.php");
|
$g->add("View App Queue (".$_SESSION['current']->getQueuedAppCount()."/".$_SESSION['current']->getQueuedVersionCount().")", BASE."admin/adminAppQueue.php");
|
||||||
|
|||||||
@@ -115,5 +115,36 @@ class Vendor {
|
|||||||
addmsg("The vendor has been deleted.", "green");
|
addmsg("The vendor has been deleted.", "green");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function OutputEditor()
|
||||||
|
{
|
||||||
|
echo html_frame_start("Vendor Form", "90%", "", 0);
|
||||||
|
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
||||||
|
|
||||||
|
// Name
|
||||||
|
echo '<tr valign=top><td class="color1" width="20%"><b>Vendor Name</b></td>',"\n";
|
||||||
|
echo '<td class="color0"><input type=text name="sName" value="'.$this->sName.'" size="50"></td></tr>',"\n";
|
||||||
|
// Url
|
||||||
|
echo '<tr valign=top><td class="color1"><b>Vendor Url</b></td>',"\n";
|
||||||
|
echo '<td class="color0"><input type=text name="sWebpage" value="'.$this->sWebpage.'" size="50"></td></tr>',"\n";
|
||||||
|
|
||||||
|
echo '<input type="hidden" name="iVendorId" value="'.$this->iVendorId.'">',"\n";
|
||||||
|
|
||||||
|
echo "</table>\n";
|
||||||
|
echo html_frame_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the total number of Vendors in the database */
|
||||||
|
function getNumberOfVendors()
|
||||||
|
{
|
||||||
|
$hResult = query_appdb("SELECT count(*) as num_vendors FROM vendor");
|
||||||
|
if($hResult)
|
||||||
|
{
|
||||||
|
$row = mysql_fetch_object($hResult);
|
||||||
|
return $row->num_vendors;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
146
vendorview.php
146
vendorview.php
@@ -7,69 +7,105 @@
|
|||||||
* application environment
|
* application environment
|
||||||
*/
|
*/
|
||||||
include("path.php");
|
include("path.php");
|
||||||
require(BASE."include/incl.php");
|
require_once(BASE."include/incl.php");
|
||||||
require(BASE."include/application.php");
|
require_once(BASE."include/application.php");
|
||||||
|
require_once(BASE."include/vendor.php");
|
||||||
|
|
||||||
$vendorId = $_REQUEST['vendorId'];
|
$oVendor = new Vendor($_REQUEST['vendorId']);
|
||||||
|
|
||||||
//exit with error if no vendor
|
if ($_REQUEST['sub'])
|
||||||
if(!$vendorId) {
|
|
||||||
errorpage("No vendor ID specified!");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
//get vendor, die with error if no match
|
|
||||||
$result = query_appdb("SELECT * FROM vendor WHERE vendorId = $vendorId");
|
|
||||||
if(!$result || mysql_num_rows($result) != 1) {
|
|
||||||
errorpage("Invalid vendor ID!");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
//show admin sidebar if user is admin
|
|
||||||
if($_SESSION['current']->hasPriv("admin")) {
|
|
||||||
apidb_sidebar_add("admin_menu");
|
|
||||||
}
|
|
||||||
|
|
||||||
//get data
|
|
||||||
$vendor = mysql_fetch_object($result);
|
|
||||||
|
|
||||||
//display page
|
|
||||||
apidb_header("View Vendor");
|
|
||||||
echo html_frame_start("Vendor Information",500);
|
|
||||||
|
|
||||||
echo "Vendor Name: $vendor->vendorName <br />\n";
|
|
||||||
|
|
||||||
if ($vendor->vendorURL) {
|
|
||||||
echo "Vendor URL: <a href='$vendor->vendorURL'>$vendor->vendorURL</a> <br />\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = query_appdb("SELECT * FROM appFamily WHERE vendorId = $vendorId ORDER BY appName");
|
|
||||||
if($result)
|
|
||||||
{
|
{
|
||||||
echo "<br />Applications by $vendor->vendorName<br /><ol>\n";
|
if(!$_SESSION['current']->hasPriv("admin"))
|
||||||
while($app = mysql_fetch_object($result))
|
{
|
||||||
{
|
errorpage("Insufficient privileges.");
|
||||||
echo "<li> <a href='appview.php?appId=$app->appId'> $app->appName </a> </li>\n";
|
exit;
|
||||||
}
|
}
|
||||||
echo "</ol>\n";
|
|
||||||
|
if($_REQUEST['sub'] == 'delete')
|
||||||
|
{
|
||||||
|
$oVendor->delete();
|
||||||
|
redirect($_SERVER['PHP_SELF']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo html_frame_end();
|
|
||||||
echo html_back_link(1);
|
|
||||||
apidb_footer();
|
|
||||||
|
|
||||||
|
if($oVendor->iVendorId)
|
||||||
|
|
||||||
// SUBS //
|
|
||||||
|
|
||||||
//admin menu for sidebar
|
|
||||||
function admin_menu()
|
|
||||||
{
|
{
|
||||||
global $vendorId;
|
//display page
|
||||||
|
apidb_header("View Vendor");
|
||||||
|
echo html_frame_start("Vendor Information",500);
|
||||||
|
|
||||||
|
echo 'Vendor Name: '.$oVendor->sName.'<br />',"\n";
|
||||||
|
|
||||||
|
if ($oVendor->sWebpage)
|
||||||
|
echo 'Vendor URL: <a href="'.$oVendor->sWebpage.'">'.$oVendor->vendorURL.'</a> <br />',"\n";
|
||||||
|
|
||||||
|
|
||||||
|
if($oVendor->aApplicationsIds)
|
||||||
|
{
|
||||||
|
echo '<br />Applications by '.$oVendor->sName.'<br /><ol>',"\n";
|
||||||
|
foreach($oVendor->aApplicationsIds as $iAppId)
|
||||||
|
{
|
||||||
|
$oApp = new application($iAppId);
|
||||||
|
echo '<li> <a href="appview.php?appId='.$oApp->iAppId.'">'.$oApp->sName.'</a> </li>',"\n";
|
||||||
|
}
|
||||||
|
echo '.</ol>',"\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo html_frame_end();
|
||||||
|
echo html_back_link(1);
|
||||||
|
apidb_footer();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
apidb_header("View Vendors");
|
||||||
|
|
||||||
|
//get available vendors
|
||||||
|
$sQuery = "SELECT vendorId FROM vendor ORDER BY vendorName, vendorId;";
|
||||||
|
$hResult = query_appdb($sQuery);
|
||||||
|
|
||||||
|
// show vendorlist
|
||||||
|
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
|
||||||
|
|
||||||
|
echo '<tr class="color4">',"\n";
|
||||||
|
echo '<td>Vendor name</td>',"\n";
|
||||||
|
echo '<td>Vendor\'s Web Page</td>',"\n";
|
||||||
|
echo '<td align="right">linked Apps</td>',"\n";
|
||||||
|
if ($_SESSION['current']->hasPriv("admin"))
|
||||||
|
{
|
||||||
|
echo '<td align="center">Action</td>',"\n";
|
||||||
|
}
|
||||||
|
echo '</tr>',"\n";
|
||||||
|
|
||||||
|
$c = 1;
|
||||||
|
while($ob = mysql_fetch_object($hResult))
|
||||||
|
{
|
||||||
|
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
|
||||||
|
$oVendor = new Vendor($ob->vendorId);
|
||||||
|
echo '<tr class="'.$bgcolor.'">',"\n";
|
||||||
|
echo '<td><a href="'.BASE.'vendorview.php?vendorId='.$oVendor->iVendorId.'">'.$oVendor->sName.'</a></td>',"\n";
|
||||||
|
echo '<td><a href="'.$oVendor->sWebpage.'">'.substr($oVendor->sWebpage,0,30).'</a></td>',"\n";
|
||||||
|
echo '<td align="right">'.sizeof($oVendor->aApplicationsIds).'</td>',"\n";
|
||||||
|
if ($_SESSION['current']->hasPriv("admin"))
|
||||||
|
{
|
||||||
|
echo '<td align="center">',"\n";
|
||||||
|
echo '[<a href="'.BASE.'admin/editVendor.php?iVendorId='.$oVendor->iVendorId.'">edit</a>]',"\n";
|
||||||
|
if(!sizeof($oVendor->aApplicationsIds))
|
||||||
|
echo ' [<a href="'.$_SERVER['PHP_SELF'].'?sub=delete&vendorId='.$oVendor->iVendorId.'">delete</a>]',"\n";
|
||||||
|
echo '</td>',"\n";
|
||||||
|
}
|
||||||
|
echo '</tr>',"\n";
|
||||||
|
$c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<tr><td>',"\n";
|
||||||
|
echo html_back_link(1);
|
||||||
|
echo '</td></tr></table>',"\n";
|
||||||
|
apidb_footer();
|
||||||
|
|
||||||
$m = new htmlmenu("Admin");
|
|
||||||
$m->add("Edit this vendor", "admin/editVendor.php?vendorId=$vendorId");
|
|
||||||
$m->done();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user