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 --- .../Application/Controllers/ScannersController.php | 43 +--------------------- 1 file changed, 2 insertions(+), 41 deletions(-) (limited to 'h-source/Application/Controllers/ScannersController.php') 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( -- cgit v1.2.3