From d6fc4f494bf9ceb326fc37679f16224b91a0fc26 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Thu, 3 Mar 2011 16:48:20 +0000 Subject: improved the vendor selection --- .../Application/Controllers/GenericController.php | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'h-source/Application/Controllers/GenericController.php') diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php index f58fa24..0bc3705 100644 --- a/h-source/Application/Controllers/GenericController.php +++ b/h-source/Application/Controllers/GenericController.php @@ -79,13 +79,14 @@ class GenericController extends BaseController { if ($this->checkDist()) { - if ($this->checkVendorId()) + $pci_id = $this->request->post('pci_id','','sanitizeAll'); + $interface = $this->request->post('interface','not-defined','sanitizeAll'); + + if ($this->checkVendorId($interface)) { - $pci_id = $this->request->post('pci_id','','sanitizeAll'); - if (strcmp($this->m['HardwareModel']->type,'notebook') !== 0) { - $this->m['HardwareModel']->values['vendor'] = sanitizeAll(Vendors::getName($pci_id)); + $this->m['HardwareModel']->values['vendor'] = sanitizeAll(Vendors::getName($pci_id,$interface)); $this->m['HardwareModel']->databaseConditions['insert']['+checkUnique'] = 'pci_id|VendorID:ProductID is already present in the database. This means that the device you are trying to insert is already in the database'; } @@ -222,13 +223,14 @@ class GenericController extends BaseController { if ($this->checkDist()) { - if ($this->checkVendorId()) + $pci_id = $this->request->post('pci_id','','sanitizeAll'); + $interface = $this->request->post('interface','not-defined','sanitizeAll'); + + if ($this->checkVendorId($interface)) { - $pci_id = $this->request->post('pci_id','','sanitizeAll'); - if (strcmp($this->m['HardwareModel']->type,'notebook') !== 0) { - $this->m['HardwareModel']->values['vendor'] = sanitizeAll(Vendors::getName($pci_id)); + $this->m['HardwareModel']->values['vendor'] = sanitizeAll(Vendors::getName($pci_id,$interface)); $this->m['HardwareModel']->databaseConditions['update']['+checkUniqueCompl'] = 'pci_id|VendorID:ProductID is already present in the database. This means that the device you are trying to insert is already in the database'; } @@ -273,7 +275,7 @@ class GenericController extends BaseController } } - protected function checkVendorId() + protected function checkVendorId($interface) { if (strcmp($this->m['HardwareModel']->type,'notebook') === 0) return true; @@ -283,14 +285,14 @@ class GenericController extends BaseController { if (preg_match('/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/',$_POST['pci_id'])) { - if (Vendors::check($_POST['pci_id'])) + if (Vendors::check($_POST['pci_id'],$interface)) { return true; } else { $this->m['HardwareModel']->result = false; - $this->m['HardwareModel']->notice = "
Vendorid code non present in the list, please open an issue here in order to ask the insertion of your vendor
\n"; + $this->m['HardwareModel']->notice = "
Vendorid code non present in the list, please open an issue here in order to ask the insertion of your vendor. NB: if it is a USB device, please choose the right interface. If it is not a USB device, and you are not sure about the right interface, choose not-defined, and it should work fine
\n"; return false; } } -- cgit v1.2.3