diff --git a/admin/addVendor.php b/admin/addVendor.php
index 5ff43a1..51cfb64 100644
--- a/admin/addVendor.php
+++ b/admin/addVendor.php
@@ -1,41 +1,44 @@
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
{
- global $admin_mode;
- $admin_mode = 1;
-}
-
apidb_header("Add Vendor");
-
-$t = new TableVE("create");
-
-if($_POST)
-{
- $t->update($_POST);
+echo "
";
}
-else
-{
- $table = "vendor";
- $query = "INSERT INTO $table VALUES(0, 'NONAME', null)";
-
- query_appdb("DELETE FROM $table WHERE vendorName = 'NONAME'");
-
- if(debugging())
- echo "$query
\n";
-
- $t->create($query, $table, "vendorId");
-}
-
apidb_footer();
-
?>
diff --git a/admin/adminVendors.php b/admin/adminVendors.php
index 80dbd35..d30116d 100644
--- a/admin/adminVendors.php
+++ b/admin/adminVendors.php
@@ -8,84 +8,55 @@
*/
include("path.php");
require(BASE."include/incl.php");
+require_once(BASE."include/vendor.php");
if(!$_SESSION['current']->hasPriv("admin"))
{
errorpage("Insufficient privileges.");
exit;
}
-
-apidb_header("Admin Vendors");
-echo '";
apidb_footer();
?>
diff --git a/include/vendor.php b/include/vendor.php
index 08bcfa0..1610b2d 100644
--- a/include/vendor.php
+++ b/include/vendor.php
@@ -81,14 +81,17 @@ class Vendor {
*/
function update($sName=null, $sWebpage=null)
{
- if ($sName)
+ if(!$this->iVendorId)
+ return $this->create($sName, $sWebpage);
+
+ if($sName)
{
if (!query_appdb("UPDATE vendor SET vendorName = '".$sName."' WHERE vendorId = ".$this->iVendorId))
return false;
$this->sName = $sName;
}
- if ($sWebpage)
+ if($sWebpage)
{
if (!query_appdb("UPDATE vendor SET vendorURL = '".$sWebpage."' WHERE vendorId = ".$this->iVendorId))
return false;
@@ -104,9 +107,17 @@ class Vendor {
*/
function delete($bSilent=false)
{
- $sQuery = "DELETE FROM vendor
- WHERE vendorId = ".$this->iVendorId."
- LIMIT 1";
+ if(sizeof($this->aApplicationsIds)>0)
+ {
+ addmsg("The vendor has not been deleted because there are still applications linked to it.", "red");
+ } else
+ {
+ $sQuery = "DELETE FROM vendor
+ WHERE vendorId = ".$this->iVendorId."
+ LIMIT 1";
+ query_appdb($sQuery);
+ addmsg("The vendor has been deleted.", "green");
+ }
}
}
?>