From be1d2d6c4c5623c6af59cf72e74e0335d1aa6cb5 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Sun, 10 Jul 2011 22:46:30 +0000 Subject: improved the way the history messages are shown --- .../Application/Controllers/BaseController.php | 4 +- .../Application/Controllers/GenericController.php | 14 ++++--- .../Application/Controllers/HistoryController.php | 22 +++++++++- .../Application/Controllers/SpecialController.php | 49 ++++++++++++++++------ h-source/Application/Models/HistoryModel.php | 5 ++- h-source/Public/Css/main.css | 15 +++---- 6 files changed, 79 insertions(+), 30 deletions(-) (limited to 'h-source') diff --git a/h-source/Application/Controllers/BaseController.php b/h-source/Application/Controllers/BaseController.php index 697b79b..02db21d 100644 --- a/h-source/Application/Controllers/BaseController.php +++ b/h-source/Application/Controllers/BaseController.php @@ -136,7 +136,9 @@ class BaseController extends Controller $data['lastModif'] = $this->m['HistoryModel'] ->select() - ->where(array('type'=>'hardware','gr'=>'registered')) + ->inner('hardware') + ->on('hardware.id_hard=history.id') + ->where(array('type'=>'hardware','gr'=>'registered','approved'=>'yes')) ->orderBy('id_history desc') ->limit(5) ->send(); diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php index 1539f9f..a5dd24c 100644 --- a/h-source/Application/Controllers/GenericController.php +++ b/h-source/Application/Controllers/GenericController.php @@ -87,13 +87,13 @@ class GenericController extends BaseController { $pci_id = $this->request->post('pci_id','','sanitizeAll'); $interface = $this->request->post('interface','not-defined','sanitizeAll'); - + if ($this->checkVendorId($interface)) { if (strcmp($this->m['HardwareModel']->type,'notebook') !== 0) { $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'; } @@ -104,15 +104,17 @@ class GenericController extends BaseController { if (strcmp($this->controller,'notebooks') === 0) { - session_start(); + @session_start(); $_SESSION['notebook_inserted'] = 'yes'; } - } - if ($this->m['HardwareModel']->queryResult) - { $data['submission_response'] = 'executed'; } + +// if ($this->m['HardwareModel']->queryResult) +// { +// $data['submission_response'] = 'executed'; +// } $this->viewRedirect($this->m['HardwareModel']->lastId); } diff --git a/h-source/Application/Controllers/HistoryController.php b/h-source/Application/Controllers/HistoryController.php index a92f906..3b6e1d2 100644 --- a/h-source/Application/Controllers/HistoryController.php +++ b/h-source/Application/Controllers/HistoryController.php @@ -275,6 +275,7 @@ class HistoryController extends BaseController 'field_name' => '-deleted', 'actions' => array('devicehide','deviceshow'), 'group' => 'admin', + 'types_to_show' => 'device_app,device', ), @@ -467,8 +468,15 @@ class HistoryController extends BaseController if (in_array($clean['group'],$this->s['registered']->status['groups'])) { $clean['type'] = $this->types[$type]['clean_type']; + $clean['typeInWhereClause'] = "'".$clean['type']."'"; - switch ($clean['type']) { + if (array_key_exists('types_to_show',$this->types[$type])) + { + $clean['typeInWhereClause'] = "'".implode("','",explode(',',$this->types[$type]['types_to_show']))."'"; + } + + switch ($clean['type']) + { case 'user': $data['object'] = 'user'; $data['box_class'] = 'details_of_actions_inner_user'; @@ -499,7 +507,17 @@ class HistoryController extends BaseController break; } - $data['res'] = $this->m['HistoryModel']->select()->where(array('id'=>$clean['id'],'type'=>$clean['type'],'gr'=>$clean['group']))->send(); + $data['res'] = $this->m['HistoryModel'] + ->select() + ->where( + array + ( + 'id'=>$clean['id'], + 'type'=>"in(".$clean['typeInWhereClause'].")", + 'gr'=>$clean['group']) + ) + ->send(); +// echo $this->m['HistoryModel']->getQuery(); $data['md_action'] = array( 'hide' => 'hidden', diff --git a/h-source/Application/Controllers/SpecialController.php b/h-source/Application/Controllers/SpecialController.php index 6f17c2c..6ef632a 100644 --- a/h-source/Application/Controllers/SpecialController.php +++ b/h-source/Application/Controllers/SpecialController.php @@ -40,17 +40,17 @@ class SpecialController extends BaseController { switch ($action) { - case 'modifications': - $data['title'] = 'last modifications - '.Website::$generalName; - - $whereClauseArray = array( - 'gr' => 'registered', - 'type' => 'hardware', - ); - - $viewFile = 'modifications'; - - break; +// case 'modifications': +// $data['title'] = 'last modifications - '.Website::$generalName; +// +// $whereClauseArray = array( +// 'gr' => 'registered', +// 'type' => 'hardware', +// ); +// +// $viewFile = 'modifications'; +// +// break; case 'modactions': $data['title'] = 'last moderations - '.Website::$generalName; $data['viewTitle'] = 'List of actions carried out by moderators'; @@ -99,7 +99,30 @@ class SpecialController extends BaseController { $this->shift(1); - $this->last($lang = 'en','modifications'); + $data['title'] = 'last modifications - '.Website::$generalName; + + $whereClauseArray = array( + 'gr' => 'registered', + 'type' => 'hardware', + 'approved' => 'yes', + ); + + $this->helper('Pages','special/'.$this->action.'/'.$this->lang,'page'); + + $this->m['HistoryModel']->clear()->inner('hardware')->on('hardware.id_hard=history.id')->select()->where($whereClauseArray)->orderBy('id_history desc'); + + $recordNumber = $this->m['HistoryModel']->rowNumber(); + $page = $this->viewArgs['page']; + + $this->m['HistoryModel']->limit = $this->h['Pages']->getLimit($page,$recordNumber,30); + + $data['table'] = $this->m['HistoryModel']->send(); + + $data['pageList'] = $this->h['Pages']->render($page-5,11); + + $this->append($data); + $this->load('modifications'); + $this->right(); } public function modactions($lang = 'en') @@ -122,7 +145,7 @@ class SpecialController extends BaseController protected function pagelist($lang = 'en', $type) { - switch($type) + switch ($type) { case 'deleted': $whereArray = array('-deleted'=>'yes','approved'=>'yes'); diff --git a/h-source/Application/Models/HistoryModel.php b/h-source/Application/Models/HistoryModel.php index 2176a4a..daeda1f 100644 --- a/h-source/Application/Models/HistoryModel.php +++ b/h-source/Application/Models/HistoryModel.php @@ -25,7 +25,10 @@ class HistoryModel extends Model_Tree { public function __construct() { $this->_tables = 'history'; $this->_idFields = 'id_history'; - + + $this->_where=array( + 'approved' => 'hardware', + ); $this->orderBy = 'history.id_history'; $this->_popupFunctions = array( diff --git a/h-source/Public/Css/main.css b/h-source/Public/Css/main.css index 952f889..2f15a7f 100644 --- a/h-source/Public/Css/main.css +++ b/h-source/Public/Css/main.css @@ -1765,15 +1765,16 @@ span.entry_label_small #admin_box, #moderator_box { margin:20px 10px; - border-bottom:1px solid #ADD8E6; - border-left:10px solid #ADD8E6; - background-color:#F0FFFF; +/* border-bottom:1px solid #DC143C; */ +/* border-top:1px solid #DC143C; */ + border-left:10px solid #DC143C; +/* background-color:#F0FFFF; */ padding:10px; } #moderator_box { - background-color:#fffc8e; - border-bottom:1px solid #FFA500; +/* background-color:#fffc8e; */ +/* border-bottom:1px solid #FFA500; */ border-left:10px solid #FFA500; } .admin_box_title, .moderator_box_title @@ -1796,8 +1797,8 @@ span.entry_label_small } #admin_box ul li a, #moderator_box ul li a { - color:#097FBC; -/* font-weight:bold; */ + color:#DC143C; + font-weight:bold; } #moderator_box ul li a { -- cgit v1.2.3