Passed
Pull Request — master (#71)
by
unknown
03:30
created
library/Trapdirector/TrapsActions/UIDatabase.php 2 patches
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -19,30 +19,30 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class DBException extends Exception
21 21
 {
22
-    /** @var array $returnArray */
23
-    private $returnArray;
22
+	/** @var array $returnArray */
23
+	private $returnArray;
24 24
     
25
-    /**
26
-     * Buil DBException
27
-     * @param array $retarray
28
-     * @param string $message
29
-     * @param int $code
30
-     * @param Exception $previous
31
-     */
32
-    public function __construct(array $retarray, string $message = null, int $code = 0, Exception $previous = null)
33
-    {
34
-        parent::__construct($message,$code,$previous);
35
-        $this->returnArray = $retarray;
36
-    }
25
+	/**
26
+	 * Buil DBException
27
+	 * @param array $retarray
28
+	 * @param string $message
29
+	 * @param int $code
30
+	 * @param Exception $previous
31
+	 */
32
+	public function __construct(array $retarray, string $message = null, int $code = 0, Exception $previous = null)
33
+	{
34
+		parent::__construct($message,$code,$previous);
35
+		$this->returnArray = $retarray;
36
+	}
37 37
     
38
-    /**
39
-     * Get exception array
40
-     * @return array
41
-     */
42
-    public function getArray()
43
-    {
44
-        return $this->returnArray;
45
-    }
38
+	/**
39
+	 * Get exception array
40
+	 * @return array
41
+	 */
42
+	public function getArray()
43
+	{
44
+		return $this->returnArray;
45
+	}
46 46
 }
47 47
 
48 48
 /**
@@ -56,278 +56,278 @@  discard block
 block discarded – undo
56 56
  */
57 57
 class UIDatabase //extends TrapDBQuery
58 58
 {
59
-    use TrapDBQuery,IdoDBQuery;
59
+	use TrapDBQuery,IdoDBQuery;
60 60
     
61
-    /** @var TrapsController $trapController TrapController 'parent' class */
62
-    protected  $trapController=null;
61
+	/** @var TrapsController $trapController TrapController 'parent' class */
62
+	protected  $trapController=null;
63 63
     
64
-    /** @var Selectable $trapDB Trap Database*/
65
-    protected $trapDB=null;
64
+	/** @var Selectable $trapDB Trap Database*/
65
+	protected $trapDB=null;
66 66
  
67
-    /** @var Selectable $trapDB Icinga IDO database*/
68
-    protected $idoDB=null;
67
+	/** @var Selectable $trapDB Icinga IDO database*/
68
+	protected $idoDB=null;
69 69
     
70
-    /** @var array $testResult */
71
-    protected $testResult;
70
+	/** @var array $testResult */
71
+	protected $testResult;
72 72
     
73
-    /**
74
-     * 
75
-     * @param TrapsController $trapCtrl
76
-     */
77
-    function __construct(TrapsController $trapCtrl)
78
-    {
79
-        $this->trapController=$trapCtrl;
80
-    }
73
+	/**
74
+	 * 
75
+	 * @param TrapsController $trapCtrl
76
+	 */
77
+	function __construct(TrapsController $trapCtrl)
78
+	{
79
+		$this->trapController=$trapCtrl;
80
+	}
81 81
     
82
-    /**
83
-     * Get TrapsController instance
84
-     * @return TrapsController
85
-     */
86
-    protected function getTrapCtrl()
87
-    {
88
-        return $this->trapController;
89
-    }
82
+	/**
83
+	 * Get TrapsController instance
84
+	 * @return TrapsController
85
+	 */
86
+	protected function getTrapCtrl()
87
+	{
88
+		return $this->trapController;
89
+	}
90 90
     
91
-    /**
92
-     * Test if database version >= min database version
93
-     * 
94
-     * @param \Zend_Db_Adapter_Abstract $dbConn
95
-     * @param int $min Minimum version
96
-     * @param bool $test Test mode
97
-     * @param string $DBname Name of DB
98
-     * @return bool true if OK, false if version < min version
99
-     * @throws Exception if error and test = true
100
-     */
101
-    protected function testDbVersion($dbAdapter,int $min,bool $test, string $DBname)
102
-    {
103
-        try
104
-        {
105
-            $query = $dbAdapter->select()
106
-            ->from($this->trapController->getModuleConfig()->getDbConfigTableName(),'value')
107
-            ->where('name=\'db_version\'');
108
-            $version=$dbAdapter->fetchRow($query);
109
-            if ( ($version == null) || ! property_exists($version,'value') )
110
-            {
111
-                if ($test === true) 
112
-                {
113
-                    $this->testResult = array(4,$DBname);
114
-                    return false;
115
-                }
116
-                $this->trapController->redirectNow('trapdirector/settings?dberror=4');
117
-                return false;
118
-            }
119
-            if ($version->value < $min)
120
-            {
121
-                if ($test === true) 
122
-                {
123
-                    $this->testResult = array(5,$version->value,$min);
124
-                    return false;
125
-                }
126
-                $this->trapController->redirectNow('trapdirector/settings?dberror=5');
127
-                return false;
128
-            }
129
-        }
130
-        catch (Exception $e)
131
-        {
132
-            if ($test === true) 
133
-            {
134
-                $this->testResult = array(3,$DBname,$e->getMessage());
135
-                return false;
136
-            }
137
-            $this->trapController->redirectNow('trapdirector/settings?dberror=4');
138
-            return false;
139
-        }
140
-        return true;
141
-    }
91
+	/**
92
+	 * Test if database version >= min database version
93
+	 * 
94
+	 * @param \Zend_Db_Adapter_Abstract $dbConn
95
+	 * @param int $min Minimum version
96
+	 * @param bool $test Test mode
97
+	 * @param string $DBname Name of DB
98
+	 * @return bool true if OK, false if version < min version
99
+	 * @throws Exception if error and test = true
100
+	 */
101
+	protected function testDbVersion($dbAdapter,int $min,bool $test, string $DBname)
102
+	{
103
+		try
104
+		{
105
+			$query = $dbAdapter->select()
106
+			->from($this->trapController->getModuleConfig()->getDbConfigTableName(),'value')
107
+			->where('name=\'db_version\'');
108
+			$version=$dbAdapter->fetchRow($query);
109
+			if ( ($version == null) || ! property_exists($version,'value') )
110
+			{
111
+				if ($test === true) 
112
+				{
113
+					$this->testResult = array(4,$DBname);
114
+					return false;
115
+				}
116
+				$this->trapController->redirectNow('trapdirector/settings?dberror=4');
117
+				return false;
118
+			}
119
+			if ($version->value < $min)
120
+			{
121
+				if ($test === true) 
122
+				{
123
+					$this->testResult = array(5,$version->value,$min);
124
+					return false;
125
+				}
126
+				$this->trapController->redirectNow('trapdirector/settings?dberror=5');
127
+				return false;
128
+			}
129
+		}
130
+		catch (Exception $e)
131
+		{
132
+			if ($test === true) 
133
+			{
134
+				$this->testResult = array(3,$DBname,$e->getMessage());
135
+				return false;
136
+			}
137
+			$this->trapController->redirectNow('trapdirector/settings?dberror=4');
138
+			return false;
139
+		}
140
+		return true;
141
+	}
142 142
     
143
-    /**	Get Database connexion
144
-     *	@param $DBname string DB name in resource.ini_ge
145
-     *	@param $test bool if set to true, returns error code and not database
146
-     *	@param $test_version bool if set to flase, does not test database version of trapDB
147
-     *  @throws DBException if test = true and error
148
-     *	@return Selectable|null : if test=false, returns DB connexion, else array(error_num,message) or null on error.
149
-     */
150
-    protected function getDbByName($DBname , $test = false , $test_version = true)
151
-    {
152
-        try
153
-        {
154
-            $dbconn = IcingaDbConnection::fromResourceName($DBname);
155
-        }
156
-        catch (Exception $e)
157
-        {
158
-            if ($test === true) 
159
-            {
160
-                throw new DBException(array(2,$DBname));
161
-            }
162
-            $this->trapController->redirectNow('trapdirector/settings?dberror=2');
163
-            return null;
164
-        }
143
+	/**	Get Database connexion
144
+	 *	@param $DBname string DB name in resource.ini_ge
145
+	 *	@param $test bool if set to true, returns error code and not database
146
+	 *	@param $test_version bool if set to flase, does not test database version of trapDB
147
+	 *  @throws DBException if test = true and error
148
+	 *	@return Selectable|null : if test=false, returns DB connexion, else array(error_num,message) or null on error.
149
+	 */
150
+	protected function getDbByName($DBname , $test = false , $test_version = true)
151
+	{
152
+		try
153
+		{
154
+			$dbconn = IcingaDbConnection::fromResourceName($DBname);
155
+		}
156
+		catch (Exception $e)
157
+		{
158
+			if ($test === true) 
159
+			{
160
+				throw new DBException(array(2,$DBname));
161
+			}
162
+			$this->trapController->redirectNow('trapdirector/settings?dberror=2');
163
+			return null;
164
+		}
165 165
         
166
-        try
167
-        {
168
-            $dbAdapter=$dbconn->getDbAdapter();
166
+		try
167
+		{
168
+			$dbAdapter=$dbconn->getDbAdapter();
169 169
             
170
-        }
171
-        catch (Exception $e)
172
-        {
173
-            if ($test === true)
174
-            {
175
-                throw new DBException(array(3,$DBname,$e->getMessage()));
176
-            }
177
-            $this->trapController->redirectNow('trapdirector/settings?dberror=3');
178
-            return null;
179
-        }
170
+		}
171
+		catch (Exception $e)
172
+		{
173
+			if ($test === true)
174
+			{
175
+				throw new DBException(array(3,$DBname,$e->getMessage()));
176
+			}
177
+			$this->trapController->redirectNow('trapdirector/settings?dberror=3');
178
+			return null;
179
+		}
180 180
         
181
-        if ($test_version == true) {
182
-            $testRet=$this->testDbVersion($dbAdapter, $this->trapController->getModuleConfig()->getDbMinVersion(), $test, $DBname);
183
-            if ($testRet !== true) 
184
-            {
185
-                throw new DBException($this->testResult);
186
-            }
187
-        }
181
+		if ($test_version == true) {
182
+			$testRet=$this->testDbVersion($dbAdapter, $this->trapController->getModuleConfig()->getDbMinVersion(), $test, $DBname);
183
+			if ($testRet !== true) 
184
+			{
185
+				throw new DBException($this->testResult);
186
+			}
187
+		}
188 188
         
189
-        return $dbconn;
190
-    }
189
+		return $dbconn;
190
+	}
191 191
 
192
-    /**
193
-     * Get Trap database
194
-     * @return Selectable|null : returns DB connexion or null on error.
195
-     */
196
-    public function getDb()
197
-    {
198
-        if ( $this->trapDB != null ) return $this->trapDB;
192
+	/**
193
+	 * Get Trap database
194
+	 * @return Selectable|null : returns DB connexion or null on error.
195
+	 */
196
+	public function getDb()
197
+	{
198
+		if ( $this->trapDB != null ) return $this->trapDB;
199 199
         
200 200
         
201
-        $dbresource=$this->trapController->Config()->get('config', 'database');
201
+		$dbresource=$this->trapController->Config()->get('config', 'database');
202 202
         
203
-        if ( ! $dbresource )
204
-        {
205
-            $this->trapController->redirectNow('trapdirector/settings?dberror=1');
206
-            return null;
207
-        }
203
+		if ( ! $dbresource )
204
+		{
205
+			$this->trapController->redirectNow('trapdirector/settings?dberror=1');
206
+			return null;
207
+		}
208 208
 
209
-        try {
210
-            $this->trapDB = $this->getDbByName($dbresource,false,true);
211
-        } catch (DBException $e) {
212
-            return null; // Should not happen as test = false
213
-        }
209
+		try {
210
+			$this->trapDB = $this->getDbByName($dbresource,false,true);
211
+		} catch (DBException $e) {
212
+			return null; // Should not happen as test = false
213
+		}
214 214
         
215
-        //$this->trapDB->getConnection();
215
+		//$this->trapDB->getConnection();
216 216
         
217
-        return $this->trapDB;
218
-    }
217
+		return $this->trapDB;
218
+	}
219 219
 
220
-    /**
221
-     * Get Zend adapter of DB.
222
-     * @return \Zend_Db_Adapter_Abstract|null
223
-     */
224
-    public function getDbConn()
225
-    {
226
-        if ($this->getDb() == null) return null;
227
-        return $this->getDb()->getDbAdapter();
228
-    }
220
+	/**
221
+	 * Get Zend adapter of DB.
222
+	 * @return \Zend_Db_Adapter_Abstract|null
223
+	 */
224
+	public function getDbConn()
225
+	{
226
+		if ($this->getDb() == null) return null;
227
+		return $this->getDb()->getDbAdapter();
228
+	}
229 229
     
230
-    /**
231
-     * Test Trap database
232
-     * @param boolean $test
233
-     * @throws DBException on error.
234
-     * @return \Zend_Db_Adapter_Abstract|array|null : if test=false, returns DB connexion, else array(error_num,message) or null on error.
235
-     */
236
-    public function testGetDb()
237
-    {       
238
-        $dbresource=$this->trapController->Config()->get('config', 'database');
230
+	/**
231
+	 * Test Trap database
232
+	 * @param boolean $test
233
+	 * @throws DBException on error.
234
+	 * @return \Zend_Db_Adapter_Abstract|array|null : if test=false, returns DB connexion, else array(error_num,message) or null on error.
235
+	 */
236
+	public function testGetDb()
237
+	{       
238
+		$dbresource=$this->trapController->Config()->get('config', 'database');
239 239
         
240
-        if ( ! $dbresource )
241
-        {
242
-                throw new DBException(array(1,''));
243
-        }
240
+		if ( ! $dbresource )
241
+		{
242
+				throw new DBException(array(1,''));
243
+		}
244 244
         
245
-        $this->trapDB = $this->getDbByName($dbresource,true,true);       
246
-        return;
247
-    }
245
+		$this->trapDB = $this->getDbByName($dbresource,true,true);       
246
+		return;
247
+	}
248 248
     
249 249
 
250
-    /**
251
-     * Get IDO Database
252
-     * @return \Zend_Db_Adapter_Abstract|NULL  returns DB connexion or null on error.
253
-     */
254
-    public function getIdoDb()
255
-    {
256
-        if ( $this->idoDB != null ) return $this->idoDB;
257
-        // TODO : get ido database directly from icingaweb2 config -> (or not if using only API)
258
-        $dbresource=$this->trapController->Config()->get('config', 'IDOdatabase');;
250
+	/**
251
+	 * Get IDO Database
252
+	 * @return \Zend_Db_Adapter_Abstract|NULL  returns DB connexion or null on error.
253
+	 */
254
+	public function getIdoDb()
255
+	{
256
+		if ( $this->idoDB != null ) return $this->idoDB;
257
+		// TODO : get ido database directly from icingaweb2 config -> (or not if using only API)
258
+		$dbresource=$this->trapController->Config()->get('config', 'IDOdatabase');;
259 259
         
260
-        if ( ! $dbresource )
261
-        {
262
-            $this->trapController->redirectNow('trapdirector/settings?idodberror=1');
263
-            return null;
264
-        }
260
+		if ( ! $dbresource )
261
+		{
262
+			$this->trapController->redirectNow('trapdirector/settings?idodberror=1');
263
+			return null;
264
+		}
265 265
         
266
-        try
267
-        {
268
-            $dbconn = IcingaDbConnection::fromResourceName($dbresource);
269
-        }
270
-        catch (Exception $e)
271
-        {
272
-            $this->trapController->redirectNow('trapdirector/settings?idodberror=2');
273
-            return null;
274
-        }
266
+		try
267
+		{
268
+			$dbconn = IcingaDbConnection::fromResourceName($dbresource);
269
+		}
270
+		catch (Exception $e)
271
+		{
272
+			$this->trapController->redirectNow('trapdirector/settings?idodberror=2');
273
+			return null;
274
+		}
275 275
 
276
-        $this->idoDB = $dbconn;
277
-        return $this->idoDB;
278
-    }
276
+		$this->idoDB = $dbconn;
277
+		return $this->idoDB;
278
+	}
279 279
 
280 280
 
281
-    /**
282
-     * Get Zend adapter of DB.
283
-     * @return \Zend_Db_Adapter_Abstract|null
284
-     */
285
-    public function getIdoDbConn()
286
-    {
287
-        if ($this->getIdoDb() == null) return null;
288
-        return $this->getIdoDb()->getConnection();
289
-    }
281
+	/**
282
+	 * Get Zend adapter of DB.
283
+	 * @return \Zend_Db_Adapter_Abstract|null
284
+	 */
285
+	public function getIdoDbConn()
286
+	{
287
+		if ($this->getIdoDb() == null) return null;
288
+		return $this->getIdoDb()->getConnection();
289
+	}
290 290
     
291
-    /**
292
-     * Get IDO Database
293
-     * @param boolean $test
294
-     * @throws DBException on error
295
-     */
296
-    public function testGetIdoDb()
297
-    {
298
-        // TODO : get ido database directly from icingaweb2 config -> (or not if using only API)
299
-        $dbresource=$this->trapController->Config()->get('config', 'IDOdatabase');;
291
+	/**
292
+	 * Get IDO Database
293
+	 * @param boolean $test
294
+	 * @throws DBException on error
295
+	 */
296
+	public function testGetIdoDb()
297
+	{
298
+		// TODO : get ido database directly from icingaweb2 config -> (or not if using only API)
299
+		$dbresource=$this->trapController->Config()->get('config', 'IDOdatabase');;
300 300
         
301
-        if ( ! $dbresource )
302
-        {
303
-            throw new DBException(array(1,'No database in config.ini'));
304
-        }
301
+		if ( ! $dbresource )
302
+		{
303
+			throw new DBException(array(1,'No database in config.ini'));
304
+		}
305 305
         
306
-        try
307
-        {
308
-            $dbconn = IcingaDbConnection::fromResourceName($dbresource);
309
-        }
310
-        catch (Exception $e)
311
-        {
312
-            throw new DBException( array(2,"Database $dbresource does not exists in IcingaWeb2") );
313
-        }
306
+		try
307
+		{
308
+			$dbconn = IcingaDbConnection::fromResourceName($dbresource);
309
+		}
310
+		catch (Exception $e)
311
+		{
312
+			throw new DBException( array(2,"Database $dbresource does not exists in IcingaWeb2") );
313
+		}
314 314
                
315
-        try
316
-        {
317
-            $query = $dbconn->select()
318
-            ->from('icinga_dbversion',array('version'));
319
-            $version=$dbconn->fetchRow($query);
320
-            if ( ($version == null) || ! property_exists($version,'version') )
321
-            {
322
-                throw new DBException( array(4,"$dbresource does not look like an IDO database"));
323
-            }
324
-        }
325
-        catch (Exception $e)
326
-        {
327
-            throw new DBException( array(3,"Error connecting to $dbresource : " . $e->getMessage()));
328
-        }
315
+		try
316
+		{
317
+			$query = $dbconn->select()
318
+			->from('icinga_dbversion',array('version'));
319
+			$version=$dbconn->fetchRow($query);
320
+			if ( ($version == null) || ! property_exists($version,'version') )
321
+			{
322
+				throw new DBException( array(4,"$dbresource does not look like an IDO database"));
323
+			}
324
+		}
325
+		catch (Exception $e)
326
+		{
327
+			throw new DBException( array(3,"Error connecting to $dbresource : " . $e->getMessage()));
328
+		}
329 329
         
330
-        return;
331
-    }
330
+		return;
331
+	}
332 332
     
333 333
 }
334 334
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +18 added lines, -16 removed lines patch added patch discarded remove patch
@@ -126,8 +126,7 @@  discard block
 block discarded – undo
126 126
                 $this->trapController->redirectNow('trapdirector/settings?dberror=5');
127 127
                 return false;
128 128
             }
129
-        }
130
-        catch (Exception $e)
129
+        } catch (Exception $e)
131 130
         {
132 131
             if ($test === true) 
133 132
             {
@@ -152,8 +151,7 @@  discard block
 block discarded – undo
152 151
         try
153 152
         {
154 153
             $dbconn = IcingaDbConnection::fromResourceName($DBname);
155
-        }
156
-        catch (Exception $e)
154
+        } catch (Exception $e)
157 155
         {
158 156
             if ($test === true) 
159 157
             {
@@ -167,8 +165,7 @@  discard block
 block discarded – undo
167 165
         {
168 166
             $dbAdapter=$dbconn->getDbAdapter();
169 167
             
170
-        }
171
-        catch (Exception $e)
168
+        } catch (Exception $e)
172 169
         {
173 170
             if ($test === true)
174 171
             {
@@ -195,7 +192,9 @@  discard block
 block discarded – undo
195 192
      */
196 193
     public function getDb()
197 194
     {
198
-        if ( $this->trapDB != null ) return $this->trapDB;
195
+        if ( $this->trapDB != null ) {
196
+        	return $this->trapDB;
197
+        }
199 198
         
200 199
         
201 200
         $dbresource=$this->trapController->Config()->get('config', 'database');
@@ -223,7 +222,9 @@  discard block
 block discarded – undo
223 222
      */
224 223
     public function getDbConn()
225 224
     {
226
-        if ($this->getDb() == null) return null;
225
+        if ($this->getDb() == null) {
226
+        	return null;
227
+        }
227 228
         return $this->getDb()->getDbAdapter();
228 229
     }
229 230
     
@@ -253,7 +254,9 @@  discard block
 block discarded – undo
253 254
      */
254 255
     public function getIdoDb()
255 256
     {
256
-        if ( $this->idoDB != null ) return $this->idoDB;
257
+        if ( $this->idoDB != null ) {
258
+        	return $this->idoDB;
259
+        }
257 260
         // TODO : get ido database directly from icingaweb2 config -> (or not if using only API)
258 261
         $dbresource=$this->trapController->Config()->get('config', 'IDOdatabase');;
259 262
         
@@ -266,8 +269,7 @@  discard block
 block discarded – undo
266 269
         try
267 270
         {
268 271
             $dbconn = IcingaDbConnection::fromResourceName($dbresource);
269
-        }
270
-        catch (Exception $e)
272
+        } catch (Exception $e)
271 273
         {
272 274
             $this->trapController->redirectNow('trapdirector/settings?idodberror=2');
273 275
             return null;
@@ -284,7 +286,9 @@  discard block
 block discarded – undo
284 286
      */
285 287
     public function getIdoDbConn()
286 288
     {
287
-        if ($this->getIdoDb() == null) return null;
289
+        if ($this->getIdoDb() == null) {
290
+        	return null;
291
+        }
288 292
         return $this->getIdoDb()->getConnection();
289 293
     }
290 294
     
@@ -306,8 +310,7 @@  discard block
 block discarded – undo
306 310
         try
307 311
         {
308 312
             $dbconn = IcingaDbConnection::fromResourceName($dbresource);
309
-        }
310
-        catch (Exception $e)
313
+        } catch (Exception $e)
311 314
         {
312 315
             throw new DBException( array(2,"Database $dbresource does not exists in IcingaWeb2") );
313 316
         }
@@ -321,8 +324,7 @@  discard block
 block discarded – undo
321 324
             {
322 325
                 throw new DBException( array(4,"$dbresource does not look like an IDO database"));
323 326
             }
324
-        }
325
-        catch (Exception $e)
327
+        } catch (Exception $e)
326 328
         {
327 329
             throw new DBException( array(3,"Error connecting to $dbresource : " . $e->getMessage()));
328 330
         }
Please login to merge, or discard this patch.
application/controllers/HandlerController.php 1 patch
Indentation   +295 added lines, -296 removed lines patch added patch discarded remove patch
@@ -12,13 +12,12 @@  discard block
 block discarded – undo
12 12
 
13 13
 //use Icinga\Web\Form as Form;
14 14
 /** Rules management
15
-
16
-*/
15
+ */
17 16
 class HandlerController extends TrapsController
18 17
 {
19 18
 
20 19
 	/** index : list existing rules 
21
-	*/
20
+	 */
22 21
 	public function indexAction()
23 22
 	{	
24 23
 		$this->checkReadPermission();
@@ -28,13 +27,13 @@  discard block
 block discarded – undo
28 27
 		if ($dbConn === null) throw new \ErrorException('uncatched db error');
29 28
 		
30 29
 		$handlerTable = new HandlerTable(
31
-		      $this->moduleConfig->getTrapRuleName(),
32
-		      $this->moduleConfig->getHandlerListTitles(),
33
-		      $this->moduleConfig->getHandlerListDisplayColumns(),
34
-		      $this->moduleConfig->getHandlerColumns(),
35
-		      $dbConn->getDbAdapter(),
36
-		      $this->view,
37
-		      $this->moduleConfig->urlPath());
30
+			  $this->moduleConfig->getTrapRuleName(),
31
+			  $this->moduleConfig->getHandlerListTitles(),
32
+			  $this->moduleConfig->getHandlerListDisplayColumns(),
33
+			  $this->moduleConfig->getHandlerColumns(),
34
+			  $dbConn->getDbAdapter(),
35
+			  $this->view,
36
+			  $this->moduleConfig->urlPath());
38 37
 		
39 38
 		$handlerTable->setMaxPerPage($this->itemListDisplay());
40 39
 		
@@ -56,7 +55,7 @@  discard block
 block discarded – undo
56 55
 		
57 56
 		// TODO : Obsolete remove after new table validation.
58 57
 		
59
-	    /**
58
+		/**
60 59
 		$this->getHandlerListTable()->setConnection($dbConn);
61 60
 		$this->getHandlerListTable()->setMibloader($this->getMIB());
62 61
 		// Apply pagination limits 
@@ -73,22 +72,22 @@  discard block
 block discarded – undo
73 72
 	 */
74 73
 	public function testruleAction()
75 74
 	{
76
-	    $this->checkReadPermission();
77
-	    $this->getTabs()->add('get',array(
78
-	        'active'	=> true,
79
-	        'label'		=> $this->translate('Test Rule'),
80
-	        'url'		=> Url::fromRequest()
81
-	    ));
75
+		$this->checkReadPermission();
76
+		$this->getTabs()->add('get',array(
77
+			'active'	=> true,
78
+			'label'		=> $this->translate('Test Rule'),
79
+			'url'		=> Url::fromRequest()
80
+		));
82 81
 	    
83 82
 
84
-	    if ($this->params->get('rule') !== null) 
85
-	    {
86
-	        $this->view->rule= $this->params->get('rule');
87
-	    }
88
-	    else
89
-	    {
90
-	        $this->view->rule='';
91
-	    }
83
+		if ($this->params->get('rule') !== null) 
84
+		{
85
+			$this->view->rule= $this->params->get('rule');
86
+		}
87
+		else
88
+		{
89
+			$this->view->rule='';
90
+		}
92 91
 	}
93 92
 	
94 93
 	/**
@@ -96,31 +95,31 @@  discard block
 block discarded – undo
96 95
 	 */
97 96
 	private function add_setup_vars()
98 97
 	{
99
-	    // variables to send to view
100
-	    $this->view->hostlist=array(); // host list to input datalist
101
-	    $this->view->hostname=''; // Host name in input text
102
-	    $this->view->serviceGet=false; // Set to true to get list of service if only one host set
103
-	    $this->view->serviceSet=null; // Select service in services select (must have serviceGet=true).
104
-	    $this->view->mainoid=''; // Trap OID
105
-	    $this->view->mib=''; // Trap mib
106
-	    $this->view->name=''; // Trap name
107
-	    $this->view->trapListForMIB=array(); // Trap list if mib exists for trap
108
-	    $this->view->objectList=array(); // objects sent with trap
109
-	    $this->view->display=''; // Initial display
110
-	    $this->view->rule=''; // rule display
111
-	    $this->view->revertOK=''; // revert OK in seconds
112
-	    $this->view->hostid=-1; // normally set by javascript serviceGet()
113
-	    $this->view->ruleid=-1; // Rule id in DB for update & delete
114
-	    $this->view->setToUpdate=false; // set form as update form
115
-	    $this->view->setRuleMatch=-1; // set action on rule match (default nothing)
116
-	    $this->view->setRuleNoMatch=-1; // set action on rule no match (default nothing)
98
+		// variables to send to view
99
+		$this->view->hostlist=array(); // host list to input datalist
100
+		$this->view->hostname=''; // Host name in input text
101
+		$this->view->serviceGet=false; // Set to true to get list of service if only one host set
102
+		$this->view->serviceSet=null; // Select service in services select (must have serviceGet=true).
103
+		$this->view->mainoid=''; // Trap OID
104
+		$this->view->mib=''; // Trap mib
105
+		$this->view->name=''; // Trap name
106
+		$this->view->trapListForMIB=array(); // Trap list if mib exists for trap
107
+		$this->view->objectList=array(); // objects sent with trap
108
+		$this->view->display=''; // Initial display
109
+		$this->view->rule=''; // rule display
110
+		$this->view->revertOK=''; // revert OK in seconds
111
+		$this->view->hostid=-1; // normally set by javascript serviceGet()
112
+		$this->view->ruleid=-1; // Rule id in DB for update & delete
113
+		$this->view->setToUpdate=false; // set form as update form
114
+		$this->view->setRuleMatch=-1; // set action on rule match (default nothing)
115
+		$this->view->setRuleNoMatch=-1; // set action on rule no match (default nothing)
117 116
 	    
118
-	    $this->view->selectGroup=false; // Select by group if true
119
-	    $this->view->hostgroupid=-1; // host group id
120
-	    $this->view->serviceGroupGet=false; // Get list of service for group (set serviceSet to select one)
117
+		$this->view->selectGroup=false; // Select by group if true
118
+		$this->view->hostgroupid=-1; // host group id
119
+		$this->view->serviceGroupGet=false; // Get list of service for group (set serviceSet to select one)
121 120
 	    
122
-	    $this->view->modifier=null;
123
-	    $this->view->modified=null;
121
+		$this->view->modifier=null;
122
+		$this->view->modified=null;
124 123
 	}
125 124
 	
126 125
 	/**
@@ -129,102 +128,102 @@  discard block
 block discarded – undo
129 128
 	 */
130 129
 	private function add_from_existing($trapid)
131 130
 	{
132
-	    /********** Setup from existing trap ***************/
133
-	    // Get the full trap info
134
-	    $trapDetail=$this->getTrapDetail($trapid);
131
+		/********** Setup from existing trap ***************/
132
+		// Get the full trap info
133
+		$trapDetail=$this->getTrapDetail($trapid);
135 134
 	    
136
-	    $hostfilter=$trapDetail->source_ip;
135
+		$hostfilter=$trapDetail->source_ip;
137 136
 	    
138
-	    // Get host
139
-	    try
140
-	    {
141
-	        $hosts=$this->getIdoConn()->getHostByIP($hostfilter);
142
-	    }
143
-	    catch (Exception $e)
144
-	    {
145
-	        $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
146
-	    }
137
+		// Get host
138
+		try
139
+		{
140
+			$hosts=$this->getIdoConn()->getHostByIP($hostfilter);
141
+		}
142
+		catch (Exception $e)
143
+		{
144
+			$this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
145
+		}
147 146
 	    
148 147
 	    
149
-	    // if one unique host found -> put id text input
150
-	    if (count($hosts)==1) {
151
-	        $this->view->hostname=$hosts[0]->name;
152
-	        //$hostid=$hosts[0]->id;
153
-	        // Tell JS to get services when page is loaded
154
-	        $this->view->serviceGet=true;
148
+		// if one unique host found -> put id text input
149
+		if (count($hosts)==1) {
150
+			$this->view->hostname=$hosts[0]->name;
151
+			//$hostid=$hosts[0]->id;
152
+			// Tell JS to get services when page is loaded
153
+			$this->view->serviceGet=true;
155 154
 	        
156
-	    }
157
-	    else
158
-	    {
159
-	        foreach($hosts as $key=>$val)
160
-	        {
161
-	            array_push($this->view->hostlist,$hosts[$key]->name);
162
-	        }
163
-	    }
155
+		}
156
+		else
157
+		{
158
+			foreach($hosts as $key=>$val)
159
+			{
160
+				array_push($this->view->hostlist,$hosts[$key]->name);
161
+			}
162
+		}
164 163
 	    
165
-	    // set up trap oid and objects received by the trap
164
+		// set up trap oid and objects received by the trap
166 165
 	    
167
-	    $this->view->mainoid=$trapDetail->trap_oid;
168
-	    if ($trapDetail->trap_name_mib != null)
169
-	    {
170
-	        $this->view->mib=$trapDetail->trap_name_mib;
171
-	        $this->view->name=$trapDetail->trap_name;
172
-	        $this->view->trapListForMIB=$this->getMIB()
173
-	        ->getTrapList($trapDetail->trap_name_mib);
174
-	    }
166
+		$this->view->mainoid=$trapDetail->trap_oid;
167
+		if ($trapDetail->trap_name_mib != null)
168
+		{
169
+			$this->view->mib=$trapDetail->trap_name_mib;
170
+			$this->view->name=$trapDetail->trap_name;
171
+			$this->view->trapListForMIB=$this->getMIB()
172
+			->getTrapList($trapDetail->trap_name_mib);
173
+		}
175 174
 	    
176
-	    // Get all objects that can be in trap from MIB
177
-	    $allObjects=$this->getMIB()->getObjectList($trapDetail->trap_oid);
178
-	    // Get all objects in current Trap
179
-	    $currentTrapObjects=$this->getTrapobjects($trapid);
180
-	    $oid_index=1;
181
-	    foreach ($currentTrapObjects as $key => $val)
182
-	    {
183
-	        $currentObjectType='Unknown';
184
-	        $currentObjectTypeEnum='Unknown';
185
-	        if (isset($allObjects[$val->oid]['type']))
186
-	        {
187
-	            $currentObjectType=$allObjects[$val->oid]['type'];
188
-	            $currentObjectTypeEnum=$allObjects[$val->oid]['type_enum'];
189
-	        }
190
-	        $currentObject=array(
191
-	            $oid_index,
192
-	            $val->oid,
193
-	            $val->oid_name_mib,
194
-	            $val->oid_name,
195
-	            $val->value,
196
-	            $currentObjectType,
197
-	            $currentObjectTypeEnum
198
-	        );
199
-	        $oid_index++;
200
-	        array_push($this->view->objectList,$currentObject);
201
-	        // set currrent object to null in allObjects
202
-	        if (isset($allObjects[$val->oid]))
203
-	        {
204
-	            $allObjects[$val->oid]=null;
205
-	        }
206
-	    }
207
-	    if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
208
-	    {
209
-	        foreach ($allObjects as $key => $val)
210
-	        {
211
-	            if ($val==null) { continue; }
212
-	            array_push($this->view->objectList, array(
213
-	                $oid_index,
214
-	                $key,
215
-	                $allObjects[$key]['mib'],
216
-	                $allObjects[$key]['name'],
217
-	                '',
218
-	                $allObjects[$key]['type'],
219
-	                $allObjects[$key]['type_enum']
220
-	            ));
221
-	            $oid_index++;
222
-	        }
223
-	    }
175
+		// Get all objects that can be in trap from MIB
176
+		$allObjects=$this->getMIB()->getObjectList($trapDetail->trap_oid);
177
+		// Get all objects in current Trap
178
+		$currentTrapObjects=$this->getTrapobjects($trapid);
179
+		$oid_index=1;
180
+		foreach ($currentTrapObjects as $key => $val)
181
+		{
182
+			$currentObjectType='Unknown';
183
+			$currentObjectTypeEnum='Unknown';
184
+			if (isset($allObjects[$val->oid]['type']))
185
+			{
186
+				$currentObjectType=$allObjects[$val->oid]['type'];
187
+				$currentObjectTypeEnum=$allObjects[$val->oid]['type_enum'];
188
+			}
189
+			$currentObject=array(
190
+				$oid_index,
191
+				$val->oid,
192
+				$val->oid_name_mib,
193
+				$val->oid_name,
194
+				$val->value,
195
+				$currentObjectType,
196
+				$currentObjectTypeEnum
197
+			);
198
+			$oid_index++;
199
+			array_push($this->view->objectList,$currentObject);
200
+			// set currrent object to null in allObjects
201
+			if (isset($allObjects[$val->oid]))
202
+			{
203
+				$allObjects[$val->oid]=null;
204
+			}
205
+		}
206
+		if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
207
+		{
208
+			foreach ($allObjects as $key => $val)
209
+			{
210
+				if ($val==null) { continue; }
211
+				array_push($this->view->objectList, array(
212
+					$oid_index,
213
+					$key,
214
+					$allObjects[$key]['mib'],
215
+					$allObjects[$key]['name'],
216
+					'',
217
+					$allObjects[$key]['type'],
218
+					$allObjects[$key]['type_enum']
219
+				));
220
+				$oid_index++;
221
+			}
222
+		}
224 223
 	    
225
-	    // Add a simple display
226
-	    $this->view->display='Trap '.$trapDetail->trap_name.' received';
227
-	    $this->view->create_basic_rule=true;
224
+		// Add a simple display
225
+		$this->view->display='Trap '.$trapDetail->trap_name.' received';
226
+		$this->view->create_basic_rule=true;
228 227
 	}
229 228
 
230 229
 	/**
@@ -233,29 +232,29 @@  discard block
 block discarded – undo
233 232
 	 */
234 233
 	private function add_check_host_exists($ruleDetail)
235 234
 	{
236
-	    // Check if hostname still exists
237
-	    $host_get=$this->getIdoConn()->getHostByName($this->view->hostname);
235
+		// Check if hostname still exists
236
+		$host_get=$this->getIdoConn()->getHostByName($this->view->hostname);
238 237
 	    
239
-	    if (count($host_get)==0)
240
-	    {
241
-	        $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
242
-	        $this->view->serviceGet=false;
243
-	    }
244
-	    else
245
-	    {
246
-	        // Tell JS to get services when page is loaded
247
-	        $this->view->serviceGet=true;
248
-	        // get service id for form to set :
249
-	        $serviceID=$this->getIdoConn()->getServiceIDByName($this->view->hostname,$ruleDetail->service_name);
250
-	        if (count($serviceID) ==0)
251
-	        {
252
-	            $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
253
-	        }
254
-	        else
255
-	        {
256
-	            $this->view->serviceSet=$serviceID[0]->id;
257
-	        }
258
-	    }
238
+		if (count($host_get)==0)
239
+		{
240
+			$this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
241
+			$this->view->serviceGet=false;
242
+		}
243
+		else
244
+		{
245
+			// Tell JS to get services when page is loaded
246
+			$this->view->serviceGet=true;
247
+			// get service id for form to set :
248
+			$serviceID=$this->getIdoConn()->getServiceIDByName($this->view->hostname,$ruleDetail->service_name);
249
+			if (count($serviceID) ==0)
250
+			{
251
+				$this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
252
+			}
253
+			else
254
+			{
255
+				$this->view->serviceSet=$serviceID[0]->id;
256
+			}
257
+		}
259 258
 	}
260 259
 
261 260
 	/**
@@ -264,33 +263,33 @@  discard block
 block discarded – undo
264 263
 	 */
265 264
 	private function add_check_hostgroup_exists($ruleDetail)
266 265
 	{
267
-	    // Check if groupe exists
268
-	    $group_get=$this->getIdoConn()->getHostGroupByName($this->view->hostgroupname);
269
-	    if (count($group_get)==0)
270
-	    {
271
-	        $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
272
-	        $this->view->serviceGroupGet=false;
273
-	    }
274
-	    else
275
-	    {
276
-	        $grpServices=$this->getIdoConn()->getServicesByHostGroupid($group_get[0]->id);
277
-	        $foundGrpService=0;
278
-	        foreach ($grpServices as $grpService)
279
-	        {
280
-	            if ($grpService[0] == $ruleDetail->service_name)
281
-	            {
282
-	                $foundGrpService=1;
283
-	                $this->view->serviceSet=$ruleDetail->service_name;
284
-	            }
285
-	        }
266
+		// Check if groupe exists
267
+		$group_get=$this->getIdoConn()->getHostGroupByName($this->view->hostgroupname);
268
+		if (count($group_get)==0)
269
+		{
270
+			$this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
271
+			$this->view->serviceGroupGet=false;
272
+		}
273
+		else
274
+		{
275
+			$grpServices=$this->getIdoConn()->getServicesByHostGroupid($group_get[0]->id);
276
+			$foundGrpService=0;
277
+			foreach ($grpServices as $grpService)
278
+			{
279
+				if ($grpService[0] == $ruleDetail->service_name)
280
+				{
281
+					$foundGrpService=1;
282
+					$this->view->serviceSet=$ruleDetail->service_name;
283
+				}
284
+			}
286 285
 	        
287
-	        // Tell JS to get services when page is loaded
288
-	        $this->view->serviceGroupGet=true;
289
-	        if ($foundGrpService==0)
290
-	        {
291
-	            $this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
292
-	        }
293
-	    }
286
+			// Tell JS to get services when page is loaded
287
+			$this->view->serviceGroupGet=true;
288
+			if ($foundGrpService==0)
289
+			{
290
+				$this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
291
+			}
292
+		}
294 293
 	}
295 294
 	
296 295
 	/**
@@ -302,52 +301,52 @@  discard block
 block discarded – undo
302 301
 	 */
303 302
 	private function add_create_trap_object_list(&$display, &$rule)
304 303
 	{
305
-	    $curObjectList=array();
306
-	    $index=1;
307
-	    // check in display & rule for : OID(<oid>)
308
-	    $matches=array();
309
-	    while ( preg_match('/_OID\(([\.0-9\*]+)\)/',$display,$matches) ||
310
-	        preg_match('/_OID\(([\.0-9\*]+)\)/',$rule,$matches))
311
-	    {
312
-	        $curOid=$matches[1];
304
+		$curObjectList=array();
305
+		$index=1;
306
+		// check in display & rule for : OID(<oid>)
307
+		$matches=array();
308
+		while ( preg_match('/_OID\(([\.0-9\*]+)\)/',$display,$matches) ||
309
+			preg_match('/_OID\(([\.0-9\*]+)\)/',$rule,$matches))
310
+		{
311
+			$curOid=$matches[1];
313 312
 	        
314
-	        if ( (preg_match('/\*/',$curOid) == 0 ) 
315
-	            && ($object=$this->getMIB()->translateOID($curOid)) != null)
316
-	        {
317
-	            array_push($curObjectList, array(
318
-	                $index,
319
-	                $curOid,
320
-	                $object['mib'],
321
-	                $object['name'],
322
-	                '',
323
-	                $object['type'],
324
-	                $object['type_enum']
325
-	            ));
326
-	        }
327
-	        else
328
-	        {
329
-	            array_push($curObjectList, array(
330
-	                $index,
331
-	                $curOid,
332
-	                'not found',
333
-	                'not found',
334
-	                '',
335
-	                'not found',
336
-	                'not found'
337
-	            ));
338
-	        }
339
-	        $curOid = preg_replace('/\*/','\*',$curOid);
340
-	        $display=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$display);
341
-	        $rule=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$rule);
342
-	        $index++;
343
-	    }
344
-	    return $curObjectList;
313
+			if ( (preg_match('/\*/',$curOid) == 0 ) 
314
+				&& ($object=$this->getMIB()->translateOID($curOid)) != null)
315
+			{
316
+				array_push($curObjectList, array(
317
+					$index,
318
+					$curOid,
319
+					$object['mib'],
320
+					$object['name'],
321
+					'',
322
+					$object['type'],
323
+					$object['type_enum']
324
+				));
325
+			}
326
+			else
327
+			{
328
+				array_push($curObjectList, array(
329
+					$index,
330
+					$curOid,
331
+					'not found',
332
+					'not found',
333
+					'',
334
+					'not found',
335
+					'not found'
336
+				));
337
+			}
338
+			$curOid = preg_replace('/\*/','\*',$curOid);
339
+			$display=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$display);
340
+			$rule=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$rule);
341
+			$index++;
342
+		}
343
+		return $curObjectList;
345 344
 	}
346 345
 	
347 346
 	/** Add a handler  
348
-	*	Get params fromid : setup from existing trap (id of trap table)
349
-	*	Get param ruleid : edit from existing handler (id of rule table)
350
-	*/
347
+	 *	Get params fromid : setup from existing trap (id of trap table)
348
+	 *	Get param ruleid : edit from existing handler (id of rule table)
349
+	 */
351 350
 	public function addAction()
352 351
 	{
353 352
 		$this->checkConfigPermission();
@@ -370,8 +369,8 @@  discard block
 block discarded – undo
370 369
 		//$this->view->trapvalues=false; // Set to true to display 'value' colum in objects
371 370
 		
372 371
 		if (($trapid = $this->params->get('fromid')) !== null) {
373
-		    /********** Setup from existing trap ***************/
374
-            $this->add_from_existing($trapid);
372
+			/********** Setup from existing trap ***************/
373
+			$this->add_from_existing($trapid);
375 374
 			return;
376 375
 		}
377 376
 		
@@ -399,14 +398,14 @@  discard block
 block discarded – undo
399 398
 			$this->view->warning_message='';
400 399
 			if ($this->view->hostname != null)
401 400
 			{
402
-			    $this->view->selectGroup=false;
403
-			    // Check if hostname still exists
404
-			    $this->add_check_host_exists($ruleDetail);
401
+				$this->view->selectGroup=false;
402
+				// Check if hostname still exists
403
+				$this->add_check_host_exists($ruleDetail);
405 404
 			}
406 405
 			else
407 406
 			{
408
-			    $this->view->selectGroup=true;
409
-			    $this->add_check_hostgroup_exists($ruleDetail); //  Check if groupe exists				
407
+				$this->view->selectGroup=true;
408
+				$this->add_check_hostgroup_exists($ruleDetail); //  Check if groupe exists				
410 409
 			}
411 410
 			
412 411
 			$this->view->mainoid=$ruleDetail->trap_oid;
@@ -434,9 +433,9 @@  discard block
 block discarded – undo
434 433
 	}
435 434
 	
436 435
 	/** Validate form and output message to user  
437
-	*	@param in postdata 
438
-	* 	@return string status : OK / <Message>
439
-	**/
436
+	 *	@param in postdata 
437
+	 * 	@return string status : OK / <Message>
438
+	 **/
440 439
 	protected function handlerformAction()
441 440
 	{
442 441
 		$postData=$this->getRequest()->getPost();
@@ -451,8 +450,8 @@  discard block
 block discarded – undo
451 450
 			'host_group_name'=>	array('post' => null,            'val' => null,  'db'=>true),
452 451
 			'serviceid'		=>	array('post' => 'serviceid',                     'db'=>false),
453 452
 			'service_name'	=>	array('post' => 'serviceName',                    'db'=>true),
454
-		    'comment'       =>  array('post' => 'comment',       'val' => '',    'db'=>true),
455
-		    'rule_type'     =>  array('post' => 'category',       'val' => 0,    'db'=>true),
453
+			'comment'       =>  array('post' => 'comment',       'val' => '',    'db'=>true),
454
+			'rule_type'     =>  array('post' => 'category',       'val' => 0,    'db'=>true),
456 455
 			'trap_oid'		=>	array('post' => 'oid',                            'db'=>true),
457 456
 			'revert_ok'		=>	array('post' => 'revertOK',      'val' => 0,      'db'=>true),
458 457
 			'display'		=>	array('post' => 'display',        'val' => '',     'db'=>true),
@@ -461,7 +460,7 @@  discard block
 block discarded – undo
461 460
 			'action_nomatch'=>	array('post' => 'ruleNoMatch',    'val' => -1,    'db'=>true),					
462 461
 			'ip4'			=>	array('post' => null,             'val' => null,  'db'=>true),
463 462
 			'ip6'			=>	array('post' => null,             'val' => null,  'db'=>true),
464
-		    'action_form'	=>	array('post' => 'action_form',    'val' => null, 'db'=>false)
463
+			'action_form'	=>	array('post' => 'action_form',    'val' => null, 'db'=>false)
465 464
 		);
466 465
 		
467 466
 		if (isset($postData[$params['action_form']['post']]) 
@@ -469,7 +468,7 @@  discard block
 block discarded – undo
469 468
 		{
470 469
 			try
471 470
 			{
472
-			    $this->getUIDatabase()->deleteRule($postData[$params['db_rule']['post']]);
471
+				$this->getUIDatabase()->deleteRule($postData[$params['db_rule']['post']]);
473 472
 			}
474 473
 			catch (Exception $e)
475 474
 			{
@@ -479,7 +478,7 @@  discard block
 block discarded – undo
479 478
 			//$this->Module()->
480 479
 			$this->_helper->json(array(
481 480
 				'status'=>'OK',
482
-			    'redirect'=>'trapdirector/handler'
481
+				'redirect'=>'trapdirector/handler'
483 482
 			      
484 483
 			));
485 484
 		}		
@@ -506,8 +505,8 @@  discard block
 block discarded – undo
506 505
 			$isHostGroup=($params['hostgroup']['val'] == 1)?true:false;
507 506
 			if (! $isHostGroup ) 
508 507
 			{  // checks if selection by host 
509
-			    $hostAddr=$this->getIdoConn()->getHostInfoByID($params['hostid']['val']);
510
-			    if ($hostAddr === NULL) throw new \Exception("No object found");
508
+				$hostAddr=$this->getIdoConn()->getHostInfoByID($params['hostid']['val']);
509
+				if ($hostAddr === NULL) throw new \Exception("No object found");
511 510
 				$params['ip4']['val']=$hostAddr->ip4;
512 511
 				$params['ip6']['val']=$hostAddr->ip6;
513 512
 				$checkHostName=$hostAddr->name;
@@ -518,49 +517,49 @@  discard block
 block discarded – undo
518 517
 				}
519 518
 				if ($this->apiMode == TRUE)
520 519
 				{
521
-				    $serviceName=$this->getIdoConn()->getServiceById($params['serviceid']['val']);
522
-				    if (count($serviceName) == 0 )
523
-				    {
524
-				        $this->_helper->json(array('status'=>"Invalid service id : Please re enter service",'sent'=>$params['serviceid']['val'],'found'=>$serviceName[0]->__name));
525
-				        return;
526
-				    }
520
+					$serviceName=$this->getIdoConn()->getServiceById($params['serviceid']['val']);
521
+					if (count($serviceName) == 0 )
522
+					{
523
+						$this->_helper->json(array('status'=>"Invalid service id : Please re enter service",'sent'=>$params['serviceid']['val'],'found'=>$serviceName[0]->__name));
524
+						return;
525
+					}
527 526
 				}
528 527
 				else
529 528
 				{
530
-    				if (!is_numeric($params['serviceid']['val']))
531
-    				{
532
-    				    $this->_helper->json(array('status'=>"Invalid service id ". $params['serviceid']['val']));
533
-    				    return;
534
-    				}
529
+					if (!is_numeric($params['serviceid']['val']))
530
+					{
531
+						$this->_helper->json(array('status'=>"Invalid service id ". $params['serviceid']['val']));
532
+						return;
533
+					}
535 534
     				
536
-    				$serviceName=$this->getUIDatabase()->getObjectNameByid($params['serviceid']['val']);
537
-    				if ($params['service_name']['val'] != $serviceName->name2)
538
-    				{
539
-    					$this->_helper->json(array('status'=>"Invalid service id : Please re enter service"));
540
-    					return;
541
-    				}
535
+					$serviceName=$this->getUIDatabase()->getObjectNameByid($params['serviceid']['val']);
536
+					if ($params['service_name']['val'] != $serviceName->name2)
537
+					{
538
+						$this->_helper->json(array('status'=>"Invalid service id : Please re enter service"));
539
+						return;
540
+					}
542 541
 				}
543 542
 			}
544 543
 			else
545 544
 			{
546
-			    if ($this->apiMode == TRUE)
547
-			    {
548
-			        $object=$this->getIdoConn()->getHostGroupById($params['hostid']['val']);
549
-			        if (count($object) == 0 || $params['host_name']['val'] != $object->__name)
550
-			        {
551
-			            $this->_helper->json(array('status'=>"Invalid object group id : Please re enter service"));
552
-			            return;
553
-			        }
554
-			    }
555
-			    else 
556
-			    {
557
-    			    $object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']);
558
-    				if ($params['host_name']['val'] != $object->name1)
559
-    				{
560
-    					$this->_helper->json(array('status'=>"Invalid object group id : Please re enter service"));
561
-    					return;					
562
-    				}
563
-			    }
545
+				if ($this->apiMode == TRUE)
546
+				{
547
+					$object=$this->getIdoConn()->getHostGroupById($params['hostid']['val']);
548
+					if (count($object) == 0 || $params['host_name']['val'] != $object->__name)
549
+					{
550
+						$this->_helper->json(array('status'=>"Invalid object group id : Please re enter service"));
551
+						return;
552
+					}
553
+				}
554
+				else 
555
+				{
556
+					$object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']);
557
+					if ($params['host_name']['val'] != $object->name1)
558
+					{
559
+						$this->_helper->json(array('status'=>"Invalid object group id : Please re enter service"));
560
+						return;					
561
+					}
562
+				}
564 563
 				// Put param in correct column (group_name)
565 564
 				$params['host_group_name']['val'] = $params['host_name']['val'];
566 565
 				$params['host_name']['val']=null;
@@ -577,17 +576,17 @@  discard block
 block discarded – undo
577 576
 			
578 577
 			if ($params['db_rule']['val'] == -1 || $params['action_form']['val'] == 'clone') 
579 578
 			{  // If no rule number or action is clone, add the handler
580
-			    $ruleID=$this->getUIDatabase()->addHandlerRule($dbparams);
579
+				$ruleID=$this->getUIDatabase()->addHandlerRule($dbparams);
581 580
 			}
582 581
 			else
583 582
 			{
584
-			    $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
583
+				$this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
585 584
 				$ruleID=$params['db_rule']['val'];
586 585
 			}
587 586
 		}
588 587
 		catch (Exception $e)
589 588
 		{
590
-		    $this->_helper->json(array('status'=>$e->getMessage(),'location'=>'Add/update Rule','line'=>$e->getLine(),'file'=>$e->getFile()));
589
+			$this->_helper->json(array('status'=>$e->getMessage(),'location'=>'Add/update Rule','line'=>$e->getLine(),'file'=>$e->getFile()));
591 590
 			return;
592 591
 		}
593 592
 		$this->_helper->json(array('status'=>'OK', 'id' => $ruleID));
@@ -595,9 +594,9 @@  discard block
 block discarded – undo
595 594
 	}
596 595
 
597 596
 	/** Get trap detail by trapid. 
598
-	*	@param integer $trapid : id of trap in received table
599
-	*	@return array (objects)
600
-	*/
597
+	 *	@param integer $trapid : id of trap in received table
598
+	 *	@return array (objects)
599
+	 */
601 600
 	protected function getTrapDetail($trapid) 
602 601
 	{
603 602
 		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
@@ -613,14 +612,14 @@  discard block
 block discarded – undo
613 612
 		}
614 613
 		try
615 614
 		{		
616
-		    $query = $dbConn->select()
615
+			$query = $dbConn->select()
617 616
 				->from($this->getModuleConfig()->getTrapTableName(),$elmts)
618 617
 				->where('id=?',$trapid);
619 618
 				$trapDetail=$dbConn->fetchRow($query);
620 619
 			if ( $trapDetail == null ) 
621 620
 			{
622
-			    $trapDetail = 'NULL';
623
-			    throw new Exception('No traps was found with id = '.$trapid);
621
+				$trapDetail = 'NULL';
622
+				throw new Exception('No traps was found with id = '.$trapid);
624 623
 			}
625 624
 		}
626 625
 		catch (Exception $e)
@@ -634,9 +633,9 @@  discard block
 block discarded – undo
634 633
 	}
635 634
 
636 635
 	/** Get trap objects
637
-	*	@param integer $trapid : trap id
638
-	* 	@return array : full column in db of trap id
639
-	*/
636
+	 *	@param integer $trapid : trap id
637
+	 * 	@return array : full column in db of trap id
638
+	 */
640 639
 	protected function getTrapobjects($trapid)
641 640
 	{	
642 641
 		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
@@ -652,7 +651,7 @@  discard block
 block discarded – undo
652 651
 		}
653 652
 		try
654 653
 		{		
655
-		    $query = $dbConn->select()
654
+			$query = $dbConn->select()
656 655
 				->from($this->moduleConfig->getTrapDataTableName(),$data_elmts)
657 656
 				->where('trap_id=?',$trapid);
658 657
 				$trapDetail=$dbConn->fetchAll($query);
@@ -668,10 +667,10 @@  discard block
 block discarded – undo
668 667
 	}
669 668
 
670 669
 	/** Get rule detail by ruleid.
671
-	*	@param integer $ruleid int id of rule in rule table
672
-	*	@return object|array : column objects in db 
673
-	*
674
-	*/
670
+	 *	@param integer $ruleid int id of rule in rule table
671
+	 *	@return object|array : column objects in db 
672
+	 *
673
+	 */
675 674
 	protected function getRuleDetail($ruleid) 
676 675
 	{
677 676
 		if (!preg_match('/^[0-9]+$/',$ruleid)) { throw new Exception('Invalid id');  }
@@ -682,7 +681,7 @@  discard block
 block discarded – undo
682 681
 		// ***************  Get main data
683 682
 		try
684 683
 		{		
685
-		    $query = $dbConn->select()
684
+			$query = $dbConn->select()
686 685
 				->from($this->getModuleConfig()->getTrapRuleName(),$queryArray)
687 686
 				->where('id=?',$ruleid);
688 687
 			$ruleDetail=$dbConn->fetchRow($query);
@@ -699,7 +698,7 @@  discard block
 block discarded – undo
699 698
 	}
700 699
 
701 700
 	/** Setup tabs for rules 
702
-	*/
701
+	 */
703 702
 	protected function prepareTabs()
704 703
 	{
705 704
 		return $this->getTabs()->add('status', array(
Please login to merge, or discard this patch.