diff --git a/admin/addVendor.php b/admin/addVendor.php
deleted file mode 100644
index 51cfb64..0000000
--- a/admin/addVendor.php
+++ /dev/null
@@ -1,44 +0,0 @@
-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 "
";
-}
-apidb_footer();
-?>
diff --git a/admin/adminVendors.php b/admin/adminVendors.php
deleted file mode 100644
index 1010e33..0000000
--- a/admin/adminVendors.php
+++ /dev/null
@@ -1,64 +0,0 @@
-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 "\n\n";
-
- echo "\n";
- echo " | Vendor name | \n";
- echo " Vendor url | \n";
- echo " Linked apps | \n";
- echo " Action | \n";
- echo "
\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 "\n";
- echo " | iVendorId."\">".$oVendor->sName." | \n";
- echo " sWebpage."\">".$oVendor->sWebpage." | \n";
- echo " ".sizeof($oVendor->aApplicationsIds)." | \n";
- echo " [edit] [delete]";
- echo " | \n";
- echo "
\n\n";
- $c++;
- }
- echo "
\n\n";
- echo html_frame_end(" ");
-}
-
-apidb_footer();
-?>
diff --git a/admin/editVendor.php b/admin/editVendor.php
index c135e1c..716272e 100644
--- a/admin/editVendor.php
+++ b/admin/editVendor.php
@@ -1,44 +1,39 @@
hasPriv("admin"))
{
errorpage();
exit;
}
-$oVendor = new Vendor($_REQUEST['vendorId']);
-if($_REQUEST['submit'])
+
+$oVendor = new Vendor($_REQUEST['iVendorId']);
+if($_REQUEST['Submit'])
{
- $oVendor->update($_REQUEST['name'],$_REQUEST['webpage']);
- redirect(apidb_fullurl("admin/adminVendors.php"));
+ $oVendor->update($_REQUEST['sName'],$_REQUEST['sWebpage']);
+ redirect(apidb_fullurl("vendorview.php"));
}
else
{
- apidb_header("Edit Vendor");
- echo "";
+ if($oVendor->iVendorId)
+ apidb_header("Edit Vendor");
+ else
+ apidb_header("Add Vendor");
+
+ // Show the form
+ echo '";
+ echo html_frame_end(" ");
apidb_footer();
+
}
?>
diff --git a/include/sidebar.php b/include/sidebar.php
index 6855813..35dd9e3 100644
--- a/include/sidebar.php
+++ b/include/sidebar.php
@@ -3,6 +3,7 @@
/* SideBar */
/***********/
require_once(BASE."include/distributions.php");
+require_once(BASE."include/vendor.php");
function global_sidebar_menu() {
@@ -19,6 +20,7 @@ function global_sidebar_menu() {
$g->add("Help & Documentation", BASE."help/");
$g->add("AppDB Stats", BASE."appdbStats.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->done();
diff --git a/include/sidebar_admin.php b/include/sidebar_admin.php
index 7758eb4..7f3e9b3 100644
--- a/include/sidebar_admin.php
+++ b/include/sidebar_admin.php
@@ -10,7 +10,7 @@ function global_admin_menu() {
$g = new htmlmenu("Global Admin");
$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->add("View App Queue (".$_SESSION['current']->getQueuedAppCount()."/".$_SESSION['current']->getQueuedVersionCount().")", BASE."admin/adminAppQueue.php");
diff --git a/include/vendor.php b/include/vendor.php
index 6bc03c6..420b9c8 100644
--- a/include/vendor.php
+++ b/include/vendor.php
@@ -115,5 +115,36 @@ class Vendor {
addmsg("The vendor has been deleted.", "green");
}
}
+
+ function OutputEditor()
+ {
+ echo html_frame_start("Vendor Form", "90%", "", 0);
+ echo "\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;
}
?>
diff --git a/vendorview.php b/vendorview.php
index 20e3b7f..087f6ee 100644
--- a/vendorview.php
+++ b/vendorview.php
@@ -7,69 +7,105 @@
* application environment
*/
include("path.php");
-require(BASE."include/incl.php");
-require(BASE."include/application.php");
+require_once(BASE."include/incl.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(!$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
\n";
-
-if ($vendor->vendorURL) {
- echo "Vendor URL: $vendor->vendorURL
\n";
-}
-
-$result = query_appdb("SELECT * FROM appFamily WHERE vendorId = $vendorId ORDER BY appName");
-if($result)
+if ($_REQUEST['sub'])
{
- echo "
Applications by $vendor->vendorName
\n";
- while($app = mysql_fetch_object($result))
- {
- echo "- $app->appName
\n";
- }
- echo "
\n";
-}
+ if(!$_SESSION['current']->hasPriv("admin"))
+ {
+ errorpage("Insufficient privileges.");
+ exit;
+ }
-echo html_frame_end();
-echo html_back_link(1);
-apidb_footer();
+ if($_REQUEST['sub'] == 'delete')
+ {
+ $oVendor->delete();
+ redirect($_SERVER['PHP_SELF']);
+ }
+
+}
-
-// SUBS //
-
-//admin menu for sidebar
-function admin_menu()
+if($oVendor->iVendorId)
{
- global $vendorId;
+ //display page
+ apidb_header("View Vendor");
+ echo html_frame_start("Vendor Information",500);
+
+ echo 'Vendor Name: '.$oVendor->sName.'
',"\n";
+
+ if ($oVendor->sWebpage)
+ echo 'Vendor URL: '.$oVendor->vendorURL.'
',"\n";
+
+
+ if($oVendor->aApplicationsIds)
+ {
+ echo '
Applications by '.$oVendor->sName.'
',"\n";
+ foreach($oVendor->aApplicationsIds as $iAppId)
+ {
+ $oApp = new application($iAppId);
+ echo '- '.$oApp->sName.'
',"\n";
+ }
+ echo '.
',"\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 "\n\n";
+
+ echo '',"\n";
+ echo '| Vendor name | ',"\n";
+ echo 'Vendor\'s Web Page | ',"\n";
+ echo 'linked Apps | ',"\n";
+ if ($_SESSION['current']->hasPriv("admin"))
+ {
+ echo 'Action | ',"\n";
+ }
+ echo '
',"\n";
+
+ $c = 1;
+ while($ob = mysql_fetch_object($hResult))
+ {
+ if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
+ $oVendor = new Vendor($ob->vendorId);
+ echo '',"\n";
+ echo '| '.$oVendor->sName.' | ',"\n";
+ echo ''.substr($oVendor->sWebpage,0,30).' | ',"\n";
+ echo ''.sizeof($oVendor->aApplicationsIds).' | ',"\n";
+ if ($_SESSION['current']->hasPriv("admin"))
+ {
+ echo '',"\n";
+ echo '[edit]',"\n";
+ if(!sizeof($oVendor->aApplicationsIds))
+ echo ' [delete]',"\n";
+ echo ' | ',"\n";
+ }
+ echo '
',"\n";
+ $c++;
+ }
+
+ echo '| ',"\n";
+ echo html_back_link(1);
+ echo ' |
',"\n";
+ apidb_footer();
- $m = new htmlmenu("Admin");
- $m->add("Edit this vendor", "admin/editVendor.php?vendorId=$vendorId");
- $m->done();
}
?>