aboutsummaryrefslogtreecommitdiff
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
parentf4420f9dea80c5be0bb7d41a20e2db0dcce715a5 (diff)
when a device is already in the database (same vendorid_productid code) the system puts the link to the device - sudoman issue
-rw-r--r--h-source/Application/Controllers/GenericController.php26
-rw-r--r--h-source/Application/Models/HardwareModel.php12
-rw-r--r--h-source/Public/Css/main.css10
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|<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)
{
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;
}