Passed
Push — master ( 3d7e39...d44cfc )
by Patrick
02:50
created
library/Trapdirector/TrapsActions/TrapDBQuery.php 3 patches
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -18,204 +18,204 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    abstract protected function getTrapCtrl();
22
-    abstract public function getDbConn();
21
+	abstract protected function getTrapCtrl();
22
+	abstract public function getDbConn();
23 23
     
24
-    /** Add handler rule in traps DB
25
-     *	@param array $params : array(<db item>=><value>)
26
-     *	@return int inserted id
27
-     */
28
-    public function addHandlerRule($params)
29
-    {
30
-        // TODO Check for rule consistency
24
+	/** Add handler rule in traps DB
25
+	 *	@param array $params : array(<db item>=><value>)
26
+	 *	@return int inserted id
27
+	 */
28
+	public function addHandlerRule($params)
29
+	{
30
+		// TODO Check for rule consistency
31 31
         
32
-        $dbConn = $this->getDbConn();
33
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
34
-        // Add last modified date = creation date and username
35
-        $params['created'] = new Zend_Db_Expr('NOW()');
36
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
37
-        $params['modifier'] = $this->Auth()->getUser()->getUsername();
32
+		$dbConn = $this->getDbConn();
33
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
34
+		// Add last modified date = creation date and username
35
+		$params['created'] = new Zend_Db_Expr('NOW()');
36
+		$params['modified'] = new 	Zend_Db_Expr('NOW()');
37
+		$params['modifier'] = $this->Auth()->getUser()->getUsername();
38 38
         
39
-        $query=$dbConn->insert(
40
-            $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
41
-            $params
42
-            );
43
-        if($query==false)
44
-        {
45
-            return null;
46
-        }
47
-        return $dbConn->lastInsertId();
48
-    }
39
+		$query=$dbConn->insert(
40
+			$this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
41
+			$params
42
+			);
43
+		if($query==false)
44
+		{
45
+			return null;
46
+		}
47
+		return $dbConn->lastInsertId();
48
+	}
49 49
     
50
-    /** Update handler rule in traps DB
51
-     *	@param array $params : (<db item>=><value>)
52
-     *   @param integer $ruleID : rule id in db
53
-     *	@return array affected rows
54
-     */
55
-    public function updateHandlerRule($params,$ruleID)
56
-    {
57
-        // TODO Check for rule consistency
58
-        $dbConn = $this->getDbConn();
59
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
60
-        // Add last modified date = creation date and username
61
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
62
-        $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
50
+	/** Update handler rule in traps DB
51
+	 *	@param array $params : (<db item>=><value>)
52
+	 *   @param integer $ruleID : rule id in db
53
+	 *	@return array affected rows
54
+	 */
55
+	public function updateHandlerRule($params,$ruleID)
56
+	{
57
+		// TODO Check for rule consistency
58
+		$dbConn = $this->getDbConn();
59
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
60
+		// Add last modified date = creation date and username
61
+		$params['modified'] = new 	Zend_Db_Expr('NOW()');
62
+		$params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
63 63
         
64
-        $numRows=$dbConn->update(
65
-            $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
66
-            $params,
67
-            'id='.$ruleID
68
-            );
69
-        return $numRows;
70
-    }
64
+		$numRows=$dbConn->update(
65
+			$this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
66
+			$params,
67
+			'id='.$ruleID
68
+			);
69
+		return $numRows;
70
+	}
71 71
     
72
-    /** Delete rule by id
73
-     *	@param int $ruleID rule id
74
-     */
75
-    public function deleteRule($ruleID)
76
-    {
77
-        if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id');  }
72
+	/** Delete rule by id
73
+	 *	@param int $ruleID rule id
74
+	 */
75
+	public function deleteRule($ruleID)
76
+	{
77
+		if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id');  }
78 78
         
79
-        $dbConn = $this->getDbConn();
80
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
79
+		$dbConn = $this->getDbConn();
80
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
81 81
         
82
-        $query=$dbConn->delete(
83
-            $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
84
-            'id='.$ruleID
85
-            );
86
-        return $query;
87
-    }
82
+		$query=$dbConn->delete(
83
+			$this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
84
+			'id='.$ruleID
85
+			);
86
+		return $query;
87
+	}
88 88
     
89
-    /** Delete trap by ip & oid
90
-     *	@param $ip string source IP (v4 or v6)
91
-     *	@param $oid string oid
92
-     */
93
-    public function deleteTrap($ip,$oid)
94
-    {
89
+	/** Delete trap by ip & oid
90
+	 *	@param $ip string source IP (v4 or v6)
91
+	 *	@param $oid string oid
92
+	 */
93
+	public function deleteTrap($ip,$oid)
94
+	{
95 95
         
96
-        $dbConn = $this->getDbConn();
97
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
98
-        $condition=null;
99
-        if ($ip != null)
100
-        {
101
-            $condition="source_ip='$ip'";
102
-        }
103
-        if ($oid != null)
104
-        {
105
-            $condition=($condition===null)?'':$condition.' AND ';
106
-            $condition.="trap_oid='$oid'";
107
-        }
108
-        if($condition === null) return null;
109
-        $query=$dbConn->delete(
110
-            $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
111
-            $condition
112
-            );
113
-        // TODO test ret code etc...
114
-        return $query;
115
-    }
96
+		$dbConn = $this->getDbConn();
97
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
98
+		$condition=null;
99
+		if ($ip != null)
100
+		{
101
+			$condition="source_ip='$ip'";
102
+		}
103
+		if ($oid != null)
104
+		{
105
+			$condition=($condition===null)?'':$condition.' AND ';
106
+			$condition.="trap_oid='$oid'";
107
+		}
108
+		if($condition === null) return null;
109
+		$query=$dbConn->delete(
110
+			$this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
111
+			$condition
112
+			);
113
+		// TODO test ret code etc...
114
+		return $query;
115
+	}
116 116
     
117 117
     
118
-    /** count trap by ip & oid
119
-     *	@param $ip string source IP (v4 or v6)
120
-     *	@param $oid string oid
121
-     */
122
-    public function countTrap($ip,$oid)
123
-    {
118
+	/** count trap by ip & oid
119
+	 *	@param $ip string source IP (v4 or v6)
120
+	 *	@param $oid string oid
121
+	 */
122
+	public function countTrap($ip,$oid)
123
+	{
124 124
         
125
-        $dbConn = $this->getDbConn();
126
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
125
+		$dbConn = $this->getDbConn();
126
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
127 127
         
128
-        $condition=null;
129
-        if ($ip != null)
130
-        {
131
-            $condition="source_ip='$ip'";
132
-        }
133
-        if ($oid != null)
134
-        {
135
-            $condition=($condition===null)?'':$condition.' AND ';
136
-            $condition.="trap_oid='$oid'";
137
-        }
138
-        if($condition === null) return 0;
139
-        $query=$dbConn->select()
140
-        ->from(
141
-            $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
142
-            array('num'=>'count(*)'))
143
-            ->where($condition);
144
-            $return_row=$dbConn->fetchRow($query);
145
-            return $return_row->num;
146
-    }
128
+		$condition=null;
129
+		if ($ip != null)
130
+		{
131
+			$condition="source_ip='$ip'";
132
+		}
133
+		if ($oid != null)
134
+		{
135
+			$condition=($condition===null)?'':$condition.' AND ';
136
+			$condition.="trap_oid='$oid'";
137
+		}
138
+		if($condition === null) return 0;
139
+		$query=$dbConn->select()
140
+		->from(
141
+			$this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
142
+			array('num'=>'count(*)'))
143
+			->where($condition);
144
+			$return_row=$dbConn->fetchRow($query);
145
+			return $return_row->num;
146
+	}
147 147
     
148
-    /** get configuration value
149
-     *	@param string $element : configuration name in db
150
-     */
151
-    public function getDBConfigValue($element)
152
-    {
148
+	/** get configuration value
149
+	 *	@param string $element : configuration name in db
150
+	 */
151
+	public function getDBConfigValue($element)
152
+	{
153 153
         
154
-        $dbConn = $this->getDbConn();
155
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
154
+		$dbConn = $this->getDbConn();
155
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
156 156
         
157
-        $query=$dbConn->select()
158
-        ->from(
159
-            $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
160
-            array('value'=>'value'))
161
-            ->where('name=?',$element);
162
-            $return_row=$dbConn->fetchRow($query);
163
-            if ($return_row==null)  // value does not exists
164
-            {
165
-                $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
166
-                if ( ! isset($default[$element])) return null; // no default and not value
157
+		$query=$dbConn->select()
158
+		->from(
159
+			$this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
160
+			array('value'=>'value'))
161
+			->where('name=?',$element);
162
+			$return_row=$dbConn->fetchRow($query);
163
+			if ($return_row==null)  // value does not exists
164
+			{
165
+				$default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
166
+				if ( ! isset($default[$element])) return null; // no default and not value
167 167
                 
168
-                $this->addDBConfigValue($element,$default[$element]);
169
-                return $default[$element];
170
-            }
171
-            if ($return_row->value == null) // value id empty
172
-            {
173
-                $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
174
-                if ( ! isset($default[$element])) return null; // no default and not value
175
-                $this->setDBConfigValue($element,$default[$element]);
176
-                return $default[$element];
177
-            }
178
-            return $return_row->value;
179
-    }
168
+				$this->addDBConfigValue($element,$default[$element]);
169
+				return $default[$element];
170
+			}
171
+			if ($return_row->value == null) // value id empty
172
+			{
173
+				$default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
174
+				if ( ! isset($default[$element])) return null; // no default and not value
175
+				$this->setDBConfigValue($element,$default[$element]);
176
+				return $default[$element];
177
+			}
178
+			return $return_row->value;
179
+	}
180 180
     
181
-    /** add configuration value
182
-     *	@param string $element : name of config element
183
-     *   @param string $value : value
184
-     */
181
+	/** add configuration value
182
+	 *	@param string $element : name of config element
183
+	 *   @param string $value : value
184
+	 */
185 185
     
186
-    public function addDBConfigValue($element,$value)
187
-    {
186
+	public function addDBConfigValue($element,$value)
187
+	{
188 188
         
189
-        $dbConn = $this->getDbConn();
190
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
189
+		$dbConn = $this->getDbConn();
190
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
191 191
         
192
-        $query=$dbConn->insert(
193
-            $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
194
-            array(
195
-                'name' => $element,
196
-                'value'=>$value
197
-            )
198
-            );
199
-        return $query;
200
-    }
192
+		$query=$dbConn->insert(
193
+			$this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
194
+			array(
195
+				'name' => $element,
196
+				'value'=>$value
197
+			)
198
+			);
199
+		return $query;
200
+	}
201 201
     
202
-    /** set configuration value
203
-     *	@param string $element : name of config element
204
-     *   @param string $value : value
205
-     */
206
-    public function setDBConfigValue($element,$value)
207
-    {
202
+	/** set configuration value
203
+	 *	@param string $element : name of config element
204
+	 *   @param string $value : value
205
+	 */
206
+	public function setDBConfigValue($element,$value)
207
+	{
208 208
         
209
-        $dbConn = $this->getDbConn();
210
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
209
+		$dbConn = $this->getDbConn();
210
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
211 211
         
212
-        $query=$dbConn->update(
213
-            $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
214
-            array('value'=>$value),
215
-            'name=\''.$element.'\''
216
-            );
217
-        return $query;
218
-    }
212
+		$query=$dbConn->update(
213
+			$this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
214
+			array('value'=>$value),
215
+			'name=\''.$element.'\''
216
+			);
217
+		return $query;
218
+	}
219 219
     
220 220
     
221 221
 }
222 222
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
     {
30 30
         // TODO Check for rule consistency
31 31
         
32
-        $dbConn = $this->getDbConn();
32
+        $dbConn=$this->getDbConn();
33 33
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
34 34
         // Add last modified date = creation date and username
35
-        $params['created'] = new Zend_Db_Expr('NOW()');
36
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
37
-        $params['modifier'] = $this->Auth()->getUser()->getUsername();
35
+        $params['created']=new Zend_Db_Expr('NOW()');
36
+        $params['modified']=new 	Zend_Db_Expr('NOW()');
37
+        $params['modifier']=$this->Auth()->getUser()->getUsername();
38 38
         
39 39
         $query=$dbConn->insert(
40 40
             $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
41 41
             $params
42 42
             );
43
-        if($query==false)
43
+        if ($query == false)
44 44
         {
45 45
             return null;
46 46
         }
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
      *   @param integer $ruleID : rule id in db
53 53
      *	@return array affected rows
54 54
      */
55
-    public function updateHandlerRule($params,$ruleID)
55
+    public function updateHandlerRule($params, $ruleID)
56 56
     {
57 57
         // TODO Check for rule consistency
58
-        $dbConn = $this->getDbConn();
58
+        $dbConn=$this->getDbConn();
59 59
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
60 60
         // Add last modified date = creation date and username
61
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
62
-        $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
61
+        $params['modified']=new 	Zend_Db_Expr('NOW()');
62
+        $params['modifier']=$this->getTrapCtrl()->Auth()->getUser()->getUsername();
63 63
         
64 64
         $numRows=$dbConn->update(
65 65
             $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function deleteRule($ruleID)
76 76
     {
77
-        if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id');  }
77
+        if (!preg_match('/^[0-9]+$/', $ruleID)) { throw new Exception('Invalid id'); }
78 78
         
79
-        $dbConn = $this->getDbConn();
79
+        $dbConn=$this->getDbConn();
80 80
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
81 81
         
82 82
         $query=$dbConn->delete(
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
      *	@param $ip string source IP (v4 or v6)
91 91
      *	@param $oid string oid
92 92
      */
93
-    public function deleteTrap($ip,$oid)
93
+    public function deleteTrap($ip, $oid)
94 94
     {
95 95
         
96
-        $dbConn = $this->getDbConn();
96
+        $dbConn=$this->getDbConn();
97 97
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
98 98
         $condition=null;
99 99
         if ($ip != null)
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
         }
103 103
         if ($oid != null)
104 104
         {
105
-            $condition=($condition===null)?'':$condition.' AND ';
105
+            $condition=($condition === null) ? '' : $condition.' AND ';
106 106
             $condition.="trap_oid='$oid'";
107 107
         }
108
-        if($condition === null) return null;
108
+        if ($condition === null) return null;
109 109
         $query=$dbConn->delete(
110 110
             $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
111 111
             $condition
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
      *	@param $ip string source IP (v4 or v6)
120 120
      *	@param $oid string oid
121 121
      */
122
-    public function countTrap($ip,$oid)
122
+    public function countTrap($ip, $oid)
123 123
     {
124 124
         
125
-        $dbConn = $this->getDbConn();
125
+        $dbConn=$this->getDbConn();
126 126
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
127 127
         
128 128
         $condition=null;
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
         }
133 133
         if ($oid != null)
134 134
         {
135
-            $condition=($condition===null)?'':$condition.' AND ';
135
+            $condition=($condition === null) ? '' : $condition.' AND ';
136 136
             $condition.="trap_oid='$oid'";
137 137
         }
138
-        if($condition === null) return 0;
138
+        if ($condition === null) return 0;
139 139
         $query=$dbConn->select()
140 140
         ->from(
141 141
             $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
@@ -151,28 +151,28 @@  discard block
 block discarded – undo
151 151
     public function getDBConfigValue($element)
152 152
     {
153 153
         
154
-        $dbConn = $this->getDbConn();
154
+        $dbConn=$this->getDbConn();
155 155
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
156 156
         
157 157
         $query=$dbConn->select()
158 158
         ->from(
159 159
             $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
160 160
             array('value'=>'value'))
161
-            ->where('name=?',$element);
161
+            ->where('name=?', $element);
162 162
             $return_row=$dbConn->fetchRow($query);
163
-            if ($return_row==null)  // value does not exists
163
+            if ($return_row == null)  // value does not exists
164 164
             {
165 165
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
166
-                if ( ! isset($default[$element])) return null; // no default and not value
166
+                if (!isset($default[$element])) return null; // no default and not value
167 167
                 
168
-                $this->addDBConfigValue($element,$default[$element]);
168
+                $this->addDBConfigValue($element, $default[$element]);
169 169
                 return $default[$element];
170 170
             }
171 171
             if ($return_row->value == null) // value id empty
172 172
             {
173 173
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
174
-                if ( ! isset($default[$element])) return null; // no default and not value
175
-                $this->setDBConfigValue($element,$default[$element]);
174
+                if (!isset($default[$element])) return null; // no default and not value
175
+                $this->setDBConfigValue($element, $default[$element]);
176 176
                 return $default[$element];
177 177
             }
178 178
             return $return_row->value;
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
      *   @param string $value : value
184 184
      */
185 185
     
186
-    public function addDBConfigValue($element,$value)
186
+    public function addDBConfigValue($element, $value)
187 187
     {
188 188
         
189
-        $dbConn = $this->getDbConn();
189
+        $dbConn=$this->getDbConn();
190 190
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
191 191
         
192 192
         $query=$dbConn->insert(
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
      *	@param string $element : name of config element
204 204
      *   @param string $value : value
205 205
      */
206
-    public function setDBConfigValue($element,$value)
206
+    public function setDBConfigValue($element, $value)
207 207
     {
208 208
         
209
-        $dbConn = $this->getDbConn();
209
+        $dbConn=$this->getDbConn();
210 210
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
211 211
         
212 212
         $query=$dbConn->update(
Please login to merge, or discard this patch.
Braces   +44 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@  discard block
 block discarded – undo
30 30
         // TODO Check for rule consistency
31 31
         
32 32
         $dbConn = $this->getDbConn();
33
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
33
+        if ($dbConn === null) {
34
+        	throw new \ErrorException('uncatched db error');
35
+        }
34 36
         // Add last modified date = creation date and username
35 37
         $params['created'] = new Zend_Db_Expr('NOW()');
36 38
         $params['modified'] = new 	Zend_Db_Expr('NOW()');
@@ -56,7 +58,9 @@  discard block
 block discarded – undo
56 58
     {
57 59
         // TODO Check for rule consistency
58 60
         $dbConn = $this->getDbConn();
59
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
61
+        if ($dbConn === null) {
62
+        	throw new \ErrorException('uncatched db error');
63
+        }
60 64
         // Add last modified date = creation date and username
61 65
         $params['modified'] = new 	Zend_Db_Expr('NOW()');
62 66
         $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
@@ -77,7 +81,9 @@  discard block
 block discarded – undo
77 81
         if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id');  }
78 82
         
79 83
         $dbConn = $this->getDbConn();
80
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
84
+        if ($dbConn === null) {
85
+        	throw new \ErrorException('uncatched db error');
86
+        }
81 87
         
82 88
         $query=$dbConn->delete(
83 89
             $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
@@ -94,7 +100,9 @@  discard block
 block discarded – undo
94 100
     {
95 101
         
96 102
         $dbConn = $this->getDbConn();
97
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
103
+        if ($dbConn === null) {
104
+        	throw new \ErrorException('uncatched db error');
105
+        }
98 106
         $condition=null;
99 107
         if ($ip != null)
100 108
         {
@@ -105,7 +113,9 @@  discard block
 block discarded – undo
105 113
             $condition=($condition===null)?'':$condition.' AND ';
106 114
             $condition.="trap_oid='$oid'";
107 115
         }
108
-        if($condition === null) return null;
116
+        if($condition === null) {
117
+        	return null;
118
+        }
109 119
         $query=$dbConn->delete(
110 120
             $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
111 121
             $condition
@@ -123,7 +133,9 @@  discard block
 block discarded – undo
123 133
     {
124 134
         
125 135
         $dbConn = $this->getDbConn();
126
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
136
+        if ($dbConn === null) {
137
+        	throw new \ErrorException('uncatched db error');
138
+        }
127 139
         
128 140
         $condition=null;
129 141
         if ($ip != null)
@@ -135,7 +147,9 @@  discard block
 block discarded – undo
135 147
             $condition=($condition===null)?'':$condition.' AND ';
136 148
             $condition.="trap_oid='$oid'";
137 149
         }
138
-        if($condition === null) return 0;
150
+        if($condition === null) {
151
+        	return 0;
152
+        }
139 153
         $query=$dbConn->select()
140 154
         ->from(
141 155
             $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
@@ -152,7 +166,9 @@  discard block
 block discarded – undo
152 166
     {
153 167
         
154 168
         $dbConn = $this->getDbConn();
155
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
169
+        if ($dbConn === null) {
170
+        	throw new \ErrorException('uncatched db error');
171
+        }
156 172
         
157 173
         $query=$dbConn->select()
158 174
         ->from(
@@ -160,18 +176,28 @@  discard block
 block discarded – undo
160 176
             array('value'=>'value'))
161 177
             ->where('name=?',$element);
162 178
             $return_row=$dbConn->fetchRow($query);
163
-            if ($return_row==null)  // value does not exists
179
+            if ($return_row==null) {
180
+            	// value does not exists
164 181
             {
165 182
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
166
-                if ( ! isset($default[$element])) return null; // no default and not value
183
+            }
184
+                if ( ! isset($default[$element])) {
185
+                	return null;
186
+                }
187
+                // no default and not value
167 188
                 
168 189
                 $this->addDBConfigValue($element,$default[$element]);
169 190
                 return $default[$element];
170 191
             }
171
-            if ($return_row->value == null) // value id empty
192
+            if ($return_row->value == null) {
193
+            	// value id empty
172 194
             {
173 195
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
174
-                if ( ! isset($default[$element])) return null; // no default and not value
196
+            }
197
+                if ( ! isset($default[$element])) {
198
+                	return null;
199
+                }
200
+                // no default and not value
175 201
                 $this->setDBConfigValue($element,$default[$element]);
176 202
                 return $default[$element];
177 203
             }
@@ -187,7 +213,9 @@  discard block
 block discarded – undo
187 213
     {
188 214
         
189 215
         $dbConn = $this->getDbConn();
190
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
216
+        if ($dbConn === null) {
217
+        	throw new \ErrorException('uncatched db error');
218
+        }
191 219
         
192 220
         $query=$dbConn->insert(
193 221
             $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
@@ -207,7 +235,9 @@  discard block
 block discarded – undo
207 235
     {
208 236
         
209 237
         $dbConn = $this->getDbConn();
210
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
238
+        if ($dbConn === null) {
239
+        	throw new \ErrorException('uncatched db error');
240
+        }
211 241
         
212 242
         $query=$dbConn->update(
213 243
             $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
Please login to merge, or discard this patch.