Passed
Push — master ( 9a2ce8...395129 )
by Patrick
02:01
created
library/Trapdirector/Tables/HandlerTable.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -28,16 +28,16 @@  discard block
 block discarded – undo
28 28
     
29 29
     public function getCurrentURL()
30 30
     {
31
-        return Url::fromPath($this->urlPath . '/handler');
31
+        return Url::fromPath($this->urlPath.'/handler');
32 32
     }
33 33
     
34 34
     public function renderLine($row)
35 35
       {
36
-          $html = '';
37
-          $firstCol = true;
36
+          $html='';
37
+          $firstCol=true;
38 38
                
39
-          $titleNames = array_keys($this->titles);
40
-          foreach ($titleNames as $rowkey )
39
+          $titleNames=array_keys($this->titles);
40
+          foreach ($titleNames as $rowkey)
41 41
           {        
42 42
               // Check missing value
43 43
               if (property_exists($row, $rowkey))
@@ -52,53 +52,53 @@  discard block
 block discarded – undo
52 52
                           
53 53
                           if ($this->doTranslate === true)
54 54
                           {
55
-                              $oidName = $this->MIB->translateOID($row->$rowkey);
55
+                              $oidName=$this->MIB->translateOID($row->$rowkey);
56 56
                               if (isset($oidName['name']))
57 57
                               {
58 58
                                   $val=$oidName['name'];
59 59
                               }
60 60
                               else
61 61
                               {
62
-                                  $val = $row->$rowkey;
62
+                                  $val=$row->$rowkey;
63 63
                               }
64 64
                           }
65 65
                           else
66 66
                           {
67
-                              $val = $row->$rowkey;
67
+                              $val=$row->$rowkey;
68 68
                           }
69 69
                           break;
70 70
                       case 'host_name': // switch to hostgroup if name is null
71 71
                           if ($row->$rowkey == null)
72 72
                           {
73
-                              $val = $row->host_group_name;
73
+                              $val=$row->host_group_name;
74 74
                           }
75 75
                           else
76 76
                           {
77
-                              $val = $row->$rowkey;
77
+                              $val=$row->$rowkey;
78 78
                           }
79 79
                           break;
80 80
                       default:
81
-                          $val = $row->$rowkey;
81
+                          $val=$row->$rowkey;
82 82
                   }
83
-                  if ($rowkey == 'trap_oid' && $this->doTranslate===true)
83
+                  if ($rowkey == 'trap_oid' && $this->doTranslate === true)
84 84
                   {
85 85
                       
86 86
                   }
87 87
               } else {
88
-                  $val = '-';
88
+                  $val='-';
89 89
               }
90 90
               if ($firstCol === true) { // Put link in first column for trap detail.
91
-                  $html .= '<td>'
91
+                  $html.='<td>'
92 92
                       . $this->view->qlink(
93 93
                           $this->view->escape($val),
94 94
                           Url::fromPath(
95
-                              $this->urlPath . '/handler/add',
95
+                              $this->urlPath.'/handler/add',
96 96
                               array('ruleid' => $row->id)
97 97
                               )
98 98
                           )
99 99
                           . '</td>';
100 100
               } else {
101
-                  $html .= '<td>' . $this->view->escape($val) . '</td>';
101
+                  $html.='<td>'.$this->view->escape($val).'</td>';
102 102
               }
103 103
               $firstCol=false;
104 104
               
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapDirectorTable.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@  discard block
 block discarded – undo
10 10
 abstract class TrapDirectorTable
11 11
 {
12 12
     /** @var array $titles table titles (name, display value) */
13
-    protected $titles = null;
13
+    protected $titles=null;
14 14
 
15 15
     /** @var array $content table content  (name, sb column name). name index must be the same as $titles*/
16
-    protected $content = null;
16
+    protected $content=null;
17 17
     
18 18
     /** @var array $columnNames names of columns for filtering */
19
-    protected $columnNames = array();
19
+    protected $columnNames=array();
20 20
     
21 21
     /** @var Selectable $dbConn connection to database  */
22
-    protected $dbConn = null;
22
+    protected $dbConn=null;
23 23
     
24 24
     /** Current view **/
25 25
     protected $view;
@@ -28,39 +28,39 @@  discard block
 block discarded – undo
28 28
     
29 29
     // Database stuff
30 30
    /** @var array $table (db ref, name) */
31
-    protected $table = array();
31
+    protected $table=array();
32 32
     
33 33
     /** @var Queryable  $query Query in database; */
34
-    protected $query = null;
34
+    protected $query=null;
35 35
     
36 36
     /** @var array $order : (db column, 'ASC' | 'DESC') */
37
-    protected $order = array();
38
-    protected $orderQuery = '';
37
+    protected $order=array();
38
+    protected $orderQuery='';
39 39
     
40 40
     /********* Filter ********/
41 41
     /** @var string $filterString : string filter for db columns */
42
-    protected $filterString = '';
42
+    protected $filterString='';
43 43
     
44 44
     /** @var array $filterColumn : columns to apply filter to */
45
-    protected $filterColumn = array();
45
+    protected $filterColumn=array();
46 46
     
47 47
     protected $filterQuery='';
48 48
     
49 49
     /*************** Paging *************/
50
-    protected $maxPerPage = 25;
50
+    protected $maxPerPage=25;
51 51
     
52
-    protected $currentPage = 0;
52
+    protected $currentPage=0;
53 53
     
54
-    function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath)
54
+    function __construct(array $table, array $titles, array $columns, array $columnNames, $dbConn, $view, $urlPath)
55 55
     {
56
-        $this->table = $table;
57
-        $this->titles = $titles;
58
-        $this->content = $columns;
59
-        $this->columnNames = $columnNames;
60
-        $this->dbConn = $dbConn;
56
+        $this->table=$table;
57
+        $this->titles=$titles;
58
+        $this->content=$columns;
59
+        $this->columnNames=$columnNames;
60
+        $this->dbConn=$dbConn;
61 61
         
62
-        $this->view = $view;
63
-        $this->urlPath = $urlPath;
62
+        $this->view=$view;
63
+        $this->urlPath=$urlPath;
64 64
         
65 65
         return $this;
66 66
     }
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
     
81 81
     protected function getCurrentURLAndQS(string $caller)
82 82
     {
83
-        $actionURL = $this->getCurrentURL() . '?' ;
83
+        $actionURL=$this->getCurrentURL().'?';
84 84
         $QSList=array();
85 85
         if ($caller != 'filter' && $this->curFilterQuery() != '')
86
-            array_push($QSList , $this->curFilterQuery());
86
+            array_push($QSList, $this->curFilterQuery());
87 87
         
88 88
         if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '')
89
-            array_push($QSList , $this->curPagingQuery());
89
+            array_push($QSList, $this->curPagingQuery());
90 90
  
91 91
         if ($caller != 'order' && $this->curOrderQuery() != '')
92
-            array_push($QSList , $this->curOrderQuery());
92
+            array_push($QSList, $this->curOrderQuery());
93 93
         
94 94
         if (count($QSList) != 0)
95
-            $actionURL .=  implode('&', $QSList);
95
+            $actionURL.=implode('&', $QSList);
96 96
         
97 97
         return $actionURL;
98 98
     }
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function getBaseQuery()
106 106
     {
107
-        $this->query = $this->dbConn->select();
108
-        $this->query = $this->query->from(
107
+        $this->query=$this->dbConn->select();
108
+        $this->query=$this->query->from(
109 109
             $this->table,
110 110
             $this->content
111 111
             );
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         {
138 138
             if ($filter != "") $filter.=' OR ';
139 139
             //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'";
140
-            $filter .= $column  . " LIKE '%" . $this->filterString. "%'";
140
+            $filter.=$column." LIKE '%".$this->filterString."%'";
141 141
         }
142 142
         //echo $filter;
143 143
         
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 
149 149
     public function setFilter(string $filter, array $filterCol)
150 150
     {
151
-        $this->filterString = $filter;
152
-        $this->filterColumn = $filterCol;
151
+        $this->filterString=$filter;
152
+        $this->filterColumn=$filterCol;
153 153
         return $this;
154 154
     }
155 155
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     {
173 173
         if (isset($getVars['f']))
174 174
         {
175
-            $this->filterQuery = $getVars['f'];
175
+            $this->filterQuery=$getVars['f'];
176 176
             $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames);
177 177
         }
178 178
     }
@@ -195,16 +195,16 @@  discard block
 block discarded – undo
195 195
         {
196 196
             if ($orderSQL != "") $orderSQL.=',';
197 197
             
198
-            $orderSQL .= $column . ' ' . $direction;
198
+            $orderSQL.=$column.' '.$direction;
199 199
         }
200
-        $this->query = $this->query->order($orderSQL);
200
+        $this->query=$this->query->order($orderSQL);
201 201
         
202 202
         return $this;
203 203
     }
204 204
     
205 205
     public function setOrder(array $order)
206 206
     {
207
-        $this->order = $order;
207
+        $this->order=$order;
208 208
         return $this;
209 209
     }
210 210
     
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     {
213 213
         if (isset($getVars['o']))
214 214
         {
215
-            $this->orderQuery = $getVars['o'];
215
+            $this->orderQuery=$getVars['o'];
216 216
             // TODO
217 217
         }
218 218
     }
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
     /*****************  Paging and counting *********/
227 227
     public function countQuery()
228 228
     {
229
-        $this->query = $this->dbConn->select();
230
-        $this->query = $this->query
229
+        $this->query=$this->dbConn->select();
230
+        $this->query=$this->query
231 231
             ->from(
232 232
                 $this->table,
233 233
                 array('COUNT(*)')
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
     
244 244
     public function setMaxPerPage(int $max)
245 245
     {
246
-        $this->maxPerPage = $max;
246
+        $this->maxPerPage=$max;
247 247
     }
248 248
     
249 249
     protected function getPagingQuery(array $getVars)
250 250
     {
251 251
         if (isset($getVars['page']))
252 252
         {
253
-            $this->currentPage = $getVars['page'];
253
+            $this->currentPage=$getVars['page'];
254 254
         }
255 255
     }
256 256
 
@@ -262,22 +262,22 @@  discard block
 block discarded – undo
262 262
     
263 263
     public function renderPagingHeader()
264 264
     {
265
-        $count = $this->count();
266
-        if ($count <= $this->maxPerPage )
265
+        $count=$this->count();
266
+        if ($count <= $this->maxPerPage)
267 267
         {
268
-            return  'count : ' . $this->count() . '<br>';
268
+            return  'count : '.$this->count().'<br>';
269 269
         }
270 270
         
271
-        if ($this->currentPage == 0) $this->currentPage = 1;
271
+        if ($this->currentPage == 0) $this->currentPage=1;
272 272
         
273
-        $numPages = intdiv($count , $this->maxPerPage);
274
-        if ($count % $this->maxPerPage != 0 ) $numPages++;
273
+        $numPages=intdiv($count, $this->maxPerPage);
274
+        if ($count % $this->maxPerPage != 0) $numPages++;
275 275
         
276
-        $html = '<div class="pagination-control" role="navigation">';
277
-        $html .= '<ul class="nav tab-nav">';
278
-        if ($this->currentPage <=1)
276
+        $html='<div class="pagination-control" role="navigation">';
277
+        $html.='<ul class="nav tab-nav">';
278
+        if ($this->currentPage <= 1)
279 279
         {
280
-            $html .= '
280
+            $html.='
281 281
                 <li class="nav-item disabled" aria-hidden="true">
282 282
                     <span class="previous-page">
283 283
                             <span class="sr-only">Previous page</span>
@@ -288,24 +288,24 @@  discard block
 block discarded – undo
288 288
         }
289 289
         else 
290 290
         {
291
-            $html .= '
291
+            $html.='
292 292
                 <li class="nav-item">
293
-                    <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage - 1 ).'" class="previous-page" >
293
+                    <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage - 1).'" class="previous-page" >
294 294
                             <i aria-hidden="true" class="icon-angle-double-left"></i>            
295 295
                      </a>
296 296
                 </li>
297 297
             ';
298 298
         }
299 299
         
300
-        for ($i=1; $i <= $numPages ; $i++)
300
+        for ($i=1; $i <= $numPages; $i++)
301 301
         {
302
-            $active = ($this->currentPage == $i) ? 'active' : '';
303
-            $first = ($i-1)*$this->maxPerPage+1;
304
-            $last = $i * $this->maxPerPage;
305
-            if ($last > $count) $last = $count;
306
-            $display = 'Show rows '. $first . ' to '. $last .' of '. $count;
307
-            $html .= '<li class="' . $active . ' nav-item">
308
-                    <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '">
302
+            $active=($this->currentPage == $i) ? 'active' : '';
303
+            $first=($i - 1) * $this->maxPerPage + 1;
304
+            $last=$i * $this->maxPerPage;
305
+            if ($last > $count) $last=$count;
306
+            $display='Show rows '.$first.' to '.$last.' of '.$count;
307
+            $html.='<li class="'.$active.' nav-item">
308
+                    <a href="'. $this->getCurrentURLAndQS('paging').'&page='.$i.'" title="'.$display.'" aria-label="'.$display.'">
309 309
                     '.$i.'                
310 310
                     </a>
311 311
                 </li>';
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         
314 314
         if ($this->currentPage == $numPages)
315 315
         {
316
-            $html .= '
316
+            $html.='
317 317
                 <li class="nav-item disabled" aria-hidden="true">
318 318
                     <span class="previous-page">
319 319
                             <span class="sr-only">Previous page</span>
@@ -324,18 +324,18 @@  discard block
 block discarded – undo
324 324
         }
325 325
         else
326 326
         {
327
-            $html .= '
327
+            $html.='
328 328
                 <li class="nav-item">
329
-                    <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage + 1 ).'" class="next-page">
329
+                    <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage + 1).'" class="next-page">
330 330
                             <i aria-hidden="true" class="icon-angle-double-right"></i>
331 331
                      </a>
332 332
                 </li>
333 333
             ';
334 334
         }
335 335
         
336
-        $html .= '</ul> </div>';
336
+        $html.='</ul> </div>';
337 337
         
338
-        $htmlOLD = '
338
+        $htmlOLD='
339 339
             <ul class="nav tab-nav">
340 340
 
341 341
                 <li class="active nav-item">
@@ -360,60 +360,60 @@  discard block
 block discarded – undo
360 360
     
361 361
     public function applyPaging()
362 362
     {
363
-        $this->query->limitPage($this->currentPage,$this->maxPerPage);
363
+        $this->query->limitPage($this->currentPage, $this->maxPerPage);
364 364
         return $this;
365 365
     }
366 366
     
367 367
     /*************** Rendering *************************/
368 368
     public function renderTitles()
369 369
     {
370
-        $html = "<thead>\n<tr>\n";
370
+        $html="<thead>\n<tr>\n";
371 371
         foreach ($this->titles as $values)
372 372
         {
373
-            $html .= '<th>' . $values . '</th>';            
373
+            $html.='<th>'.$values.'</th>';            
374 374
         }
375
-        $html .= "</tr>\n</thead>\n";
375
+        $html.="</tr>\n</thead>\n";
376 376
         return $html;
377 377
     }
378 378
     
379
-    public function renderLine( $value)
379
+    public function renderLine($value)
380 380
     {
381
-        $html = '';
382
-        $titleNames = array_keys($this->titles);
383
-        foreach ($titleNames as $name )
381
+        $html='';
382
+        $titleNames=array_keys($this->titles);
383
+        foreach ($titleNames as $name)
384 384
         {
385
-            $html .= '<td>';
386
-            $html .= $value->$name;
387
-            $html .= "</td>\n";
385
+            $html.='<td>';
386
+            $html.=$value->$name;
387
+            $html.="</td>\n";
388 388
         }
389 389
         return $html;
390 390
     }
391 391
     
392 392
     public function renderTable(array $values)
393 393
     {
394
-       $html = '<tbody id="obj_table_body">';
395
-       foreach($values as $value)
394
+       $html='<tbody id="obj_table_body">';
395
+       foreach ($values as $value)
396 396
        {
397
-           $html .= "<tr>\n";
398
-           $html .= $this->renderLine($value);
399
-           $html .= "</tr>\n";
397
+           $html.="<tr>\n";
398
+           $html.=$this->renderLine($value);
399
+           $html.="</tr>\n";
400 400
        }
401
-       $html .= '</tbody>';
401
+       $html.='</tbody>';
402 402
        return $html;
403 403
     }
404 404
     
405 405
     public function render()
406 406
     {
407
-        $html = '';
407
+        $html='';
408 408
         
409 409
         
410
-        $values = $this->fullQuery();
410
+        $values=$this->fullQuery();
411 411
         
412 412
         $html.="<table class='simple common-table table-row-selectable'>\n";
413 413
         
414
-        $html .= $this->renderTitles();
415
-        $html .= $this->renderTable($values);
416
-        $html .= '</table>'; 
414
+        $html.=$this->renderTitles();
415
+        $html.=$this->renderTable($values);
416
+        $html.='</table>'; 
417 417
         
418 418
 
419 419
         return $html;
Please login to merge, or discard this patch.
application/controllers/HandlerController.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 		$this->checkReadPermission();
25 25
 		$this->prepareTabs()->activate('status');
26 26
 
27
-		$dbConn = $this->getUIDatabase()->getDb();
27
+		$dbConn=$this->getUIDatabase()->getDb();
28 28
 		if ($dbConn === null) throw new \ErrorException('uncatched db error');
29 29
 		
30
-		$this->view->handlerTable = new HandlerTable(
30
+		$this->view->handlerTable=new HandlerTable(
31 31
 		      $this->moduleConfig->getTrapRuleName(),
32 32
 		      $this->moduleConfig->getHandlerListTitles(),
33 33
 		      $this->moduleConfig->getHandlerListDisplayColumns(),
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		      $this->view,
37 37
 		      $this->moduleConfig->urlPath());
38 38
 		
39
-		$getVars = $this->getRequest()->getParams();		
39
+		$getVars=$this->getRequest()->getParams();		
40 40
 		$this->view->handlerTable->getParams($getVars);
41 41
 		
42 42
 		//$this->view->handlerTable->setFilter('127.0.0.1',array('ip4'));
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 		$this->getHandlerListTable()->setConnection($dbConn);
49 49
 		$this->getHandlerListTable()->setMibloader($this->getMIB());
50 50
 		// Apply pagination limits 
51
-		$this->view->table=$this->applyPaginationLimits($this->getHandlerListTable(),$this->getModuleConfig()->itemListDisplay());		
51
+		$this->view->table=$this->applyPaginationLimits($this->getHandlerListTable(), $this->getModuleConfig()->itemListDisplay());		
52 52
 		
53 53
 		// Set Filter
54
-		$this->view->filterEditor = $this->getHandlerListTable()->getFilterEditor($this->getRequest());		
54
+		$this->view->filterEditor=$this->getHandlerListTable()->getFilterEditor($this->getRequest());		
55 55
 	
56 56
 		//$this->displayExitError('Handler/indexAction','Not implemented');
57 57
 	}
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	public function testruleAction()
62 62
 	{
63 63
 	    $this->checkReadPermission();
64
-	    $this->getTabs()->add('get',array(
64
+	    $this->getTabs()->add('get', array(
65 65
 	        'active'	=> true,
66 66
 	        'label'		=> $this->translate('Test Rule'),
67 67
 	        'url'		=> Url::fromRequest()
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 	    if ($this->params->get('rule') !== null) 
72 72
 	    {
73
-	        $this->view->rule= $this->params->get('rule');
73
+	        $this->view->rule=$this->params->get('rule');
74 74
 	    }
75 75
 	    else
76 76
 	    {
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 	    }
130 130
 	    catch (Exception $e)
131 131
 	    {
132
-	        $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
132
+	        $this->displayExitError('Add handler : get host by IP/Name ', $e->getMessage());
133 133
 	    }
134 134
 	    
135 135
 	    
136 136
 	    // if one unique host found -> put id text input
137
-	    if (count($hosts)==1) {
137
+	    if (count($hosts) == 1) {
138 138
 	        $this->view->hostname=$hosts[0]->name;
139 139
 	        //$hostid=$hosts[0]->id;
140 140
 	        // Tell JS to get services when page is loaded
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	    }
144 144
 	    else
145 145
 	    {
146
-	        foreach($hosts as $key=>$val)
146
+	        foreach ($hosts as $key=>$val)
147 147
 	        {
148
-	            array_push($this->view->hostlist,$hosts[$key]->name);
148
+	            array_push($this->view->hostlist, $hosts[$key]->name);
149 149
 	        }
150 150
 	    }
151 151
 	    
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
 	            $currentObjectTypeEnum
185 185
 	        );
186 186
 	        $oid_index++;
187
-	        array_push($this->view->objectList,$currentObject);
187
+	        array_push($this->view->objectList, $currentObject);
188 188
 	        // set currrent object to null in allObjects
189 189
 	        if (isset($allObjects[$val->oid]))
190 190
 	        {
191 191
 	            $allObjects[$val->oid]=null;
192 192
 	        }
193 193
 	    }
194
-	    if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
194
+	    if ($allObjects != null) // in case trap doesn't have objects or is not resolved
195 195
 	    {
196 196
 	        foreach ($allObjects as $key => $val)
197 197
 	        {
198
-	            if ($val==null) { continue; }
198
+	            if ($val == null) { continue; }
199 199
 	            array_push($this->view->objectList, array(
200 200
 	                $oid_index,
201 201
 	                $key,
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 	    // Check if hostname still exists
224 224
 	    $host_get=$this->getUIDatabase()->getHostByName($this->view->hostname);
225 225
 	    
226
-	    if (count($host_get)==0)
226
+	    if (count($host_get) == 0)
227 227
 	    {
228
-	        $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
228
+	        $this->view->warning_message='Host '.$this->view->hostname.' doesn\'t exists anymore';
229 229
 	        $this->view->serviceGet=false;
230 230
 	    }
231 231
 	    else
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 	        // Tell JS to get services when page is loaded
234 234
 	        $this->view->serviceGet=true;
235 235
 	        // get service id for form to set :
236
-	        $serviceID=$this->getUIDatabase()->getServiceIDByName($this->view->hostname,$ruleDetail->service_name);
237
-	        if (count($serviceID) ==0)
236
+	        $serviceID=$this->getUIDatabase()->getServiceIDByName($this->view->hostname, $ruleDetail->service_name);
237
+	        if (count($serviceID) == 0)
238 238
 	        {
239
-	            $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
239
+	            $this->view->warning_message=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore';
240 240
 	        }
241 241
 	        else
242 242
 	        {
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 	{
254 254
 	    // Check if groupe exists
255 255
 	    $group_get=$this->getUIDatabase()->getHostGroupByName($this->view->hostgroupname);
256
-	    if (count($group_get)==0)
256
+	    if (count($group_get) == 0)
257 257
 	    {
258
-	        $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
258
+	        $this->view->warning_message='HostGroup '.$this->view->hostgroupname.' doesn\'t exists anymore';
259 259
 	        $this->view->serviceGroupGet=false;
260 260
 	    }
261 261
 	    else
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
 	        
274 274
 	        // Tell JS to get services when page is loaded
275 275
 	        $this->view->serviceGroupGet=true;
276
-	        if ($foundGrpService==0)
276
+	        if ($foundGrpService == 0)
277 277
 	        {
278
-	            $this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
278
+	            $this->view->warning_message.=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore';
279 279
 	        }
280 280
 	    }
281 281
 	}
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
 	    $index=1;
294 294
 	    // check in display & rule for : OID(<oid>)
295 295
 	    $matches=array();
296
-	    while ( preg_match('/_OID\(([\.0-9\*]+)\)/',$display,$matches) ||
297
-	        preg_match('/_OID\(([\.0-9\*]+)\)/',$rule,$matches))
296
+	    while (preg_match('/_OID\(([\.0-9\*]+)\)/', $display, $matches) ||
297
+	        preg_match('/_OID\(([\.0-9\*]+)\)/', $rule, $matches))
298 298
 	    {
299 299
 	        $curOid=$matches[1];
300 300
 	        
301
-	        if ( (preg_match('/\*/',$curOid) == 0 ) 
301
+	        if ((preg_match('/\*/', $curOid) == 0) 
302 302
 	            && ($object=$this->getMIB()->translateOID($curOid)) != null)
303 303
 	        {
304 304
 	            array_push($curObjectList, array(
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 	                'not found'
324 324
 	            ));
325 325
 	        }
326
-	        $curOid = preg_replace('/\*/','\*',$curOid);
327
-	        $display=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$display);
328
-	        $rule=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$rule);
326
+	        $curOid=preg_replace('/\*/', '\*', $curOid);
327
+	        $display=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $display);
328
+	        $rule=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $rule);
329 329
 	        $index++;
330 330
 	    }
331 331
 	    return $curObjectList;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		$this->checkConfigPermission();
341 341
 		// set up tab
342 342
 		$this->prepareTabs();
343
-		$this->getTabs()->add('get',array(
343
+		$this->getTabs()->add('get', array(
344 344
 			'active'	=> true,
345 345
 			'label'		=> $this->translate('Add handler'),
346 346
 			'url'		=> Url::fromRequest()
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		
354 354
 		//$this->view->trapvalues=false; // Set to true to display 'value' colum in objects
355 355
 		
356
-		if (($trapid = $this->params->get('fromid')) !== null) {
356
+		if (($trapid=$this->params->get('fromid')) !== null) {
357 357
 		    /********** Setup from existing trap ***************/
358 358
             $this->add_from_existing($trapid);
359 359
 			return;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			$this->view->setRuleMatch=$ruleDetail->action_match;
374 374
 			$this->view->setRuleNoMatch=$ruleDetail->action_nomatch;
375 375
 			$this->view->hostgroupname=$ruleDetail->host_group_name;
376
-			$this->view->modified=gmdate("Y-m-d\TH:i:s\Z",$ruleDetail->modified);
376
+			$this->view->modified=gmdate("Y-m-d\TH:i:s\Z", $ruleDetail->modified);
377 377
 			$this->view->modifier=$ruleDetail->modifier;
378 378
 			
379 379
 			// Warning message if host/service don't exists anymore
@@ -425,26 +425,26 @@  discard block
 block discarded – undo
425 425
 	
426 426
 		$params=array(
427 427
 			// id (also db) => 	array('post' => post id, 'val' => default val, 'db' => send to table)
428
-			'hostgroup'		=>	array('post' => 'hostgroup',                    'db'=>false),
429
-			'db_rule'		=>	array('post' => 'db_rule',                      'db'=>false),
430
-			'hostid'		=>	array('post' => 'hostid',                       'db'=>false),
431
-			'host_name'		=>	array('post' => 'hostname',      'val' => null,  'db'=>true),
432
-			'host_group_name'=>	array('post' => null,            'val' => null,  'db'=>true),
433
-			'serviceid'		=>	array('post' => 'serviceid',                     'db'=>false),
434
-			'service_name'	=>	array('post' => 'serviceName',                    'db'=>true),
435
-			'trap_oid'		=>	array('post' => 'oid',                            'db'=>true),
436
-			'revert_ok'		=>	array('post' => 'revertOK',      'val' => 0,      'db'=>true),
437
-			'display'		=>	array('post' => 'display',        'val' => '',     'db'=>true),
438
-			'rule'			=>	array('post' => 'rule',          'val' => '',        'db'=>true),			
439
-			'action_match'	=>	array('post' => 'ruleMatch',       'val' => -1,    'db'=>true),
440
-			'action_nomatch'=>	array('post' => 'ruleNoMatch',    'val' => -1,    'db'=>true),					
441
-			'ip4'			=>	array('post' => null,             'val' => null,  'db'=>true),
442
-			'ip6'			=>	array('post' => null,             'val' => null,  'db'=>true),
443
-		    'action_form'	=>	array('post' => 'action_form',    'val' => null, 'db'=>false)
428
+			'hostgroup'		=>	array('post' => 'hostgroup', 'db'=>false),
429
+			'db_rule'		=>	array('post' => 'db_rule', 'db'=>false),
430
+			'hostid'		=>	array('post' => 'hostid', 'db'=>false),
431
+			'host_name'		=>	array('post' => 'hostname', 'val' => null, 'db'=>true),
432
+			'host_group_name'=>	array('post' => null, 'val' => null, 'db'=>true),
433
+			'serviceid'		=>	array('post' => 'serviceid', 'db'=>false),
434
+			'service_name'	=>	array('post' => 'serviceName', 'db'=>true),
435
+			'trap_oid'		=>	array('post' => 'oid', 'db'=>true),
436
+			'revert_ok'		=>	array('post' => 'revertOK', 'val' => 0, 'db'=>true),
437
+			'display'		=>	array('post' => 'display', 'val' => '', 'db'=>true),
438
+			'rule'			=>	array('post' => 'rule', 'val' => '', 'db'=>true),			
439
+			'action_match'	=>	array('post' => 'ruleMatch', 'val' => -1, 'db'=>true),
440
+			'action_nomatch'=>	array('post' => 'ruleNoMatch', 'val' => -1, 'db'=>true),					
441
+			'ip4'			=>	array('post' => null, 'val' => null, 'db'=>true),
442
+			'ip6'			=>	array('post' => null, 'val' => null, 'db'=>true),
443
+		    'action_form'	=>	array('post' => 'action_form', 'val' => null, 'db'=>false)
444 444
 		);
445 445
 		
446 446
 		if (isset($postData[$params['action_form']['post']]) 
447
-			&& $postData[$params['action_form']['post']] == 'delete' )
447
+			&& $postData[$params['action_form']['post']] == 'delete')
448 448
 		{
449 449
 			try
450 450
 			{
@@ -464,16 +464,16 @@  discard block
 block discarded – undo
464 464
 		}		
465 465
 		foreach (array_keys($params) as $key)
466 466
 		{
467
-			if ($params[$key]['post']==null) continue; // data not sent in post vars
468
-			if (! isset($postData[$params[$key]['post']]))
467
+			if ($params[$key]['post'] == null) continue; // data not sent in post vars
468
+			if (!isset($postData[$params[$key]['post']]))
469 469
 			{
470 470
 				// should not happen as the js checks data
471
-				$this->_helper->json(array('status'=>'No ' . $key));
471
+				$this->_helper->json(array('status'=>'No '.$key));
472 472
 			}
473 473
 			else
474 474
 			{
475 475
 				$data=$postData[$params[$key]['post']];
476
-				if ($data!=null && $data !="")
476
+				if ($data != null && $data != "")
477 477
 				{
478 478
 					$params[$key]['val']=$postData[$params[$key]['post']];
479 479
 				}
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 
483 483
 		try 
484 484
 		{
485
-			$isHostGroup=($params['hostgroup']['val'] == 1)?true:false;
486
-			if (! $isHostGroup ) 
485
+			$isHostGroup=($params['hostgroup']['val'] == 1) ?true:false;
486
+			if (!$isHostGroup) 
487 487
 			{  // checks if selection by host 
488 488
 			    $hostAddr=$this->getUIDatabase()->getHostInfoByID($params['hostid']['val']);
489 489
 				$params['ip4']['val']=$hostAddr->ip4;
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 				}
497 497
 				if (!is_numeric($params['serviceid']['val']))
498 498
 				{
499
-				    $this->_helper->json(array('status'=>"Invalid service id ". $params['serviceid']['val']));
499
+				    $this->_helper->json(array('status'=>"Invalid service id ".$params['serviceid']['val']));
500 500
 				    return;
501 501
 				}
502 502
 				$serviceName=$this->getUIDatabase()->getObjectNameByid($params['serviceid']['val']);
@@ -515,15 +515,15 @@  discard block
 block discarded – undo
515 515
 					return;					
516 516
 				}
517 517
 				// Put param in correct column (group_name)
518
-				$params['host_group_name']['val'] = $params['host_name']['val'];
518
+				$params['host_group_name']['val']=$params['host_name']['val'];
519 519
 				$params['host_name']['val']=null;
520 520
 			}
521 521
 			$dbparams=array();
522 522
 			foreach ($params as $key=>$val)
523 523
 			{
524
-				if ($val['db']==true )
524
+				if ($val['db'] == true)
525 525
 				{
526
-					$dbparams[$key] = $val['val'];
526
+					$dbparams[$key]=$val['val'];
527 527
 				}
528 528
 			}
529 529
 			// echo '<br>';	print_r($dbparams);echo '<br>';
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 			}
535 535
 			else
536 536
 			{
537
-			    $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
537
+			    $this->getUIDatabase()->updateHandlerRule($dbparams, $params['db_rule']['val']);
538 538
 				$ruleID=$params['db_rule']['val'];
539 539
 			}
540 540
 		}
@@ -553,10 +553,10 @@  discard block
 block discarded – undo
553 553
 	*/
554 554
 	protected function getTrapDetail($trapid) 
555 555
 	{
556
-		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
556
+		if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); }
557 557
 		$queryArray=$this->getModuleConfig()->trapDetailQuery();
558 558
 		
559
-		$dbConn = $this->getUIDatabase()->getDbConn();
559
+		$dbConn=$this->getUIDatabase()->getDbConn();
560 560
 		if ($dbConn === null) throw new \ErrorException('uncatched db error');
561 561
 		// ***************  Get main data
562 562
 		// extract columns and titles;
@@ -566,19 +566,19 @@  discard block
 block discarded – undo
566 566
 		}
567 567
 		try
568 568
 		{		
569
-		    $query = $dbConn->select()
570
-				->from($this->getModuleConfig()->getTrapTableName(),$elmts)
571
-				->where('id=?',$trapid);
569
+		    $query=$dbConn->select()
570
+				->from($this->getModuleConfig()->getTrapTableName(), $elmts)
571
+				->where('id=?', $trapid);
572 572
 				$trapDetail=$dbConn->fetchRow($query);
573
-			if ( $trapDetail == null ) 
573
+			if ($trapDetail == null) 
574 574
 			{
575
-			    $trapDetail = 'NULL';
575
+			    $trapDetail='NULL';
576 576
 			    throw new Exception('No traps was found with id = '.$trapid);
577 577
 			}
578 578
 		}
579 579
 		catch (Exception $e)
580 580
 		{
581
-			$this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage());
581
+			$this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail, true), $e->getMessage());
582 582
 			return;
583 583
 		}
584 584
 
@@ -592,10 +592,10 @@  discard block
 block discarded – undo
592 592
 	*/
593 593
 	protected function getTrapobjects($trapid)
594 594
 	{	
595
-		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
595
+		if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); }
596 596
 		$queryArrayData=$this->getModuleConfig()->trapDataDetailQuery();
597 597
 		
598
-		$dbConn = $this->getUIDatabase()->getDbConn();
598
+		$dbConn=$this->getUIDatabase()->getDbConn();
599 599
 		if ($dbConn === null) throw new \ErrorException('uncatched db error');
600 600
 		// ***************  Get object data
601 601
 		// extract columns and titles;
@@ -605,15 +605,15 @@  discard block
 block discarded – undo
605 605
 		}
606 606
 		try
607 607
 		{		
608
-		    $query = $dbConn->select()
609
-				->from($this->moduleConfig->getTrapDataTableName(),$data_elmts)
610
-				->where('trap_id=?',$trapid);
608
+		    $query=$dbConn->select()
609
+				->from($this->moduleConfig->getTrapDataTableName(), $data_elmts)
610
+				->where('trap_id=?', $trapid);
611 611
 				$trapDetail=$dbConn->fetchAll($query);
612 612
 			// if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid);
613 613
 		}
614 614
 		catch (Exception $e)
615 615
 		{
616
-			$this->displayExitError('Add handler : get trap data detail : ',$e->getMessage());
616
+			$this->displayExitError('Add handler : get trap data detail : ', $e->getMessage());
617 617
 			return array();
618 618
 		}
619 619
 
@@ -627,24 +627,24 @@  discard block
 block discarded – undo
627 627
 	*/
628 628
 	protected function getRuleDetail($ruleid) 
629 629
 	{
630
-		if (!preg_match('/^[0-9]+$/',$ruleid)) { throw new Exception('Invalid id');  }
630
+		if (!preg_match('/^[0-9]+$/', $ruleid)) { throw new Exception('Invalid id'); }
631 631
 		$queryArray=$this->getModuleConfig()->ruleDetailQuery();
632 632
 		
633
-		$dbConn = $this->getUIDatabase()->getDbConn();
633
+		$dbConn=$this->getUIDatabase()->getDbConn();
634 634
 		if ($dbConn === null) throw new \ErrorException('uncatched db error');
635 635
 		// ***************  Get main data
636 636
 		try
637 637
 		{		
638
-		    $query = $dbConn->select()
639
-				->from($this->getModuleConfig()->getTrapRuleName(),$queryArray)
640
-				->where('id=?',$ruleid);
638
+		    $query=$dbConn->select()
639
+				->from($this->getModuleConfig()->getTrapRuleName(), $queryArray)
640
+				->where('id=?', $ruleid);
641 641
 			$ruleDetail=$dbConn->fetchRow($query);
642
-			if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid);
642
+			if ($ruleDetail == null) throw new Exception('No rule was found with id = '.$ruleid);
643 643
 		}
644 644
 		catch (Exception $e)
645 645
 		{
646
-			$this->displayExitError('Update handler : get rule detail',$e->getMessage());
647
-			throw new Exception('Error : ' . $e->getMessage());
646
+			$this->displayExitError('Update handler : get rule detail', $e->getMessage());
647
+			throw new Exception('Error : '.$e->getMessage());
648 648
 		}
649 649
 
650 650
 		return $ruleDetail;
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 	{
658 658
 		return $this->getTabs()->add('status', array(
659 659
 			'label' => $this->translate('Trap handlers'),
660
-			'url'   => $this->getModuleConfig()->urlPath() . '/handler')
660
+			'url'   => $this->getModuleConfig()->urlPath().'/handler')
661 661
 		);
662 662
 	} 
663 663
 	
Please login to merge, or discard this patch.