Passed
Push — master ( 1d8afe...b3ce84 )
by Patrick
02:10
created
library/Trapdirector/Tables/HandlerTable.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -7,137 +7,137 @@
 block discarded – undo
7 7
 class HandlerTable extends TrapDirectorTable
8 8
 {
9 9
 
10
-    protected $status_display=array(
11
-        -2	=>'ignore',
12
-        -1 => '-',
13
-        0	=> 'OK',
14
-        1	=> 'warning',
15
-        2	=> 'critical',
16
-        3	=> 'unknown',);
10
+	protected $status_display=array(
11
+		-2	=>'ignore',
12
+		-1 => '-',
13
+		0	=> 'OK',
14
+		1	=> 'warning',
15
+		2	=> 'critical',
16
+		3	=> 'unknown',);
17 17
     
18
-    // translate
19
-    protected $doTranslate=false;
20
-    protected $MIB;
18
+	// translate
19
+	protected $doTranslate=false;
20
+	protected $MIB;
21 21
     
22
-    // categories
23
-    protected $categories = NULL;
22
+	// categories
23
+	protected $categories = NULL;
24 24
     
25
-    public function setCategoriesArray(array $categories)
26
-    {
27
-        $this->categories = $categories;
28
-    }
25
+	public function setCategoriesArray(array $categories)
26
+	{
27
+		$this->categories = $categories;
28
+	}
29 29
     
30
-    public function groupingPrintData( $value)
31
-    {
32
-        if ($this->groupingColumn == 'rule_type')
33
-        {
34
-            if ($this->categories == NULL || (! isset($this->categories[$value])))
35
-                return 'Unknown category ('.$value.')';
36
-            return 'Category : '. $this->categories[$value];
37
-        }
38
-        $html = "$value";
39
-        return $html;
40
-    }
30
+	public function groupingPrintData( $value)
31
+	{
32
+		if ($this->groupingColumn == 'rule_type')
33
+		{
34
+			if ($this->categories == NULL || (! isset($this->categories[$value])))
35
+				return 'Unknown category ('.$value.')';
36
+			return 'Category : '. $this->categories[$value];
37
+		}
38
+		$html = "$value";
39
+		return $html;
40
+	}
41 41
     
42
-    public function setMibloader($mibloader)
43
-    {
44
-        $this->MIB=$mibloader;
45
-        $this->doTranslate=true;
46
-    }
42
+	public function setMibloader($mibloader)
43
+	{
44
+		$this->MIB=$mibloader;
45
+		$this->doTranslate=true;
46
+	}
47 47
 
48
-    public function titleOrder($name)
49
-    {
50
-        switch ($name)
51
-        {
52
-            case 'host_name' : return $this->content[$name]; break;
53
-            case 'source_ip' : return 'ip4'; break;
54
-            default: return $this->content[$name];	
55
-        }
56
-        return NULL;
57
-    }
48
+	public function titleOrder($name)
49
+	{
50
+		switch ($name)
51
+		{
52
+			case 'host_name' : return $this->content[$name]; break;
53
+			case 'source_ip' : return 'ip4'; break;
54
+			default: return $this->content[$name];	
55
+		}
56
+		return NULL;
57
+	}
58 58
     
59
-    public function getCurrentURL()
60
-    {
61
-        return Url::fromPath($this->urlPath . '/handler');
62
-    }
59
+	public function getCurrentURL()
60
+	{
61
+		return Url::fromPath($this->urlPath . '/handler');
62
+	}
63 63
     
64
-    public function renderLine($row)
65
-      {
66
-          $html = '';
67
-          $firstCol = true;
64
+	public function renderLine($row)
65
+	  {
66
+		  $html = '';
67
+		  $firstCol = true;
68 68
                
69
-          $titleNames = array_keys($this->titles);
70
-          foreach ($titleNames as $rowkey )
71
-          {        
72
-              // Check missing value
73
-              if (property_exists($row, $rowkey))
74
-              {
75
-                  switch ($rowkey)
76
-                  {
77
-                      case 'action_match': // display text levels
78
-                      case 'action_nomatch':
79
-                          $val=$this->status_display[$row->$rowkey];
80
-                          break;
81
-                      case 'trap_oid': // try to traslate oids.
69
+		  $titleNames = array_keys($this->titles);
70
+		  foreach ($titleNames as $rowkey )
71
+		  {        
72
+			  // Check missing value
73
+			  if (property_exists($row, $rowkey))
74
+			  {
75
+				  switch ($rowkey)
76
+				  {
77
+					  case 'action_match': // display text levels
78
+					  case 'action_nomatch':
79
+						  $val=$this->status_display[$row->$rowkey];
80
+						  break;
81
+					  case 'trap_oid': // try to traslate oids.
82 82
                           
83
-                          if ($this->doTranslate === true)
84
-                          {
85
-                              $oidName = $this->MIB->translateOID($row->$rowkey);
86
-                              if (isset($oidName['name']))
87
-                              {
88
-                                  $val=$oidName['name'];
89
-                              }
90
-                              else
91
-                              {
92
-                                  $val = $row->$rowkey;
93
-                              }
94
-                          }
95
-                          else
96
-                          {
97
-                              $val = $row->$rowkey;
98
-                          }
99
-                          break;
100
-                      case 'host_name': // switch to hostgroup if name is null
101
-                          if ($row->$rowkey == null)
102
-                          {
103
-                              $val = $row->host_group_name;
104
-                          }
105
-                          else
106
-                          {
107
-                              $val = $row->$rowkey;
108
-                          }
109
-                          break;
110
-                      default:
111
-                          $val = $row->$rowkey;
112
-                  }
113
-                  if ($rowkey == 'trap_oid' && $this->doTranslate===true)
114
-                  {
83
+						  if ($this->doTranslate === true)
84
+						  {
85
+							  $oidName = $this->MIB->translateOID($row->$rowkey);
86
+							  if (isset($oidName['name']))
87
+							  {
88
+								  $val=$oidName['name'];
89
+							  }
90
+							  else
91
+							  {
92
+								  $val = $row->$rowkey;
93
+							  }
94
+						  }
95
+						  else
96
+						  {
97
+							  $val = $row->$rowkey;
98
+						  }
99
+						  break;
100
+					  case 'host_name': // switch to hostgroup if name is null
101
+						  if ($row->$rowkey == null)
102
+						  {
103
+							  $val = $row->host_group_name;
104
+						  }
105
+						  else
106
+						  {
107
+							  $val = $row->$rowkey;
108
+						  }
109
+						  break;
110
+					  default:
111
+						  $val = $row->$rowkey;
112
+				  }
113
+				  if ($rowkey == 'trap_oid' && $this->doTranslate===true)
114
+				  {
115 115
                       
116
-                  }
117
-              } else {
118
-                  $val = '-';
119
-              }
120
-              if ($firstCol === true) { // Put link in first column for trap detail.
121
-                  $html .= '<td class="traphover">'
122
-                      . $this->view->qlink(
123
-                          $this->view->escape($val),
124
-                          Url::fromPath(
125
-                              $this->urlPath . '/handler/add',
126
-                              array('ruleid' => $row->id)
127
-                              )
128
-                          );
129
-                  if ($row->comment != '')
130
-                  {
131
-                      $html.= '<span class="tohover">'. $row->comment .'</span></td>';
132
-                  }
133
-                  $html.= '</td>';
134
-              } else {
135
-                  $html .= '<td>' . $this->view->escape($val) . '</td>';
136
-              }
137
-              $firstCol=false;
116
+				  }
117
+			  } else {
118
+				  $val = '-';
119
+			  }
120
+			  if ($firstCol === true) { // Put link in first column for trap detail.
121
+				  $html .= '<td class="traphover">'
122
+					  . $this->view->qlink(
123
+						  $this->view->escape($val),
124
+						  Url::fromPath(
125
+							  $this->urlPath . '/handler/add',
126
+							  array('ruleid' => $row->id)
127
+							  )
128
+						  );
129
+				  if ($row->comment != '')
130
+				  {
131
+					  $html.= '<span class="tohover">'. $row->comment .'</span></td>';
132
+				  }
133
+				  $html.= '</td>';
134
+			  } else {
135
+				  $html .= '<td>' . $this->view->escape($val) . '</td>';
136
+			  }
137
+			  $firstCol=false;
138 138
               
139
-          }
140
-          return $html;
141
-      }
139
+		  }
140
+		  return $html;
141
+	  }
142 142
 
143 143
 }
144 144
\ No newline at end of file
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapDirectorTable.php 1 patch
Indentation   +391 added lines, -391 removed lines patch added patch discarded remove patch
@@ -5,299 +5,299 @@  discard block
 block discarded – undo
5 5
 
6 6
 abstract class TrapDirectorTable
7 7
 {
8
-    /** @var array $titles table titles (name, display value) */
9
-    protected $titles = null;
8
+	/** @var array $titles table titles (name, display value) */
9
+	protected $titles = null;
10 10
 
11
-    /** @var array $content table content  (name, sb column name). name index must be the same as $titles*/
12
-    protected $content = null;
11
+	/** @var array $content table content  (name, sb column name). name index must be the same as $titles*/
12
+	protected $content = null;
13 13
     
14
-    /** @var array $columnNames names of columns for filtering */
15
-    protected $columnNames = array();
14
+	/** @var array $columnNames names of columns for filtering */
15
+	protected $columnNames = array();
16 16
     
17
-    /** @var mixed $dbConn connection to database  */
18
-    protected $dbConn = null;
17
+	/** @var mixed $dbConn connection to database  */
18
+	protected $dbConn = null;
19 19
     
20
-    /** Current view **/
21
-    protected $view;
20
+	/** Current view **/
21
+	protected $view;
22 22
     
23
-    protected $urlPath;
23
+	protected $urlPath;
24 24
     
25
-    // Database stuff
25
+	// Database stuff
26 26
    /** @var array $table (db ref, name) */
27
-    protected $table = array();
27
+	protected $table = array();
28 28
     
29
-    /** @var mixed  $query Query in database; */
30
-    protected $query = null;
29
+	/** @var mixed  $query Query in database; */
30
+	protected $query = null;
31 31
     
32
-    /** @var array $order : (db column, 'ASC' | 'DESC') */
33
-    protected $order = array();
34
-    protected $orderQuery = '';
32
+	/** @var array $order : (db column, 'ASC' | 'DESC') */
33
+	protected $order = array();
34
+	protected $orderQuery = '';
35 35
     
36
-    /********* Filter ********/
37
-    /** @var string $filterString : string filter for db columns */
38
-    protected $filterString = '';
36
+	/********* Filter ********/
37
+	/** @var string $filterString : string filter for db columns */
38
+	protected $filterString = '';
39 39
     
40
-    /** @var array $filterColumn : columns to apply filter to */
41
-    protected $filterColumn = array();
40
+	/** @var array $filterColumn : columns to apply filter to */
41
+	protected $filterColumn = array();
42 42
     
43
-    protected $filterQuery='';
43
+	protected $filterQuery='';
44 44
     
45
-    /*************** Paging *************/
46
-    protected $maxPerPage = 25;
45
+	/*************** Paging *************/
46
+	protected $maxPerPage = 25;
47 47
     
48
-    protected $currentPage = 0;
48
+	protected $currentPage = 0;
49 49
     
50
-    /*************** Grouping ************/
51
-    protected $grouppingActive=false;
50
+	/*************** Grouping ************/
51
+	protected $grouppingActive=false;
52 52
     
53
-    protected $groupingColumn='';
53
+	protected $groupingColumn='';
54 54
     
55
-    protected $groupingVal='';
55
+	protected $groupingVal='';
56 56
     
57
-    protected $groupingColSpan=1;
57
+	protected $groupingColSpan=1;
58 58
     
59
-    function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath)
60
-    {
61
-        $this->table = $table;
62
-        $this->titles = $titles;
63
-        $this->content = $columns;
64
-        $this->columnNames = $columnNames;
65
-        $this->dbConn = $dbConn;
59
+	function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath)
60
+	{
61
+		$this->table = $table;
62
+		$this->titles = $titles;
63
+		$this->content = $columns;
64
+		$this->columnNames = $columnNames;
65
+		$this->dbConn = $dbConn;
66 66
         
67
-        $this->view = $view;
68
-        $this->urlPath = $urlPath;
67
+		$this->view = $view;
68
+		$this->urlPath = $urlPath;
69 69
         
70
-        return $this;
71
-    }
70
+		return $this;
71
+	}
72 72
 
73 73
     
74
-    /************** GET variables and URLs *************/
75
-    public function getParams(array $getVars)
76
-    {
77
-        $this->getFilterQuery($getVars);
78
-        $this->getPagingQuery($getVars);
79
-        $this->getOrderQuery($getVars);
80
-    }
81
-    
82
-    public function getCurrentURL()
83
-    {
84
-        return '?';
85
-    }
86
-    
87
-    protected function getCurrentURLAndQS(string $caller)
88
-    {
89
-        $actionURL = $this->getCurrentURL() . '?' ;
90
-        $QSList=array();
91
-        if ($caller != 'filter' && $this->curFilterQuery() != '')
92
-            array_push($QSList , $this->curFilterQuery());
74
+	/************** GET variables and URLs *************/
75
+	public function getParams(array $getVars)
76
+	{
77
+		$this->getFilterQuery($getVars);
78
+		$this->getPagingQuery($getVars);
79
+		$this->getOrderQuery($getVars);
80
+	}
81
+    
82
+	public function getCurrentURL()
83
+	{
84
+		return '?';
85
+	}
86
+    
87
+	protected function getCurrentURLAndQS(string $caller)
88
+	{
89
+		$actionURL = $this->getCurrentURL() . '?' ;
90
+		$QSList=array();
91
+		if ($caller != 'filter' && $this->curFilterQuery() != '')
92
+			array_push($QSList , $this->curFilterQuery());
93 93
         
94
-        if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '')
95
-            array_push($QSList , $this->curPagingQuery());
94
+		if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '')
95
+			array_push($QSList , $this->curPagingQuery());
96 96
  
97
-        if ($caller != 'order' && $this->curOrderQuery() != '')
98
-            array_push($QSList , $this->curOrderQuery());
97
+		if ($caller != 'order' && $this->curOrderQuery() != '')
98
+			array_push($QSList , $this->curOrderQuery());
99 99
         
100
-        if (count($QSList) != 0)
101
-            $actionURL .=  implode('&', $QSList) . '&';
100
+		if (count($QSList) != 0)
101
+			$actionURL .=  implode('&', $QSList) . '&';
102 102
         
103
-        return $actionURL;
104
-    }
105
-    
106
-    /************* DB queries ******************/
107
-    /**
108
-     * Get base query in $this->query
109
-     * @return  TrapDirectorTable
110
-     */
111
-    public function getBaseQuery()
112
-    {
113
-        $this->query = $this->dbConn->select();
114
-        $this->query = $this->query->from(
115
-            $this->table,
116
-            $this->content
117
-            );
103
+		return $actionURL;
104
+	}
105
+    
106
+	/************* DB queries ******************/
107
+	/**
108
+	 * Get base query in $this->query
109
+	 * @return  TrapDirectorTable
110
+	 */
111
+	public function getBaseQuery()
112
+	{
113
+		$this->query = $this->dbConn->select();
114
+		$this->query = $this->query->from(
115
+			$this->table,
116
+			$this->content
117
+			);
118 118
         
119
-        return $this;
120
-    }
121
-    
122
-    public function fullQuery()
123
-    {
124
-        $this->getBaseQuery()
125
-        ->applyFilter()
126
-        ->applyPaging()
127
-        ->applyOrder();
119
+		return $this;
120
+	}
121
+    
122
+	public function fullQuery()
123
+	{
124
+		$this->getBaseQuery()
125
+		->applyFilter()
126
+		->applyPaging()
127
+		->applyOrder();
128 128
         
129
-        return $this->dbConn->fetchAll($this->query);
130
-        //return $this->query->fetchAll();
131
-    }
132
-    
133
-    
134
-    /**************** Filtering ******************/
135
-    
136
-    public function applyFilter()
137
-    {
138
-        if ($this->filterString == '' || count($this->filterColumn) == 0)
139
-        {
140
-            return $this;
141
-        }
142
-        $filter='';
143
-        foreach ($this->filterColumn as $column)
144
-        {
145
-            if ($filter != "") $filter.=' OR ';
146
-            //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'";
147
-            $filter .= $column  . " LIKE '%" . $this->filterString. "%'";
148
-        }
149
-        //echo $filter;
129
+		return $this->dbConn->fetchAll($this->query);
130
+		//return $this->query->fetchAll();
131
+	}
132
+    
133
+    
134
+	/**************** Filtering ******************/
135
+    
136
+	public function applyFilter()
137
+	{
138
+		if ($this->filterString == '' || count($this->filterColumn) == 0)
139
+		{
140
+			return $this;
141
+		}
142
+		$filter='';
143
+		foreach ($this->filterColumn as $column)
144
+		{
145
+			if ($filter != "") $filter.=' OR ';
146
+			//$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'";
147
+			$filter .= $column  . " LIKE '%" . $this->filterString. "%'";
148
+		}
149
+		//echo $filter;
150 150
         
151
-        $this->query=$this->query->where($filter);
151
+		$this->query=$this->query->where($filter);
152 152
 
153
-        return $this;
154
-    }
153
+		return $this;
154
+	}
155 155
 
156
-    public function setFilter(string $filter, array $filterCol)
157
-    {
158
-        $this->filterString = $filter;
159
-        $this->filterColumn = $filterCol;
160
-        return $this;
161
-    }
156
+	public function setFilter(string $filter, array $filterCol)
157
+	{
158
+		$this->filterString = $filter;
159
+		$this->filterColumn = $filterCol;
160
+		return $this;
161
+	}
162 162
    
163
-    public function renderFilter()
164
-    {
163
+	public function renderFilter()
164
+	{
165 165
         
166
-        $html=' <form id="genfilter" name="mainFilterGen"
166
+		$html=' <form id="genfilter" name="mainFilterGen"
167 167
 			enctype="application/x-www-form-urlencoded"
168 168
 			action="'.$this->getCurrentURLAndQS('filter').'"
169 169
 			method="get">';
170
-        $html.='<input type="text" name="f" title="Search is simple! Try to combine multiple words"
170
+		$html.='<input type="text" name="f" title="Search is simple! Try to combine multiple words"
171 171
 	placeholder="Search..."  value="'.$this->filterQuery.'">';
172 172
 
173
-        $html.='</form>';
174
-        return $html;
175
-    }
173
+		$html.='</form>';
174
+		return $html;
175
+	}
176 176
  
177
-    public function getFilterQuery(array $getVars)
178
-    {
179
-        if (isset($getVars['f']))
180
-        {
181
-            $this->filterQuery = $getVars['f'];
182
-            $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames);
183
-        }
184
-    }
185
-    
186
-    protected function curFilterQuery()
187
-    {
188
-        if ($this->filterQuery == '') return '';
189
-        return 'f='.$this->filterQuery;
190
-    }
191
-    
192
-    /***************** Ordering ********************/
193
-    
194
-    public function applyOrder()
195
-    {
196
-        if (count($this->order) == 0)
197
-        {
198
-            return $this;
199
-        }
200
-        $orderSQL='';
201
-        foreach ($this->order as $column => $direction)
202
-        {
203
-            if ($orderSQL != "") $orderSQL.=',';
177
+	public function getFilterQuery(array $getVars)
178
+	{
179
+		if (isset($getVars['f']))
180
+		{
181
+			$this->filterQuery = $getVars['f'];
182
+			$this->setFilter(html_entity_decode($getVars['f']), $this->columnNames);
183
+		}
184
+	}
185
+    
186
+	protected function curFilterQuery()
187
+	{
188
+		if ($this->filterQuery == '') return '';
189
+		return 'f='.$this->filterQuery;
190
+	}
191
+    
192
+	/***************** Ordering ********************/
193
+    
194
+	public function applyOrder()
195
+	{
196
+		if (count($this->order) == 0)
197
+		{
198
+			return $this;
199
+		}
200
+		$orderSQL='';
201
+		foreach ($this->order as $column => $direction)
202
+		{
203
+			if ($orderSQL != "") $orderSQL.=',';
204 204
             
205
-            $orderSQL .= $column . ' ' . $direction;
206
-        }
207
-        $this->query = $this->query->order($orderSQL);
205
+			$orderSQL .= $column . ' ' . $direction;
206
+		}
207
+		$this->query = $this->query->order($orderSQL);
208 208
         
209
-        return $this;
210
-    }
211
-    
212
-    public function setOrder(array $order)
213
-    {
214
-        $this->order = $order;
215
-        return $this;
216
-    }
209
+		return $this;
210
+	}
211
+    
212
+	public function setOrder(array $order)
213
+	{
214
+		$this->order = $order;
215
+		return $this;
216
+	}
217 217
 
218
-    public function isOrderSet()
219
-    {
220
-        if (count($this->order == 0)) return FALSE;
221
-        return TRUE;
222
-    }
223
-    
224
-    public function getOrderQuery(array $getVars)
225
-    {
226
-        if (isset($getVars['o']))
227
-        {
228
-            $this->orderQuery = $getVars['o'];
229
-            $match = array();
230
-            if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match))
231
-            {
232
-                $orderArray=array($match[1] => $match[2]);
233
-                echo "$match[1] => $match[2]";
234
-                $this->setOrder($orderArray);
235
-            }
236
-        }
237
-    }
238
-    
239
-    protected function curOrderQuery()
240
-    {
241
-        if ($this->orderQuery == '') return '';
242
-        return 'o='.$this->orderQuery;
243
-    }
244
-    
245
-    /*****************  Paging and counting *********/
246
-    
247
-    public function countQuery()
248
-    {
249
-        $this->query = $this->dbConn->select();
250
-        $this->query = $this->query
251
-            ->from(
252
-                $this->table,
253
-                array('COUNT(*)')
254
-                );
255
-        $this->applyFilter();                   
256
-    }
257
-    
258
-    public function count()
259
-    {
260
-        $this->countQuery();
261
-        return $this->dbConn->fetchOne($this->query);
262
-    }
263
-    
264
-    public function setMaxPerPage(int $max)
265
-    {
266
-        $this->maxPerPage = $max;
267
-    }
268
-    
269
-    protected function getPagingQuery(array $getVars)
270
-    {
271
-        if (isset($getVars['page']))
272
-        {
273
-            $this->currentPage = $getVars['page'];
274
-        }
275
-    }
218
+	public function isOrderSet()
219
+	{
220
+		if (count($this->order == 0)) return FALSE;
221
+		return TRUE;
222
+	}
223
+    
224
+	public function getOrderQuery(array $getVars)
225
+	{
226
+		if (isset($getVars['o']))
227
+		{
228
+			$this->orderQuery = $getVars['o'];
229
+			$match = array();
230
+			if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match))
231
+			{
232
+				$orderArray=array($match[1] => $match[2]);
233
+				echo "$match[1] => $match[2]";
234
+				$this->setOrder($orderArray);
235
+			}
236
+		}
237
+	}
238
+    
239
+	protected function curOrderQuery()
240
+	{
241
+		if ($this->orderQuery == '') return '';
242
+		return 'o='.$this->orderQuery;
243
+	}
244
+    
245
+	/*****************  Paging and counting *********/
246
+    
247
+	public function countQuery()
248
+	{
249
+		$this->query = $this->dbConn->select();
250
+		$this->query = $this->query
251
+			->from(
252
+				$this->table,
253
+				array('COUNT(*)')
254
+				);
255
+		$this->applyFilter();                   
256
+	}
257
+    
258
+	public function count()
259
+	{
260
+		$this->countQuery();
261
+		return $this->dbConn->fetchOne($this->query);
262
+	}
263
+    
264
+	public function setMaxPerPage(int $max)
265
+	{
266
+		$this->maxPerPage = $max;
267
+	}
268
+    
269
+	protected function getPagingQuery(array $getVars)
270
+	{
271
+		if (isset($getVars['page']))
272
+		{
273
+			$this->currentPage = $getVars['page'];
274
+		}
275
+	}
276 276
 
277
-    protected function curPagingQuery()
278
-    {
279
-        if ($this->currentPage == '') return '';
280
-        return 'page='.$this->currentPage;
281
-    }
282
-    
283
-    public function renderPagingHeader()
284
-    {
285
-        $count = $this->count();
286
-        if ($count <= $this->maxPerPage )
287
-        {
288
-            return  'count : ' . $this->count() . '<br>';
289
-        }
277
+	protected function curPagingQuery()
278
+	{
279
+		if ($this->currentPage == '') return '';
280
+		return 'page='.$this->currentPage;
281
+	}
282
+    
283
+	public function renderPagingHeader()
284
+	{
285
+		$count = $this->count();
286
+		if ($count <= $this->maxPerPage )
287
+		{
288
+			return  'count : ' . $this->count() . '<br>';
289
+		}
290 290
         
291
-        if ($this->currentPage == 0) $this->currentPage = 1;
291
+		if ($this->currentPage == 0) $this->currentPage = 1;
292 292
         
293
-        $numPages = intdiv($count , $this->maxPerPage);
294
-        if ($count % $this->maxPerPage != 0 ) $numPages++;
293
+		$numPages = intdiv($count , $this->maxPerPage);
294
+		if ($count % $this->maxPerPage != 0 ) $numPages++;
295 295
         
296
-        $html = '<div class="pagination-control" role="navigation">';
297
-        $html .= '<ul class="nav tab-nav">';
298
-        if ($this->currentPage <=1)
299
-        {
300
-            $html .= '
296
+		$html = '<div class="pagination-control" role="navigation">';
297
+		$html .= '<ul class="nav tab-nav">';
298
+		if ($this->currentPage <=1)
299
+		{
300
+			$html .= '
301 301
                 <li class="nav-item disabled" aria-hidden="true">
302 302
                     <span class="previous-page">
303 303
                             <span class="sr-only">Previous page</span>
@@ -305,35 +305,35 @@  discard block
 block discarded – undo
305 305
                      </span>
306 306
                 </li>
307 307
                ';
308
-        }
309
-        else 
310
-        {
311
-            $html .= '
308
+		}
309
+		else 
310
+		{
311
+			$html .= '
312 312
                 <li class="nav-item">
313 313
                     <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage - 1 ).'" class="previous-page" >
314 314
                             <i aria-hidden="true" class="icon-angle-double-left"></i>            
315 315
                      </a>
316 316
                 </li>
317 317
             ';
318
-        }
318
+		}
319 319
         
320
-        for ($i=1; $i <= $numPages ; $i++)
321
-        {
322
-            $active = ($this->currentPage == $i) ? 'active' : '';
323
-            $first = ($i-1)*$this->maxPerPage+1;
324
-            $last = $i * $this->maxPerPage;
325
-            if ($last > $count) $last = $count;
326
-            $display = 'Show rows '. $first . ' to '. $last .' of '. $count;
327
-            $html .= '<li class="' . $active . ' nav-item">
320
+		for ($i=1; $i <= $numPages ; $i++)
321
+		{
322
+			$active = ($this->currentPage == $i) ? 'active' : '';
323
+			$first = ($i-1)*$this->maxPerPage+1;
324
+			$last = $i * $this->maxPerPage;
325
+			if ($last > $count) $last = $count;
326
+			$display = 'Show rows '. $first . ' to '. $last .' of '. $count;
327
+			$html .= '<li class="' . $active . ' nav-item">
328 328
                     <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '">
329 329
                     '.$i.'                
330 330
                     </a>
331 331
                 </li>';
332
-        }
332
+		}
333 333
         
334
-        if ($this->currentPage == $numPages)
335
-        {
336
-            $html .= '
334
+		if ($this->currentPage == $numPages)
335
+		{
336
+			$html .= '
337 337
                 <li class="nav-item disabled" aria-hidden="true">
338 338
                     <span class="previous-page">
339 339
                             <span class="sr-only">Previous page</span>
@@ -341,150 +341,150 @@  discard block
 block discarded – undo
341 341
                      </span>
342 342
                 </li>
343 343
                ';
344
-        }
345
-        else
346
-        {
347
-            $html .= '
344
+		}
345
+		else
346
+		{
347
+			$html .= '
348 348
                 <li class="nav-item">
349 349
                     <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage + 1 ).'" class="next-page">
350 350
                             <i aria-hidden="true" class="icon-angle-double-right"></i>
351 351
                      </a>
352 352
                 </li>
353 353
             ';
354
-        }
354
+		}
355 355
         
356
-        $html .= '</ul> </div>';
356
+		$html .= '</ul> </div>';
357 357
         
358
-        return $html;
359
-    }
360
-    
361
-    public function applyPaging()
362
-    {
363
-        $this->query->limitPage($this->currentPage,$this->maxPerPage);
364
-        return $this;
365
-    }
366
-    
367
-    /*****************  Grouping ****************/
368
-    
369
-    public function setGrouping($columnDBName)
370
-    {
371
-        $this->groupingColumn = $columnDBName;
372
-        $this->grouppingActive = TRUE;
373
-    }
374
-    
375
-    public function initGrouping()
376
-    {
377
-        $this->groupingVal = '';
378
-        $this->groupingColSpan = count($this->titles);
379
-    }
380
-    
381
-    public function groupingPrintData( $value)
382
-    {
383
-        $html = "$value";
384
-        return $html;
385
-    }
386
-    
387
-    public function groupingNextLine( $values)
388
-    {
389
-        if ($this->grouppingActive === FALSE) return '';
358
+		return $html;
359
+	}
360
+    
361
+	public function applyPaging()
362
+	{
363
+		$this->query->limitPage($this->currentPage,$this->maxPerPage);
364
+		return $this;
365
+	}
366
+    
367
+	/*****************  Grouping ****************/
368
+    
369
+	public function setGrouping($columnDBName)
370
+	{
371
+		$this->groupingColumn = $columnDBName;
372
+		$this->grouppingActive = TRUE;
373
+	}
374
+    
375
+	public function initGrouping()
376
+	{
377
+		$this->groupingVal = '';
378
+		$this->groupingColSpan = count($this->titles);
379
+	}
380
+    
381
+	public function groupingPrintData( $value)
382
+	{
383
+		$html = "$value";
384
+		return $html;
385
+	}
386
+    
387
+	public function groupingNextLine( $values)
388
+	{
389
+		if ($this->grouppingActive === FALSE) return '';
390 390
         
391
-        $dbcol = $this->groupingColumn;
392
-        if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol )
393
-        {
394
-            $this->groupingVal = $values->$dbcol;
395
-            $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>';
396
-            return $html;
397
-        }
398
-        return '';
391
+		$dbcol = $this->groupingColumn;
392
+		if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol )
393
+		{
394
+			$this->groupingVal = $values->$dbcol;
395
+			$html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>';
396
+			return $html;
397
+		}
398
+		return '';
399 399
         
400
-    }
401
-    
402
-    /*************** Rendering *************************/
403
-    
404
-    public function titleOrder($name)
405
-    {
406
-        return $this->content[$name];
407
-    }
408
-    
409
-    public function renderTitles()
410
-    {
411
-        $html = "<thead>\n<tr>\n";
412
-        foreach ($this->titles as $name => $values)
413
-        {
414
-            $titleOrder = $this->titleOrder($name);
415
-            if ($titleOrder != NULL)
416
-            {
417
-                if (isset($this->order[$titleOrder]))
418
-                {
419
-                    if ($this->order[$titleOrder] == 'ASC')
420
-                    {
421
-                        $titleOrder.='DESC';
422
-                    }
423
-                    else
424
-                    {
425
-                        $titleOrder.='ASC';
426
-                    }
427
-                }
428
-                else 
429
-                {
430
-                    $titleOrder.='ASC';
431
-                }
432
-                $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder;
433
-                $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>';
434
-            }
435
-            else 
436
-            {
437
-                $html .= '<th>' . $values . '</th>';
438
-            }          
439
-        }
440
-        $html .= "</tr>\n</thead>\n";
441
-        return $html;
442
-    }
443
-    
444
-    public function renderLine( $value)
445
-    {
446
-        $html = '';
447
-        $titleNames = array_keys($this->titles);
448
-        foreach ($titleNames as $name )
449
-        {
450
-            $html .= '<td>';
451
-            $html .= $value->$name;
452
-            $html .= "</td>\n";
453
-        }
454
-        return $html;
455
-    }
456
-    
457
-    public function renderTable(array $values)
458
-    {
459
-       $html = '<tbody id="obj_table_body">';
460
-       foreach($values as $value)
461
-       {
462
-           $html .= $this->groupingNextLine($value);
400
+	}
401
+    
402
+	/*************** Rendering *************************/
403
+    
404
+	public function titleOrder($name)
405
+	{
406
+		return $this->content[$name];
407
+	}
408
+    
409
+	public function renderTitles()
410
+	{
411
+		$html = "<thead>\n<tr>\n";
412
+		foreach ($this->titles as $name => $values)
413
+		{
414
+			$titleOrder = $this->titleOrder($name);
415
+			if ($titleOrder != NULL)
416
+			{
417
+				if (isset($this->order[$titleOrder]))
418
+				{
419
+					if ($this->order[$titleOrder] == 'ASC')
420
+					{
421
+						$titleOrder.='DESC';
422
+					}
423
+					else
424
+					{
425
+						$titleOrder.='ASC';
426
+					}
427
+				}
428
+				else 
429
+				{
430
+					$titleOrder.='ASC';
431
+				}
432
+				$actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder;
433
+				$html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>';
434
+			}
435
+			else 
436
+			{
437
+				$html .= '<th>' . $values . '</th>';
438
+			}          
439
+		}
440
+		$html .= "</tr>\n</thead>\n";
441
+		return $html;
442
+	}
443
+    
444
+	public function renderLine( $value)
445
+	{
446
+		$html = '';
447
+		$titleNames = array_keys($this->titles);
448
+		foreach ($titleNames as $name )
449
+		{
450
+			$html .= '<td>';
451
+			$html .= $value->$name;
452
+			$html .= "</td>\n";
453
+		}
454
+		return $html;
455
+	}
456
+    
457
+	public function renderTable(array $values)
458
+	{
459
+	   $html = '<tbody id="obj_table_body">';
460
+	   foreach($values as $value)
461
+	   {
462
+		   $html .= $this->groupingNextLine($value);
463 463
            
464
-           $html .= "<tr>\n";
465
-           $html .= $this->renderLine($value);
466
-           $html .= "</tr>\n";
467
-       }
468
-       $html .= '</tbody>';
469
-       return $html;
470
-    }
471
-    
472
-    public function render()
473
-    {
474
-        $html = '';
464
+		   $html .= "<tr>\n";
465
+		   $html .= $this->renderLine($value);
466
+		   $html .= "</tr>\n";
467
+	   }
468
+	   $html .= '</tbody>';
469
+	   return $html;
470
+	}
471
+    
472
+	public function render()
473
+	{
474
+		$html = '';
475 475
         
476 476
         
477
-        $values = $this->fullQuery();
478
-        $this->initGrouping();
477
+		$values = $this->fullQuery();
478
+		$this->initGrouping();
479 479
         
480
-        $html.="<table class='simple common-table table-row-selectable'>\n";
480
+		$html.="<table class='simple common-table table-row-selectable'>\n";
481 481
         
482
-        $html .= $this->renderTitles();
483
-        $html .= $this->renderTable($values);
484
-        $html .= '</table>'; 
482
+		$html .= $this->renderTitles();
483
+		$html .= $this->renderTable($values);
484
+		$html .= '</table>'; 
485 485
         
486 486
 
487
-        return $html;
488
-    }
487
+		return $html;
488
+	}
489 489
     
490 490
 }
491 491
\ No newline at end of file
Please login to merge, or discard this patch.
library/Trapdirector/Config/TrapModuleConfig.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@  discard block
 block discarded – undo
4 4
 
5 5
 class TrapModuleConfig
6 6
 {
7
-    /********** Database configuration ***********************/
7
+	/********** Database configuration ***********************/
8 8
 	// Database prefix for tables 
9
-    protected $table_prefix; //< Database prefix for tables 	
9
+	protected $table_prefix; //< Database prefix for tables 	
10 10
 	protected $DBConfigDefaults=array(
11 11
 		'db_remove_days' => 60, // number of days before removing traps
12 12
 		'log_destination' => 'syslog', // Log destination for trap handler
13 13
 		'log_file' => '/tmp/trapdirector.log', // Log file
14 14
 		'log_level' => 2, // log level
15 15
 		'use_SnmpTrapAddess' => 1, // use SnmpTrapAddress by default
16
-	    'SnmpTrapAddess_oid' => '.1.3.6.1.6.3.18.1.3', // default snmpTrapAdress OID
17
-	    'max_rows_in_list' => 5, // Max rows displayed in table before paging
18
-	    'handler_categories' => '0:Not categorized' // handlers categories : <index>:<name>!<index>:<name> ....
16
+		'SnmpTrapAddess_oid' => '.1.3.6.1.6.3.18.1.3', // default snmpTrapAdress OID
17
+		'max_rows_in_list' => 5, // Max rows displayed in table before paging
18
+		'handler_categories' => '0:Not categorized' // handlers categories : <index>:<name>!<index>:<name> ....
19 19
 	);
20 20
 	// get default values for dbconfig
21 21
 	public function getDBConfigDefaults() { return $this->DBConfigDefaults;}
@@ -122,27 +122,27 @@  discard block
 block discarded – undo
122 122
 	// Note : must have 'source_ip' and 'last_sent'
123 123
 	public function getTrapHostListDisplayColumns()
124 124
 	{
125
-	    return array(
126
-	        'source_name'  =>  't.source_name',
127
-	        'source_ip'    =>  't.source_ip',
128
-	        'trap_oid'     =>  't.trap_oid',
129
-	        'count'        =>  'count(*)',
130
-	        'last_sent'    =>  'UNIX_TIMESTAMP(max(t.date_received))'
131
-	    );
125
+		return array(
126
+			'source_name'  =>  't.source_name',
127
+			'source_ip'    =>  't.source_ip',
128
+			'trap_oid'     =>  't.trap_oid',
129
+			'count'        =>  'count(*)',
130
+			'last_sent'    =>  'UNIX_TIMESTAMP(max(t.date_received))'
131
+		);
132 132
 	}
133 133
 
134 134
 	public function getTrapHostListSearchColumns()
135 135
 	{
136
-	    return array(); // No search needed on this table
136
+		return array(); // No search needed on this table
137 137
 	}
138 138
 	// Titles display in Trap List table
139 139
 	public function getTrapHostListTitles()
140 140
 	{
141
-	    return array(
142
-	        'trap_oid'		=> 'Trap OID',
143
-	        'count'		    => 'Number of traps received',
144
-	        'last_sent'     => 'Last trap received'
145
-	    );
141
+		return array(
142
+			'trap_oid'		=> 'Trap OID',
143
+			'count'		    => 'Number of traps received',
144
+			'last_sent'     => 'Last trap received'
145
+		);
146 146
 	}
147 147
 	
148 148
 	
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 			'source_ip'		=> "CASE WHEN r.ip4 IS NULL THEN r.ip6 ELSE r.ip4 END",
158 158
 			'trap_oid'		=> 'r.trap_oid',
159 159
 			'rule'			=> 'r.rule',
160
-		    'comment'	    => 'r.comment',
161
-		    'category'	    => 'r.rule_type',
160
+			'comment'	    => 'r.comment',
161
+			'category'	    => 'r.rule_type',
162 162
 			'action_match'	=> 'r.action_match',
163 163
 			'action_nomatch'=> 'r.action_nomatch',
164 164
 			'service_name'	=> 'r.service_name',
165 165
 			'num_match'		=> 'r.num_match',
166
-		    'rule_type'     => 'r.rule_type',
166
+			'rule_type'     => 'r.rule_type',
167 167
 			'id'           	=> 'r.id'
168 168
 		);
169 169
 	}
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 	}
185 185
 	public function getHandlerColumns()
186 186
 	{
187
-	    return array(
188
-	        'r.host_name', 'r.host_group_name',
189
-	        'r.ip4', 'r.ip6',
190
-	        'r.trap_oid',
191
-	        'r.rule',
192
-	        'r.action_match',
193
-	        'r.action_nomatch',
194
-	        'r.service_name',
195
-	        'r.num_match',
196
-	        'r.id'
197
-	    );
187
+		return array(
188
+			'r.host_name', 'r.host_group_name',
189
+			'r.ip4', 'r.ip6',
190
+			'r.trap_oid',
191
+			'r.rule',
192
+			'r.action_match',
193
+			'r.action_nomatch',
194
+			'r.service_name',
195
+			'r.num_match',
196
+			'r.id'
197
+		);
198 198
 	}
199 199
 
200 200
 	// handler update (<key> => <sql select>)
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 			'revert_ok'		=> 'r.revert_ok',
215 215
 			'display'		=> 'r.display',
216 216
 			'modified'		=> 'UNIX_TIMESTAMP(r.modified)',
217
-            'modifier'		=> 'r.modifier',
218
-		    'comment'       => 'r.comment',
219
-		    'category'      => 'r.rule_type'
217
+			'modifier'		=> 'r.modifier',
218
+			'comment'       => 'r.comment',
219
+			'category'      => 'r.rule_type'
220 220
 		);
221 221
 	}	
222 222
 		
Please login to merge, or discard this patch.
library/Trapdirector/TrapsController.php 1 patch
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	
48 48
 	
49 49
 	/** Get instance of TrapModuleConfig class
50
-	*	@return TrapModuleConfig
51
-	*/
50
+	 *	@return TrapModuleConfig
51
+	 */
52 52
 	public function getModuleConfig() 
53 53
 	{
54 54
 		if ($this->moduleConfig == Null) 
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function getTrapHostListTable()
82 82
 	{
83
-	    if ($this->trapTableHostList == Null) 
83
+		if ($this->trapTableHostList == Null) 
84 84
 		{
85
-	        $this->trapTableHostList = new TrapTableHostList();
86
-	        $this->trapTableHostList->setConfig($this->getModuleConfig());
87
-	    }
88
-	    return $this->trapTableHostList;
85
+			$this->trapTableHostList = new TrapTableHostList();
86
+			$this->trapTableHostList->setConfig($this->getModuleConfig());
87
+		}
88
+		return $this->trapTableHostList;
89 89
 	}
90 90
 	
91 91
 	/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function getUIDatabase()
108 108
 	{
109
-	    if ($this->UIDatabase == Null)
110
-	    {
111
-	        $this->UIDatabase = new UIDatabase($this);
109
+		if ($this->UIDatabase == Null)
110
+		{
111
+			$this->UIDatabase = new UIDatabase($this);
112 112
 	       
113
-	    }
114
-	    return $this->UIDatabase;
113
+		}
114
+		return $this->UIDatabase;
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,34 +120,34 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function getIdoConn()
122 122
 	{
123
-	    if ($this->icingaAPI === NULL)
124
-	    {
125
-    	    $host = $this->Config()->get('config', 'icingaAPI_host');
126
-    	    $port = $this->Config()->get('config', 'icingaAPI_port');
127
-    	    $user = $this->Config()->get('config', 'icingaAPI_user');
128
-    	    $pass = $this->Config()->get('config', 'icingaAPI_password');
129
-    	    $this->icingaAPI = new Icinga2API($host,$port);
130
-    	    $this->icingaAPI->setCredentials($user, $pass);
131
-    	    list($ret,$message) = $this->icingaAPI->test(NULL);
132
-    	    if ($ret === TRUE)
133
-    	    {
134
-    	        return $this->getUIDatabase();
135
-    	    }
123
+		if ($this->icingaAPI === NULL)
124
+		{
125
+			$host = $this->Config()->get('config', 'icingaAPI_host');
126
+			$port = $this->Config()->get('config', 'icingaAPI_port');
127
+			$user = $this->Config()->get('config', 'icingaAPI_user');
128
+			$pass = $this->Config()->get('config', 'icingaAPI_password');
129
+			$this->icingaAPI = new Icinga2API($host,$port);
130
+			$this->icingaAPI->setCredentials($user, $pass);
131
+			list($ret,$message) = $this->icingaAPI->test(NULL);
132
+			if ($ret === TRUE)
133
+			{
134
+				return $this->getUIDatabase();
135
+			}
136 136
     	    
137
-	    }
138
-	    return $this->icingaAPI;
137
+		}
138
+		return $this->icingaAPI;
139 139
 	    
140 140
 	}
141 141
 	
142
-    protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null)
143
-    {
144
-        $limit = $this->params->get('limit', $limit);
145
-        $page = $this->params->get('page', $offset);
142
+	protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null)
143
+	{
144
+		$limit = $this->params->get('limit', $limit);
145
+		$page = $this->params->get('page', $offset);
146 146
 
147
-        $paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0);
147
+		$paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0);
148 148
 
149
-        return $paginatable;
150
-    }	
149
+		return $paginatable;
150
+	}	
151 151
 	
152 152
 	public function displayExitError($source,$message)
153 153
 	{	// TODO : check better ways to transmit data (with POST ?)
@@ -156,33 +156,33 @@  discard block
 block discarded – undo
156 156
 	
157 157
 	protected function checkReadPermission()
158 158
 	{
159
-        if (! $this->Auth()->hasPermission('trapdirector/view')) {
160
-            $this->displayExitError('Permissions','No permission fo view content');
161
-        }		
159
+		if (! $this->Auth()->hasPermission('trapdirector/view')) {
160
+			$this->displayExitError('Permissions','No permission fo view content');
161
+		}		
162 162
 	}
163 163
 
164 164
 	protected function checkConfigPermission()
165 165
 	{
166
-        if (! $this->Auth()->hasPermission('trapdirector/config')) {
167
-            $this->displayExitError('Permissions','No permission fo configure');
168
-        }		
166
+		if (! $this->Auth()->hasPermission('trapdirector/config')) {
167
+			$this->displayExitError('Permissions','No permission fo configure');
168
+		}		
169 169
 	}
170 170
 	
171
-    /**
172
-     * Check if user has write permission
173
-     * @param number $check optional : if set to 1, return true (user has permission) or false instead of displaying error page
174
-     * @return boolean : user has permission
175
-     */
171
+	/**
172
+	 * Check if user has write permission
173
+	 * @param number $check optional : if set to 1, return true (user has permission) or false instead of displaying error page
174
+	 * @return boolean : user has permission
175
+	 */
176 176
 	protected function checkModuleConfigPermission($check=0)
177 177
 	{
178
-        if (! $this->Auth()->hasPermission('trapdirector/module_config')) {
179
-            if ($check == 0)
180
-            {
181
-                $this->displayExitError('Permissions','No permission fo configure module');
182
-            }
183
-            return false;
184
-        }
185
-        return true;
178
+		if (! $this->Auth()->hasPermission('trapdirector/module_config')) {
179
+			if ($check == 0)
180
+			{
181
+				$this->displayExitError('Permissions','No permission fo configure module');
182
+			}
183
+			return false;
184
+		}
185
+		return true;
186 186
 	}
187 187
 
188 188
 	/*************************  Trap class get **********************/
@@ -202,18 +202,18 @@  discard block
 block discarded – undo
202 202
 	/************************** MIB related **************************/
203 203
 	
204 204
 	/** Get MIBLoader class
205
-	*	@return MIBLoader class
206
-	*/
205
+	 *	@return MIBLoader class
206
+	 */
207 207
 	protected function getMIB()
208 208
 	{
209 209
 		if ($this->MIBData == null)
210 210
 		{
211
-		    $dbConn = $this->getUIDatabase()->getDbConn();
212
-		    if ($dbConn === null) throw new \ErrorException('uncatched db error');
211
+			$dbConn = $this->getUIDatabase()->getDbConn();
212
+			if ($dbConn === null) throw new \ErrorException('uncatched db error');
213 213
 			$this->MIBData=new MIBLoader(
214 214
 				$this->Config()->get('config', 'snmptranslate'),
215 215
 				$this->Config()->get('config', 'snmptranslate_dirs'),
216
-			    $dbConn,
216
+				$dbConn,
217 217
 				$this->getModuleConfig()
218 218
 			);
219 219
 		}
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 	/**************************  Database queries *******************/		
224 224
 	
225 225
 	/** Check if director is installed
226
-	*	@return bool true/false
227
-	*/
226
+	 *	@return bool true/false
227
+	 */
228 228
 	protected function isDirectorInstalled()
229 229
 	{
230
-	    $output=array();
231
-	    exec('icingacli module list',$output);
232
-	    foreach ($output as $line)
230
+		$output=array();
231
+		exec('icingacli module list',$output);
232
+		foreach ($output as $line)
233 233
 		{
234 234
 			if (preg_match('/^director .*enabled/',$line))
235 235
 			{
@@ -242,72 +242,72 @@  discard block
 block discarded – undo
242 242
 
243 243
 	/************************ UI elements **************************/
244 244
 	
245
-    /**
246
-     * get max rows to display before paging.
247
-     * @return number
248
-     */
245
+	/**
246
+	 * get max rows to display before paging.
247
+	 * @return number
248
+	 */
249 249
 	public function itemListDisplay()
250 250
 	{
251
-	    return $this->getUIDatabase()->getDBConfigValue('max_rows_in_list');
251
+		return $this->getUIDatabase()->getDBConfigValue('max_rows_in_list');
252 252
 	}
253 253
 
254 254
 	public function setitemListDisplay(int $maxRows)
255 255
 	{
256
-	    return $this->getUIDatabase()->setDBConfigValue('max_rows_in_list',$maxRows);
256
+		return $this->getUIDatabase()->setDBConfigValue('max_rows_in_list',$maxRows);
257 257
 	}
258 258
 	
259
-    /**
260
-     * get Handlers categories list (index => textvalue).
261
-     * @return array
262
-     */	
259
+	/**
260
+	 * get Handlers categories list (index => textvalue).
261
+	 * @return array
262
+	 */	
263 263
 	public function getHandlersCategory()
264 264
 	{
265
-	    //<index>:<name>!<index>:<name>
266
-	    $catList = $this->getUIDatabase()->getDBConfigValue('handler_categories');
267
-	    $catListArray=explode('!',$catList);
268
-	    $retArray=array();
269
-	    foreach ($catListArray as $category)
270
-	    {
271
-	        $catArray=explode(':',$category);
272
-	        $retArray[$catArray[0]] = $catArray[1];
273
-	    }
274
-	    return $retArray; 
265
+		//<index>:<name>!<index>:<name>
266
+		$catList = $this->getUIDatabase()->getDBConfigValue('handler_categories');
267
+		$catListArray=explode('!',$catList);
268
+		$retArray=array();
269
+		foreach ($catListArray as $category)
270
+		{
271
+			$catArray=explode(':',$category);
272
+			$retArray[$catArray[0]] = $catArray[1];
273
+		}
274
+		return $retArray; 
275 275
 	}
276 276
 
277 277
 	public function setHandlerCategory(array $catArray)
278 278
 	{
279
-	    $catString='';
280
-	    foreach ($catArray as $index => $value)
281
-	    {
282
-	        if ($catString != '' ) $catString .= '!';
283
-	        $catString .= $index . ':' . $value;
284
-	    }
285
-	    $this->getUIDatabase()->setDBConfigValue('handler_categories', $catString);
279
+		$catString='';
280
+		foreach ($catArray as $index => $value)
281
+		{
282
+			if ($catString != '' ) $catString .= '!';
283
+			$catString .= $index . ':' . $value;
284
+		}
285
+		$this->getUIDatabase()->setDBConfigValue('handler_categories', $catString);
286 286
 	}
287 287
 	
288 288
 	public function addHandlersCategory(string $catName)
289 289
 	{
290
-	    $catArray = $this->getHandlersCategory();
291
-	    $i=1;
292
-	    while (isset($catArray[$i]) && $i < 100) $i++;
293
-	    if ($i == 100) throw new ProgrammingError('Category array error');
294
-	    $catArray[$i] = $catName;
295
-	    $this->setHandlerCategory($catArray);
290
+		$catArray = $this->getHandlersCategory();
291
+		$i=1;
292
+		while (isset($catArray[$i]) && $i < 100) $i++;
293
+		if ($i == 100) throw new ProgrammingError('Category array error');
294
+		$catArray[$i] = $catName;
295
+		$this->setHandlerCategory($catArray);
296 296
 	}
297 297
 	
298 298
 	public function delHandlersCategory(int $catIndex)
299 299
 	{
300
-	    $catArray = $this->getHandlersCategory();
301
-	    unset($catArray[$catIndex]);
302
-	    $this->setHandlerCategory($catArray);
303
-	    $this->getUIDatabase()->updateHandlersOnCategoryDelete($catIndex);
300
+		$catArray = $this->getHandlersCategory();
301
+		unset($catArray[$catIndex]);
302
+		$this->setHandlerCategory($catArray);
303
+		$this->getUIDatabase()->updateHandlersOnCategoryDelete($catIndex);
304 304
 	}
305 305
 	
306 306
 	public function renameHandlersCategory(int $catIndex, string $catName)
307 307
 	{
308
-	    $catArray = $this->getHandlersCategory();
309
-	    $catArray[$catIndex] = $catName;
310
-	    $this->setHandlerCategory($catArray);
308
+		$catArray = $this->getHandlersCategory();
309
+		$catArray[$catIndex] = $catName;
310
+		$this->setHandlerCategory($catArray);
311 311
 	}
312 312
 	
313 313
 }
Please login to merge, or discard this patch.
library/Trapdirector/TrapsActions/TrapDBQuery.php 1 patch
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -20,245 +20,245 @@
 block discarded – undo
20 20
 trait TrapDBQuery
21 21
 {
22 22
     
23
-    /** @return TrapsController */
24
-    abstract protected function getTrapCtrl();
23
+	/** @return TrapsController */
24
+	abstract protected function getTrapCtrl();
25 25
 
26
-    /** @return Zend_Db_Adapter_Abstract : returns DB connexion or null on error */
27
-    abstract public function getDbConn();
26
+	/** @return Zend_Db_Adapter_Abstract : returns DB connexion or null on error */
27
+	abstract public function getDbConn();
28 28
     
29
-    /** Add handler rule in traps DB
30
-     *	@param array $params : array(<db item>=><value>)
31
-     *	@return int inserted id
32
-     */
33
-    public function addHandlerRule($params)
34
-    {
35
-        // TODO Check for rule consistency
29
+	/** Add handler rule in traps DB
30
+	 *	@param array $params : array(<db item>=><value>)
31
+	 *	@return int inserted id
32
+	 */
33
+	public function addHandlerRule($params)
34
+	{
35
+		// TODO Check for rule consistency
36 36
         
37
-        $dbConn = $this->getDbConn();
38
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
39
-        // Add last modified date = creation date and username
40
-        $params['created'] = new Zend_Db_Expr('NOW()');
41
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
42
-        $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
37
+		$dbConn = $this->getDbConn();
38
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
39
+		// Add last modified date = creation date and username
40
+		$params['created'] = new Zend_Db_Expr('NOW()');
41
+		$params['modified'] = new 	Zend_Db_Expr('NOW()');
42
+		$params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
43 43
         
44
-        $query=$dbConn->insert(
45
-            $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
46
-            $params
47
-            );
48
-        if($query==false)
49
-        {
50
-            return null;
51
-        }
52
-        return $dbConn->lastInsertId();
53
-    }
44
+		$query=$dbConn->insert(
45
+			$this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
46
+			$params
47
+			);
48
+		if($query==false)
49
+		{
50
+			return null;
51
+		}
52
+		return $dbConn->lastInsertId();
53
+	}
54 54
     
55
-    /** Update handler rule in traps DB
56
-     *	@param array $params : (<db item>=><value>)
57
-     *   @param integer $ruleID : rule id in db
58
-     *	@return array affected rows
59
-     */
60
-    public function updateHandlerRule($params,$ruleID)
61
-    {
62
-        // TODO Check for rule consistency
63
-        $dbConn = $this->getDbConn();
64
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
65
-        // Add last modified date = creation date and username
66
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
67
-        $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
55
+	/** Update handler rule in traps DB
56
+	 *	@param array $params : (<db item>=><value>)
57
+	 *   @param integer $ruleID : rule id in db
58
+	 *	@return array affected rows
59
+	 */
60
+	public function updateHandlerRule($params,$ruleID)
61
+	{
62
+		// TODO Check for rule consistency
63
+		$dbConn = $this->getDbConn();
64
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
65
+		// Add last modified date = creation date and username
66
+		$params['modified'] = new 	Zend_Db_Expr('NOW()');
67
+		$params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
68 68
         
69
-        $numRows=$dbConn->update(
70
-            $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
71
-            $params,
72
-            'id='.$ruleID
73
-            );
74
-        return $numRows;
75
-    }
69
+		$numRows=$dbConn->update(
70
+			$this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
71
+			$params,
72
+			'id='.$ruleID
73
+			);
74
+		return $numRows;
75
+	}
76 76
     
77
-    /**
78
-     * ON category removal, put back cat to 0 on handlers with this category.
79
-     * @param int $catIndex
80
-     * @throws \ErrorException
81
-     * @return number
82
-     */
83
-    public function updateHandlersOnCategoryDelete($catIndex)
84
-    {
85
-        // TODO Check for rule consistency
86
-        $dbConn = $this->getDbConn();
87
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
77
+	/**
78
+	 * ON category removal, put back cat to 0 on handlers with this category.
79
+	 * @param int $catIndex
80
+	 * @throws \ErrorException
81
+	 * @return number
82
+	 */
83
+	public function updateHandlersOnCategoryDelete($catIndex)
84
+	{
85
+		// TODO Check for rule consistency
86
+		$dbConn = $this->getDbConn();
87
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
88 88
         
89
-        $numRows=$dbConn->update(
90
-            $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
91
-            array('rule_type' => 0),
92
-            'rule_type='.$catIndex
93
-            );
94
-        return $numRows;
95
-    }
89
+		$numRows=$dbConn->update(
90
+			$this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
91
+			array('rule_type' => 0),
92
+			'rule_type='.$catIndex
93
+			);
94
+		return $numRows;
95
+	}
96 96
     
97
-    /** Delete rule by id
98
-     *	@param int $ruleID rule id
99
-     */
100
-    public function deleteRule($ruleID)
101
-    {
102
-        if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id');  }
97
+	/** Delete rule by id
98
+	 *	@param int $ruleID rule id
99
+	 */
100
+	public function deleteRule($ruleID)
101
+	{
102
+		if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id');  }
103 103
         
104
-        $dbConn = $this->getDbConn();
105
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
104
+		$dbConn = $this->getDbConn();
105
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
106 106
         
107
-        $query=$dbConn->delete(
108
-            $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
109
-            'id='.$ruleID
110
-            );
111
-        return $query;
112
-    }
107
+		$query=$dbConn->delete(
108
+			$this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
109
+			'id='.$ruleID
110
+			);
111
+		return $query;
112
+	}
113 113
 
114
-    /**
115
-     * Get last trap rule table modification
116
-     * @throws \ErrorException
117
-     * @return Zend_Db_Select
118
-     */
119
-    public function lastModification()
120
-    {
121
-        $dbConn = $this->getDbConn();
122
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
114
+	/**
115
+	 * Get last trap rule table modification
116
+	 * @throws \ErrorException
117
+	 * @return Zend_Db_Select
118
+	 */
119
+	public function lastModification()
120
+	{
121
+		$dbConn = $this->getDbConn();
122
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
123 123
         
124
-        $query = $dbConn->select()
125
-        ->from(
126
-            $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
127
-            array('lastModified'=>'UNIX_TIMESTAMP(MAX(modified))'));
128
-        $returnRow=$dbConn->fetchRow($query);
129
-        return $returnRow->lastmodified;
130
-    }
124
+		$query = $dbConn->select()
125
+		->from(
126
+			$this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
127
+			array('lastModified'=>'UNIX_TIMESTAMP(MAX(modified))'));
128
+		$returnRow=$dbConn->fetchRow($query);
129
+		return $returnRow->lastmodified;
130
+	}
131 131
     
132
-    /** Delete trap by ip & oid
133
-     *	@param $ipAddr string source IP (v4 or v6)
134
-     *	@param $oid string oid
135
-     */
136
-    public function deleteTrap($ipAddr,$oid)
137
-    {
132
+	/** Delete trap by ip & oid
133
+	 *	@param $ipAddr string source IP (v4 or v6)
134
+	 *	@param $oid string oid
135
+	 */
136
+	public function deleteTrap($ipAddr,$oid)
137
+	{
138 138
         
139
-        $dbConn = $this->getDbConn();
140
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
141
-        $condition=null;
142
-        if ($ipAddr != null)
143
-        {
144
-            $condition="source_ip='$ipAddr'";
145
-        }
146
-        if ($oid != null)
147
-        {
148
-            $condition=($condition===null)?'':$condition.' AND ';
149
-            $condition.="trap_oid='$oid'";
150
-        }
151
-        if($condition === null) return null;
152
-        $query=$dbConn->delete(
153
-            $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
154
-            $condition
155
-            );
156
-        // TODO test ret code etc...
157
-        return $query;
158
-    }
139
+		$dbConn = $this->getDbConn();
140
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
141
+		$condition=null;
142
+		if ($ipAddr != null)
143
+		{
144
+			$condition="source_ip='$ipAddr'";
145
+		}
146
+		if ($oid != null)
147
+		{
148
+			$condition=($condition===null)?'':$condition.' AND ';
149
+			$condition.="trap_oid='$oid'";
150
+		}
151
+		if($condition === null) return null;
152
+		$query=$dbConn->delete(
153
+			$this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
154
+			$condition
155
+			);
156
+		// TODO test ret code etc...
157
+		return $query;
158
+	}
159 159
     
160 160
     
161
-    /** count trap by ip & oid
162
-     *	@param $ipAddr string source IP (v4 or v6)
163
-     *	@param $oid string oid
164
-     */
165
-    public function countTrap($ipAddr,$oid)
166
-    {
161
+	/** count trap by ip & oid
162
+	 *	@param $ipAddr string source IP (v4 or v6)
163
+	 *	@param $oid string oid
164
+	 */
165
+	public function countTrap($ipAddr,$oid)
166
+	{
167 167
         
168
-        $dbConn = $this->getDbConn();
169
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
168
+		$dbConn = $this->getDbConn();
169
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
170 170
         
171
-        $condition=null;
172
-        if ($ipAddr != null)
173
-        {
174
-            $condition="source_ip='$ipAddr'";
175
-        }
176
-        if ($oid != null)
177
-        {
178
-            $condition=($condition===null)?'':$condition.' AND ';
179
-            $condition.="trap_oid='$oid'";
180
-        }
181
-        if($condition === null) return 0;
182
-        $query=$dbConn->select()
183
-            ->from(
184
-                $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
185
-                array('num'=>'count(*)'))
186
-            ->where($condition);
187
-        $returnRow=$dbConn->fetchRow($query);
188
-        return $returnRow->num;
189
-    }
171
+		$condition=null;
172
+		if ($ipAddr != null)
173
+		{
174
+			$condition="source_ip='$ipAddr'";
175
+		}
176
+		if ($oid != null)
177
+		{
178
+			$condition=($condition===null)?'':$condition.' AND ';
179
+			$condition.="trap_oid='$oid'";
180
+		}
181
+		if($condition === null) return 0;
182
+		$query=$dbConn->select()
183
+			->from(
184
+				$this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
185
+				array('num'=>'count(*)'))
186
+			->where($condition);
187
+		$returnRow=$dbConn->fetchRow($query);
188
+		return $returnRow->num;
189
+	}
190 190
     
191
-    /** get configuration value
192
-     *	@param string $element : configuration name in db
193
-     */
194
-    public function getDBConfigValue($element)
195
-    {
191
+	/** get configuration value
192
+	 *	@param string $element : configuration name in db
193
+	 */
194
+	public function getDBConfigValue($element)
195
+	{
196 196
         
197
-        $dbConn = $this->getDbConn();
198
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
197
+		$dbConn = $this->getDbConn();
198
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
199 199
         
200
-        $query=$dbConn->select()
201
-        ->from(
202
-            $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
203
-            array('value'=>'value'))
204
-            ->where('name=?',$element);
205
-            $returnRow=$dbConn->fetchRow($query);
206
-            if ($returnRow==null)  // value does not exists
207
-            {
208
-                $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
209
-                if ( ! isset($default[$element])) return null; // no default and not value
200
+		$query=$dbConn->select()
201
+		->from(
202
+			$this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
203
+			array('value'=>'value'))
204
+			->where('name=?',$element);
205
+			$returnRow=$dbConn->fetchRow($query);
206
+			if ($returnRow==null)  // value does not exists
207
+			{
208
+				$default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
209
+				if ( ! isset($default[$element])) return null; // no default and not value
210 210
                 
211
-                $this->addDBConfigValue($element,$default[$element]);
212
-                return $default[$element];
213
-            }
214
-            if ($returnRow->value == null) // value id empty
215
-            {
216
-                $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
217
-                if ( ! isset($default[$element])) return null; // no default and not value
218
-                $this->setDBConfigValue($element,$default[$element]);
219
-                return $default[$element];
220
-            }
221
-            return $returnRow->value;
222
-    }
211
+				$this->addDBConfigValue($element,$default[$element]);
212
+				return $default[$element];
213
+			}
214
+			if ($returnRow->value == null) // value id empty
215
+			{
216
+				$default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
217
+				if ( ! isset($default[$element])) return null; // no default and not value
218
+				$this->setDBConfigValue($element,$default[$element]);
219
+				return $default[$element];
220
+			}
221
+			return $returnRow->value;
222
+	}
223 223
     
224
-    /** add configuration value
225
-     *	@param string $element : name of config element
226
-     *   @param string $value : value
227
-     */
224
+	/** add configuration value
225
+	 *	@param string $element : name of config element
226
+	 *   @param string $value : value
227
+	 */
228 228
     
229
-    public function addDBConfigValue($element,$value)
230
-    {
229
+	public function addDBConfigValue($element,$value)
230
+	{
231 231
         
232
-        $dbConn = $this->getDbConn();
233
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
232
+		$dbConn = $this->getDbConn();
233
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
234 234
         
235
-        $query=$dbConn->insert(
236
-            $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
237
-            array(
238
-                'name' => $element,
239
-                'value'=>$value
240
-            )
241
-            );
242
-        return $query;
243
-    }
235
+		$query=$dbConn->insert(
236
+			$this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
237
+			array(
238
+				'name' => $element,
239
+				'value'=>$value
240
+			)
241
+			);
242
+		return $query;
243
+	}
244 244
     
245
-    /** set configuration value
246
-     *	@param string $element : name of config element
247
-     *   @param string $value : value
248
-     */
249
-    public function setDBConfigValue($element,$value)
250
-    {
245
+	/** set configuration value
246
+	 *	@param string $element : name of config element
247
+	 *   @param string $value : value
248
+	 */
249
+	public function setDBConfigValue($element,$value)
250
+	{
251 251
         
252
-        $dbConn = $this->getDbConn();
253
-        if ($dbConn === null) throw new \ErrorException('uncatched db error');
252
+		$dbConn = $this->getDbConn();
253
+		if ($dbConn === null) throw new \ErrorException('uncatched db error');
254 254
         
255
-        $query=$dbConn->update(
256
-            $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
257
-            array('value'=>$value),
258
-            'name=\''.$element.'\''
259
-            );
260
-        return $query;
261
-    }
255
+		$query=$dbConn->update(
256
+			$this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
257
+			array('value'=>$value),
258
+			'name=\''.$element.'\''
259
+			);
260
+		return $query;
261
+	}
262 262
     
263 263
     
264 264
 }
265 265
\ No newline at end of file
Please login to merge, or discard this patch.
application/controllers/StatusController.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 		/************  Trapdb ***********/
22 22
 		try
23 23
 		{
24
-		    $dbConn = $this->getUIDatabase()->getDbConn();
25
-		    if ($dbConn === null) throw new \ErrorException('uncatched db error');
24
+			$dbConn = $this->getUIDatabase()->getDbConn();
25
+			if ($dbConn === null) throw new \ErrorException('uncatched db error');
26 26
 			$query = $dbConn->select()->from(
27 27
 				$this->getModuleConfig()->getTrapTableName(),
28 28
 				array('COUNT(*)')
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		
52 52
 		try
53 53
 		{		
54
-		    $this->view->currentLogDestination=$this->getUIDatabase()->getDBConfigValue('log_destination');
54
+			$this->view->currentLogDestination=$this->getUIDatabase()->getDBConfigValue('log_destination');
55 55
 			$this->view->logDestinations=$this->getModuleConfig()->getLogDestinations();
56 56
 			$this->view->currentLogFile=$this->getUIDatabase()->getDBConfigValue('log_file');
57 57
 			$this->view->logLevels=$this->getModuleConfig()->getlogLevels();
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
 		/*************** SNMP configuration ****************/
66 66
 		try
67 67
 		{
68
-		    $this->view->useSnmpTrapAddess= ( $this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1 ) ? TRUE : FALSE;
69
-		    $this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid');
70
-		    $this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE;
68
+			$this->view->useSnmpTrapAddess= ( $this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1 ) ? TRUE : FALSE;
69
+			$this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid');
70
+			$this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE;
71 71
 		    
72 72
 		}
73 73
 		catch (Exception $e)
74 74
 		{
75
-		    $this->displayExitError('status',$e->getMessage());
75
+			$this->displayExitError('status',$e->getMessage());
76 76
 		}		
77 77
 		
78 78
 	} 
79 79
   
80 80
 	/** Mib management
81
-	*	Post param : action=update_mib_db : update mib database
82
-	*	Post param : ation=check_update : check if mib update is finished
83
-	*	File post : mibfile -> save mib file
84
-	*/
81
+	 *	Post param : action=update_mib_db : update mib database
82
+	 *	Post param : ation=check_update : check if mib update is finished
83
+	 *	File post : mibfile -> save mib file
84
+	 */
85 85
 	public function mibAction()
86 86
 	{
87 87
 		$this->prepareTabs()->activate('mib');
@@ -100,22 +100,22 @@  discard block
 block discarded – undo
100 100
 					$return=exec('icingacli trapdirector mib update --pid /tmp/trapdirector_update.pid');
101 101
 					if (preg_match('/OK/',$return))
102 102
 					{
103
-					    $this->_helper->json(array('status'=>'OK'));
103
+						$this->_helper->json(array('status'=>'OK'));
104 104
 					}
105 105
 					// Error
106 106
 					$this->_helper->json(array('status'=>$return));
107 107
 				}
108 108
 				if ($action == 'check_update')
109 109
 				{
110
-				    $file=@fopen('/tmp/trapdirector_update.pid','r');
111
-				    if ($file == false)
112
-				    {   // process is dead
113
-				        $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file'));
114
-				        return;
115
-				    }
116
-				    $pid=fgets($file);
117
-				    $output=array();
118
-				    $retVal=0;
110
+					$file=@fopen('/tmp/trapdirector_update.pid','r');
111
+					if ($file == false)
112
+					{   // process is dead
113
+						$this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file'));
114
+						return;
115
+					}
116
+					$pid=fgets($file);
117
+					$output=array();
118
+					$retVal=0;
119 119
 					exec('ps '.$pid,$output,$retVal);
120 120
 					if ($retVal == 0)
121 121
 					{ // process is alive
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 					}
124 124
 					else
125 125
 					{ // process is dead
126
-					    $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid));
126
+						$this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid));
127 127
 					}
128 128
 				}
129 129
 				$this->_helper->json(array('status'=>'ERR : no '.$action.' action possible' ));
@@ -131,32 +131,32 @@  discard block
 block discarded – undo
131 131
 			/** Check for mib file UPLOAD */
132 132
 			if (isset($_FILES['mibfile']))
133 133
 			{
134
-			    $name=filter_var($_FILES['mibfile']['name'],FILTER_SANITIZE_STRING);
134
+				$name=filter_var($_FILES['mibfile']['name'],FILTER_SANITIZE_STRING);
135 135
 				$DirConf=explode(':',$this->Config()->get('config', 'snmptranslate_dirs'));
136 136
 				$destDir=array_shift($DirConf);
137 137
 				if (!is_dir($destDir))
138 138
 				{
139
-				    $this->view->uploadStatus="ERROR : no $destDir directory, check module configuration";
139
+					$this->view->uploadStatus="ERROR : no $destDir directory, check module configuration";
140 140
 				}
141 141
 				else
142 142
 				{
143
-				    if (!is_writable($destDir))
144
-				    {
145
-				        $this->view->uploadStatus="ERROR : $destDir directory is not writable";
146
-				    }
147
-				    else
148
-				    {
149
-				        $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name";
150
-				        $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING);
151
-				        if (move_uploaded_file($sourceTmpNam,$destination)===false)
152
-    				    {
153
-    				        $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations";
154
-    				    }
155
-    				    else
156
-    				    {
157
-    				        $this->view->uploadStatus="File $name uploaded in $destDir";
158
-    				    }
159
-				    }
143
+					if (!is_writable($destDir))
144
+					{
145
+						$this->view->uploadStatus="ERROR : $destDir directory is not writable";
146
+					}
147
+					else
148
+					{
149
+						$destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name";
150
+						$sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING);
151
+						if (move_uploaded_file($sourceTmpNam,$destination)===false)
152
+						{
153
+							$this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations";
154
+						}
155
+						else
156
+						{
157
+							$this->view->uploadStatus="File $name uploaded in $destDir";
158
+						}
159
+					}
160 160
 				}
161 161
 
162 162
 			}
@@ -236,63 +236,63 @@  discard block
 block discarded – undo
236 236
 	/** UI options */
237 237
 	public function uimgtAction()
238 238
 	{
239
-	    $this->prepareTabs()->activate('uimgt');
239
+		$this->prepareTabs()->activate('uimgt');
240 240
 	    
241
-	    $this->view->setError='';
242
-	    $this->view->setOKMsg='';
241
+		$this->view->setError='';
242
+		$this->view->setOKMsg='';
243 243
 	    
244
-	    //max_rows=25&row_update=update
245
-	    if ( $this->getRequest()->getParam('max_rows',NULL) !== NULL )
246
-	    {
247
-	        $maxRows = $this->getRequest()->getParam('max_rows');
248
-	        if (!preg_match('/^[0-9]+$/', $maxRows) || $maxRows < 1)
249
-	        {
250
-	            $this->view->setError='Max rows must be a number';
251
-	        }
252
-	        else
253
-	        {
254
-	            $this->setitemListDisplay($maxRows);
255
-	            $this->view->setOKMsg='Set max rows to ' . $maxRows;
256
-	        }
257
-	    }
244
+		//max_rows=25&row_update=update
245
+		if ( $this->getRequest()->getParam('max_rows',NULL) !== NULL )
246
+		{
247
+			$maxRows = $this->getRequest()->getParam('max_rows');
248
+			if (!preg_match('/^[0-9]+$/', $maxRows) || $maxRows < 1)
249
+			{
250
+				$this->view->setError='Max rows must be a number';
251
+			}
252
+			else
253
+			{
254
+				$this->setitemListDisplay($maxRows);
255
+				$this->view->setOKMsg='Set max rows to ' . $maxRows;
256
+			}
257
+		}
258 258
 	    
259
-	    if ( $this->getRequest()->getParam('add_category',NULL) !== NULL )
260
-	    {
261
-	        $addCat = $this->getRequest()->getParam('add_category');
262
-            $this->addHandlersCategory($addCat);
263
-	    }
259
+		if ( $this->getRequest()->getParam('add_category',NULL) !== NULL )
260
+		{
261
+			$addCat = $this->getRequest()->getParam('add_category');
262
+			$this->addHandlersCategory($addCat);
263
+		}
264 264
 	    
265
-	    if ( $this->getRequest()->getPost('type',NULL) !== NULL )
266
-	    {
267
-	        $type = $this->getRequest()->getPost('type',NULL);
268
-	        $index = $this->getRequest()->getPost('index',NULL);
269
-	        $newname = $this->getRequest()->getPost('newname',NULL);
265
+		if ( $this->getRequest()->getPost('type',NULL) !== NULL )
266
+		{
267
+			$type = $this->getRequest()->getPost('type',NULL);
268
+			$index = $this->getRequest()->getPost('index',NULL);
269
+			$newname = $this->getRequest()->getPost('newname',NULL);
270 270
 
271
-	        if (!preg_match('/^[0-9]+$/', $index) || $index < 1)
272
-	            $this->_helper->json(array('status'=>'Bad index'));
271
+			if (!preg_match('/^[0-9]+$/', $index) || $index < 1)
272
+				$this->_helper->json(array('status'=>'Bad index'));
273 273
 	        
274
-	        switch ($type)
275
-	        {
276
-	            case 'delete':
277
-	                $this->delHandlersCategory($index);
278
-	                $this->_helper->json(array('status'=>'OK'));
279
-	                return;
280
-	                break;
281
-	            case 'rename':
282
-	                $this->renameHandlersCategory($index, $newname);
283
-	                $this->_helper->json(array('status'=>'OK'));
284
-	                return;
285
-	                break;
286
-	            default:
287
-	                $this->_helper->json(array('status'=>'Unknwon command'));
288
-	                return;
289
-	                break;
290
-	        }
291
-	    }
274
+			switch ($type)
275
+			{
276
+				case 'delete':
277
+					$this->delHandlersCategory($index);
278
+					$this->_helper->json(array('status'=>'OK'));
279
+					return;
280
+					break;
281
+				case 'rename':
282
+					$this->renameHandlersCategory($index, $newname);
283
+					$this->_helper->json(array('status'=>'OK'));
284
+					return;
285
+					break;
286
+				default:
287
+					$this->_helper->json(array('status'=>'Unknwon command'));
288
+					return;
289
+					break;
290
+			}
291
+		}
292 292
 	    
293
-	    $this->view->maxRows = $this->itemListDisplay();
293
+		$this->view->maxRows = $this->itemListDisplay();
294 294
 	    
295
-	    $this->view->categories = $this->getHandlersCategory();
295
+		$this->view->categories = $this->getHandlersCategory();
296 296
 	    
297 297
 	    
298 298
 	    
@@ -341,47 +341,47 @@  discard block
 block discarded – undo
341 341
 	 */
342 342
 	public function pluginsAction()
343 343
 	{
344
-	    $this->prepareTabs()->activate('plugins');
344
+		$this->prepareTabs()->activate('plugins');
345 345
 	    
346
-	    require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
347
-	    $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
348
-	    $Trap = new Trap($icingaweb2_etc,4);
346
+		require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
347
+		$icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
348
+		$Trap = new Trap($icingaweb2_etc,4);
349 349
 	    
350
-	    $this->view->pluginLoaded = htmlentities($Trap->pluginClass->registerAllPlugins(false));
350
+		$this->view->pluginLoaded = htmlentities($Trap->pluginClass->registerAllPlugins(false));
351 351
 	    
352
-	    $enabledPlugins = $Trap->pluginClass->getEnabledPlugins();
352
+		$enabledPlugins = $Trap->pluginClass->getEnabledPlugins();
353 353
 
354
-	    $pluginList = $Trap->pluginClass->pluginList();
354
+		$pluginList = $Trap->pluginClass->pluginList();
355 355
 	    
356
-	    // Plugin list and fill function name list
357
-	    $functionList=array();
358
-	    $this->view->pluginArray=array();
359
-	    foreach ($pluginList as $plugin)
360
-	    {
361
-	        $pluginDetails=$Trap->pluginClass->pluginDetails($plugin);
362
-	        $pluginDetails->enabled =  (in_array($plugin, $enabledPlugins)) ? true : false;
363
-	        $pluginDetails->catchAllTraps = ($pluginDetails->catchAllTraps === true )? 'Yes' : 'No';
364
-	        $pluginDetails->processTraps = ($pluginDetails->processTraps === true )? 'Yes' : 'No';
365
-	        $pluginDetails->description = htmlentities($pluginDetails->description);
366
-	        $pluginDetails->description = preg_replace('/\n/','<br>',$pluginDetails->description);
367
-	        array_push($this->view->pluginArray, $pluginDetails);
368
-	        // Get functions for function details
369
-	        foreach ($pluginDetails->funcArray as $function)
370
-	        {
371
-	            array_push($functionList,$function);
372
-	        }
373
-	    }
356
+		// Plugin list and fill function name list
357
+		$functionList=array();
358
+		$this->view->pluginArray=array();
359
+		foreach ($pluginList as $plugin)
360
+		{
361
+			$pluginDetails=$Trap->pluginClass->pluginDetails($plugin);
362
+			$pluginDetails->enabled =  (in_array($plugin, $enabledPlugins)) ? true : false;
363
+			$pluginDetails->catchAllTraps = ($pluginDetails->catchAllTraps === true )? 'Yes' : 'No';
364
+			$pluginDetails->processTraps = ($pluginDetails->processTraps === true )? 'Yes' : 'No';
365
+			$pluginDetails->description = htmlentities($pluginDetails->description);
366
+			$pluginDetails->description = preg_replace('/\n/','<br>',$pluginDetails->description);
367
+			array_push($this->view->pluginArray, $pluginDetails);
368
+			// Get functions for function details
369
+			foreach ($pluginDetails->funcArray as $function)
370
+			{
371
+				array_push($functionList,$function);
372
+			}
373
+		}
374 374
 	    
375
-	    // Function list with details
376
-	    $this->view->functionList=array();
377
-	    foreach ($functionList as $function)
378
-	    {
379
-	        $functionDetail = $Trap->pluginClass->getFunctionDetails($function);
380
-	        $functionDetail->params = htmlentities($functionDetail->params);
381
-	        $functionDetail->description = htmlentities($functionDetail->description);
382
-	        $functionDetail->description = preg_replace('/\n/','<br>',$functionDetail->description);
383
-	        array_push($this->view->functionList, $functionDetail);
384
-	    }
375
+		// Function list with details
376
+		$this->view->functionList=array();
377
+		foreach ($functionList as $function)
378
+		{
379
+			$functionDetail = $Trap->pluginClass->getFunctionDetails($function);
380
+			$functionDetail->params = htmlentities($functionDetail->params);
381
+			$functionDetail->description = htmlentities($functionDetail->description);
382
+			$functionDetail->description = preg_replace('/\n/','<br>',$functionDetail->description);
383
+			array_push($this->view->functionList, $functionDetail);
384
+		}
385 385
 
386 386
 	}
387 387
 	
@@ -393,36 +393,36 @@  discard block
 block discarded – undo
393 393
 		)->add('mib', array(
394 394
 			'label' => $this->translate('MIB Management'),
395 395
 			'url'   => $this->getModuleConfig()->urlPath() . '/status/mib')
396
-	    )->add('uimgt', array(
397
-	        'label' => $this->translate('UI Configuration'),
398
-	        'url'   => $this->getModuleConfig()->urlPath() . '/status/uimgt')
399
-        )->add('services', array(
396
+		)->add('uimgt', array(
397
+			'label' => $this->translate('UI Configuration'),
398
+			'url'   => $this->getModuleConfig()->urlPath() . '/status/uimgt')
399
+		)->add('services', array(
400 400
 			'label' => $this->translate('Services management'),
401 401
 			'url'   => $this->getModuleConfig()->urlPath() . '/status/services')
402
-	    )->add('plugins', array(
403
-	        'label' => $this->translate('Plugins management'),
404
-	        'url'   => $this->getModuleConfig()->urlPath() . '/status/plugins')
405
-	    );
402
+		)->add('plugins', array(
403
+			'label' => $this->translate('Plugins management'),
404
+			'url'   => $this->getModuleConfig()->urlPath() . '/status/plugins')
405
+		);
406 406
 	} 
407 407
 }
408 408
 
409 409
 // TODO : see if useless 
410 410
 class UploadForm extends Form
411 411
 { 
412
-    public function __construct($options = null) 
413
-    {
414
-        parent::__construct($options);
415
-        $this->addElements2();
416
-    }
412
+	public function __construct($options = null) 
413
+	{
414
+		parent::__construct($options);
415
+		$this->addElements2();
416
+	}
417 417
 
418
-    public function addElements2()
419
-    {
420
-        // File Input
421
-        $file = new File('mib-file');
422
-        $file->setLabel('Mib upload');
423
-             //->setAttrib('multiple', null);
424
-        $this->addElement($file);
418
+	public function addElements2()
419
+	{
420
+		// File Input
421
+		$file = new File('mib-file');
422
+		$file->setLabel('Mib upload');
423
+			 //->setAttrib('multiple', null);
424
+		$this->addElement($file);
425 425
 		$button = new Submit("upload",array('ignore'=>false));
426 426
 		$this->addElement($button);//->setIgnore(false);
427
-    }
427
+	}
428 428
 }
Please login to merge, or discard this patch.
application/controllers/HandlerController.php 1 patch
Indentation   +261 added lines, -262 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->getConnection(),
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->getConnection(),
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->getUIDatabase()->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->getUIDatabase()->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->getUIDatabase()->getHostByName($this->view->hostname);
235
+		// Check if hostname still exists
236
+		$host_get=$this->getUIDatabase()->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->getUIDatabase()->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->getUIDatabase()->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->getUIDatabase()->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->getUIDatabase()->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->getUIDatabase()->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->getUIDatabase()->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,7 +505,7 @@  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->getUIDatabase()->getHostInfoByID($params['hostid']['val']);
508
+				$hostAddr=$this->getUIDatabase()->getHostInfoByID($params['hostid']['val']);
510 509
 				$params['ip4']['val']=$hostAddr->ip4;
511 510
 				$params['ip6']['val']=$hostAddr->ip6;
512 511
 				$checkHostName=$hostAddr->name;
@@ -517,8 +516,8 @@  discard block
 block discarded – undo
517 516
 				}
518 517
 				if (!is_numeric($params['serviceid']['val']))
519 518
 				{
520
-				    $this->_helper->json(array('status'=>"Invalid service id ". $params['serviceid']['val']));
521
-				    return;
519
+					$this->_helper->json(array('status'=>"Invalid service id ". $params['serviceid']['val']));
520
+					return;
522 521
 				}
523 522
 				$serviceName=$this->getUIDatabase()->getObjectNameByid($params['serviceid']['val']);
524 523
 				if ($params['service_name']['val'] != $serviceName->name2)
@@ -529,7 +528,7 @@  discard block
 block discarded – undo
529 528
 			}
530 529
 			else
531 530
 			{
532
-			    $object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']);
531
+				$object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']);
533 532
 				if ($params['host_name']['val'] != $object->name1)
534 533
 				{
535 534
 					$this->_helper->json(array('status'=>"Invalid object group id : Please re enter service"));
@@ -551,11 +550,11 @@  discard block
 block discarded – undo
551 550
 			
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
-			    $ruleID=$this->getUIDatabase()->addHandlerRule($dbparams);
553
+				$ruleID=$this->getUIDatabase()->addHandlerRule($dbparams);
555 554
 			}
556 555
 			else
557 556
 			{
558
-			    $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
557
+				$this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
559 558
 				$ruleID=$params['db_rule']['val'];
560 559
 			}
561 560
 		}
@@ -569,9 +568,9 @@  discard block
 block discarded – undo
569 568
 	}
570 569
 
571 570
 	/** Get trap detail by trapid. 
572
-	*	@param integer $trapid : id of trap in received table
573
-	*	@return array (objects)
574
-	*/
571
+	 *	@param integer $trapid : id of trap in received table
572
+	 *	@return array (objects)
573
+	 */
575 574
 	protected function getTrapDetail($trapid) 
576 575
 	{
577 576
 		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
@@ -587,14 +586,14 @@  discard block
 block discarded – undo
587 586
 		}
588 587
 		try
589 588
 		{		
590
-		    $query = $dbConn->select()
589
+			$query = $dbConn->select()
591 590
 				->from($this->getModuleConfig()->getTrapTableName(),$elmts)
592 591
 				->where('id=?',$trapid);
593 592
 				$trapDetail=$dbConn->fetchRow($query);
594 593
 			if ( $trapDetail == null ) 
595 594
 			{
596
-			    $trapDetail = 'NULL';
597
-			    throw new Exception('No traps was found with id = '.$trapid);
595
+				$trapDetail = 'NULL';
596
+				throw new Exception('No traps was found with id = '.$trapid);
598 597
 			}
599 598
 		}
600 599
 		catch (Exception $e)
@@ -608,9 +607,9 @@  discard block
 block discarded – undo
608 607
 	}
609 608
 
610 609
 	/** Get trap objects
611
-	*	@param integer $trapid : trap id
612
-	* 	@return array : full column in db of trap id
613
-	*/
610
+	 *	@param integer $trapid : trap id
611
+	 * 	@return array : full column in db of trap id
612
+	 */
614 613
 	protected function getTrapobjects($trapid)
615 614
 	{	
616 615
 		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
@@ -626,7 +625,7 @@  discard block
 block discarded – undo
626 625
 		}
627 626
 		try
628 627
 		{		
629
-		    $query = $dbConn->select()
628
+			$query = $dbConn->select()
630 629
 				->from($this->moduleConfig->getTrapDataTableName(),$data_elmts)
631 630
 				->where('trap_id=?',$trapid);
632 631
 				$trapDetail=$dbConn->fetchAll($query);
@@ -642,10 +641,10 @@  discard block
 block discarded – undo
642 641
 	}
643 642
 
644 643
 	/** Get rule detail by ruleid.
645
-	*	@param integer $ruleid int id of rule in rule table
646
-	*	@return object|array : column objects in db 
647
-	*
648
-	*/
644
+	 *	@param integer $ruleid int id of rule in rule table
645
+	 *	@return object|array : column objects in db 
646
+	 *
647
+	 */
649 648
 	protected function getRuleDetail($ruleid) 
650 649
 	{
651 650
 		if (!preg_match('/^[0-9]+$/',$ruleid)) { throw new Exception('Invalid id');  }
@@ -656,7 +655,7 @@  discard block
 block discarded – undo
656 655
 		// ***************  Get main data
657 656
 		try
658 657
 		{		
659
-		    $query = $dbConn->select()
658
+			$query = $dbConn->select()
660 659
 				->from($this->getModuleConfig()->getTrapRuleName(),$queryArray)
661 660
 				->where('id=?',$ruleid);
662 661
 			$ruleDetail=$dbConn->fetchRow($query);
@@ -673,7 +672,7 @@  discard block
 block discarded – undo
673 672
 	}
674 673
 
675 674
 	/** Setup tabs for rules 
676
-	*/
675
+	 */
677 676
 	protected function prepareTabs()
678 677
 	{
679 678
 		return $this->getTabs()->add('status', array(
Please login to merge, or discard this patch.