Passed
Push — master ( 9a2ce8...395129 )
by Patrick
02:01
created
library/Trapdirector/Tables/HandlerTable.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -56,13 +56,11 @@  discard block
 block discarded – undo
56 56
                               if (isset($oidName['name']))
57 57
                               {
58 58
                                   $val=$oidName['name'];
59
-                              }
60
-                              else
59
+                              } else
61 60
                               {
62 61
                                   $val = $row->$rowkey;
63 62
                               }
64
-                          }
65
-                          else
63
+                          } else
66 64
                           {
67 65
                               $val = $row->$rowkey;
68 66
                           }
@@ -71,8 +69,7 @@  discard block
 block discarded – undo
71 69
                           if ($row->$rowkey == null)
72 70
                           {
73 71
                               $val = $row->host_group_name;
74
-                          }
75
-                          else
72
+                          } else
76 73
                           {
77 74
                               $val = $row->$rowkey;
78 75
                           }
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapTableList.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -212,7 +212,9 @@  discard block
 block discarded – undo
212 212
 			$first=1;
213 213
 			foreach($this->moduleConfig->getTrapListSearchColumns() as $column)
214 214
 			{
215
-				if ($first==0) $sql.=' OR ';
215
+				if ($first==0) {
216
+					$sql.=' OR ';
217
+				}
216 218
 				$first=0;
217 219
 				$sql.=" CAST(".$column." AS  char(100))  LIKE  '%".$this->filter_query."%' ";
218 220
 			}
@@ -220,10 +222,14 @@  discard block
 block discarded – undo
220 222
 		}
221 223
 		if ($this->filter_done == 1)
222 224
 		{
223
-			if ($sql != '') $sql.=' AND ';
225
+			if ($sql != '') {
226
+				$sql.=' AND ';
227
+			}
224 228
 			$sql.="(status != 'done')";
225 229
 		}
226
-		if ($sql != '') $query->where($sql);	
230
+		if ($sql != '') {
231
+			$query->where($sql);
232
+		}
227 233
         return $query;
228 234
     }	
229 235
 
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapDirectorTable.php 1 patch
Braces   +38 added lines, -20 removed lines patch added patch discarded remove patch
@@ -82,17 +82,21 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $actionURL = $this->getCurrentURL() . '?' ;
84 84
         $QSList=array();
85
-        if ($caller != 'filter' && $this->curFilterQuery() != '')
86
-            array_push($QSList , $this->curFilterQuery());
85
+        if ($caller != 'filter' && $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
+        if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') {
90
+                    array_push($QSList , $this->curPagingQuery());
91
+        }
90 92
  
91
-        if ($caller != 'order' && $this->curOrderQuery() != '')
92
-            array_push($QSList , $this->curOrderQuery());
93
+        if ($caller != 'order' && $this->curOrderQuery() != '') {
94
+                    array_push($QSList , $this->curOrderQuery());
95
+        }
93 96
         
94
-        if (count($QSList) != 0)
95
-            $actionURL .=  implode('&', $QSList);
97
+        if (count($QSList) != 0) {
98
+                    $actionURL .=  implode('&', $QSList);
99
+        }
96 100
         
97 101
         return $actionURL;
98 102
     }
@@ -135,7 +139,9 @@  discard block
 block discarded – undo
135 139
         $filter='';
136 140
         foreach ($this->filterColumn as $column)
137 141
         {
138
-            if ($filter != "") $filter.=' OR ';
142
+            if ($filter != "") {
143
+            	$filter.=' OR ';
144
+            }
139 145
             //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'";
140 146
             $filter .= $column  . " LIKE '%" . $this->filterString. "%'";
141 147
         }
@@ -179,7 +185,9 @@  discard block
 block discarded – undo
179 185
     
180 186
     protected function curFilterQuery()
181 187
     {
182
-        if ($this->filterQuery == '') return '';
188
+        if ($this->filterQuery == '') {
189
+        	return '';
190
+        }
183 191
         return 'f='.$this->filterQuery;
184 192
     }
185 193
     
@@ -193,7 +201,9 @@  discard block
 block discarded – undo
193 201
         $orderSQL='';
194 202
         foreach ($this->order as $column => $direction)
195 203
         {
196
-            if ($orderSQL != "") $orderSQL.=',';
204
+            if ($orderSQL != "") {
205
+            	$orderSQL.=',';
206
+            }
197 207
             
198 208
             $orderSQL .= $column . ' ' . $direction;
199 209
         }
@@ -219,7 +229,9 @@  discard block
 block discarded – undo
219 229
     
220 230
     protected function curOrderQuery()
221 231
     {
222
-        if ($this->orderQuery == '') return '';
232
+        if ($this->orderQuery == '') {
233
+        	return '';
234
+        }
223 235
         return 'o='.$this->orderQuery;
224 236
     }
225 237
     
@@ -256,7 +268,9 @@  discard block
 block discarded – undo
256 268
 
257 269
     protected function curPagingQuery()
258 270
     {
259
-        if ($this->currentPage == '') return '';
271
+        if ($this->currentPage == '') {
272
+        	return '';
273
+        }
260 274
         return 'page='.$this->currentPage;
261 275
     }
262 276
     
@@ -268,10 +282,14 @@  discard block
 block discarded – undo
268 282
             return  'count : ' . $this->count() . '<br>';
269 283
         }
270 284
         
271
-        if ($this->currentPage == 0) $this->currentPage = 1;
285
+        if ($this->currentPage == 0) {
286
+        	$this->currentPage = 1;
287
+        }
272 288
         
273 289
         $numPages = intdiv($count , $this->maxPerPage);
274
-        if ($count % $this->maxPerPage != 0 ) $numPages++;
290
+        if ($count % $this->maxPerPage != 0 ) {
291
+        	$numPages++;
292
+        }
275 293
         
276 294
         $html = '<div class="pagination-control" role="navigation">';
277 295
         $html .= '<ul class="nav tab-nav">';
@@ -285,8 +303,7 @@  discard block
 block discarded – undo
285 303
                      </span>
286 304
                 </li>
287 305
                ';
288
-        }
289
-        else 
306
+        } else 
290 307
         {
291 308
             $html .= '
292 309
                 <li class="nav-item">
@@ -302,7 +319,9 @@  discard block
 block discarded – undo
302 319
             $active = ($this->currentPage == $i) ? 'active' : '';
303 320
             $first = ($i-1)*$this->maxPerPage+1;
304 321
             $last = $i * $this->maxPerPage;
305
-            if ($last > $count) $last = $count;
322
+            if ($last > $count) {
323
+            	$last = $count;
324
+            }
306 325
             $display = 'Show rows '. $first . ' to '. $last .' of '. $count;
307 326
             $html .= '<li class="' . $active . ' nav-item">
308 327
                     <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '">
@@ -321,8 +340,7 @@  discard block
 block discarded – undo
321 340
                      </span>
322 341
                 </li>
323 342
                ';
324
-        }
325
-        else
343
+        } else
326 344
         {
327 345
             $html .= '
328 346
                 <li class="nav-item">
Please login to merge, or discard this patch.
application/controllers/HandlerController.php 1 patch
Braces   +44 added lines, -42 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 		$this->prepareTabs()->activate('status');
26 26
 
27 27
 		$dbConn = $this->getUIDatabase()->getDb();
28
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
28
+		if ($dbConn === null) {
29
+			throw new \ErrorException('uncatched db error');
30
+		}
29 31
 		
30 32
 		$this->view->handlerTable = new HandlerTable(
31 33
 		      $this->moduleConfig->getTrapRuleName(),
@@ -71,8 +73,7 @@  discard block
 block discarded – undo
71 73
 	    if ($this->params->get('rule') !== null) 
72 74
 	    {
73 75
 	        $this->view->rule= $this->params->get('rule');
74
-	    }
75
-	    else
76
+	    } else
76 77
 	    {
77 78
 	        $this->view->rule='';
78 79
 	    }
@@ -126,8 +127,7 @@  discard block
 block discarded – undo
126 127
 	    try
127 128
 	    {
128 129
 	        $hosts=$this->getUIDatabase()->getHostByIP($hostfilter);
129
-	    }
130
-	    catch (Exception $e)
130
+	    } catch (Exception $e)
131 131
 	    {
132 132
 	        $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
133 133
 	    }
@@ -140,8 +140,7 @@  discard block
 block discarded – undo
140 140
 	        // Tell JS to get services when page is loaded
141 141
 	        $this->view->serviceGet=true;
142 142
 	        
143
-	    }
144
-	    else
143
+	    } else
145 144
 	    {
146 145
 	        foreach($hosts as $key=>$val)
147 146
 	        {
@@ -191,11 +190,14 @@  discard block
 block discarded – undo
191 190
 	            $allObjects[$val->oid]=null;
192 191
 	        }
193 192
 	    }
194
-	    if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
193
+	    if ($allObjects!=null) {
194
+	    	// 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
+	    }
200
+	    }
199 201
 	            array_push($this->view->objectList, array(
200 202
 	                $oid_index,
201 203
 	                $key,
@@ -227,8 +229,7 @@  discard block
 block discarded – undo
227 229
 	    {
228 230
 	        $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
229 231
 	        $this->view->serviceGet=false;
230
-	    }
231
-	    else
232
+	    } else
232 233
 	    {
233 234
 	        // Tell JS to get services when page is loaded
234 235
 	        $this->view->serviceGet=true;
@@ -237,8 +238,7 @@  discard block
 block discarded – undo
237 238
 	        if (count($serviceID) ==0)
238 239
 	        {
239 240
 	            $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
240
-	        }
241
-	        else
241
+	        } else
242 242
 	        {
243 243
 	            $this->view->serviceSet=$serviceID[0]->id;
244 244
 	        }
@@ -257,8 +257,7 @@  discard block
 block discarded – undo
257 257
 	    {
258 258
 	        $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
259 259
 	        $this->view->serviceGroupGet=false;
260
-	    }
261
-	    else
260
+	    } else
262 261
 	    {
263 262
 	        $grpServices=$this->getUIDatabase()->getServicesByHostGroupid($group_get[0]->id);
264 263
 	        $foundGrpService=0;
@@ -310,8 +309,7 @@  discard block
 block discarded – undo
310 309
 	                $object['type'],
311 310
 	                $object['type_enum']
312 311
 	            ));
313
-	        }
314
-	        else
312
+	        } else
315 313
 	        {
316 314
 	            array_push($curObjectList, array(
317 315
 	                $index,
@@ -383,8 +381,7 @@  discard block
 block discarded – undo
383 381
 			    $this->view->selectGroup=false;
384 382
 			    // Check if hostname still exists
385 383
 			    $this->add_check_host_exists($ruleDetail);
386
-			}
387
-			else
384
+			} else
388 385
 			{
389 386
 			    $this->view->selectGroup=true;
390 387
 			    $this->add_check_hostgroup_exists($ruleDetail); //  Check if groupe exists				
@@ -392,9 +389,11 @@  discard block
 block discarded – undo
392 389
 			
393 390
 			$this->view->mainoid=$ruleDetail->trap_oid;
394 391
 			$oidName=$this->getMIB()->translateOID($ruleDetail->trap_oid);
395
-			if ($oidName != null)  // oid is found in mibs
392
+			if ($oidName != null) {
393
+				// oid is found in mibs
396 394
 			{
397
-				$this->view->mib=$oidName['mib']; 
395
+				$this->view->mib=$oidName['mib'];
396
+			}
398 397
 				$this->view->name=$oidName['name'];
399 398
 				$this->view->trapListForMIB=$this->getMIB()
400 399
 					->getTrapList($oidName['mib']);				
@@ -449,8 +448,7 @@  discard block
 block discarded – undo
449 448
 			try
450 449
 			{
451 450
 			    $this->getUIDatabase()->deleteRule($postData[$params['db_rule']['post']]);
452
-			}
453
-			catch (Exception $e)
451
+			} catch (Exception $e)
454 452
 			{
455 453
 				$this->_helper->json(array('status'=>$e->getMessage()));
456 454
 				return;
@@ -464,13 +462,15 @@  discard block
 block discarded – undo
464 462
 		}		
465 463
 		foreach (array_keys($params) as $key)
466 464
 		{
467
-			if ($params[$key]['post']==null) continue; // data not sent in post vars
465
+			if ($params[$key]['post']==null) {
466
+				continue;
467
+			}
468
+			// data not sent in post vars
468 469
 			if (! isset($postData[$params[$key]['post']]))
469 470
 			{
470 471
 				// should not happen as the js checks data
471 472
 				$this->_helper->json(array('status'=>'No ' . $key));
472
-			}
473
-			else
473
+			} else
474 474
 			{
475 475
 				$data=$postData[$params[$key]['post']];
476 476
 				if ($data!=null && $data !="")
@@ -505,8 +505,7 @@  discard block
 block discarded – undo
505 505
 					$this->_helper->json(array('status'=>"Invalid service id : Please re enter service"));
506 506
 					return;
507 507
 				}
508
-			}
509
-			else
508
+			} else
510 509
 			{
511 510
 			    $object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']);
512 511
 				if ($params['host_name']['val'] != $object->name1)
@@ -531,14 +530,12 @@  discard block
 block discarded – undo
531 530
 			if ($params['db_rule']['val'] == -1 || $params['action_form']['val'] == 'clone') 
532 531
 			{  // If no rule number or action is clone, add the handler
533 532
 			    $ruleID=$this->getUIDatabase()->addHandlerRule($dbparams);
534
-			}
535
-			else
533
+			} else
536 534
 			{
537 535
 			    $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
538 536
 				$ruleID=$params['db_rule']['val'];
539 537
 			}
540
-		}
541
-		catch (Exception $e)
538
+		} catch (Exception $e)
542 539
 		{
543 540
 			$this->_helper->json(array('status'=>$e->getMessage()));
544 541
 			return;
@@ -557,7 +554,9 @@  discard block
 block discarded – undo
557 554
 		$queryArray=$this->getModuleConfig()->trapDetailQuery();
558 555
 		
559 556
 		$dbConn = $this->getUIDatabase()->getDbConn();
560
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
557
+		if ($dbConn === null) {
558
+			throw new \ErrorException('uncatched db error');
559
+		}
561 560
 		// ***************  Get main data
562 561
 		// extract columns and titles;
563 562
 		$elmts=NULL;
@@ -575,8 +574,7 @@  discard block
 block discarded – undo
575 574
 			    $trapDetail = 'NULL';
576 575
 			    throw new Exception('No traps was found with id = '.$trapid);
577 576
 			}
578
-		}
579
-		catch (Exception $e)
577
+		} catch (Exception $e)
580 578
 		{
581 579
 			$this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage());
582 580
 			return;
@@ -596,7 +594,9 @@  discard block
 block discarded – undo
596 594
 		$queryArrayData=$this->getModuleConfig()->trapDataDetailQuery();
597 595
 		
598 596
 		$dbConn = $this->getUIDatabase()->getDbConn();
599
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
597
+		if ($dbConn === null) {
598
+			throw new \ErrorException('uncatched db error');
599
+		}
600 600
 		// ***************  Get object data
601 601
 		// extract columns and titles;
602 602
 		$data_elmts=NULL;
@@ -610,8 +610,7 @@  discard block
 block discarded – undo
610 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
-		}
614
-		catch (Exception $e)
613
+		} catch (Exception $e)
615 614
 		{
616 615
 			$this->displayExitError('Add handler : get trap data detail : ',$e->getMessage());
617 616
 			return array();
@@ -631,7 +630,9 @@  discard block
 block discarded – undo
631 630
 		$queryArray=$this->getModuleConfig()->ruleDetailQuery();
632 631
 		
633 632
 		$dbConn = $this->getUIDatabase()->getDbConn();
634
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
633
+		if ($dbConn === null) {
634
+			throw new \ErrorException('uncatched db error');
635
+		}
635 636
 		// ***************  Get main data
636 637
 		try
637 638
 		{		
@@ -639,9 +640,10 @@  discard block
 block discarded – undo
639 640
 				->from($this->getModuleConfig()->getTrapRuleName(),$queryArray)
640 641
 				->where('id=?',$ruleid);
641 642
 			$ruleDetail=$dbConn->fetchRow($query);
642
-			if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid);
643
-		}
644
-		catch (Exception $e)
643
+			if ( $ruleDetail == null ) {
644
+				throw new Exception('No rule was found with id = '.$ruleid);
645
+			}
646
+		} catch (Exception $e)
645 647
 		{
646 648
 			$this->displayExitError('Update handler : get rule detail',$e->getMessage());
647 649
 			throw new Exception('Error : ' . $e->getMessage());
Please login to merge, or discard this patch.