Passed
Push — master ( 1d8afe...b3ce84 )
by Patrick
02:10
created
library/Trapdirector/Tables/HandlerTable.php 1 patch
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
     {
32 32
         if ($this->groupingColumn == 'rule_type')
33 33
         {
34
-            if ($this->categories == NULL || (! isset($this->categories[$value])))
35
-                return 'Unknown category ('.$value.')';
34
+            if ($this->categories == NULL || (! isset($this->categories[$value]))) {
35
+                            return 'Unknown category ('.$value.')';
36
+            }
36 37
             return 'Category : '. $this->categories[$value];
37 38
         }
38 39
         $html = "$value";
@@ -86,13 +87,11 @@  discard block
 block discarded – undo
86 87
                               if (isset($oidName['name']))
87 88
                               {
88 89
                                   $val=$oidName['name'];
89
-                              }
90
-                              else
90
+                              } else
91 91
                               {
92 92
                                   $val = $row->$rowkey;
93 93
                               }
94
-                          }
95
-                          else
94
+                          } else
96 95
                           {
97 96
                               $val = $row->$rowkey;
98 97
                           }
@@ -101,8 +100,7 @@  discard block
 block discarded – undo
101 100
                           if ($row->$rowkey == null)
102 101
                           {
103 102
                               $val = $row->host_group_name;
104
-                          }
105
-                          else
103
+                          } else
106 104
                           {
107 105
                               $val = $row->$rowkey;
108 106
                           }
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapDirectorTable.php 1 patch
Braces   +47 added lines, -28 removed lines patch added patch discarded remove patch
@@ -88,17 +88,21 @@  discard block
 block discarded – undo
88 88
     {
89 89
         $actionURL = $this->getCurrentURL() . '?' ;
90 90
         $QSList=array();
91
-        if ($caller != 'filter' && $this->curFilterQuery() != '')
92
-            array_push($QSList , $this->curFilterQuery());
91
+        if ($caller != 'filter' && $this->curFilterQuery() != '') {
92
+                    array_push($QSList , $this->curFilterQuery());
93
+        }
93 94
         
94
-        if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '')
95
-            array_push($QSList , $this->curPagingQuery());
95
+        if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') {
96
+                    array_push($QSList , $this->curPagingQuery());
97
+        }
96 98
  
97
-        if ($caller != 'order' && $this->curOrderQuery() != '')
98
-            array_push($QSList , $this->curOrderQuery());
99
+        if ($caller != 'order' && $this->curOrderQuery() != '') {
100
+                    array_push($QSList , $this->curOrderQuery());
101
+        }
99 102
         
100
-        if (count($QSList) != 0)
101
-            $actionURL .=  implode('&', $QSList) . '&';
103
+        if (count($QSList) != 0) {
104
+                    $actionURL .=  implode('&', $QSList) . '&';
105
+        }
102 106
         
103 107
         return $actionURL;
104 108
     }
@@ -142,7 +146,9 @@  discard block
 block discarded – undo
142 146
         $filter='';
143 147
         foreach ($this->filterColumn as $column)
144 148
         {
145
-            if ($filter != "") $filter.=' OR ';
149
+            if ($filter != "") {
150
+            	$filter.=' OR ';
151
+            }
146 152
             //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'";
147 153
             $filter .= $column  . " LIKE '%" . $this->filterString. "%'";
148 154
         }
@@ -185,7 +191,9 @@  discard block
 block discarded – undo
185 191
     
186 192
     protected function curFilterQuery()
187 193
     {
188
-        if ($this->filterQuery == '') return '';
194
+        if ($this->filterQuery == '') {
195
+        	return '';
196
+        }
189 197
         return 'f='.$this->filterQuery;
190 198
     }
191 199
     
@@ -200,7 +208,9 @@  discard block
 block discarded – undo
200 208
         $orderSQL='';
201 209
         foreach ($this->order as $column => $direction)
202 210
         {
203
-            if ($orderSQL != "") $orderSQL.=',';
211
+            if ($orderSQL != "") {
212
+            	$orderSQL.=',';
213
+            }
204 214
             
205 215
             $orderSQL .= $column . ' ' . $direction;
206 216
         }
@@ -217,7 +227,9 @@  discard block
 block discarded – undo
217 227
 
218 228
     public function isOrderSet()
219 229
     {
220
-        if (count($this->order == 0)) return FALSE;
230
+        if (count($this->order == 0)) {
231
+        	return FALSE;
232
+        }
221 233
         return TRUE;
222 234
     }
223 235
     
@@ -238,7 +250,9 @@  discard block
 block discarded – undo
238 250
     
239 251
     protected function curOrderQuery()
240 252
     {
241
-        if ($this->orderQuery == '') return '';
253
+        if ($this->orderQuery == '') {
254
+        	return '';
255
+        }
242 256
         return 'o='.$this->orderQuery;
243 257
     }
244 258
     
@@ -276,7 +290,9 @@  discard block
 block discarded – undo
276 290
 
277 291
     protected function curPagingQuery()
278 292
     {
279
-        if ($this->currentPage == '') return '';
293
+        if ($this->currentPage == '') {
294
+        	return '';
295
+        }
280 296
         return 'page='.$this->currentPage;
281 297
     }
282 298
     
@@ -288,10 +304,14 @@  discard block
 block discarded – undo
288 304
             return  'count : ' . $this->count() . '<br>';
289 305
         }
290 306
         
291
-        if ($this->currentPage == 0) $this->currentPage = 1;
307
+        if ($this->currentPage == 0) {
308
+        	$this->currentPage = 1;
309
+        }
292 310
         
293 311
         $numPages = intdiv($count , $this->maxPerPage);
294
-        if ($count % $this->maxPerPage != 0 ) $numPages++;
312
+        if ($count % $this->maxPerPage != 0 ) {
313
+        	$numPages++;
314
+        }
295 315
         
296 316
         $html = '<div class="pagination-control" role="navigation">';
297 317
         $html .= '<ul class="nav tab-nav">';
@@ -305,8 +325,7 @@  discard block
 block discarded – undo
305 325
                      </span>
306 326
                 </li>
307 327
                ';
308
-        }
309
-        else 
328
+        } else 
310 329
         {
311 330
             $html .= '
312 331
                 <li class="nav-item">
@@ -322,7 +341,9 @@  discard block
 block discarded – undo
322 341
             $active = ($this->currentPage == $i) ? 'active' : '';
323 342
             $first = ($i-1)*$this->maxPerPage+1;
324 343
             $last = $i * $this->maxPerPage;
325
-            if ($last > $count) $last = $count;
344
+            if ($last > $count) {
345
+            	$last = $count;
346
+            }
326 347
             $display = 'Show rows '. $first . ' to '. $last .' of '. $count;
327 348
             $html .= '<li class="' . $active . ' nav-item">
328 349
                     <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '">
@@ -341,8 +362,7 @@  discard block
 block discarded – undo
341 362
                      </span>
342 363
                 </li>
343 364
                ';
344
-        }
345
-        else
365
+        } else
346 366
         {
347 367
             $html .= '
348 368
                 <li class="nav-item">
@@ -386,7 +406,9 @@  discard block
 block discarded – undo
386 406
     
387 407
     public function groupingNextLine( $values)
388 408
     {
389
-        if ($this->grouppingActive === FALSE) return '';
409
+        if ($this->grouppingActive === FALSE) {
410
+        	return '';
411
+        }
390 412
         
391 413
         $dbcol = $this->groupingColumn;
392 414
         if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol )
@@ -419,20 +441,17 @@  discard block
 block discarded – undo
419 441
                     if ($this->order[$titleOrder] == 'ASC')
420 442
                     {
421 443
                         $titleOrder.='DESC';
422
-                    }
423
-                    else
444
+                    } else
424 445
                     {
425 446
                         $titleOrder.='ASC';
426 447
                     }
427
-                }
428
-                else 
448
+                } else 
429 449
                 {
430 450
                     $titleOrder.='ASC';
431 451
                 }
432 452
                 $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder;
433 453
                 $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>';
434
-            }
435
-            else 
454
+            } else 
436 455
             {
437 456
                 $html .= '<th>' . $values . '</th>';
438 457
             }          
Please login to merge, or discard this patch.
library/Trapdirector/TrapsController.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -209,7 +209,9 @@  discard block
 block discarded – undo
209 209
 		if ($this->MIBData == null)
210 210
 		{
211 211
 		    $dbConn = $this->getUIDatabase()->getDbConn();
212
-		    if ($dbConn === null) throw new \ErrorException('uncatched db error');
212
+		    if ($dbConn === null) {
213
+		    	throw new \ErrorException('uncatched db error');
214
+		    }
213 215
 			$this->MIBData=new MIBLoader(
214 216
 				$this->Config()->get('config', 'snmptranslate'),
215 217
 				$this->Config()->get('config', 'snmptranslate_dirs'),
@@ -279,7 +281,9 @@  discard block
 block discarded – undo
279 281
 	    $catString='';
280 282
 	    foreach ($catArray as $index => $value)
281 283
 	    {
282
-	        if ($catString != '' ) $catString .= '!';
284
+	        if ($catString != '' ) {
285
+	        	$catString .= '!';
286
+	        }
283 287
 	        $catString .= $index . ':' . $value;
284 288
 	    }
285 289
 	    $this->getUIDatabase()->setDBConfigValue('handler_categories', $catString);
@@ -289,8 +293,12 @@  discard block
 block discarded – undo
289 293
 	{
290 294
 	    $catArray = $this->getHandlersCategory();
291 295
 	    $i=1;
292
-	    while (isset($catArray[$i]) && $i < 100) $i++;
293
-	    if ($i == 100) throw new ProgrammingError('Category array error');
296
+	    while (isset($catArray[$i]) && $i < 100) {
297
+	    	$i++;
298
+	    }
299
+	    if ($i == 100) {
300
+	    	throw new ProgrammingError('Category array error');
301
+	    }
294 302
 	    $catArray[$i] = $catName;
295 303
 	    $this->setHandlerCategory($catArray);
296 304
 	}
Please login to merge, or discard this patch.
library/Trapdirector/TrapsActions/TrapDBQuery.php 1 patch
Braces   +50 added lines, -16 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
         // TODO Check for rule consistency
36 36
         
37 37
         $dbConn = $this->getDbConn();
38
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
38
+        if ($dbConn === null) {
39
+        	throw new \ErrorException('uncatched db error');
40
+        }
39 41
         // Add last modified date = creation date and username
40 42
         $params['created'] = new Zend_Db_Expr('NOW()');
41 43
         $params['modified'] = new 	Zend_Db_Expr('NOW()');
@@ -61,7 +63,9 @@  discard block
 block discarded – undo
61 63
     {
62 64
         // TODO Check for rule consistency
63 65
         $dbConn = $this->getDbConn();
64
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
66
+        if ($dbConn === null) {
67
+        	throw new \ErrorException('uncatched db error');
68
+        }
65 69
         // Add last modified date = creation date and username
66 70
         $params['modified'] = new 	Zend_Db_Expr('NOW()');
67 71
         $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
@@ -84,7 +88,9 @@  discard block
 block discarded – undo
84 88
     {
85 89
         // TODO Check for rule consistency
86 90
         $dbConn = $this->getDbConn();
87
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
91
+        if ($dbConn === null) {
92
+        	throw new \ErrorException('uncatched db error');
93
+        }
88 94
         
89 95
         $numRows=$dbConn->update(
90 96
             $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
@@ -102,7 +108,9 @@  discard block
 block discarded – undo
102 108
         if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id');  }
103 109
         
104 110
         $dbConn = $this->getDbConn();
105
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
111
+        if ($dbConn === null) {
112
+        	throw new \ErrorException('uncatched db error');
113
+        }
106 114
         
107 115
         $query=$dbConn->delete(
108 116
             $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
@@ -119,7 +127,9 @@  discard block
 block discarded – undo
119 127
     public function lastModification()
120 128
     {
121 129
         $dbConn = $this->getDbConn();
122
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
130
+        if ($dbConn === null) {
131
+        	throw new \ErrorException('uncatched db error');
132
+        }
123 133
         
124 134
         $query = $dbConn->select()
125 135
         ->from(
@@ -137,7 +147,9 @@  discard block
 block discarded – undo
137 147
     {
138 148
         
139 149
         $dbConn = $this->getDbConn();
140
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
150
+        if ($dbConn === null) {
151
+        	throw new \ErrorException('uncatched db error');
152
+        }
141 153
         $condition=null;
142 154
         if ($ipAddr != null)
143 155
         {
@@ -148,7 +160,9 @@  discard block
 block discarded – undo
148 160
             $condition=($condition===null)?'':$condition.' AND ';
149 161
             $condition.="trap_oid='$oid'";
150 162
         }
151
-        if($condition === null) return null;
163
+        if($condition === null) {
164
+        	return null;
165
+        }
152 166
         $query=$dbConn->delete(
153 167
             $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
154 168
             $condition
@@ -166,7 +180,9 @@  discard block
 block discarded – undo
166 180
     {
167 181
         
168 182
         $dbConn = $this->getDbConn();
169
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
183
+        if ($dbConn === null) {
184
+        	throw new \ErrorException('uncatched db error');
185
+        }
170 186
         
171 187
         $condition=null;
172 188
         if ($ipAddr != null)
@@ -178,7 +194,9 @@  discard block
 block discarded – undo
178 194
             $condition=($condition===null)?'':$condition.' AND ';
179 195
             $condition.="trap_oid='$oid'";
180 196
         }
181
-        if($condition === null) return 0;
197
+        if($condition === null) {
198
+        	return 0;
199
+        }
182 200
         $query=$dbConn->select()
183 201
             ->from(
184 202
                 $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
@@ -195,7 +213,9 @@  discard block
 block discarded – undo
195 213
     {
196 214
         
197 215
         $dbConn = $this->getDbConn();
198
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
216
+        if ($dbConn === null) {
217
+        	throw new \ErrorException('uncatched db error');
218
+        }
199 219
         
200 220
         $query=$dbConn->select()
201 221
         ->from(
@@ -203,18 +223,28 @@  discard block
 block discarded – undo
203 223
             array('value'=>'value'))
204 224
             ->where('name=?',$element);
205 225
             $returnRow=$dbConn->fetchRow($query);
206
-            if ($returnRow==null)  // value does not exists
226
+            if ($returnRow==null) {
227
+            	// value does not exists
207 228
             {
208 229
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
209
-                if ( ! isset($default[$element])) return null; // no default and not value
230
+            }
231
+                if ( ! isset($default[$element])) {
232
+                	return null;
233
+                }
234
+                // no default and not value
210 235
                 
211 236
                 $this->addDBConfigValue($element,$default[$element]);
212 237
                 return $default[$element];
213 238
             }
214
-            if ($returnRow->value == null) // value id empty
239
+            if ($returnRow->value == null) {
240
+            	// value id empty
215 241
             {
216 242
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
217
-                if ( ! isset($default[$element])) return null; // no default and not value
243
+            }
244
+                if ( ! isset($default[$element])) {
245
+                	return null;
246
+                }
247
+                // no default and not value
218 248
                 $this->setDBConfigValue($element,$default[$element]);
219 249
                 return $default[$element];
220 250
             }
@@ -230,7 +260,9 @@  discard block
 block discarded – undo
230 260
     {
231 261
         
232 262
         $dbConn = $this->getDbConn();
233
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
263
+        if ($dbConn === null) {
264
+        	throw new \ErrorException('uncatched db error');
265
+        }
234 266
         
235 267
         $query=$dbConn->insert(
236 268
             $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
@@ -250,7 +282,9 @@  discard block
 block discarded – undo
250 282
     {
251 283
         
252 284
         $dbConn = $this->getDbConn();
253
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
285
+        if ($dbConn === null) {
286
+        	throw new \ErrorException('uncatched db error');
287
+        }
254 288
         
255 289
         $query=$dbConn->update(
256 290
             $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
Please login to merge, or discard this patch.
application/controllers/StatusController.php 1 patch
Braces   +18 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
 		try
23 23
 		{
24 24
 		    $dbConn = $this->getUIDatabase()->getDbConn();
25
-		    if ($dbConn === null) throw new \ErrorException('uncatched db error');
25
+		    if ($dbConn === null) {
26
+		    	throw new \ErrorException('uncatched db error');
27
+		    }
26 28
 			$query = $dbConn->select()->from(
27 29
 				$this->getModuleConfig()->getTrapTableName(),
28 30
 				array('COUNT(*)')
@@ -41,8 +43,7 @@  discard block
 block discarded – undo
41 43
  			
42 44
 			$this->view->trap_days_delete=$this->getUIDatabase()->getDBConfigValue('db_remove_days');
43 45
 			
44
-		}
45
-		catch (Exception $e)
46
+		} catch (Exception $e)
46 47
 		{
47 48
 			$this->displayExitError('status',$e->getMessage());
48 49
 		}
@@ -56,8 +57,7 @@  discard block
 block discarded – undo
56 57
 			$this->view->currentLogFile=$this->getUIDatabase()->getDBConfigValue('log_file');
57 58
 			$this->view->logLevels=$this->getModuleConfig()->getlogLevels();
58 59
 			$this->view->currentLogLevel=$this->getUIDatabase()->getDBConfigValue('log_level');
59
-		}
60
-		catch (Exception $e)
60
+		} catch (Exception $e)
61 61
 		{
62 62
 			$this->displayExitError('status',$e->getMessage());
63 63
 		}
@@ -69,8 +69,7 @@  discard block
 block discarded – undo
69 69
 		    $this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid');
70 70
 		    $this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE;
71 71
 		    
72
-		}
73
-		catch (Exception $e)
72
+		} catch (Exception $e)
74 73
 		{
75 74
 		    $this->displayExitError('status',$e->getMessage());
76 75
 		}		
@@ -120,8 +119,7 @@  discard block
 block discarded – undo
120 119
 					if ($retVal == 0)
121 120
 					{ // process is alive
122 121
 						$this->_helper->json(array('status'=>'Alive and kicking'));
123
-					}
124
-					else
122
+					} else
125 123
 					{ // process is dead
126 124
 					    $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid));
127 125
 					}
@@ -137,22 +135,19 @@  discard block
 block discarded – undo
137 135
 				if (!is_dir($destDir))
138 136
 				{
139 137
 				    $this->view->uploadStatus="ERROR : no $destDir directory, check module configuration";
140
-				}
141
-				else
138
+				} else
142 139
 				{
143 140
 				    if (!is_writable($destDir))
144 141
 				    {
145 142
 				        $this->view->uploadStatus="ERROR : $destDir directory is not writable";
146
-				    }
147
-				    else
143
+				    } else
148 144
 				    {
149 145
 				        $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name";
150 146
 				        $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING);
151 147
 				        if (move_uploaded_file($sourceTmpNam,$destination)===false)
152 148
     				    {
153 149
     				        $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations";
154
-    				    }
155
-    				    else
150
+    				    } else
156 151
     				    {
157 152
     				        $this->view->uploadStatus="File $name uploaded in $destDir";
158 153
     				    }
@@ -174,13 +169,11 @@  discard block
 block discarded – undo
174 169
 			{
175 170
 				$this->view->snmptranslate='works fine';
176 171
 				$this->view->snmptranslate_state='ok';
177
-			}
178
-			else
172
+			} else
179 173
 			{
180 174
 				$this->view->snmptranslate='can execute but no resolution';
181 175
 			}
182
-		}
183
-		else
176
+		} else
184 177
 		{
185 178
 			$this->view->snmptranslate='cannot execute';
186 179
 		}
@@ -201,15 +194,13 @@  discard block
 block discarded – undo
201 194
 		if ($retVal==0)
202 195
 		{
203 196
 			$dirArray=array_merge($dirArray,explode(':',$sysDirs));
204
-		}
205
-		else
197
+		} else
206 198
 		{
207 199
 			$translateOut=exec($this->Config()->get('config', 'snmptranslate') . ' -Dinit_mib .1.3 2>&1 | grep MIBDIRS');
208 200
 			if (preg_match('/MIBDIRS.*\'([^\']+)\'/',$translateOut,$matches))
209 201
 			{
210 202
 				$dirArray=array_merge($dirArray,explode(':',$matches[1]));
211
-			}
212
-			else
203
+			} else
213 204
 			{
214 205
 				array_push($dirArray,'Install net-snmp-config to see system directories');
215 206
 			}
@@ -248,8 +239,7 @@  discard block
 block discarded – undo
248 239
 	        if (!preg_match('/^[0-9]+$/', $maxRows) || $maxRows < 1)
249 240
 	        {
250 241
 	            $this->view->setError='Max rows must be a number';
251
-	        }
252
-	        else
242
+	        } else
253 243
 	        {
254 244
 	            $this->setitemListDisplay($maxRows);
255 245
 	            $this->view->setOKMsg='Set max rows to ' . $maxRows;
@@ -268,8 +258,9 @@  discard block
 block discarded – undo
268 258
 	        $index = $this->getRequest()->getPost('index',NULL);
269 259
 	        $newname = $this->getRequest()->getPost('newname',NULL);
270 260
 
271
-	        if (!preg_match('/^[0-9]+$/', $index) || $index < 1)
272
-	            $this->_helper->json(array('status'=>'Bad index'));
261
+	        if (!preg_match('/^[0-9]+$/', $index) || $index < 1) {
262
+	        	            $this->_helper->json(array('status'=>'Bad index'));
263
+	        }
273 264
 	        
274 265
 	        switch ($type)
275 266
 	        {
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
 		$handlerTable = new HandlerTable(
31 33
 		      $this->moduleConfig->getTrapRuleName(),
@@ -84,8 +86,7 @@  discard block
 block discarded – undo
84 86
 	    if ($this->params->get('rule') !== null) 
85 87
 	    {
86 88
 	        $this->view->rule= $this->params->get('rule');
87
-	    }
88
-	    else
89
+	    } else
89 90
 	    {
90 91
 	        $this->view->rule='';
91 92
 	    }
@@ -139,8 +140,7 @@  discard block
 block discarded – undo
139 140
 	    try
140 141
 	    {
141 142
 	        $hosts=$this->getUIDatabase()->getHostByIP($hostfilter);
142
-	    }
143
-	    catch (Exception $e)
143
+	    } catch (Exception $e)
144 144
 	    {
145 145
 	        $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
146 146
 	    }
@@ -153,8 +153,7 @@  discard block
 block discarded – undo
153 153
 	        // Tell JS to get services when page is loaded
154 154
 	        $this->view->serviceGet=true;
155 155
 	        
156
-	    }
157
-	    else
156
+	    } else
158 157
 	    {
159 158
 	        foreach($hosts as $key=>$val)
160 159
 	        {
@@ -204,11 +203,14 @@  discard block
 block discarded – undo
204 203
 	            $allObjects[$val->oid]=null;
205 204
 	        }
206 205
 	    }
207
-	    if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
206
+	    if ($allObjects!=null) {
207
+	    	// in case trap doesn't have objects or is not resolved
208 208
 	    {
209 209
 	        foreach ($allObjects as $key => $val)
210 210
 	        {
211
-	            if ($val==null) { continue; }
211
+	            if ($val==null) { continue;
212
+	    }
213
+	    }
212 214
 	            array_push($this->view->objectList, array(
213 215
 	                $oid_index,
214 216
 	                $key,
@@ -240,8 +242,7 @@  discard block
 block discarded – undo
240 242
 	    {
241 243
 	        $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
242 244
 	        $this->view->serviceGet=false;
243
-	    }
244
-	    else
245
+	    } else
245 246
 	    {
246 247
 	        // Tell JS to get services when page is loaded
247 248
 	        $this->view->serviceGet=true;
@@ -250,8 +251,7 @@  discard block
 block discarded – undo
250 251
 	        if (count($serviceID) ==0)
251 252
 	        {
252 253
 	            $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
253
-	        }
254
-	        else
254
+	        } else
255 255
 	        {
256 256
 	            $this->view->serviceSet=$serviceID[0]->id;
257 257
 	        }
@@ -270,8 +270,7 @@  discard block
 block discarded – undo
270 270
 	    {
271 271
 	        $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
272 272
 	        $this->view->serviceGroupGet=false;
273
-	    }
274
-	    else
273
+	    } else
275 274
 	    {
276 275
 	        $grpServices=$this->getUIDatabase()->getServicesByHostGroupid($group_get[0]->id);
277 276
 	        $foundGrpService=0;
@@ -323,8 +322,7 @@  discard block
 block discarded – undo
323 322
 	                $object['type'],
324 323
 	                $object['type_enum']
325 324
 	            ));
326
-	        }
327
-	        else
325
+	        } else
328 326
 	        {
329 327
 	            array_push($curObjectList, array(
330 328
 	                $index,
@@ -402,8 +400,7 @@  discard block
 block discarded – undo
402 400
 			    $this->view->selectGroup=false;
403 401
 			    // Check if hostname still exists
404 402
 			    $this->add_check_host_exists($ruleDetail);
405
-			}
406
-			else
403
+			} else
407 404
 			{
408 405
 			    $this->view->selectGroup=true;
409 406
 			    $this->add_check_hostgroup_exists($ruleDetail); //  Check if groupe exists				
@@ -411,9 +408,11 @@  discard block
 block discarded – undo
411 408
 			
412 409
 			$this->view->mainoid=$ruleDetail->trap_oid;
413 410
 			$oidName=$this->getMIB()->translateOID($ruleDetail->trap_oid);
414
-			if ($oidName != null)  // oid is found in mibs
411
+			if ($oidName != null) {
412
+				// oid is found in mibs
415 413
 			{
416
-				$this->view->mib=$oidName['mib']; 
414
+				$this->view->mib=$oidName['mib'];
415
+			}
417 416
 				$this->view->name=$oidName['name'];
418 417
 				$this->view->trapListForMIB=$this->getMIB()
419 418
 					->getTrapList($oidName['mib']);				
@@ -470,8 +469,7 @@  discard block
 block discarded – undo
470 469
 			try
471 470
 			{
472 471
 			    $this->getUIDatabase()->deleteRule($postData[$params['db_rule']['post']]);
473
-			}
474
-			catch (Exception $e)
472
+			} catch (Exception $e)
475 473
 			{
476 474
 				$this->_helper->json(array('status'=>$e->getMessage()));
477 475
 				return;
@@ -485,13 +483,15 @@  discard block
 block discarded – undo
485 483
 		}		
486 484
 		foreach (array_keys($params) as $key)
487 485
 		{
488
-			if ($params[$key]['post']==null) continue; // data not sent in post vars
486
+			if ($params[$key]['post']==null) {
487
+				continue;
488
+			}
489
+			// data not sent in post vars
489 490
 			if (! isset($postData[$params[$key]['post']]))
490 491
 			{
491 492
 				// should not happen as the js checks data
492 493
 				$this->_helper->json(array('status'=>'No ' . $key));
493
-			}
494
-			else
494
+			} else
495 495
 			{
496 496
 				$data=$postData[$params[$key]['post']];
497 497
 				if ($data!=null && $data !="")
@@ -526,8 +526,7 @@  discard block
 block discarded – undo
526 526
 					$this->_helper->json(array('status'=>"Invalid service id : Please re enter service"));
527 527
 					return;
528 528
 				}
529
-			}
530
-			else
529
+			} else
531 530
 			{
532 531
 			    $object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']);
533 532
 				if ($params['host_name']['val'] != $object->name1)
@@ -552,14 +551,12 @@  discard block
 block discarded – undo
552 551
 			if ($params['db_rule']['val'] == -1 || $params['action_form']['val'] == 'clone') 
553 552
 			{  // If no rule number or action is clone, add the handler
554 553
 			    $ruleID=$this->getUIDatabase()->addHandlerRule($dbparams);
555
-			}
556
-			else
554
+			} else
557 555
 			{
558 556
 			    $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
559 557
 				$ruleID=$params['db_rule']['val'];
560 558
 			}
561
-		}
562
-		catch (Exception $e)
559
+		} catch (Exception $e)
563 560
 		{
564 561
 			$this->_helper->json(array('status'=>$e->getMessage()));
565 562
 			return;
@@ -578,7 +575,9 @@  discard block
 block discarded – undo
578 575
 		$queryArray=$this->getModuleConfig()->trapDetailQuery();
579 576
 		
580 577
 		$dbConn = $this->getUIDatabase()->getDbConn();
581
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
578
+		if ($dbConn === null) {
579
+			throw new \ErrorException('uncatched db error');
580
+		}
582 581
 		// ***************  Get main data
583 582
 		// extract columns and titles;
584 583
 		$elmts=NULL;
@@ -596,8 +595,7 @@  discard block
 block discarded – undo
596 595
 			    $trapDetail = 'NULL';
597 596
 			    throw new Exception('No traps was found with id = '.$trapid);
598 597
 			}
599
-		}
600
-		catch (Exception $e)
598
+		} catch (Exception $e)
601 599
 		{
602 600
 			$this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage());
603 601
 			return;
@@ -617,7 +615,9 @@  discard block
 block discarded – undo
617 615
 		$queryArrayData=$this->getModuleConfig()->trapDataDetailQuery();
618 616
 		
619 617
 		$dbConn = $this->getUIDatabase()->getDbConn();
620
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
618
+		if ($dbConn === null) {
619
+			throw new \ErrorException('uncatched db error');
620
+		}
621 621
 		// ***************  Get object data
622 622
 		// extract columns and titles;
623 623
 		$data_elmts=NULL;
@@ -631,8 +631,7 @@  discard block
 block discarded – undo
631 631
 				->where('trap_id=?',$trapid);
632 632
 				$trapDetail=$dbConn->fetchAll($query);
633 633
 			// if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid);
634
-		}
635
-		catch (Exception $e)
634
+		} catch (Exception $e)
636 635
 		{
637 636
 			$this->displayExitError('Add handler : get trap data detail : ',$e->getMessage());
638 637
 			return array();
@@ -652,7 +651,9 @@  discard block
 block discarded – undo
652 651
 		$queryArray=$this->getModuleConfig()->ruleDetailQuery();
653 652
 		
654 653
 		$dbConn = $this->getUIDatabase()->getDbConn();
655
-		if ($dbConn === null) throw new \ErrorException('uncatched db error');
654
+		if ($dbConn === null) {
655
+			throw new \ErrorException('uncatched db error');
656
+		}
656 657
 		// ***************  Get main data
657 658
 		try
658 659
 		{		
@@ -660,9 +661,10 @@  discard block
 block discarded – undo
660 661
 				->from($this->getModuleConfig()->getTrapRuleName(),$queryArray)
661 662
 				->where('id=?',$ruleid);
662 663
 			$ruleDetail=$dbConn->fetchRow($query);
663
-			if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid);
664
-		}
665
-		catch (Exception $e)
664
+			if ( $ruleDetail == null ) {
665
+				throw new Exception('No rule was found with id = '.$ruleid);
666
+			}
667
+		} catch (Exception $e)
666 668
 		{
667 669
 			$this->displayExitError('Update handler : get rule detail',$e->getMessage());
668 670
 			throw new Exception('Error : ' . $e->getMessage());
Please login to merge, or discard this patch.