From 377b513193b4d0c155eafa2f2cf13592190be17f Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Wed, 14 Sep 2011 22:21:12 +0000 Subject: improved the way validate conditions are set --- .../Controllers/AcquisitioncardsController.php | 51 ++++----------------- .../Controllers/BluetoothController.php | 51 ++++----------------- .../Application/Controllers/DownloadController.php | 2 +- .../Controllers/EthernetcardsController.php | 51 ++++----------------- .../Controllers/FingerprintreadersController.php | 53 ++++------------------ .../Application/Controllers/GenericController.php | 2 +- .../Application/Controllers/ScannersController.php | 43 +----------------- .../Controllers/SoundcardsController.php | 41 +---------------- .../Controllers/ThreegcardsController.php | 41 +---------------- .../Controllers/VideocardsController.php | 41 +---------------- .../Application/Controllers/WebcamsController.php | 41 +---------------- .../Application/Controllers/WifiController.php | 41 +---------------- h-source/Application/Models/HardwareModel.php | 32 ++++++++++++- 13 files changed, 72 insertions(+), 418 deletions(-) diff --git a/h-source/Application/Controllers/AcquisitioncardsController.php b/h-source/Application/Controllers/AcquisitioncardsController.php index 0a4090a..4e320d9 100644 --- a/h-source/Application/Controllers/AcquisitioncardsController.php +++ b/h-source/Application/Controllers/AcquisitioncardsController.php @@ -27,6 +27,10 @@ class AcquisitioncardsController extends GenericController { $this->_topMenuClasses['hardware'] = " class='currentitem'"; + + $worksOptions = Acquisitioncards::$select; + $worksField = 'compatibility'; + $interfaceOptions = Acquisitioncards::$interface; parent::__construct($model, $controller, $queryString); @@ -41,47 +45,8 @@ class AcquisitioncardsController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = 'acquisition-card'; - //hardware conditions - $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", - "+++checkIsStrings|".Acquisitioncards::$select => "compatibility", - "++++checkIsStrings|".Acquisitioncards::$interface => "interface", - ); - - $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", - "+++checkIsStrings|".Acquisitioncards::$select => "compatibility", - "++++checkIsStrings|".Acquisitioncards::$interface => "interface", - ); + $this->m['HardwareModel']->setConditions($worksOptions,$worksField,$interfaceOptions); - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - $this->m['HardwareModel']->setFields('model,kernel,description,distribution,comm_year,compatibility,pci_id,interface,driver,other_names','sanitizeAll'); $argKeys = array( @@ -98,9 +63,9 @@ class AcquisitioncardsController extends GenericController $data['title'] = 'Acquisition cards'; - $data['intefaceOptions'] = Acquisitioncards::$interface; - $data['worksOptions'] = Acquisitioncards::$select; - $data['worksField'] = 'compatibility'; + $data['intefaceOptions'] = $interfaceOptions; + $data['worksOptions'] = $worksOptions; + $data['worksField'] = $worksField; $this->append($data); } diff --git a/h-source/Application/Controllers/BluetoothController.php b/h-source/Application/Controllers/BluetoothController.php index b452f61..bff2723 100644 --- a/h-source/Application/Controllers/BluetoothController.php +++ b/h-source/Application/Controllers/BluetoothController.php @@ -27,6 +27,10 @@ class BluetoothController extends GenericController { $this->_topMenuClasses['hardware'] = " class='currentitem'"; + + $worksOptions = Bluetooth::$select;; + $worksField = 'bluetooth_works'; + $interfaceOptions = Bluetooth::$interface; parent::__construct($model, $controller, $queryString); @@ -41,46 +45,7 @@ class BluetoothController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = 'bluetooth'; - //hardware conditions - $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", - "+++checkIsStrings|".Bluetooth::$select => "bluetooth_works", - "++++checkIsStrings|".Bluetooth::$interface => "interface", - ); - - $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", - "+++checkIsStrings|".Bluetooth::$select => "bluetooth_works", - "++++checkIsStrings|".Bluetooth::$interface => "interface", - ); - - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); + $this->m['HardwareModel']->setConditions($worksOptions,$worksField,$interfaceOptions); $this->m['HardwareModel']->setFields('model,kernel,description,distribution,comm_year,bluetooth_works,pci_id,interface,driver,other_names','sanitizeAll'); @@ -98,9 +63,9 @@ class BluetoothController extends GenericController $data['title'] = 'Bluetooth'; - $data['intefaceOptions'] = Bluetooth::$interface; - $data['worksOptions'] = Bluetooth::$select; - $data['worksField'] = 'bluetooth_works'; + $data['intefaceOptions'] = $interfaceOptions; + $data['worksOptions'] = $worksOptions; + $data['worksField'] = $worksField; $this->append($data); } diff --git a/h-source/Application/Controllers/DownloadController.php b/h-source/Application/Controllers/DownloadController.php index 20d00a3..d44d343 100644 --- a/h-source/Application/Controllers/DownloadController.php +++ b/h-source/Application/Controllers/DownloadController.php @@ -69,7 +69,7 @@ class DownloadController extends BaseController } if ($type === 'notebook') { - $xml .= "\t\t".$row['hardware']['architecture']."\n"; + $xml .= "\t\t".translate($row['hardware']['architecture'])."\n"; $xml .= "\t\t".$row['hardware']['bios']."\n"; } diff --git a/h-source/Application/Controllers/EthernetcardsController.php b/h-source/Application/Controllers/EthernetcardsController.php index 40b90de..74e733c 100644 --- a/h-source/Application/Controllers/EthernetcardsController.php +++ b/h-source/Application/Controllers/EthernetcardsController.php @@ -27,6 +27,10 @@ class EthernetcardsController extends GenericController { $this->_topMenuClasses['hardware'] = " class='currentitem'"; + + $worksOptions = Ethernetcards::$select; + $worksField = 'ethernet_card_works'; + $interfaceOptions = Ethernetcards::$interface; parent::__construct($model, $controller, $queryString); @@ -41,46 +45,7 @@ class EthernetcardsController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = 'ethernet-card'; - //hardware conditions - $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", - "+++checkIsStrings|".Ethernetcards::$select => "ethernet_card_works", - "++++checkIsStrings|".Ethernetcards::$interface => "interface", - ); - - $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", - "+++checkIsStrings|".Ethernetcards::$select => "ethernet_card_works", - "++++checkIsStrings|".Ethernetcards::$interface => "interface", - ); - - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); + $this->m['HardwareModel']->setConditions($worksOptions,$worksField,$interfaceOptions); $this->m['HardwareModel']->setFields('model,kernel,description,distribution,comm_year,ethernet_card_works,pci_id,interface,driver,other_names','sanitizeAll'); @@ -98,9 +63,9 @@ class EthernetcardsController extends GenericController $data['title'] = 'Ethernet cards'; - $data['intefaceOptions'] = Ethernetcards::$interface; - $data['worksOptions'] = Ethernetcards::$select; - $data['worksField'] = 'ethernet_card_works'; + $data['intefaceOptions'] = $interfaceOptions; + $data['worksOptions'] = $worksOptions; + $data['worksField'] = $worksField; $this->append($data); } diff --git a/h-source/Application/Controllers/FingerprintreadersController.php b/h-source/Application/Controllers/FingerprintreadersController.php index 6b34fe1..1ea22c4 100644 --- a/h-source/Application/Controllers/FingerprintreadersController.php +++ b/h-source/Application/Controllers/FingerprintreadersController.php @@ -27,7 +27,11 @@ class FingerprintreadersController extends GenericController { $this->_topMenuClasses['hardware'] = " class='currentitem'"; - + + $worksOptions = Fingerprintreaders::$select; + $worksField = 'fingerprint_works'; + $interfaceOptions = Fingerprintreaders::$interface; + parent::__construct($model, $controller, $queryString); //load the model @@ -41,47 +45,8 @@ class FingerprintreadersController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = 'fingerprint-reader'; - //hardware conditions - $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", - "+++checkIsStrings|".Fingerprintreaders::$select => "fingerprint_works", - "++++checkIsStrings|".Fingerprintreaders::$interface => "interface", - ); - - $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", - "+++checkIsStrings|".Fingerprintreaders::$select => "fingerprint_works", - "++++checkIsStrings|".Fingerprintreaders::$interface => "interface", - ); + $this->m['HardwareModel']->setConditions($worksOptions,$worksField,$interfaceOptions); - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - $this->m['HardwareModel']->setFields('model,kernel,description,distribution,comm_year,fingerprint_works,pci_id,interface,driver,other_names','sanitizeAll'); $argKeys = array( @@ -98,9 +63,9 @@ class FingerprintreadersController extends GenericController $data['title'] = 'Fingerprint reader'; - $data['intefaceOptions'] = Fingerprintreaders::$interface; - $data['worksOptions'] = Fingerprintreaders::$select; - $data['worksField'] = 'fingerprint_works'; + $data['intefaceOptions'] = $interfaceOptions; + $data['worksOptions'] = $worksOptions; + $data['worksField'] = $worksField; $this->append($data); } diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php index 5cc81a5..362ea1e 100644 --- a/h-source/Application/Controllers/GenericController.php +++ b/h-source/Application/Controllers/GenericController.php @@ -26,7 +26,7 @@ class GenericController extends BaseController protected $_controllerName = null; //as in the URL public $orderPopup; - + public function __construct($model, $controller, $queryString) { parent::__construct($model, $controller, $queryString); diff --git a/h-source/Application/Controllers/ScannersController.php b/h-source/Application/Controllers/ScannersController.php index 24cd332..c913cf7 100644 --- a/h-source/Application/Controllers/ScannersController.php +++ b/h-source/Application/Controllers/ScannersController.php @@ -27,7 +27,7 @@ class ScannersController extends GenericController { $this->_topMenuClasses['hardware'] = " class='currentitem'"; - + parent::__construct($model, $controller, $queryString); //load the model @@ -41,47 +41,8 @@ class ScannersController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = 'scanner'; - //hardware conditions - $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|".Printer::compatibilityList() => "compatibility", - "++checkIsStrings|".Printer::$commYear => "comm_year", - "+++checkIsStrings|".Printer::$interface => "interface", - ); - - $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|".Printer::compatibilityList() => "compatibility", - "++checkIsStrings|".Printer::$commYear => "comm_year", - "+++checkIsStrings|".Printer::$interface => "interface", - ); + $this->m['HardwareModel']->setConditions(Printer::compatibilityList(),'compatibility',Printer::$interface); - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "driver", - "++checkLength|49" => "kernel", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "driver", - "++checkLength|49" => "kernel", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - $this->m['HardwareModel']->setFields('model,kernel,description,compatibility,distribution,comm_year,pci_id,driver,interface,other_names','sanitizeAll'); $argKeys = array( diff --git a/h-source/Application/Controllers/SoundcardsController.php b/h-source/Application/Controllers/SoundcardsController.php index ba04987..b032aaa 100644 --- a/h-source/Application/Controllers/SoundcardsController.php +++ b/h-source/Application/Controllers/SoundcardsController.php @@ -41,47 +41,8 @@ class SoundcardsController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = 'soundcard'; - //hardware conditions - $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", - "+++checkIsStrings|".Soundcards::$audioSelect => "sound_card_works", - "++++checkIsStrings|".Soundcards::$interface => "interface", - ); - - $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", - "+++checkIsStrings|".Soundcards::$audioSelect => "sound_card_works", - "++++checkIsStrings|".Soundcards::$interface => "interface", - ); + $this->m['HardwareModel']->setConditions(Soundcards::$audioSelect,'sound_card_works',Soundcards::$interface); - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - $this->m['HardwareModel']->setFields('model,kernel,description,distribution,comm_year,sound_card_works,pci_id,interface,driver,other_names','sanitizeAll'); $argKeys = array( diff --git a/h-source/Application/Controllers/ThreegcardsController.php b/h-source/Application/Controllers/ThreegcardsController.php index 2ddc108..dbd1315 100644 --- a/h-source/Application/Controllers/ThreegcardsController.php +++ b/h-source/Application/Controllers/ThreegcardsController.php @@ -41,46 +41,7 @@ class ThreegcardsController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = '3G-card'; - //hardware conditions - $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|".ThreeGcards::$commYear => "comm_year", - "+++checkIsStrings|".ThreeGcards::$select => "wifi_works", - "++++checkIsStrings|".ThreeGcards::interfaceList() => "interface", - ); - - $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|".ThreeGcards::$commYear => "comm_year", - "+++checkIsStrings|".ThreeGcards::$select => "wifi_works", - "++++checkIsStrings|".ThreeGcards::interfaceList() => "interface", - ); - - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); + $this->m['HardwareModel']->setConditions(Wifi::$wifiSelect,'wifi_works',ThreeGcards::interfaceList()); $this->m['HardwareModel']->setFields('model,kernel,description,distribution,comm_year,wifi_works,pci_id,interface,driver,other_names','sanitizeAll'); diff --git a/h-source/Application/Controllers/VideocardsController.php b/h-source/Application/Controllers/VideocardsController.php index 08eda31..f165713 100644 --- a/h-source/Application/Controllers/VideocardsController.php +++ b/h-source/Application/Controllers/VideocardsController.php @@ -41,46 +41,7 @@ class VideocardsController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = 'videocard'; - //hardware conditions - $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|".Notebooks::$commYear => "comm_year", - "+++checkIsStrings|".Videocard::videoList() => "video_card_works", - "++++checkIsStrings|".Videocard::$interface => "interface", - ); - - $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|".Notebooks::$commYear => "comm_year", - "+++checkIsStrings|".Videocard::videoList() => "video_card_works", - "++++checkIsStrings|".Videocard::$interface => "interface", - ); - - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); + $this->m['HardwareModel']->setConditions(Videocard::videoList(),'video_card_works',Videocard::$interface); $this->m['HardwareModel']->setFields('model,kernel,description,distribution,video_card_works,comm_year,pci_id,interface,driver,other_names','sanitizeAll'); diff --git a/h-source/Application/Controllers/WebcamsController.php b/h-source/Application/Controllers/WebcamsController.php index 562cc58..e68e318 100644 --- a/h-source/Application/Controllers/WebcamsController.php +++ b/h-source/Application/Controllers/WebcamsController.php @@ -41,46 +41,7 @@ class WebcamsController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = 'webcam'; - //hardware conditions - $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|".Webcams::$commYear => "comm_year", - "+++checkIsStrings|".Webcams::$select => "webcam_works", - "++++checkIsStrings|".Webcams::$interface => "interface", - ); - - $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|".Webcams::$commYear => "comm_year", - "+++checkIsStrings|".Webcams::$select => "webcam_works", - "++++checkIsStrings|".Webcams::$interface => "interface", - ); - - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); + $this->m['HardwareModel']->setConditions(Webcams::$select,'webcam_works',Webcams::$interface); $this->m['HardwareModel']->setFields('model,kernel,description,distribution,comm_year,webcam_works,pci_id,interface,driver,other_names','sanitizeAll'); diff --git a/h-source/Application/Controllers/WifiController.php b/h-source/Application/Controllers/WifiController.php index 52a9657..fe86922 100644 --- a/h-source/Application/Controllers/WifiController.php +++ b/h-source/Application/Controllers/WifiController.php @@ -41,46 +41,7 @@ class WifiController extends GenericController $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; $this->m['HardwareModel']->type = 'wifi'; - //hardware conditions - $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", - "+++checkIsStrings|".Wifi::$wifiSelect => "wifi_works", - "++++checkIsStrings|".Wifi::interfaceList() => "interface", - ); - - $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", - "+++checkIsStrings|".Wifi::$wifiSelect => "wifi_works", - "++++checkIsStrings|".Wifi::interfaceList() => "interface", - ); - - $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); - - $this->m['HardwareModel']->softConditions['insert'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", - ); + $this->m['HardwareModel']->setConditions(Wifi::$wifiSelect,'wifi_works',ThreeGcards::interfaceList()); $this->m['HardwareModel']->setFields('model,kernel,description,distribution,comm_year,wifi_works,pci_id,interface,driver,other_names','sanitizeAll'); diff --git a/h-source/Application/Models/HardwareModel.php b/h-source/Application/Models/HardwareModel.php index 7d5060c..d5aaffb 100644 --- a/h-source/Application/Models/HardwareModel.php +++ b/h-source/Application/Models/HardwareModel.php @@ -25,7 +25,7 @@ class HardwareModel extends Model_Map { public $id_user = 0; public $type = ''; //device type public $lastId = 0; //the id of the last record inserted - + public $formStruct = array( 'entries' => array( 'deleted'=> array('type'=>'Select','options'=>'no,yes'), @@ -68,10 +68,38 @@ class HardwareModel extends Model_Map { // $this->databaseConditions['update'] = array( // 'checkUniqueCompl' => 'model', // ); - + parent::__construct(); } + //set the soft and strong conditions + public function setConditions($worksOptions,$worksField,$interfaceOptions) + { + $this->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", + "+++checkIsStrings|".$worksOptions => $worksField, + "++++checkIsStrings|".$interfaceOptions => "interface", + ); + + $this->strongConditions['insert'] = $this->strongConditions['update']; + + $this->softConditions['update'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "kernel", + "++checkLength|49" => "driver", + "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", + ); + + $this->softConditions['insert'] = $this->softConditions['update']; + } + public function permanentlyDelete($id) { $clean['id'] = (int)$id; -- cgit v1.2.3