From fab22f5ebb7c5f757e48292a7f8de605638b7213 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Mon, 3 Oct 2011 07:53:59 +0000 Subject: when a device is already in the database (same vendorid_productid code) the system puts the link to the device - sudoman issue --- .../Application/Controllers/GenericController.php | 26 +++++++++++++++++----- h-source/Application/Models/HardwareModel.php | 12 ++++++++++ h-source/Public/Css/main.css | 10 ++++----- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php index 362ea1e..a2c5bdf 100644 --- a/h-source/Application/Controllers/GenericController.php +++ b/h-source/Application/Controllers/GenericController.php @@ -59,7 +59,7 @@ class GenericController extends BaseController $data['isApproved'] = true; $this->append($data); } - + protected function insert($lang = 'en', $token = '') { $this->shift(2); @@ -96,7 +96,7 @@ class GenericController extends BaseController { $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'; + $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. See here: '.$this->getAlreadyExixtsLink($pci_id); } //insert the new device @@ -264,7 +264,7 @@ class GenericController extends BaseController { $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'; + $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. See here: '.$this->getAlreadyExixtsLink($pci_id); } //carry out the update database action @@ -820,11 +820,25 @@ class GenericController extends BaseController $this->append($data); $this->loadViewAll('talk,if_page_deleted,moderator_dialog'); } + + //get the link to the device page from vendorid:productid code + protected function getAlreadyExixtsLink($code) + { + $hw = new HardwareModel(); + $info = $hw->getModelByCode($code); + + if ($info) + { + return $this->getViewLink($info['id_hard'],$info['model'],Hardware::getControllerFromType($info['type'])); + } + return ''; + } - protected function getViewLink($id,$ne_name) + protected function getViewLink($id,$ne_name,$controller = null) { -// $text = isset() - return "controller.'/view/'.$this->lang.'/'.$id.'/'.encodeUrl($ne_name).$this->viewStatus."'>".$ne_name.""; + $contr = isset($controller) ? $controller : $this->controller; + + return "lang.'/'.$id.'/'.encodeUrl($ne_name).$this->viewStatus."'>".$ne_name.""; } protected function getHistoryLink($id) diff --git a/h-source/Application/Models/HardwareModel.php b/h-source/Application/Models/HardwareModel.php index d5aaffb..9a40e4b 100644 --- a/h-source/Application/Models/HardwareModel.php +++ b/h-source/Application/Models/HardwareModel.php @@ -282,6 +282,18 @@ class HardwareModel extends Model_Map { return $name; } + //get the model info by the vendorid:productid code + public function getModelByCode($code) + { + $res = $this->clear()->where(array('pci_id'=>sanitizePciid($code)))->send(); + + if (count($res) > 0) + { + return $res[0]['hardware']; + } + return false; + } + //save in the history all the action carried out by users protected function updateHistory($action) { diff --git a/h-source/Public/Css/main.css b/h-source/Public/Css/main.css index a7c658e..296843e 100644 --- a/h-source/Public/Css/main.css +++ b/h-source/Public/Css/main.css @@ -386,11 +386,11 @@ a.link_menu clear:left; clear:right; font:bold 12px/1.5 sans-serif,arial; - padding:2px; - margin:5px 5px 15px 5px; -/* background:TOMATO; */ -/* border-top:2px solid MAROON; */ -/* border-bottom:2px solid MAROON; */ + padding:10px; + margin:5px 0px 15px 0px; + background:TOMATO; + border-top:2px solid MAROON; + border-bottom:2px solid MAROON; color:MAROON; } -- cgit v1.2.3