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 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 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 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) -- cgit v1.2.3