Passed
Pull Request — master (#23)
by Patrick
02:12
created
configuration.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,22 +10,22 @@
 block discarded – undo
10 10
     'url'   => 'settings'
11 11
 ));
12 12
 
13
-$section = $this->menuSection(N_('Traps'),array (
13
+$section=$this->menuSection(N_('Traps'), array(
14 14
 	'icon'	=> 'filter',
15 15
 	'url'	=> 'trapdirector'
16 16
 ));
17 17
 
18
-$section->add(N_('Status & Mibs'),array(
18
+$section->add(N_('Status & Mibs'), array(
19 19
 	'url'			=> 'trapdirector/status/',
20 20
 	'permission' 	=> 'trapdirector/view'
21 21
 ));
22 22
 
23
-$section->add(N_('Received'),array(
23
+$section->add(N_('Received'), array(
24 24
 	'url'			=> 'trapdirector/received/',
25 25
 	'permission' 	=> 'trapdirector/view'
26 26
 ));
27 27
 
28
-$section->add(N_('Handlers'),array(
28
+$section->add(N_('Handlers'), array(
29 29
 	'url'			=> 'trapdirector/handler/',
30 30
 	'permission' 	=> 'trapdirector/config'
31 31
 ));
Please login to merge, or discard this patch.
application/clicommands/StatusCommand.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,21 +24,21 @@
 block discarded – undo
24 24
 	public function dbAction()
25 25
 	{
26 26
 		$db_prefix=$this->Config()->get('config', 'database_prefix');
27
-		$Config = new TrapModuleConfig($db_prefix);
27
+		$Config=new TrapModuleConfig($db_prefix);
28 28
 		
29 29
 		try
30 30
 		{
31 31
 			
32 32
 			$dbresource=$this->Config()->get('config', 'database');
33
-			printf("DB name : %s\n",$dbresource);
34
-			$dataBase = IcingaDbConnection::fromResourceName($dbresource)->getConnection();
33
+			printf("DB name : %s\n", $dbresource);
34
+			$dataBase=IcingaDbConnection::fromResourceName($dbresource)->getConnection();
35 35
 			
36
-			$query = $dataBase->select()->from($Config->getTrapTableName(),array('COUNT(*)'));			
37
-			printf("Number of traps : %s\n", $dataBase->fetchOne($query) );
38
-			$query = $dataBase->select()->from($Config->getTrapDataTableName(),array('COUNT(*)'));			
39
-			printf("Number of trap objects : %s\n", $dataBase->fetchOne($query) );
40
-			$query = $dataBase->select()->from($Config->getTrapRuleName(),array('COUNT(*)'));			
41
-			printf("Number of rules : %s\n", $dataBase->fetchOne($query) );
36
+			$query=$dataBase->select()->from($Config->getTrapTableName(), array('COUNT(*)'));			
37
+			printf("Number of traps : %s\n", $dataBase->fetchOne($query));
38
+			$query=$dataBase->select()->from($Config->getTrapDataTableName(), array('COUNT(*)'));			
39
+			printf("Number of trap objects : %s\n", $dataBase->fetchOne($query));
40
+			$query=$dataBase->select()->from($Config->getTrapRuleName(), array('COUNT(*)'));			
41
+			printf("Number of rules : %s\n", $dataBase->fetchOne($query));
42 42
 			
43 43
 		}
44 44
 		catch (Exception $e)
Please login to merge, or discard this patch.
application/clicommands/TrapsCommand.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 	public function rotateAction()
31 31
 	{
32 32
 		$module=Icinga::app()->getModuleManager()->getModule($this->getModuleName());
33
-		require_once($module->getBaseDir() .'/bin/trap_class.php');
33
+		require_once($module->getBaseDir().'/bin/trap_class.php');
34 34
 		$icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
35 35
 		$debug_level=2;
36
-		$trap = new Trap($icingaweb2_etc);
37
-		$trap->setLogging($debug_level,'display');
36
+		$trap=new Trap($icingaweb2_etc);
37
+		$trap->setLogging($debug_level, 'display');
38 38
 		try
39 39
 		{
40
-			$days = $this->params->get('days', '<default>');
40
+			$days=$this->params->get('days', '<default>');
41 41
 			echo $this->screen->colorize("Deleting traps older than $days days\n", 'lightblue');
42
-			if ($days=='<default>')
42
+			if ($days == '<default>')
43 43
 			{
44 44
 				$trap->eraseOldTraps();
45 45
 			}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		}
52 52
 		catch (Exception $e)
53 53
 		{
54
-			echo 'Error in updating : ' . $e->getMessage();
54
+			echo 'Error in updating : '.$e->getMessage();
55 55
 		}	   
56 56
 	}  	
57 57
 	
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 	public function resetOKAction()
67 67
 	{
68 68
 		$module=Icinga::app()->getModuleManager()->getModule($this->getModuleName());
69
-		require_once($module->getBaseDir() .'/bin/trap_class.php');
69
+		require_once($module->getBaseDir().'/bin/trap_class.php');
70 70
 		$icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
71 71
 		$debug_level=2;
72
-		$trap = new Trap($icingaweb2_etc);
73
-		$trap->setLogging($debug_level,'display');
72
+		$trap=new Trap($icingaweb2_etc);
73
+		$trap->setLogging($debug_level, 'display');
74 74
 		try 
75 75
 		{
76 76
 			$trap->reset_services();
77 77
 		} 
78 78
 		catch (Exception $e) 
79 79
 		{
80
-			echo 'ERROR : '. $e->getMessage();
80
+			echo 'ERROR : '.$e->getMessage();
81 81
 		}
82 82
 	} 	
83 83
 	
Please login to merge, or discard this patch.
application/forms/TrapsConfigForm.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		$this->setName('form_config_traps');
19 19
 		$this->setSubmitLabel($this->translate('Save Changes'));
20 20
 	}
21
-	public function setPaths($module_base_path,$icinga_base_path)
21
+	public function setPaths($module_base_path, $icinga_base_path)
22 22
 	{
23 23
 		$this->module_base_path=$module_base_path;
24 24
 		$this->icinga_base_path=$icinga_base_path;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         );
83 83
 		$retval=0;
84 84
 		$output=array();
85
-		$snmptranslate=exec('which snmptranslate',$output,$retval);
85
+		$snmptranslate=exec('which snmptranslate', $output, $retval);
86 86
 		if ($retval != 0) 
87 87
 		{
88 88
 			$snmptranslate='/usr/bin/snmptranslate';
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     }	
173 173
 
174 174
     
175
-    public function render(Zend_View_Interface $view = NULL)
175
+    public function render(Zend_View_Interface $view=NULL)
176 176
     {
177 177
         
178 178
 
Please login to merge, or discard this patch.
application/controllers/ErrorController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 	
13 13
 	public function indexAction()
14 14
 	{	  
15
-		$this->getTabs()->add('get',array(
15
+		$this->getTabs()->add('get', array(
16 16
 			'active'	=> true,
17 17
 			'label'		=> $this->translate('Error'),
18 18
 			'url'		=> Url::fromRequest()
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapTable.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	// Filters 
36 36
 	
37 37
     protected $filter;
38
-    protected $enforcedFilters = array();
39
-    protected $searchColumns = array();
38
+    protected $enforcedFilters=array();
39
+    protected $searchColumns=array();
40 40
 	
41 41
 	
42 42
 	// Must return titles in array ( id => display_name )
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	// ****************** Day header
45 45
     protected function renderDayIfNew($timestamp)
46 46
     {
47
-        $view = $this->getView();
47
+        $view=$this->getView();
48 48
 
49 49
 		// Check for date local format
50 50
         if (in_array(setlocale(LC_ALL, 0), array('en_US.UTF-8', 'C'))) {
51
-            $day = date('l, jS F Y', (int) $timestamp);
51
+            $day=date('l, jS F Y', (int) $timestamp);
52 52
         } else {
53
-            $day = strftime('%A, %e. %B, %Y', (int) $timestamp);
53
+            $day=strftime('%A, %e. %B, %Y', (int) $timestamp);
54 54
         }
55 55
 
56 56
         if ($this->lastDay === $day) {
@@ -58,25 +58,25 @@  discard block
 block discarded – undo
58 58
         }
59 59
 
60 60
         if ($this->lastDay === null) {
61
-            $htm = "<thead>\n  <tr>\n";
61
+            $htm="<thead>\n  <tr>\n";
62 62
         } else {
63
-            $htm = "</tbody>\n<thead>\n  <tr>\n";
63
+            $htm="</tbody>\n<thead>\n  <tr>\n";
64 64
         }
65 65
 
66 66
         if ($this->columnCount === null) {
67
-            $this->columnCount = count($this->getTitles());
67
+            $this->columnCount=count($this->getTitles());
68 68
         }
69 69
 
70
-        $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($day) . '</th>' . "\n";
70
+        $htm.='<th colspan="'.$this->columnCount.'">'.$view->escape($day).'</th>'."\n";
71 71
         if ($this->lastDay === null) {
72
-            $htm .= "  </tr>\n";
72
+            $htm.="  </tr>\n";
73 73
         } else {
74
-            $htm .= "  </tr>\n</thead>\n";
74
+            $htm.="  </tr>\n</thead>\n";
75 75
         }
76 76
 
77
-        $this->lastDay = $day;
77
+        $this->lastDay=$day;
78 78
 
79
-        return $htm . "<tbody>\n";
79
+        return $htm."<tbody>\n";
80 80
     }		
81 81
 	// ******************  Render table in html  
82 82
     public function __toString()
@@ -89,28 +89,28 @@  discard block
 block discarded – undo
89 89
 	// ******************  Static config set
90 90
 	public function setConfig($conf)
91 91
 	{
92
-		$this->moduleConfig = $conf;
92
+		$this->moduleConfig=$conf;
93 93
 	}
94 94
 	// ******************  View get/set
95 95
     protected function getView()
96 96
     {
97 97
         if ($this->view === null) {
98
-            $this->view = Icinga::app()->getViewRenderer()->view;
98
+            $this->view=Icinga::app()->getViewRenderer()->view;
99 99
         }
100 100
         return $this->view;
101 101
     }
102 102
 
103 103
     public function setView($view)
104 104
     {
105
-        $this->view = $view;
105
+        $this->view=$view;
106 106
     }	
107 107
 	
108 108
 	// Limits
109 109
 	
110
-    public function limit($count = null, $offset = null)
110
+    public function limit($count=null, $offset=null)
111 111
     {
112
-        $this->limit = $count;
113
-        $this->offset = $offset;
112
+        $this->limit=$count;
113
+        $this->offset=$offset;
114 114
 
115 115
         return $this;
116 116
     }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	
140 140
     public function getPaginator()
141 141
     {
142
-        $paginator = new Paginator();
142
+        $paginator=new Paginator();
143 143
         $paginator->setQuery($this);
144 144
 
145 145
         return $paginator;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	
150 150
     public function setConnection(Selectable $connection)
151 151
     {
152
-        $this->connection = $connection;
152
+        $this->connection=$connection;
153 153
         return $this;
154 154
     }
155 155
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	{
168 168
 		$db=$this->db();
169 169
 		
170
-		$query = $this->getBaseQuery();
170
+		$query=$this->getBaseQuery();
171 171
 		
172 172
        if ($this->hasLimit() || $this->hasOffset()) {
173 173
             $query->limit($this->getLimit(), $this->getOffset());
@@ -189,20 +189,20 @@  discard block
 block discarded – undo
189 189
 
190 190
     public function setFilter($filter)
191 191
     {
192
-        $this->filter = $filter;
192
+        $this->filter=$filter;
193 193
         return $this;
194 194
     }
195 195
 	
196 196
 	public function getFilterEditor(Request $request)
197 197
     {
198
-        $filterEditor = Widget::create('filterEditor')
198
+        $filterEditor=Widget::create('filterEditor')
199 199
             ->setColumns(array_keys($this->getColumns()))
200 200
             ->setSearchColumns(array_keys($this->getSearchColumns()))
201 201
             ->preserveParams('limit', 'sort', 'dir', 'view', 'backend')
202 202
             ->ignoreParams('page')
203 203
             ->handleRequest($request);
204 204
 
205
-        $filter = $filterEditor->getFilter();
205
+        $filter=$filterEditor->getFilter();
206 206
         $this->setFilter($filter);
207 207
 
208 208
         return $filterEditor;
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapTableList.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	// Filters 
22 22
 	
23 23
     protected $filter;
24
-    protected $enforcedFilters = array();
25
-    protected $searchColumns = array();
24
+    protected $enforcedFilters=array();
25
+    protected $searchColumns=array();
26 26
 	
27 27
 	protected function getTitles() {
28 28
 		// TODO : check moduleconfig is set
@@ -38,60 +38,60 @@  discard block
 block discarded – undo
38 38
 	public function render()
39 39
 	{
40 40
 		$data=$this->getTable();
41
-		$view = $this->getView();
42
-		$this->columnCount = count($this->getTitles());
41
+		$view=$this->getView();
42
+		$this->columnCount=count($this->getTitles());
43 43
 		$this->lastDay=null;
44 44
 		// Table start
45
-		$htm  = '<table class="simple common-table table-row-selectable">';
45
+		$htm='<table class="simple common-table table-row-selectable">';
46 46
 		
47 47
 		// Titles
48
-		$htm .= "<thead>\n  <tr>\n";
49
-		$titles = $this->getTitles();
48
+		$htm.="<thead>\n  <tr>\n";
49
+		$titles=$this->getTitles();
50 50
 		foreach ($titles as $title) 
51 51
 		{
52
-			$htm .= '    <th>' . $view->escape($view->translate($title)) . "</th>\n";
52
+			$htm.='    <th>'.$view->escape($view->translate($title))."</th>\n";
53 53
 		}
54
-		$htm .= "  </tr>\n</thead>\n";
54
+		$htm.="  </tr>\n</thead>\n";
55 55
 		
56 56
 		// Rows
57
-		$htm .= "<tbody>\n";
57
+		$htm.="<tbody>\n";
58 58
 		
59 59
 		foreach ($data as $row) 
60 60
 		{
61
-			$firstCol = true;
61
+			$firstCol=true;
62 62
 			// Put date header
63
-			$htm .= $this->renderDayIfNew($row->timestamp);
63
+			$htm.=$this->renderDayIfNew($row->timestamp);
64 64
 			
65 65
 			
66 66
 			// Render row
67
-			$htm .= '<tr '.' >';
68
-			foreach ( $titles as $rowkey => $title) 
67
+			$htm.='<tr '.' >';
68
+			foreach ($titles as $rowkey => $title) 
69 69
 			{
70 70
 				// Check missing value
71 71
 				if (property_exists($row, $rowkey)) 
72 72
 				{
73
-					$val = ($rowkey=='timestamp') ?  strftime('%T',$row->$rowkey) : $row->$rowkey;
73
+					$val=($rowkey == 'timestamp') ?  strftime('%T', $row->$rowkey) : $row->$rowkey;
74 74
 				} else {
75
-					$val = '-';
75
+					$val='-';
76 76
 				}
77 77
 				if ($firstCol == true) { // Put link in first column for trap detail.
78
-					$htm .= '<td>' 
78
+					$htm.='<td>' 
79 79
 							. $view->qlink(
80 80
 									$view->escape($val),  
81 81
 									Url::fromPath(
82
-										$this->moduleConfig->urlPath() . '/received/trapdetail', 
82
+										$this->moduleConfig->urlPath().'/received/trapdetail', 
83 83
 										array('id' => $row->id)
84 84
 									)
85 85
 							)
86 86
 							. '</td>';
87 87
 				} else {
88
-					$htm .= '<td>' . $view->escape($val) . '</td>';
88
+					$htm.='<td>'.$view->escape($val).'</td>';
89 89
 				}
90 90
 				$firstCol=false;
91 91
 			}
92
-			$htm .= "<tr>\n";
92
+			$htm.="<tr>\n";
93 93
 		}
94
-		$htm .= "</tbody></table>\n";
94
+		$htm.="</tbody></table>\n";
95 95
 		//$htm .= "Filter : " . $this->filter."<br>\n";
96 96
 		return $htm;
97 97
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     {
102 102
         $db=$this->db();
103 103
 		
104
-		$query = $db->select()->from(
104
+		$query=$db->select()->from(
105 105
             $this->moduleConfig->getTrapTableName(),
106 106
             array('COUNT(*)')
107 107
         );
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	
113 113
     public function getPaginator()
114 114
     {
115
-        $paginator = new Paginator();
115
+        $paginator=new Paginator();
116 116
         $paginator->setQuery($this);
117 117
 
118 118
         return $paginator;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	{
125 125
 		$db=$this->db();
126 126
 		
127
-		$query = $this->getBaseQuery();
127
+		$query=$this->getBaseQuery();
128 128
 		$this->applyFiltersToQuery($query);
129 129
        if ($this->hasLimit() || $this->hasOffset()) {
130 130
             $query->limit($this->getLimit(), $this->getOffset());
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     {
138 138
 		$db=$this->db();
139 139
 		
140
-		$query = $db->select()->from(
140
+		$query=$db->select()->from(
141 141
             $this->moduleConfig->getTrapTableName(),
142 142
             $this->moduleConfig->getTrapListDisplayColumns()
143 143
         )->order('timestamp DESC');
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	protected $filter_Handler;
151 151
 	protected $filter_query='';
152 152
 	protected $filter_done='';
153
-	protected $filter_query_list=array('q','done');
153
+	protected $filter_query_list=array('q', 'done');
154 154
 	public function renderFilterHTML()
155 155
 	{
156 156
 		$htm=' <form id="filter" name="mainFilter" 
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 		$htm.='<input type="text" name="q" title="Search is simple! Try to combine multiple words" 
161 161
 		placeholder="Search..." class="search" value="'.$this->filter_query.'">';
162 162
 		$htm.='<input type="checkbox" id="checkbox_done" name="done" value="1" class="autosubmit" ';
163
-		if	($this->filter_done == 1) { $htm.=' checked ';}
163
+		if ($this->filter_done == 1) { $htm.=' checked '; }
164 164
 		$htm.='> <label for="checkbox_done">Hide processed traps</label>';
165 165
 		$htm.='</form>';
166 166
 		return $htm;
167 167
 	}
168 168
 	
169
-	public function updateFilter($handler,$filter)
169
+	public function updateFilter($handler, $filter)
170 170
 	{
171 171
 		$this->filter_Handler=$handler->remove($this->filter_query_list)->__toString();
172
-		$this->filter_query=(isset($filter['q']))?$this->filter_query=$filter['q']:'';
173
-		$this->filter_done=(isset($filter['done']))?$this->filter_done=$filter['done']:0;
172
+		$this->filter_query=(isset($filter['q'])) ? $this->filter_query=$filter['q'] : '';
173
+		$this->filter_done=(isset($filter['done'])) ? $this->filter_done=$filter['done'] : 0;
174 174
 	}
175 175
 	
176 176
     protected function getSearchColumns()
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
 
186 186
     public function setFilter($filter)
187 187
     {
188
-        $this->filter = $filter;
188
+        $this->filter=$filter;
189 189
         return $this;
190 190
     }
191 191
 	
192 192
 	public function getFilterEditor(Request $request)
193 193
     {
194
-        $filterEditor = Widget::create('filterEditor')
194
+        $filterEditor=Widget::create('filterEditor')
195 195
             ->setColumns(array_keys($this->getColumns()))
196 196
             ->setSearchColumns(array_keys($this->getSearchColumns()))
197 197
             ->preserveParams('limit', 'sort', 'dir', 'view', 'backend')
198 198
             ->ignoreParams('page')
199 199
             ->handleRequest($request);
200 200
 
201
-        $filter = $filterEditor->getFilter();
201
+        $filter=$filterEditor->getFilter();
202 202
         $this->setFilter($filter);
203 203
 
204 204
         return $filterEditor;
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
 		{
213 213
 			$sql.='(';
214 214
 			$first=1;
215
-			foreach($this->moduleConfig->getTrapListSearchColumns() as $column)
215
+			foreach ($this->moduleConfig->getTrapListSearchColumns() as $column)
216 216
 			{
217
-				if ($first==0) $sql.=' OR ';
217
+				if ($first == 0) $sql.=' OR ';
218 218
 				$first=0;
219 219
 				$sql.=" CAST(".$column." AS  char(100))  LIKE  '%".$this->filter_query."%' ";
220 220
 			}
Please login to merge, or discard this patch.
library/Trapdirector/Config/TrapModuleConfig.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@  discard block
 block discarded – undo
14 14
 		'log_level' => 2, // log level
15 15
 	);
16 16
 	// get default values for dbconfig
17
-	public function getDBConfigDefaults() { return $this->DBConfigDefaults;}
17
+	public function getDBConfigDefaults() { return $this->DBConfigDefaults; }
18 18
 	// Minimum DB version
19
-	static public function getDbMinVersion() { return 2;}	
19
+	static public function getDbMinVersion() { return 2; }	
20 20
 	// Current DB version
21
-	static public function getDbCurVersion() { return 2;}
21
+	static public function getDbCurVersion() { return 2; }
22 22
 
23 23
 	/************ Module configuration **********************/
24 24
 	// Module base path
25 25
 	static public function urlPath() { return 'trapdirector'; }
26
-	static public function getapiUserPermissions() { return array("status", "objects/query/Host", "objects/query/Service" , "actions/process-check-result"); } //< api user permissions required
26
+	static public function getapiUserPermissions() { return array("status", "objects/query/Host", "objects/query/Service", "actions/process-check-result"); } //< api user permissions required
27 27
 	
28 28
 	/*********** Log configuration *************************/
29 29
 	protected $logLevels=array(0=>'No output', 1=>'critical', 2=>'warning', 3=>'trace', 4=>'ALL');
30
-	public function getlogLevels() { return $this->logLevels;}
31
-	protected $logDestinations=array('syslog'=>'syslog','file'=>'file','display'=>'display');
32
-	public function getLogDestinations() { return $this->logDestinations;}
30
+	public function getlogLevels() { return $this->logLevels; }
31
+	protected $logDestinations=array('syslog'=>'syslog', 'file'=>'file', 'display'=>'display');
32
+	public function getLogDestinations() { return $this->logDestinations; }
33 33
 	
34 34
 	function __construct($prefix)
35 35
 	{
@@ -40,29 +40,29 @@  discard block
 block discarded – undo
40 40
 	// DB table name of trap received list : prefix 't'
41 41
 	public function getTrapTableName() 
42 42
 	{ 
43
-		return array('t' => $this->table_prefix . 'received'); 
43
+		return array('t' => $this->table_prefix.'received'); 
44 44
 	}
45 45
 	// DB table name of trap data  list : prefix 'd'
46 46
 	public function getTrapDataTableName() 
47 47
 	{ 
48
-		return array('d' => $this->table_prefix . 'received_data'); 
48
+		return array('d' => $this->table_prefix.'received_data'); 
49 49
 	}	
50 50
 
51 51
 	// DB table name of rules : prefix 'r'
52 52
 	public function getTrapRuleName() 
53 53
 	{ 
54
-		return array('r' => $this->table_prefix . 'rules'); 
54
+		return array('r' => $this->table_prefix.'rules'); 
55 55
 	}		
56 56
 	
57 57
 	// DB table name of db config : prefix 'c'
58 58
 	public function getDbConfigTableName() 
59 59
 	{ 
60
-		return array('c' => $this->table_prefix . 'db_config');
60
+		return array('c' => $this->table_prefix.'db_config');
61 61
 	}
62 62
 	
63 63
 	// Mib cache tables
64
-	public function getMIBCacheTableName() { return $this->table_prefix . 'mib_cache'; }
65
-	public function getMIBCacheTableTrapObjName() { return $this->table_prefix . 'mib_cache_trap_object'; }
64
+	public function getMIBCacheTableName() { return $this->table_prefix.'mib_cache'; }
65
+	public function getMIBCacheTableTrapObjName() { return $this->table_prefix.'mib_cache_trap_object'; }
66 66
 	
67 67
 	
68 68
 	/****************** Database queries *******************/
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	public function getHandlerListDisplayColumns()
144 144
 	{
145 145
 		return array(
146
-			'host_name'		=> 'r.host_name',//'UNIX_TIMESTAMP(t.date_received)',
146
+			'host_name'		=> 'r.host_name', //'UNIX_TIMESTAMP(t.date_received)',
147 147
 			'host_group_name'=> 'r.host_group_name',
148 148
 			'source_ip'		=> "CASE WHEN r.ip4 IS NULL THEN r.ip6 ELSE r.ip4 END",
149 149
 			'trap_oid'		=> 'r.trap_oid',
@@ -196,32 +196,32 @@  discard block
 block discarded – undo
196 196
 	public function trapDetailQuery()
197 197
 	{
198 198
 		return array(
199
-			'timestamp'			=> array('Date','UNIX_TIMESTAMP(t.date_received)'),
200
-			'source_ip'			=> array('Source IP','t.source_ip'),
201
-			'source_name'		=> array('Source name','t.source_name'),
202
-			'source_port'		=> array('Source port','t.source_port'),
203
-			'destination_ip'	=> array('Destination IP','t.destination_ip'),
204
-			'destination_port'	=> array('Destination port','t.destination_port'),			
205
-			'trap_oid'			=> array('Numeric OID','t.trap_oid'),
206
-			'trap_name'			=> array('Trap name','t.trap_name'),
207
-			'trap_name_mib'		=> array('Trap MIB','t.trap_name_mib'),
208
-			'status'			=> array('Processing status','t.status'),
209
-			'status_detail'		=> array('Status details','t.status_detail'),
210
-			'process_time'		=> array('Trap processing time','t.process_time'),			
199
+			'timestamp'			=> array('Date', 'UNIX_TIMESTAMP(t.date_received)'),
200
+			'source_ip'			=> array('Source IP', 't.source_ip'),
201
+			'source_name'		=> array('Source name', 't.source_name'),
202
+			'source_port'		=> array('Source port', 't.source_port'),
203
+			'destination_ip'	=> array('Destination IP', 't.destination_ip'),
204
+			'destination_port'	=> array('Destination port', 't.destination_port'),			
205
+			'trap_oid'			=> array('Numeric OID', 't.trap_oid'),
206
+			'trap_name'			=> array('Trap name', 't.trap_name'),
207
+			'trap_name_mib'		=> array('Trap MIB', 't.trap_name_mib'),
208
+			'status'			=> array('Processing status', 't.status'),
209
+			'status_detail'		=> array('Status details', 't.status_detail'),
210
+			'process_time'		=> array('Trap processing time', 't.process_time'),			
211 211
 		);
212 212
 	}
213 213
 	// Trap detail : additional data (<key> => <title> <sql select>)
214 214
 	public function trapDataDetailQuery()
215 215
 	{
216 216
 		return array(
217
-			'oid'				=> array('Numeric OID','d.oid'),
218
-			'oid_name'			=> array('Text OID','d.oid_name'),
219
-			'oid_name_mib'		=> array('MIB','d.oid_name_mib'),
220
-			'value'				=> array('Value','d.value'),
217
+			'oid'				=> array('Numeric OID', 'd.oid'),
218
+			'oid_name'			=> array('Text OID', 'd.oid_name'),
219
+			'oid_name_mib'		=> array('MIB', 'd.oid_name_mib'),
220
+			'value'				=> array('Value', 'd.value'),
221 221
 		);
222 222
 	}
223 223
 	// foreign key of trap data table
224
-	public function trapDataFK() { return 'trap_id';}
224
+	public function trapDataFK() { return 'trap_id'; }
225 225
 	
226 226
 	// Max items in a list
227 227
 	public function itemListDisplay() { return 25; }
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapTableHostList.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	// Filters 
23 23
 	
24 24
     protected $filter;
25
-    protected $enforcedFilters = array();
26
-    protected $searchColumns = array();
25
+    protected $enforcedFilters=array();
26
+    protected $searchColumns=array();
27 27
 	
28 28
 	protected function getTitles() {
29 29
 		// TODO : check moduleconfig is set
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	// ******************  Render table in html 
34 34
 	
35 35
 	// Host grouping
36
-	protected function renderHostIfNew($IP,$hostname)
36
+	protected function renderHostIfNew($IP, $hostname)
37 37
 	{
38
-	    $view = $this->getView();
38
+	    $view=$this->getView();
39 39
 	    
40 40
 	    if ($this->lastHost === $IP) {
41 41
 	        return;
@@ -43,31 +43,31 @@  discard block
 block discarded – undo
43 43
 	    
44 44
 	    if ($this->lastHost === null) 
45 45
 	    {
46
-	        $htm = "<thead>\n  <tr>\n";
46
+	        $htm="<thead>\n  <tr>\n";
47 47
 	    } else {
48
-	        $htm = "</tbody>\n<thead>\n  <tr>\n";
48
+	        $htm="</tbody>\n<thead>\n  <tr>\n";
49 49
 	    }
50 50
 	    
51 51
 	    if ($this->columnCount === null) 
52 52
 	    {
53
-	        $this->columnCount = count($this->getTitles());
53
+	        $this->columnCount=count($this->getTitles());
54 54
 	    }
55 55
 	    
56
-	    $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($IP);
56
+	    $htm.='<th colspan="'.$this->columnCount.'">'.$view->escape($IP);
57 57
 	    if ($hostname != null)
58 58
 	    {
59
-	        $htm .= ' ('.$hostname.')';
59
+	        $htm.=' ('.$hostname.')';
60 60
 	    }
61
-	    $htm .= '</th>' . "\n";
61
+	    $htm.='</th>'."\n";
62 62
 	    if ($this->lastHost === null) {
63
-	        $htm .= "  </tr>\n";
63
+	        $htm.="  </tr>\n";
64 64
 	    } else {
65
-	        $htm .= "  </tr>\n</thead>\n";
65
+	        $htm.="  </tr>\n</thead>\n";
66 66
 	    }
67 67
 	    
68
-	    $this->lastHost = $IP;
68
+	    $this->lastHost=$IP;
69 69
 	    
70
-	    return $htm . "<tbody>\n";
70
+	    return $htm."<tbody>\n";
71 71
 	}		
72 72
 	
73 73
     public function __toString()
@@ -78,62 +78,62 @@  discard block
 block discarded – undo
78 78
 	public function render()
79 79
 	{
80 80
 		$data=$this->getTable();
81
-		$view = $this->getView();
82
-		$this->columnCount = count($this->getTitles());
81
+		$view=$this->getView();
82
+		$this->columnCount=count($this->getTitles());
83 83
 		$this->lastHost=null;
84 84
 		// Table start
85
-		$htm  = '<table class="simple common-table table-row-selectable">';
85
+		$htm='<table class="simple common-table table-row-selectable">';
86 86
 		
87 87
 		// Titles
88
-		$htm .= "<thead>\n  <tr>\n";
89
-		$titles = $this->getTitles();
88
+		$htm.="<thead>\n  <tr>\n";
89
+		$titles=$this->getTitles();
90 90
 		foreach ($titles as $title) 
91 91
 		{
92
-			$htm .= '    <th>' . $view->escape($view->translate($title)) . "</th>\n";
92
+			$htm.='    <th>'.$view->escape($view->translate($title))."</th>\n";
93 93
 		}
94
-		$htm .= "  </tr>\n</thead>\n";
94
+		$htm.="  </tr>\n</thead>\n";
95 95
 		
96 96
 		// Rows
97
-		$htm .= "<tbody>\n";
97
+		$htm.="<tbody>\n";
98 98
 		
99 99
 		foreach ($data as $row) 
100 100
 		{
101 101
 
102
-			$firstCol = true;
102
+			$firstCol=true;
103 103
 			// Put host header
104
-			$source_name=(property_exists($row,'source_name'))?$row->source_name:null;
105
-			$htm .= $this->renderHostIfNew($row->source_ip,$source_name);
104
+			$source_name=(property_exists($row, 'source_name')) ? $row->source_name : null;
105
+			$htm.=$this->renderHostIfNew($row->source_ip, $source_name);
106 106
 			
107 107
 			
108 108
 			// Render row
109
-			$htm .= '<tr '.' >';
110
-			foreach ( $titles as $rowkey => $title) 
109
+			$htm.='<tr '.' >';
110
+			foreach ($titles as $rowkey => $title) 
111 111
 			{
112 112
 				// Check missing value
113 113
 				if (property_exists($row, $rowkey)) 
114 114
 				{
115
-					$val = ($rowkey=='last_sent') ?  strftime('%c',$row->$rowkey) : $row->$rowkey;
115
+					$val=($rowkey == 'last_sent') ?  strftime('%c', $row->$rowkey) : $row->$rowkey;
116 116
 				} else {
117
-					$val = '-';
117
+					$val='-';
118 118
 				}
119 119
 				if ($firstCol === true) { // Put link in first column for trap detail.
120
-					$htm .= '<td>' 
120
+					$htm.='<td>' 
121 121
 							. $view->qlink(
122 122
 									$view->escape($val),  
123 123
 									Url::fromPath(
124
-										$this->moduleConfig->urlPath() . '/received', 
124
+										$this->moduleConfig->urlPath().'/received', 
125 125
 										array('q' => $row->trap_oid)
126 126
 									)
127 127
 							)
128 128
 							. '</td>';
129 129
 				} else {
130
-					$htm .= '<td>' . $view->escape($val) . '</td>';
130
+					$htm.='<td>'.$view->escape($val).'</td>';
131 131
 				}
132 132
 				$firstCol=false;
133 133
 			}
134
-			$htm .= "<tr>\n";
134
+			$htm.="<tr>\n";
135 135
 		}
136
-		$htm .= "</tbody></table>\n";
136
+		$htm.="</tbody></table>\n";
137 137
 		//$htm .= "Filter : " . $this->filter."<br>\n";
138 138
 		return $htm;
139 139
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     {  
144 144
         $db=$this->db();
145 145
 		
146
-		$query = $this->getBaseQuery();
146
+		$query=$this->getBaseQuery();
147 147
 		$this->applyFiltersToQuery($query);
148 148
 		$values=$db->fetchAll($query);
149 149
 		
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	
155 155
     public function getPaginator()
156 156
     {
157
-        $paginator = new Paginator();
157
+        $paginator=new Paginator();
158 158
         $paginator->setQuery($this);
159 159
 
160 160
         return $paginator;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	{
167 167
 		$db=$this->db();
168 168
 		
169
-		$query = $this->getBaseQuery();
169
+		$query=$this->getBaseQuery();
170 170
 		$this->applyFiltersToQuery($query);
171 171
        if ($this->hasLimit() || $this->hasOffset()) {
172 172
             $query->limit($this->getLimit(), $this->getOffset());
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
     public function getBaseQuery()
179 179
     {
180 180
 		$db=$this->db();
181
-		$query = $db->select()->from(
181
+		$query=$db->select()->from(
182 182
             $this->moduleConfig->getTrapTableName(),
183 183
 		    $this->moduleConfig->getTrapHostListDisplayColumns()
184
-		    )->group(array('t.source_ip','t.source_name','t.trap_oid'))
184
+		    )->group(array('t.source_ip', 't.source_name', 't.trap_oid'))
185 185
 		    ->order('t.source_ip');
186 186
 
187 187
         return $query;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	protected $filter_Handler;
193 193
 	protected $filter_query='';
194 194
 	protected $filter_done='';
195
-	protected $filter_query_list=array('q','done');
195
+	protected $filter_query_list=array('q', 'done');
196 196
 	public function renderFilterHTML()
197 197
 	{
198 198
 		$htm=' <form id="filter" name="mainFilter" 
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
 		$htm.='<input type="text" name="q" title="Search is simple! Try to combine multiple words" 
203 203
 		placeholder="Search..." class="search" value="'.$this->filter_query.'">';
204 204
 		$htm.='<input type="checkbox" id="checkbox_done" name="done" value="1" class="autosubmit" ';
205
-		if	($this->filter_done == 1) { $htm.=' checked ';}
205
+		if ($this->filter_done == 1) { $htm.=' checked '; }
206 206
 		$htm.='> <label for="checkbox_done">Hide processed traps</label>';
207 207
 		$htm.='</form>';
208 208
 		return $htm;
209 209
 	}
210 210
 	
211
-	public function updateFilter($handler,$filter)
211
+	public function updateFilter($handler, $filter)
212 212
 	{
213 213
 		$this->filter_Handler=$handler->remove($this->filter_query_list)->__toString();
214
-		$this->filter_query=(isset($filter['q']))?$this->filter_query=$filter['q']:'';
215
-		$this->filter_done=(isset($filter['done']))?$this->filter_done=$filter['done']:0;
214
+		$this->filter_query=(isset($filter['q'])) ? $this->filter_query=$filter['q'] : '';
215
+		$this->filter_done=(isset($filter['done'])) ? $this->filter_done=$filter['done'] : 0;
216 216
 	}
217 217
 	
218 218
     protected function getSearchColumns()
@@ -227,20 +227,20 @@  discard block
 block discarded – undo
227 227
 
228 228
     public function setFilter($filter)
229 229
     {
230
-        $this->filter = $filter;
230
+        $this->filter=$filter;
231 231
         return $this;
232 232
     }
233 233
 	
234 234
 	public function getFilterEditor(Request $request)
235 235
     {
236
-        $filterEditor = Widget::create('filterEditor')
236
+        $filterEditor=Widget::create('filterEditor')
237 237
             ->setColumns(array_keys($this->getColumns()))
238 238
             ->setSearchColumns(array_keys($this->getSearchColumns()))
239 239
             ->preserveParams('limit', 'sort', 'dir', 'view', 'backend')
240 240
             ->ignoreParams('page')
241 241
             ->handleRequest($request);
242 242
 
243
-        $filter = $filterEditor->getFilter();
243
+        $filter=$filterEditor->getFilter();
244 244
         $this->setFilter($filter);
245 245
 
246 246
         return $filterEditor;
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 		{
255 255
 			$sql.='(';
256 256
 			$first=1;
257
-			foreach($this->moduleConfig->getTrapListSearchColumns() as $column)
257
+			foreach ($this->moduleConfig->getTrapListSearchColumns() as $column)
258 258
 			{
259
-				if ($first==0) $sql.=' OR ';
259
+				if ($first == 0) $sql.=' OR ';
260 260
 				$first=0;
261 261
 				$sql.=" ".$column." LIKE  '%".$this->filter_query."%' ";
262 262
 			}
Please login to merge, or discard this patch.