Passed
Push — master ( b6634d...971a50 )
by Patrick
01:58
created
application/controllers/HandlerController.php 1 patch
Braces   +44 added lines, -42 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 		$this->prepareTabs()->activate('status');
25 25
 
26 26
 		$dbConn = $this->getUIDatabase()->getDb();
27
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
27
+		if ($dbConn === null) {
28
+			throw new \ErrorException('uncatched db error');
29
+		}
28 30
 		
29 31
 		$this->getHandlerListTable()->setConnection($dbConn);
30 32
 		$this->getHandlerListTable()->setMibloader($this->getMIB());
@@ -52,8 +54,7 @@  discard block
 block discarded – undo
52 54
 	    if ($this->params->get('rule') !== null) 
53 55
 	    {
54 56
 	        $this->view->rule= $this->params->get('rule');
55
-	    }
56
-	    else
57
+	    } else
57 58
 	    {
58 59
 	        $this->view->rule='';
59 60
 	    }
@@ -107,8 +108,7 @@  discard block
 block discarded – undo
107 108
 	    try
108 109
 	    {
109 110
 	        $hosts=$this->getUIDatabase()->getHostByIP($hostfilter);
110
-	    }
111
-	    catch (Exception $e)
111
+	    } catch (Exception $e)
112 112
 	    {
113 113
 	        $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
114 114
 	    }
@@ -121,8 +121,7 @@  discard block
 block discarded – undo
121 121
 	        // Tell JS to get services when page is loaded
122 122
 	        $this->view->serviceGet=true;
123 123
 	        
124
-	    }
125
-	    else
124
+	    } else
126 125
 	    {
127 126
 	        foreach($hosts as $key=>$val)
128 127
 	        {
@@ -172,11 +171,14 @@  discard block
 block discarded – undo
172 171
 	            $allObjects[$val->oid]=null;
173 172
 	        }
174 173
 	    }
175
-	    if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
174
+	    if ($allObjects!=null) {
175
+	    	// in case trap doesn't have objects or is not resolved
176 176
 	    {
177 177
 	        foreach ($allObjects as $key => $val)
178 178
 	        {
179
-	            if ($val==null) { continue; }
179
+	            if ($val==null) { continue;
180
+	    }
181
+	    }
180 182
 	            array_push($this->view->objectList, array(
181 183
 	                $oid_index,
182 184
 	                $key,
@@ -208,8 +210,7 @@  discard block
 block discarded – undo
208 210
 	    {
209 211
 	        $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
210 212
 	        $this->view->serviceGet=false;
211
-	    }
212
-	    else
213
+	    } else
213 214
 	    {
214 215
 	        // Tell JS to get services when page is loaded
215 216
 	        $this->view->serviceGet=true;
@@ -218,8 +219,7 @@  discard block
 block discarded – undo
218 219
 	        if (count($serviceID) ==0)
219 220
 	        {
220 221
 	            $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
221
-	        }
222
-	        else
222
+	        } else
223 223
 	        {
224 224
 	            $this->view->serviceSet=$serviceID[0]->id;
225 225
 	        }
@@ -238,8 +238,7 @@  discard block
 block discarded – undo
238 238
 	    {
239 239
 	        $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
240 240
 	        $this->view->serviceGroupGet=false;
241
-	    }
242
-	    else
241
+	    } else
243 242
 	    {
244 243
 	        $grpServices=$this->getUIDatabase()->getServicesByHostGroupid($group_get[0]->id);
245 244
 	        $foundGrpService=0;
@@ -291,8 +290,7 @@  discard block
 block discarded – undo
291 290
 	                $object['type'],
292 291
 	                $object['type_enum']
293 292
 	            ));
294
-	        }
295
-	        else
293
+	        } else
296 294
 	        {
297 295
 	            array_push($curObjectList, array(
298 296
 	                $index,
@@ -363,8 +361,7 @@  discard block
 block discarded – undo
363 361
 			    $this->view->selectGroup=false;
364 362
 			    // Check if hostname still exists
365 363
 			    $this->add_check_host_exists($ruleDetail);
366
-			}
367
-			else
364
+			} else
368 365
 			{
369 366
 			    $this->view->selectGroup=true;
370 367
 			    $this->add_check_hostgroup_exists($ruleDetail); //  Check if groupe exists				
@@ -372,9 +369,11 @@  discard block
 block discarded – undo
372 369
 			
373 370
 			$this->view->mainoid=$ruleDetail->trap_oid;
374 371
 			$oidName=$this->getMIB()->translateOID($ruleDetail->trap_oid);
375
-			if ($oidName != null)  // oid is found in mibs
372
+			if ($oidName != null) {
373
+				// oid is found in mibs
376 374
 			{
377
-				$this->view->mib=$oidName['mib']; 
375
+				$this->view->mib=$oidName['mib'];
376
+			}
378 377
 				$this->view->name=$oidName['name'];
379 378
 				$this->view->trapListForMIB=$this->getMIB()
380 379
 					->getTrapList($oidName['mib']);				
@@ -429,8 +428,7 @@  discard block
 block discarded – undo
429 428
 			try
430 429
 			{
431 430
 			    $this->getUIDatabase()->deleteRule($postData[$params['db_rule']['post']]);
432
-			}
433
-			catch (Exception $e)
431
+			} catch (Exception $e)
434 432
 			{
435 433
 				$this->_helper->json(array('status'=>$e->getMessage()));
436 434
 				return;
@@ -444,13 +442,15 @@  discard block
 block discarded – undo
444 442
 		}		
445 443
 		foreach (array_keys($params) as $key)
446 444
 		{
447
-			if ($params[$key]['post']==null) continue; // data not sent in post vars
445
+			if ($params[$key]['post']==null) {
446
+				continue;
447
+			}
448
+			// data not sent in post vars
448 449
 			if (! isset($postData[$params[$key]['post']]))
449 450
 			{
450 451
 				// should not happen as the js checks data
451 452
 				$this->_helper->json(array('status'=>'No ' . $key));
452
-			}
453
-			else
453
+			} else
454 454
 			{
455 455
 				$data=$postData[$params[$key]['post']];
456 456
 				if ($data!=null && $data !="")
@@ -485,8 +485,7 @@  discard block
 block discarded – undo
485 485
 					$this->_helper->json(array('status'=>"Invalid service id : Please re enter service"));
486 486
 					return;
487 487
 				}
488
-			}
489
-			else
488
+			} else
490 489
 			{
491 490
 			    $object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']);
492 491
 				if ($params['host_name']['val'] != $object->name1)
@@ -511,14 +510,12 @@  discard block
 block discarded – undo
511 510
 			if ($params['db_rule']['val'] == -1 || $params['action_form']['val'] == 'clone') 
512 511
 			{  // If no rule number or action is clone, add the handler
513 512
 			    $ruleID=$this->getUIDatabase()->addHandlerRule($dbparams);
514
-			}
515
-			else
513
+			} else
516 514
 			{
517 515
 			    $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
518 516
 				$ruleID=$params['db_rule']['val'];
519 517
 			}
520
-		}
521
-		catch (Exception $e)
518
+		} catch (Exception $e)
522 519
 		{
523 520
 			$this->_helper->json(array('status'=>$e->getMessage()));
524 521
 			return;
@@ -537,7 +534,9 @@  discard block
 block discarded – undo
537 534
 		$queryArray=$this->getModuleConfig()->trapDetailQuery();
538 535
 		
539 536
 		$dbConn = $this->getUIDatabase()->getDbConn();
540
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
537
+		if ($dbConn === null) {
538
+			throw new \ErrorException('uncatched db error');
539
+		}
541 540
 		// ***************  Get main data
542 541
 		// extract columns and titles;
543 542
 		$elmts=NULL;
@@ -555,8 +554,7 @@  discard block
 block discarded – undo
555 554
 			    $trapDetail = 'NULL';
556 555
 			    throw new Exception('No traps was found with id = '.$trapid);
557 556
 			}
558
-		}
559
-		catch (Exception $e)
557
+		} catch (Exception $e)
560 558
 		{
561 559
 			$this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage());
562 560
 			return;
@@ -576,7 +574,9 @@  discard block
 block discarded – undo
576 574
 		$queryArrayData=$this->getModuleConfig()->trapDataDetailQuery();
577 575
 		
578 576
 		$dbConn = $this->getUIDatabase()->getDbConn();
579
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
577
+		if ($dbConn === null) {
578
+			throw new \ErrorException('uncatched db error');
579
+		}
580 580
 		// ***************  Get object data
581 581
 		// extract columns and titles;
582 582
 		$data_elmts=NULL;
@@ -590,8 +590,7 @@  discard block
 block discarded – undo
590 590
 				->where('trap_id=?',$trapid);
591 591
 				$trapDetail=$dbConn->fetchAll($query);
592 592
 			// if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid);
593
-		}
594
-		catch (Exception $e)
593
+		} catch (Exception $e)
595 594
 		{
596 595
 			$this->displayExitError('Add handler : get trap data detail : ',$e->getMessage());
597 596
 			return array();
@@ -611,7 +610,9 @@  discard block
 block discarded – undo
611 610
 		$queryArray=$this->getModuleConfig()->ruleDetailQuery();
612 611
 		
613 612
 		$dbConn = $this->getUIDatabase()->getDbConn();
614
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
613
+		if ($dbConn === null) {
614
+			throw new \ErrorException('uncatched db error');
615
+		}
615 616
 		// ***************  Get main data
616 617
 		try
617 618
 		{		
@@ -619,9 +620,10 @@  discard block
 block discarded – undo
619 620
 				->from($this->getModuleConfig()->getTrapRuleName(),$queryArray)
620 621
 				->where('id=?',$ruleid);
621 622
 			$ruleDetail=$dbConn->fetchRow($query);
622
-			if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid);
623
-		}
624
-		catch (Exception $e)
623
+			if ( $ruleDetail == null ) {
624
+				throw new Exception('No rule was found with id = '.$ruleid);
625
+			}
626
+		} catch (Exception $e)
625 627
 		{
626 628
 			$this->displayExitError('Update handler : get rule detail',$e->getMessage());
627 629
 			throw new Exception('Error : ' . $e->getMessage());
Please login to merge, or discard this patch.