aboutsummaryrefslogtreecommitdiff
path: root/h-source/Application
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-10-03 07:53:59 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-10-03 07:53:59 +0000
commitfab22f5ebb7c5f757e48292a7f8de605638b7213 (patch)
treebb33937250d0b36117a65047a4bad32f6279a52f /h-source/Application
parentf4420f9dea80c5be0bb7d41a20e2db0dcce715a5 (diff)
when a device is already in the database (same vendorid_productid code) the system puts the link to the device - sudoman issue
Diffstat (limited to 'h-source/Application')
-rw-r--r--h-source/Application/Controllers/GenericController.php26
-rw-r--r--h-source/Application/Models/HardwareModel.php12
2 files changed, 32 insertions, 6 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|<i>VendorID:ProductID</i> 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|<i>VendorID:ProductID</i> 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|<i>VendorID:ProductID</i> 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|<i>VendorID:ProductID</i> 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 "<a href='".$this->baseUrl.'/'.$this->controller.'/view/'.$this->lang.'/'.$id.'/'.encodeUrl($ne_name).$this->viewStatus."'>".$ne_name."</a>";
+ $contr = isset($controller) ? $controller : $this->controller;
+
+ return "<a href='".$this->baseUrl.'/'.$contr.'/view/'.$this->lang.'/'.$id.'/'.encodeUrl($ne_name).$this->viewStatus."'>".$ne_name."</a>";
}
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)
{