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 --- .../Controllers/BluetoothController.php | 6 +++--- .../Application/Controllers/GenericController.php | 24 ++++++++++++---------- h-source/Application/Include/hardware.php | 2 +- h-source/Application/Include/languages.php | 1 + h-source/Application/Include/vendors.php | 19 +++++++++++------ h-source/Application/Views/Bluetooth/form.php | 2 +- h-source/Application/Views/Help/index.php | 4 ++-- h-source/Application/Views/Help/index_es.php | 2 +- h-source/Application/Views/Help/index_fr.php | 2 +- h-source/Application/Views/Help/index_it.php | 2 +- h-source/Application/Views/Printers/form.php | 2 +- h-source/Application/Views/Scanners/form.php | 2 +- h-source/Application/Views/Soundcards/form.php | 2 +- h-source/Application/Views/Threegcards/form.php | 2 +- h-source/Application/Views/Videocards/form.php | 2 +- h-source/Application/Views/Webcams/form.php | 2 +- h-source/Application/Views/Wifi/form.php | 2 +- 17 files changed, 44 insertions(+), 34 deletions(-) (limited to 'h-source/Application') diff --git a/h-source/Application/Controllers/BluetoothController.php b/h-source/Application/Controllers/BluetoothController.php index 4730081..58269bf 100644 --- a/h-source/Application/Controllers/BluetoothController.php +++ b/h-source/Application/Controllers/BluetoothController.php @@ -45,6 +45,7 @@ class BluetoothController extends GenericController $this->m['HardwareModel']->strongConditions['update'] = array( "checkNotEmpty" => "model|you have to fill the model name entry", "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)\@\[\]\/]+$/" => "model|characters not allowed in the model name entry", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", "checkLength|99" => "model", "+checkLength|299" => "distribution", "++checkIsStrings|".Wifi::$commYear => "comm_year", @@ -55,6 +56,7 @@ class BluetoothController extends GenericController $this->m['HardwareModel']->strongConditions['insert'] = array( "checkNotEmpty" => "model|you have to fill the model name entry", "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)\@\[\]\/]+$/" => "model|characters not allowed in the model name entry", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", "checkLength|99" => "model", "+checkLength|299" => "distribution", "++checkIsStrings|".Wifi::$commYear => "comm_year", @@ -67,7 +69,6 @@ class BluetoothController extends GenericController "checkLength|20000" => "description", "+checkLength|49" => "kernel", "++checkLength|49" => "driver", - "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", ); @@ -76,7 +77,6 @@ class BluetoothController extends GenericController "checkLength|20000" => "description", "+checkLength|49" => "kernel", "++checkLength|49" => "driver", - "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", ); @@ -94,7 +94,7 @@ class BluetoothController extends GenericController $this->setArgKeys($argKeys); - $data['title'] = 'Soundcard'; + $data['title'] = 'Bluetooth'; $this->append($data); } 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; } } diff --git a/h-source/Application/Include/hardware.php b/h-source/Application/Include/hardware.php index cae6b74..cd5fcab 100644 --- a/h-source/Application/Include/hardware.php +++ b/h-source/Application/Include/hardware.php @@ -492,7 +492,7 @@ class Bluetooth extends Hardware public static $select = 'yes,no'; - public static $interface = "not-specified,USB"; + public static $interface = "not-specified,USB,PCI,PCI-E,mini-PCI,mini-PCI-E,ExpressCard,PC-Card"; public static function vendorsList() { diff --git a/h-source/Application/Include/languages.php b/h-source/Application/Include/languages.php index 8ce107c..ffcef4e 100644 --- a/h-source/Application/Include/languages.php +++ b/h-source/Application/Include/languages.php @@ -213,6 +213,7 @@ class Lang "special pages" => "pagine speciali", "Watch all the actions carried out by administrators" => "Guarda tutte le azioni compiute dagli amministratori", "No bluetooth devices found" => "Non è stato trovato alcun dispositivo bluetooth", + "learn how to find it" => "scopri come individuarlo", ), 'es' => array ( diff --git a/h-source/Application/Include/vendors.php b/h-source/Application/Include/vendors.php index 79fcefb..8dcc312 100644 --- a/h-source/Application/Include/vendors.php +++ b/h-source/Application/Include/vendors.php @@ -3,24 +3,28 @@ class Vendors { - public static function getName($id) + public static function getName($id,$interface) { - if (self::check($id)) + if (self::check($id,$interface)) { + $idArray = strcmp($interface,'USB') === 0 ? self::$usbId : self::$pciId; + $temp = explode(':',$id); $vendorId = $temp[0]; - return self::$id[$vendorId]; + return $idArray[$vendorId]; } return 'not-known'; } - public static function check($id) + public static function check($id,$interface = 'USB') { if (preg_match('/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/',$id)) { + $idArray = strcmp($interface,'USB') === 0 ? self::$usbId : self::$pciId; + $temp = explode(':',$id); $vendorId = $temp[0]; - if (array_key_exists($vendorId,self::$id)) + if (array_key_exists($vendorId,$idArray)) { return true; } @@ -28,7 +32,7 @@ class Vendors return false; } - public static $id = array( + public static $pciId = array( '0010' => 'Allied-Telesis-Inc', '001a' => 'Ascend-Communications-Inc.', '001c' => 'PEAK-System-Technik-GmbH', @@ -1802,6 +1806,9 @@ class Vendors 'feda' => 'Broadcom', 'fede' => 'Fedetec-Inc.', 'fffd' => 'XenSource-Inc.', + ); + + public static $usbId = array( '0001' => 'Frys-Electronics', '0002' => 'Ingram', '0003' => 'Club-Mac', diff --git a/h-source/Application/Views/Bluetooth/form.php b/h-source/Application/Views/Bluetooth/form.php index a03597a..f6ba115 100644 --- a/h-source/Application/Views/Bluetooth/form.php +++ b/h-source/Application/Views/Bluetooth/form.php @@ -45,7 +45,7 @@
- +
diff --git a/h-source/Application/Views/Help/index.php b/h-source/Application/Views/Help/index.php index 7929cbe..ad9f31b 100644 --- a/h-source/Application/Views/Help/index.php +++ b/h-source/Application/Views/Help/index.php @@ -304,8 +304,8 @@
 		lspci | grep "VGA"
 	
- -

How to discover the VendorID and the ProductID of your device (VendorID:ProductID code)

+ +

How to discover the VendorID and the ProductID of your device (VendorID:ProductID code)

(Thanks Michał Masłowski and Julius22) diff --git a/h-source/Application/Views/Help/index_es.php b/h-source/Application/Views/Help/index_es.php index bf19b5b..df4f09f 100644 --- a/h-source/Application/Views/Help/index_es.php +++ b/h-source/Application/Views/Help/index_es.php @@ -306,7 +306,7 @@ lspci | grep "VGA" -

Como descubrir el ID del vendedor y el ID del producto de su dispositivo (código VendorID:ProductID)

+

Como descubrir el ID del vendedor y el ID del producto de su dispositivo (código VendorID:ProductID)

(Gracias Michał Masłowski y Julius22) diff --git a/h-source/Application/Views/Help/index_fr.php b/h-source/Application/Views/Help/index_fr.php index d98d13b..4a51221 100644 --- a/h-source/Application/Views/Help/index_fr.php +++ b/h-source/Application/Views/Help/index_fr.php @@ -297,7 +297,7 @@ lspci | grep "VGA" -

Comment connaitre le VendorID ou le ProductID (VendorID:ProductID code)

+

Comment connaitre le VendorID ou le ProductID (VendorID:ProductID code)

(Merci à Michał Masłowski et Julius22) diff --git a/h-source/Application/Views/Help/index_it.php b/h-source/Application/Views/Help/index_it.php index d4f6f7d..7d8fbe4 100644 --- a/h-source/Application/Views/Help/index_it.php +++ b/h-source/Application/Views/Help/index_it.php @@ -318,7 +318,7 @@ lspci | grep "VGA" -

Come scoprire il VendorID e il ProductID del tuo dispositivo (VendorID:ProductID code)

+

Come scoprire il VendorID e il ProductID del tuo dispositivo (VendorID:ProductID code)

(Grazie Michał Masłowski e Julius22) diff --git a/h-source/Application/Views/Printers/form.php b/h-source/Application/Views/Printers/form.php index 2ccfb38..dd7be91 100644 --- a/h-source/Application/Views/Printers/form.php +++ b/h-source/Application/Views/Printers/form.php @@ -50,7 +50,7 @@
- +
diff --git a/h-source/Application/Views/Scanners/form.php b/h-source/Application/Views/Scanners/form.php index c9085d9..d666514 100644 --- a/h-source/Application/Views/Scanners/form.php +++ b/h-source/Application/Views/Scanners/form.php @@ -45,7 +45,7 @@
- +
diff --git a/h-source/Application/Views/Soundcards/form.php b/h-source/Application/Views/Soundcards/form.php index 4e754dd..965ecfc 100644 --- a/h-source/Application/Views/Soundcards/form.php +++ b/h-source/Application/Views/Soundcards/form.php @@ -45,7 +45,7 @@
- +
diff --git a/h-source/Application/Views/Threegcards/form.php b/h-source/Application/Views/Threegcards/form.php index 55a4402..075333e 100644 --- a/h-source/Application/Views/Threegcards/form.php +++ b/h-source/Application/Views/Threegcards/form.php @@ -45,7 +45,7 @@
- +
diff --git a/h-source/Application/Views/Videocards/form.php b/h-source/Application/Views/Videocards/form.php index bdbeaa9..6faab56 100644 --- a/h-source/Application/Views/Videocards/form.php +++ b/h-source/Application/Views/Videocards/form.php @@ -45,7 +45,7 @@
- +
diff --git a/h-source/Application/Views/Webcams/form.php b/h-source/Application/Views/Webcams/form.php index 24fe218..e1b819c 100644 --- a/h-source/Application/Views/Webcams/form.php +++ b/h-source/Application/Views/Webcams/form.php @@ -45,7 +45,7 @@
- +
diff --git a/h-source/Application/Views/Wifi/form.php b/h-source/Application/Views/Wifi/form.php index fc26f70..016f90a 100644 --- a/h-source/Application/Views/Wifi/form.php +++ b/h-source/Application/Views/Wifi/form.php @@ -45,7 +45,7 @@
- +
-- cgit v1.2.3