Passed
Push — master ( f89bd2...1d8afe )
by Patrick
02:00
created
library/Trapdirector/Tables/HandlerTable.php 2 patches
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -7,117 +7,117 @@
 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
-    public function setMibloader($mibloader)
23
-    {
24
-        $this->MIB=$mibloader;
25
-        $this->doTranslate=true;
26
-    }
22
+	public function setMibloader($mibloader)
23
+	{
24
+		$this->MIB=$mibloader;
25
+		$this->doTranslate=true;
26
+	}
27 27
 
28
-    public function titleOrder($name)
29
-    {
30
-        switch ($name)
31
-        {
32
-            case 'host_name' : return $this->content[$name]; break;
33
-            case 'source_ip' : return 'ip4'; break;
34
-            default: return $this->content[$name];	
35
-        }
36
-        return NULL;
37
-    }
28
+	public function titleOrder($name)
29
+	{
30
+		switch ($name)
31
+		{
32
+			case 'host_name' : return $this->content[$name]; break;
33
+			case 'source_ip' : return 'ip4'; break;
34
+			default: return $this->content[$name];	
35
+		}
36
+		return NULL;
37
+	}
38 38
     
39
-    public function getCurrentURL()
40
-    {
41
-        return Url::fromPath($this->urlPath . '/handler');
42
-    }
39
+	public function getCurrentURL()
40
+	{
41
+		return Url::fromPath($this->urlPath . '/handler');
42
+	}
43 43
     
44
-    public function renderLine($row)
45
-      {
46
-          $html = '';
47
-          $firstCol = true;
44
+	public function renderLine($row)
45
+	  {
46
+		  $html = '';
47
+		  $firstCol = true;
48 48
                
49
-          $titleNames = array_keys($this->titles);
50
-          foreach ($titleNames as $rowkey )
51
-          {        
52
-              // Check missing value
53
-              if (property_exists($row, $rowkey))
54
-              {
55
-                  switch ($rowkey)
56
-                  {
57
-                      case 'action_match': // display text levels
58
-                      case 'action_nomatch':
59
-                          $val=$this->status_display[$row->$rowkey];
60
-                          break;
61
-                      case 'trap_oid': // try to traslate oids.
49
+		  $titleNames = array_keys($this->titles);
50
+		  foreach ($titleNames as $rowkey )
51
+		  {        
52
+			  // Check missing value
53
+			  if (property_exists($row, $rowkey))
54
+			  {
55
+				  switch ($rowkey)
56
+				  {
57
+					  case 'action_match': // display text levels
58
+					  case 'action_nomatch':
59
+						  $val=$this->status_display[$row->$rowkey];
60
+						  break;
61
+					  case 'trap_oid': // try to traslate oids.
62 62
                           
63
-                          if ($this->doTranslate === true)
64
-                          {
65
-                              $oidName = $this->MIB->translateOID($row->$rowkey);
66
-                              if (isset($oidName['name']))
67
-                              {
68
-                                  $val=$oidName['name'];
69
-                              }
70
-                              else
71
-                              {
72
-                                  $val = $row->$rowkey;
73
-                              }
74
-                          }
75
-                          else
76
-                          {
77
-                              $val = $row->$rowkey;
78
-                          }
79
-                          break;
80
-                      case 'host_name': // switch to hostgroup if name is null
81
-                          if ($row->$rowkey == null)
82
-                          {
83
-                              $val = $row->host_group_name;
84
-                          }
85
-                          else
86
-                          {
87
-                              $val = $row->$rowkey;
88
-                          }
89
-                          break;
90
-                      default:
91
-                          $val = $row->$rowkey;
92
-                  }
93
-                  if ($rowkey == 'trap_oid' && $this->doTranslate===true)
94
-                  {
63
+						  if ($this->doTranslate === true)
64
+						  {
65
+							  $oidName = $this->MIB->translateOID($row->$rowkey);
66
+							  if (isset($oidName['name']))
67
+							  {
68
+								  $val=$oidName['name'];
69
+							  }
70
+							  else
71
+							  {
72
+								  $val = $row->$rowkey;
73
+							  }
74
+						  }
75
+						  else
76
+						  {
77
+							  $val = $row->$rowkey;
78
+						  }
79
+						  break;
80
+					  case 'host_name': // switch to hostgroup if name is null
81
+						  if ($row->$rowkey == null)
82
+						  {
83
+							  $val = $row->host_group_name;
84
+						  }
85
+						  else
86
+						  {
87
+							  $val = $row->$rowkey;
88
+						  }
89
+						  break;
90
+					  default:
91
+						  $val = $row->$rowkey;
92
+				  }
93
+				  if ($rowkey == 'trap_oid' && $this->doTranslate===true)
94
+				  {
95 95
                       
96
-                  }
97
-              } else {
98
-                  $val = '-';
99
-              }
100
-              if ($firstCol === true) { // Put link in first column for trap detail.
101
-                  $html .= '<td class="traphover">'
102
-                      . $this->view->qlink(
103
-                          $this->view->escape($val),
104
-                          Url::fromPath(
105
-                              $this->urlPath . '/handler/add',
106
-                              array('ruleid' => $row->id)
107
-                              )
108
-                          );
109
-                  if ($row->comment != '')
110
-                  {
111
-                      $html.= '<span class="tohover">'. $row->comment .'</span></td>';
112
-                  }
113
-                  $html.= '</td>';
114
-              } else {
115
-                  $html .= '<td>' . $this->view->escape($val) . '</td>';
116
-              }
117
-              $firstCol=false;
96
+				  }
97
+			  } else {
98
+				  $val = '-';
99
+			  }
100
+			  if ($firstCol === true) { // Put link in first column for trap detail.
101
+				  $html .= '<td class="traphover">'
102
+					  . $this->view->qlink(
103
+						  $this->view->escape($val),
104
+						  Url::fromPath(
105
+							  $this->urlPath . '/handler/add',
106
+							  array('ruleid' => $row->id)
107
+							  )
108
+						  );
109
+				  if ($row->comment != '')
110
+				  {
111
+					  $html.= '<span class="tohover">'. $row->comment .'</span></td>';
112
+				  }
113
+				  $html.= '</td>';
114
+			  } else {
115
+				  $html .= '<td>' . $this->view->escape($val) . '</td>';
116
+			  }
117
+			  $firstCol=false;
118 118
               
119
-          }
120
-          return $html;
121
-      }
119
+		  }
120
+		  return $html;
121
+	  }
122 122
 
123 123
 }
124 124
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
     
39 39
     public function getCurrentURL()
40 40
     {
41
-        return Url::fromPath($this->urlPath . '/handler');
41
+        return Url::fromPath($this->urlPath.'/handler');
42 42
     }
43 43
     
44 44
     public function renderLine($row)
45 45
       {
46
-          $html = '';
47
-          $firstCol = true;
46
+          $html='';
47
+          $firstCol=true;
48 48
                
49
-          $titleNames = array_keys($this->titles);
50
-          foreach ($titleNames as $rowkey )
49
+          $titleNames=array_keys($this->titles);
50
+          foreach ($titleNames as $rowkey)
51 51
           {        
52 52
               // Check missing value
53 53
               if (property_exists($row, $rowkey))
@@ -62,57 +62,57 @@  discard block
 block discarded – undo
62 62
                           
63 63
                           if ($this->doTranslate === true)
64 64
                           {
65
-                              $oidName = $this->MIB->translateOID($row->$rowkey);
65
+                              $oidName=$this->MIB->translateOID($row->$rowkey);
66 66
                               if (isset($oidName['name']))
67 67
                               {
68 68
                                   $val=$oidName['name'];
69 69
                               }
70 70
                               else
71 71
                               {
72
-                                  $val = $row->$rowkey;
72
+                                  $val=$row->$rowkey;
73 73
                               }
74 74
                           }
75 75
                           else
76 76
                           {
77
-                              $val = $row->$rowkey;
77
+                              $val=$row->$rowkey;
78 78
                           }
79 79
                           break;
80 80
                       case 'host_name': // switch to hostgroup if name is null
81 81
                           if ($row->$rowkey == null)
82 82
                           {
83
-                              $val = $row->host_group_name;
83
+                              $val=$row->host_group_name;
84 84
                           }
85 85
                           else
86 86
                           {
87
-                              $val = $row->$rowkey;
87
+                              $val=$row->$rowkey;
88 88
                           }
89 89
                           break;
90 90
                       default:
91
-                          $val = $row->$rowkey;
91
+                          $val=$row->$rowkey;
92 92
                   }
93
-                  if ($rowkey == 'trap_oid' && $this->doTranslate===true)
93
+                  if ($rowkey == 'trap_oid' && $this->doTranslate === true)
94 94
                   {
95 95
                       
96 96
                   }
97 97
               } else {
98
-                  $val = '-';
98
+                  $val='-';
99 99
               }
100 100
               if ($firstCol === true) { // Put link in first column for trap detail.
101
-                  $html .= '<td class="traphover">'
101
+                  $html.='<td class="traphover">'
102 102
                       . $this->view->qlink(
103 103
                           $this->view->escape($val),
104 104
                           Url::fromPath(
105
-                              $this->urlPath . '/handler/add',
105
+                              $this->urlPath.'/handler/add',
106 106
                               array('ruleid' => $row->id)
107 107
                               )
108 108
                           );
109 109
                   if ($row->comment != '')
110 110
                   {
111
-                      $html.= '<span class="tohover">'. $row->comment .'</span></td>';
111
+                      $html.='<span class="tohover">'.$row->comment.'</span></td>';
112 112
                   }
113
-                  $html.= '</td>';
113
+                  $html.='</td>';
114 114
               } else {
115
-                  $html .= '<td>' . $this->view->escape($val) . '</td>';
115
+                  $html.='<td>'.$this->view->escape($val).'</td>';
116 116
               }
117 117
               $firstCol=false;
118 118
               
Please login to merge, or discard this patch.
library/Trapdirector/Config/TrapModuleConfig.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  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
16
+		'SnmpTrapAddess_oid' => '.1.3.6.1.6.3.18.1.3', // default snmpTrapAdress OID
17 17
 	);
18 18
 	// get default values for dbconfig
19 19
 	public function getDBConfigDefaults() { return $this->DBConfigDefaults;}
@@ -120,27 +120,27 @@  discard block
 block discarded – undo
120 120
 	// Note : must have 'source_ip' and 'last_sent'
121 121
 	public function getTrapHostListDisplayColumns()
122 122
 	{
123
-	    return array(
124
-	        'source_name'  =>  't.source_name',
125
-	        'source_ip'    =>  't.source_ip',
126
-	        'trap_oid'     =>  't.trap_oid',
127
-	        'count'        =>  'count(*)',
128
-	        'last_sent'    =>  'UNIX_TIMESTAMP(max(t.date_received))'
129
-	    );
123
+		return array(
124
+			'source_name'  =>  't.source_name',
125
+			'source_ip'    =>  't.source_ip',
126
+			'trap_oid'     =>  't.trap_oid',
127
+			'count'        =>  'count(*)',
128
+			'last_sent'    =>  'UNIX_TIMESTAMP(max(t.date_received))'
129
+		);
130 130
 	}
131 131
 
132 132
 	public function getTrapHostListSearchColumns()
133 133
 	{
134
-	    return array(); // No search needed on this table
134
+		return array(); // No search needed on this table
135 135
 	}
136 136
 	// Titles display in Trap List table
137 137
 	public function getTrapHostListTitles()
138 138
 	{
139
-	    return array(
140
-	        'trap_oid'		=> 'Trap OID',
141
-	        'count'		    => 'Number of traps received',
142
-	        'last_sent'     => 'Last trap received'
143
-	    );
139
+		return array(
140
+			'trap_oid'		=> 'Trap OID',
141
+			'count'		    => 'Number of traps received',
142
+			'last_sent'     => 'Last trap received'
143
+		);
144 144
 	}
145 145
 	
146 146
 	
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 			'source_ip'		=> "CASE WHEN r.ip4 IS NULL THEN r.ip6 ELSE r.ip4 END",
156 156
 			'trap_oid'		=> 'r.trap_oid',
157 157
 			'rule'			=> 'r.rule',
158
-		    'comment'	    => 'r.comment',
159
-		    'category'	    => 'r.rule_type',
158
+			'comment'	    => 'r.comment',
159
+			'category'	    => 'r.rule_type',
160 160
 			'action_match'	=> 'r.action_match',
161 161
 			'action_nomatch'=> 'r.action_nomatch',
162 162
 			'service_name'	=> 'r.service_name',
@@ -181,17 +181,17 @@  discard block
 block discarded – undo
181 181
 	}
182 182
 	public function getHandlerColumns()
183 183
 	{
184
-	    return array(
185
-	        'r.host_name', 'r.host_group_name',
186
-	        'r.ip4', 'r.ip6',
187
-	        'r.trap_oid',
188
-	        'r.rule',
189
-	        'r.action_match',
190
-	        'r.action_nomatch',
191
-	        'r.service_name',
192
-	        'r.num_match',
193
-	        'r.id'
194
-	    );
184
+		return array(
185
+			'r.host_name', 'r.host_group_name',
186
+			'r.ip4', 'r.ip6',
187
+			'r.trap_oid',
188
+			'r.rule',
189
+			'r.action_match',
190
+			'r.action_nomatch',
191
+			'r.service_name',
192
+			'r.num_match',
193
+			'r.id'
194
+		);
195 195
 	}
196 196
 
197 197
 	// handler update (<key> => <sql select>)
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 			'revert_ok'		=> 'r.revert_ok',
212 212
 			'display'		=> 'r.display',
213 213
 			'modified'		=> 'UNIX_TIMESTAMP(r.modified)',
214
-            'modifier'		=> 'r.modifier',
215
-		    'comment'       => 'r.comment',
216
-		    'category'      => 'r.rule_type'
214
+			'modifier'		=> 'r.modifier',
215
+			'comment'       => 'r.comment',
216
+			'category'      => 'r.rule_type'
217 217
 		);
218 218
 	}	
219 219
 		
Please login to merge, or discard this patch.
application/controllers/HandlerController.php 2 patches
Indentation   +260 added lines, -261 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
 		$this->view->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
 		$this->view->handlerTable->setMaxPerPage($this->getModuleConfig()->itemListDisplay());
40 39
 				
@@ -60,22 +59,22 @@  discard block
 block discarded – undo
60 59
 	 */
61 60
 	public function testruleAction()
62 61
 	{
63
-	    $this->checkReadPermission();
64
-	    $this->getTabs()->add('get',array(
65
-	        'active'	=> true,
66
-	        'label'		=> $this->translate('Test Rule'),
67
-	        'url'		=> Url::fromRequest()
68
-	    ));
62
+		$this->checkReadPermission();
63
+		$this->getTabs()->add('get',array(
64
+			'active'	=> true,
65
+			'label'		=> $this->translate('Test Rule'),
66
+			'url'		=> Url::fromRequest()
67
+		));
69 68
 	    
70 69
 
71
-	    if ($this->params->get('rule') !== null) 
72
-	    {
73
-	        $this->view->rule= $this->params->get('rule');
74
-	    }
75
-	    else
76
-	    {
77
-	        $this->view->rule='';
78
-	    }
70
+		if ($this->params->get('rule') !== null) 
71
+		{
72
+			$this->view->rule= $this->params->get('rule');
73
+		}
74
+		else
75
+		{
76
+			$this->view->rule='';
77
+		}
79 78
 	}
80 79
 	
81 80
 	/**
@@ -83,31 +82,31 @@  discard block
 block discarded – undo
83 82
 	 */
84 83
 	private function add_setup_vars()
85 84
 	{
86
-	    // variables to send to view
87
-	    $this->view->hostlist=array(); // host list to input datalist
88
-	    $this->view->hostname=''; // Host name in input text
89
-	    $this->view->serviceGet=false; // Set to true to get list of service if only one host set
90
-	    $this->view->serviceSet=null; // Select service in services select (must have serviceGet=true).
91
-	    $this->view->mainoid=''; // Trap OID
92
-	    $this->view->mib=''; // Trap mib
93
-	    $this->view->name=''; // Trap name
94
-	    $this->view->trapListForMIB=array(); // Trap list if mib exists for trap
95
-	    $this->view->objectList=array(); // objects sent with trap
96
-	    $this->view->display=''; // Initial display
97
-	    $this->view->rule=''; // rule display
98
-	    $this->view->revertOK=''; // revert OK in seconds
99
-	    $this->view->hostid=-1; // normally set by javascript serviceGet()
100
-	    $this->view->ruleid=-1; // Rule id in DB for update & delete
101
-	    $this->view->setToUpdate=false; // set form as update form
102
-	    $this->view->setRuleMatch=-1; // set action on rule match (default nothing)
103
-	    $this->view->setRuleNoMatch=-1; // set action on rule no match (default nothing)
85
+		// variables to send to view
86
+		$this->view->hostlist=array(); // host list to input datalist
87
+		$this->view->hostname=''; // Host name in input text
88
+		$this->view->serviceGet=false; // Set to true to get list of service if only one host set
89
+		$this->view->serviceSet=null; // Select service in services select (must have serviceGet=true).
90
+		$this->view->mainoid=''; // Trap OID
91
+		$this->view->mib=''; // Trap mib
92
+		$this->view->name=''; // Trap name
93
+		$this->view->trapListForMIB=array(); // Trap list if mib exists for trap
94
+		$this->view->objectList=array(); // objects sent with trap
95
+		$this->view->display=''; // Initial display
96
+		$this->view->rule=''; // rule display
97
+		$this->view->revertOK=''; // revert OK in seconds
98
+		$this->view->hostid=-1; // normally set by javascript serviceGet()
99
+		$this->view->ruleid=-1; // Rule id in DB for update & delete
100
+		$this->view->setToUpdate=false; // set form as update form
101
+		$this->view->setRuleMatch=-1; // set action on rule match (default nothing)
102
+		$this->view->setRuleNoMatch=-1; // set action on rule no match (default nothing)
104 103
 	    
105
-	    $this->view->selectGroup=false; // Select by group if true
106
-	    $this->view->hostgroupid=-1; // host group id
107
-	    $this->view->serviceGroupGet=false; // Get list of service for group (set serviceSet to select one)
104
+		$this->view->selectGroup=false; // Select by group if true
105
+		$this->view->hostgroupid=-1; // host group id
106
+		$this->view->serviceGroupGet=false; // Get list of service for group (set serviceSet to select one)
108 107
 	    
109
-	    $this->view->modifier=null;
110
-	    $this->view->modified=null;
108
+		$this->view->modifier=null;
109
+		$this->view->modified=null;
111 110
 	}
112 111
 	
113 112
 	/**
@@ -116,102 +115,102 @@  discard block
 block discarded – undo
116 115
 	 */
117 116
 	private function add_from_existing($trapid)
118 117
 	{
119
-	    /********** Setup from existing trap ***************/
120
-	    // Get the full trap info
121
-	    $trapDetail=$this->getTrapDetail($trapid);
118
+		/********** Setup from existing trap ***************/
119
+		// Get the full trap info
120
+		$trapDetail=$this->getTrapDetail($trapid);
122 121
 	    
123
-	    $hostfilter=$trapDetail->source_ip;
122
+		$hostfilter=$trapDetail->source_ip;
124 123
 	    
125
-	    // Get host
126
-	    try
127
-	    {
128
-	        $hosts=$this->getUIDatabase()->getHostByIP($hostfilter);
129
-	    }
130
-	    catch (Exception $e)
131
-	    {
132
-	        $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
133
-	    }
124
+		// Get host
125
+		try
126
+		{
127
+			$hosts=$this->getUIDatabase()->getHostByIP($hostfilter);
128
+		}
129
+		catch (Exception $e)
130
+		{
131
+			$this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
132
+		}
134 133
 	    
135 134
 	    
136
-	    // if one unique host found -> put id text input
137
-	    if (count($hosts)==1) {
138
-	        $this->view->hostname=$hosts[0]->name;
139
-	        //$hostid=$hosts[0]->id;
140
-	        // Tell JS to get services when page is loaded
141
-	        $this->view->serviceGet=true;
135
+		// if one unique host found -> put id text input
136
+		if (count($hosts)==1) {
137
+			$this->view->hostname=$hosts[0]->name;
138
+			//$hostid=$hosts[0]->id;
139
+			// Tell JS to get services when page is loaded
140
+			$this->view->serviceGet=true;
142 141
 	        
143
-	    }
144
-	    else
145
-	    {
146
-	        foreach($hosts as $key=>$val)
147
-	        {
148
-	            array_push($this->view->hostlist,$hosts[$key]->name);
149
-	        }
150
-	    }
142
+		}
143
+		else
144
+		{
145
+			foreach($hosts as $key=>$val)
146
+			{
147
+				array_push($this->view->hostlist,$hosts[$key]->name);
148
+			}
149
+		}
151 150
 	    
152
-	    // set up trap oid and objects received by the trap
151
+		// set up trap oid and objects received by the trap
153 152
 	    
154
-	    $this->view->mainoid=$trapDetail->trap_oid;
155
-	    if ($trapDetail->trap_name_mib != null)
156
-	    {
157
-	        $this->view->mib=$trapDetail->trap_name_mib;
158
-	        $this->view->name=$trapDetail->trap_name;
159
-	        $this->view->trapListForMIB=$this->getMIB()
160
-	        ->getTrapList($trapDetail->trap_name_mib);
161
-	    }
153
+		$this->view->mainoid=$trapDetail->trap_oid;
154
+		if ($trapDetail->trap_name_mib != null)
155
+		{
156
+			$this->view->mib=$trapDetail->trap_name_mib;
157
+			$this->view->name=$trapDetail->trap_name;
158
+			$this->view->trapListForMIB=$this->getMIB()
159
+			->getTrapList($trapDetail->trap_name_mib);
160
+		}
162 161
 	    
163
-	    // Get all objects that can be in trap from MIB
164
-	    $allObjects=$this->getMIB()->getObjectList($trapDetail->trap_oid);
165
-	    // Get all objects in current Trap
166
-	    $currentTrapObjects=$this->getTrapobjects($trapid);
167
-	    $oid_index=1;
168
-	    foreach ($currentTrapObjects as $key => $val)
169
-	    {
170
-	        $currentObjectType='Unknown';
171
-	        $currentObjectTypeEnum='Unknown';
172
-	        if (isset($allObjects[$val->oid]['type']))
173
-	        {
174
-	            $currentObjectType=$allObjects[$val->oid]['type'];
175
-	            $currentObjectTypeEnum=$allObjects[$val->oid]['type_enum'];
176
-	        }
177
-	        $currentObject=array(
178
-	            $oid_index,
179
-	            $val->oid,
180
-	            $val->oid_name_mib,
181
-	            $val->oid_name,
182
-	            $val->value,
183
-	            $currentObjectType,
184
-	            $currentObjectTypeEnum
185
-	        );
186
-	        $oid_index++;
187
-	        array_push($this->view->objectList,$currentObject);
188
-	        // set currrent object to null in allObjects
189
-	        if (isset($allObjects[$val->oid]))
190
-	        {
191
-	            $allObjects[$val->oid]=null;
192
-	        }
193
-	    }
194
-	    if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
195
-	    {
196
-	        foreach ($allObjects as $key => $val)
197
-	        {
198
-	            if ($val==null) { continue; }
199
-	            array_push($this->view->objectList, array(
200
-	                $oid_index,
201
-	                $key,
202
-	                $allObjects[$key]['mib'],
203
-	                $allObjects[$key]['name'],
204
-	                '',
205
-	                $allObjects[$key]['type'],
206
-	                $allObjects[$key]['type_enum']
207
-	            ));
208
-	            $oid_index++;
209
-	        }
210
-	    }
162
+		// Get all objects that can be in trap from MIB
163
+		$allObjects=$this->getMIB()->getObjectList($trapDetail->trap_oid);
164
+		// Get all objects in current Trap
165
+		$currentTrapObjects=$this->getTrapobjects($trapid);
166
+		$oid_index=1;
167
+		foreach ($currentTrapObjects as $key => $val)
168
+		{
169
+			$currentObjectType='Unknown';
170
+			$currentObjectTypeEnum='Unknown';
171
+			if (isset($allObjects[$val->oid]['type']))
172
+			{
173
+				$currentObjectType=$allObjects[$val->oid]['type'];
174
+				$currentObjectTypeEnum=$allObjects[$val->oid]['type_enum'];
175
+			}
176
+			$currentObject=array(
177
+				$oid_index,
178
+				$val->oid,
179
+				$val->oid_name_mib,
180
+				$val->oid_name,
181
+				$val->value,
182
+				$currentObjectType,
183
+				$currentObjectTypeEnum
184
+			);
185
+			$oid_index++;
186
+			array_push($this->view->objectList,$currentObject);
187
+			// set currrent object to null in allObjects
188
+			if (isset($allObjects[$val->oid]))
189
+			{
190
+				$allObjects[$val->oid]=null;
191
+			}
192
+		}
193
+		if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
194
+		{
195
+			foreach ($allObjects as $key => $val)
196
+			{
197
+				if ($val==null) { continue; }
198
+				array_push($this->view->objectList, array(
199
+					$oid_index,
200
+					$key,
201
+					$allObjects[$key]['mib'],
202
+					$allObjects[$key]['name'],
203
+					'',
204
+					$allObjects[$key]['type'],
205
+					$allObjects[$key]['type_enum']
206
+				));
207
+				$oid_index++;
208
+			}
209
+		}
211 210
 	    
212
-	    // Add a simple display
213
-	    $this->view->display='Trap '.$trapDetail->trap_name.' received';
214
-	    $this->view->create_basic_rule=true;
211
+		// Add a simple display
212
+		$this->view->display='Trap '.$trapDetail->trap_name.' received';
213
+		$this->view->create_basic_rule=true;
215 214
 	}
216 215
 
217 216
 	/**
@@ -220,29 +219,29 @@  discard block
 block discarded – undo
220 219
 	 */
221 220
 	private function add_check_host_exists($ruleDetail)
222 221
 	{
223
-	    // Check if hostname still exists
224
-	    $host_get=$this->getUIDatabase()->getHostByName($this->view->hostname);
222
+		// Check if hostname still exists
223
+		$host_get=$this->getUIDatabase()->getHostByName($this->view->hostname);
225 224
 	    
226
-	    if (count($host_get)==0)
227
-	    {
228
-	        $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
229
-	        $this->view->serviceGet=false;
230
-	    }
231
-	    else
232
-	    {
233
-	        // Tell JS to get services when page is loaded
234
-	        $this->view->serviceGet=true;
235
-	        // get service id for form to set :
236
-	        $serviceID=$this->getUIDatabase()->getServiceIDByName($this->view->hostname,$ruleDetail->service_name);
237
-	        if (count($serviceID) ==0)
238
-	        {
239
-	            $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
240
-	        }
241
-	        else
242
-	        {
243
-	            $this->view->serviceSet=$serviceID[0]->id;
244
-	        }
245
-	    }
225
+		if (count($host_get)==0)
226
+		{
227
+			$this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
228
+			$this->view->serviceGet=false;
229
+		}
230
+		else
231
+		{
232
+			// Tell JS to get services when page is loaded
233
+			$this->view->serviceGet=true;
234
+			// get service id for form to set :
235
+			$serviceID=$this->getUIDatabase()->getServiceIDByName($this->view->hostname,$ruleDetail->service_name);
236
+			if (count($serviceID) ==0)
237
+			{
238
+				$this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
239
+			}
240
+			else
241
+			{
242
+				$this->view->serviceSet=$serviceID[0]->id;
243
+			}
244
+		}
246 245
 	}
247 246
 
248 247
 	/**
@@ -251,33 +250,33 @@  discard block
 block discarded – undo
251 250
 	 */
252 251
 	private function add_check_hostgroup_exists($ruleDetail)
253 252
 	{
254
-	    // Check if groupe exists
255
-	    $group_get=$this->getUIDatabase()->getHostGroupByName($this->view->hostgroupname);
256
-	    if (count($group_get)==0)
257
-	    {
258
-	        $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
259
-	        $this->view->serviceGroupGet=false;
260
-	    }
261
-	    else
262
-	    {
263
-	        $grpServices=$this->getUIDatabase()->getServicesByHostGroupid($group_get[0]->id);
264
-	        $foundGrpService=0;
265
-	        foreach ($grpServices as $grpService)
266
-	        {
267
-	            if ($grpService[0] == $ruleDetail->service_name)
268
-	            {
269
-	                $foundGrpService=1;
270
-	                $this->view->serviceSet=$ruleDetail->service_name;
271
-	            }
272
-	        }
253
+		// Check if groupe exists
254
+		$group_get=$this->getUIDatabase()->getHostGroupByName($this->view->hostgroupname);
255
+		if (count($group_get)==0)
256
+		{
257
+			$this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
258
+			$this->view->serviceGroupGet=false;
259
+		}
260
+		else
261
+		{
262
+			$grpServices=$this->getUIDatabase()->getServicesByHostGroupid($group_get[0]->id);
263
+			$foundGrpService=0;
264
+			foreach ($grpServices as $grpService)
265
+			{
266
+				if ($grpService[0] == $ruleDetail->service_name)
267
+				{
268
+					$foundGrpService=1;
269
+					$this->view->serviceSet=$ruleDetail->service_name;
270
+				}
271
+			}
273 272
 	        
274
-	        // Tell JS to get services when page is loaded
275
-	        $this->view->serviceGroupGet=true;
276
-	        if ($foundGrpService==0)
277
-	        {
278
-	            $this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
279
-	        }
280
-	    }
273
+			// Tell JS to get services when page is loaded
274
+			$this->view->serviceGroupGet=true;
275
+			if ($foundGrpService==0)
276
+			{
277
+				$this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
278
+			}
279
+		}
281 280
 	}
282 281
 	
283 282
 	/**
@@ -289,52 +288,52 @@  discard block
 block discarded – undo
289 288
 	 */
290 289
 	private function add_create_trap_object_list(&$display, &$rule)
291 290
 	{
292
-	    $curObjectList=array();
293
-	    $index=1;
294
-	    // check in display & rule for : OID(<oid>)
295
-	    $matches=array();
296
-	    while ( preg_match('/_OID\(([\.0-9\*]+)\)/',$display,$matches) ||
297
-	        preg_match('/_OID\(([\.0-9\*]+)\)/',$rule,$matches))
298
-	    {
299
-	        $curOid=$matches[1];
291
+		$curObjectList=array();
292
+		$index=1;
293
+		// check in display & rule for : OID(<oid>)
294
+		$matches=array();
295
+		while ( preg_match('/_OID\(([\.0-9\*]+)\)/',$display,$matches) ||
296
+			preg_match('/_OID\(([\.0-9\*]+)\)/',$rule,$matches))
297
+		{
298
+			$curOid=$matches[1];
300 299
 	        
301
-	        if ( (preg_match('/\*/',$curOid) == 0 ) 
302
-	            && ($object=$this->getMIB()->translateOID($curOid)) != null)
303
-	        {
304
-	            array_push($curObjectList, array(
305
-	                $index,
306
-	                $curOid,
307
-	                $object['mib'],
308
-	                $object['name'],
309
-	                '',
310
-	                $object['type'],
311
-	                $object['type_enum']
312
-	            ));
313
-	        }
314
-	        else
315
-	        {
316
-	            array_push($curObjectList, array(
317
-	                $index,
318
-	                $curOid,
319
-	                'not found',
320
-	                'not found',
321
-	                '',
322
-	                'not found',
323
-	                'not found'
324
-	            ));
325
-	        }
326
-	        $curOid = preg_replace('/\*/','\*',$curOid);
327
-	        $display=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$display);
328
-	        $rule=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$rule);
329
-	        $index++;
330
-	    }
331
-	    return $curObjectList;
300
+			if ( (preg_match('/\*/',$curOid) == 0 ) 
301
+				&& ($object=$this->getMIB()->translateOID($curOid)) != null)
302
+			{
303
+				array_push($curObjectList, array(
304
+					$index,
305
+					$curOid,
306
+					$object['mib'],
307
+					$object['name'],
308
+					'',
309
+					$object['type'],
310
+					$object['type_enum']
311
+				));
312
+			}
313
+			else
314
+			{
315
+				array_push($curObjectList, array(
316
+					$index,
317
+					$curOid,
318
+					'not found',
319
+					'not found',
320
+					'',
321
+					'not found',
322
+					'not found'
323
+				));
324
+			}
325
+			$curOid = preg_replace('/\*/','\*',$curOid);
326
+			$display=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$display);
327
+			$rule=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$rule);
328
+			$index++;
329
+		}
330
+		return $curObjectList;
332 331
 	}
333 332
 	
334 333
 	/** Add a handler  
335
-	*	Get params fromid : setup from existing trap (id of trap table)
336
-	*	Get param ruleid : edit from existing handler (id of rule table)
337
-	*/
334
+	 *	Get params fromid : setup from existing trap (id of trap table)
335
+	 *	Get param ruleid : edit from existing handler (id of rule table)
336
+	 */
338 337
 	public function addAction()
339 338
 	{
340 339
 		$this->checkConfigPermission();
@@ -354,8 +353,8 @@  discard block
 block discarded – undo
354 353
 		//$this->view->trapvalues=false; // Set to true to display 'value' colum in objects
355 354
 		
356 355
 		if (($trapid = $this->params->get('fromid')) !== null) {
357
-		    /********** Setup from existing trap ***************/
358
-            $this->add_from_existing($trapid);
356
+			/********** Setup from existing trap ***************/
357
+			$this->add_from_existing($trapid);
359 358
 			return;
360 359
 		}
361 360
 		
@@ -383,14 +382,14 @@  discard block
 block discarded – undo
383 382
 			$this->view->warning_message='';
384 383
 			if ($this->view->hostname != null)
385 384
 			{
386
-			    $this->view->selectGroup=false;
387
-			    // Check if hostname still exists
388
-			    $this->add_check_host_exists($ruleDetail);
385
+				$this->view->selectGroup=false;
386
+				// Check if hostname still exists
387
+				$this->add_check_host_exists($ruleDetail);
389 388
 			}
390 389
 			else
391 390
 			{
392
-			    $this->view->selectGroup=true;
393
-			    $this->add_check_hostgroup_exists($ruleDetail); //  Check if groupe exists				
391
+				$this->view->selectGroup=true;
392
+				$this->add_check_hostgroup_exists($ruleDetail); //  Check if groupe exists				
394 393
 			}
395 394
 			
396 395
 			$this->view->mainoid=$ruleDetail->trap_oid;
@@ -418,9 +417,9 @@  discard block
 block discarded – undo
418 417
 	}
419 418
 	
420 419
 	/** Validate form and output message to user  
421
-	*	@param in postdata 
422
-	* 	@return string status : OK / <Message>
423
-	**/
420
+	 *	@param in postdata 
421
+	 * 	@return string status : OK / <Message>
422
+	 **/
424 423
 	protected function handlerformAction()
425 424
 	{
426 425
 		$postData=$this->getRequest()->getPost();
@@ -435,8 +434,8 @@  discard block
 block discarded – undo
435 434
 			'host_group_name'=>	array('post' => null,            'val' => null,  'db'=>true),
436 435
 			'serviceid'		=>	array('post' => 'serviceid',                     'db'=>false),
437 436
 			'service_name'	=>	array('post' => 'serviceName',                    'db'=>true),
438
-		    'comment'       =>  array('post' => 'comment',       'val' => '',    'db'=>true),
439
-		    'rule_type'     =>  array('post' => 'category',       'val' => 0,    'db'=>true),
437
+			'comment'       =>  array('post' => 'comment',       'val' => '',    'db'=>true),
438
+			'rule_type'     =>  array('post' => 'category',       'val' => 0,    'db'=>true),
440 439
 			'trap_oid'		=>	array('post' => 'oid',                            'db'=>true),
441 440
 			'revert_ok'		=>	array('post' => 'revertOK',      'val' => 0,      'db'=>true),
442 441
 			'display'		=>	array('post' => 'display',        'val' => '',     'db'=>true),
@@ -445,7 +444,7 @@  discard block
 block discarded – undo
445 444
 			'action_nomatch'=>	array('post' => 'ruleNoMatch',    'val' => -1,    'db'=>true),					
446 445
 			'ip4'			=>	array('post' => null,             'val' => null,  'db'=>true),
447 446
 			'ip6'			=>	array('post' => null,             'val' => null,  'db'=>true),
448
-		    'action_form'	=>	array('post' => 'action_form',    'val' => null, 'db'=>false)
447
+			'action_form'	=>	array('post' => 'action_form',    'val' => null, 'db'=>false)
449 448
 		);
450 449
 		
451 450
 		if (isset($postData[$params['action_form']['post']]) 
@@ -453,7 +452,7 @@  discard block
 block discarded – undo
453 452
 		{
454 453
 			try
455 454
 			{
456
-			    $this->getUIDatabase()->deleteRule($postData[$params['db_rule']['post']]);
455
+				$this->getUIDatabase()->deleteRule($postData[$params['db_rule']['post']]);
457 456
 			}
458 457
 			catch (Exception $e)
459 458
 			{
@@ -463,7 +462,7 @@  discard block
 block discarded – undo
463 462
 			//$this->Module()->
464 463
 			$this->_helper->json(array(
465 464
 				'status'=>'OK',
466
-			    'redirect'=>'trapdirector/handler'
465
+				'redirect'=>'trapdirector/handler'
467 466
 			      
468 467
 			));
469 468
 		}		
@@ -490,7 +489,7 @@  discard block
 block discarded – undo
490 489
 			$isHostGroup=($params['hostgroup']['val'] == 1)?true:false;
491 490
 			if (! $isHostGroup ) 
492 491
 			{  // checks if selection by host 
493
-			    $hostAddr=$this->getUIDatabase()->getHostInfoByID($params['hostid']['val']);
492
+				$hostAddr=$this->getUIDatabase()->getHostInfoByID($params['hostid']['val']);
494 493
 				$params['ip4']['val']=$hostAddr->ip4;
495 494
 				$params['ip6']['val']=$hostAddr->ip6;
496 495
 				$checkHostName=$hostAddr->name;
@@ -501,8 +500,8 @@  discard block
 block discarded – undo
501 500
 				}
502 501
 				if (!is_numeric($params['serviceid']['val']))
503 502
 				{
504
-				    $this->_helper->json(array('status'=>"Invalid service id ". $params['serviceid']['val']));
505
-				    return;
503
+					$this->_helper->json(array('status'=>"Invalid service id ". $params['serviceid']['val']));
504
+					return;
506 505
 				}
507 506
 				$serviceName=$this->getUIDatabase()->getObjectNameByid($params['serviceid']['val']);
508 507
 				if ($params['service_name']['val'] != $serviceName->name2)
@@ -513,7 +512,7 @@  discard block
 block discarded – undo
513 512
 			}
514 513
 			else
515 514
 			{
516
-			    $object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']);
515
+				$object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']);
517 516
 				if ($params['host_name']['val'] != $object->name1)
518 517
 				{
519 518
 					$this->_helper->json(array('status'=>"Invalid object group id : Please re enter service"));
@@ -535,11 +534,11 @@  discard block
 block discarded – undo
535 534
 			
536 535
 			if ($params['db_rule']['val'] == -1 || $params['action_form']['val'] == 'clone') 
537 536
 			{  // If no rule number or action is clone, add the handler
538
-			    $ruleID=$this->getUIDatabase()->addHandlerRule($dbparams);
537
+				$ruleID=$this->getUIDatabase()->addHandlerRule($dbparams);
539 538
 			}
540 539
 			else
541 540
 			{
542
-			    $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
541
+				$this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
543 542
 				$ruleID=$params['db_rule']['val'];
544 543
 			}
545 544
 		}
@@ -553,9 +552,9 @@  discard block
 block discarded – undo
553 552
 	}
554 553
 
555 554
 	/** Get trap detail by trapid. 
556
-	*	@param integer $trapid : id of trap in received table
557
-	*	@return array (objects)
558
-	*/
555
+	 *	@param integer $trapid : id of trap in received table
556
+	 *	@return array (objects)
557
+	 */
559 558
 	protected function getTrapDetail($trapid) 
560 559
 	{
561 560
 		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
@@ -571,14 +570,14 @@  discard block
 block discarded – undo
571 570
 		}
572 571
 		try
573 572
 		{		
574
-		    $query = $dbConn->select()
573
+			$query = $dbConn->select()
575 574
 				->from($this->getModuleConfig()->getTrapTableName(),$elmts)
576 575
 				->where('id=?',$trapid);
577 576
 				$trapDetail=$dbConn->fetchRow($query);
578 577
 			if ( $trapDetail == null ) 
579 578
 			{
580
-			    $trapDetail = 'NULL';
581
-			    throw new Exception('No traps was found with id = '.$trapid);
579
+				$trapDetail = 'NULL';
580
+				throw new Exception('No traps was found with id = '.$trapid);
582 581
 			}
583 582
 		}
584 583
 		catch (Exception $e)
@@ -592,9 +591,9 @@  discard block
 block discarded – undo
592 591
 	}
593 592
 
594 593
 	/** Get trap objects
595
-	*	@param integer $trapid : trap id
596
-	* 	@return array : full column in db of trap id
597
-	*/
594
+	 *	@param integer $trapid : trap id
595
+	 * 	@return array : full column in db of trap id
596
+	 */
598 597
 	protected function getTrapobjects($trapid)
599 598
 	{	
600 599
 		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
@@ -610,7 +609,7 @@  discard block
 block discarded – undo
610 609
 		}
611 610
 		try
612 611
 		{		
613
-		    $query = $dbConn->select()
612
+			$query = $dbConn->select()
614 613
 				->from($this->moduleConfig->getTrapDataTableName(),$data_elmts)
615 614
 				->where('trap_id=?',$trapid);
616 615
 				$trapDetail=$dbConn->fetchAll($query);
@@ -626,10 +625,10 @@  discard block
 block discarded – undo
626 625
 	}
627 626
 
628 627
 	/** Get rule detail by ruleid.
629
-	*	@param integer $ruleid int id of rule in rule table
630
-	*	@return object|array : column objects in db 
631
-	*
632
-	*/
628
+	 *	@param integer $ruleid int id of rule in rule table
629
+	 *	@return object|array : column objects in db 
630
+	 *
631
+	 */
633 632
 	protected function getRuleDetail($ruleid) 
634 633
 	{
635 634
 		if (!preg_match('/^[0-9]+$/',$ruleid)) { throw new Exception('Invalid id');  }
@@ -640,7 +639,7 @@  discard block
 block discarded – undo
640 639
 		// ***************  Get main data
641 640
 		try
642 641
 		{		
643
-		    $query = $dbConn->select()
642
+			$query = $dbConn->select()
644 643
 				->from($this->getModuleConfig()->getTrapRuleName(),$queryArray)
645 644
 				->where('id=?',$ruleid);
646 645
 			$ruleDetail=$dbConn->fetchRow($query);
@@ -657,7 +656,7 @@  discard block
 block discarded – undo
657 656
 	}
658 657
 
659 658
 	/** Setup tabs for rules 
660
-	*/
659
+	 */
661 660
 	protected function prepareTabs()
662 661
 	{
663 662
 		return $this->getTabs()->add('status', array(
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 		$this->checkReadPermission();
25 25
 		$this->prepareTabs()->activate('status');
26 26
 
27
-		$dbConn = $this->getUIDatabase()->getDb();
27
+		$dbConn=$this->getUIDatabase()->getDb();
28 28
 		if ($dbConn === null) throw new \ErrorException('uncatched db error');
29 29
 		
30
-		$this->view->handlerTable = new HandlerTable(
30
+		$this->view->handlerTable=new HandlerTable(
31 31
 		      $this->moduleConfig->getTrapRuleName(),
32 32
 		      $this->moduleConfig->getHandlerListTitles(),
33 33
 		      $this->moduleConfig->getHandlerListDisplayColumns(),
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		
39 39
 		$this->view->handlerTable->setMaxPerPage($this->getModuleConfig()->itemListDisplay());
40 40
 				
41
-		$getVars = $this->getRequest()->getParams();		
41
+		$getVars=$this->getRequest()->getParams();		
42 42
 		$this->view->handlerTable->getParams($getVars);
43 43
 		
44 44
 		$this->view->handlerTable->setMibloader($this->getMIB());
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 		$this->getHandlerListTable()->setConnection($dbConn);
49 49
 		$this->getHandlerListTable()->setMibloader($this->getMIB());
50 50
 		// Apply pagination limits 
51
-		$this->view->table=$this->applyPaginationLimits($this->getHandlerListTable(),$this->getModuleConfig()->itemListDisplay());		
51
+		$this->view->table=$this->applyPaginationLimits($this->getHandlerListTable(), $this->getModuleConfig()->itemListDisplay());		
52 52
 		
53 53
 		// Set Filter
54
-		$this->view->filterEditor = $this->getHandlerListTable()->getFilterEditor($this->getRequest());		
54
+		$this->view->filterEditor=$this->getHandlerListTable()->getFilterEditor($this->getRequest());		
55 55
 	
56 56
 		//$this->displayExitError('Handler/indexAction','Not implemented');
57 57
 	}
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	public function testruleAction()
62 62
 	{
63 63
 	    $this->checkReadPermission();
64
-	    $this->getTabs()->add('get',array(
64
+	    $this->getTabs()->add('get', array(
65 65
 	        'active'	=> true,
66 66
 	        'label'		=> $this->translate('Test Rule'),
67 67
 	        'url'		=> Url::fromRequest()
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 	    if ($this->params->get('rule') !== null) 
72 72
 	    {
73
-	        $this->view->rule= $this->params->get('rule');
73
+	        $this->view->rule=$this->params->get('rule');
74 74
 	    }
75 75
 	    else
76 76
 	    {
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 	    }
130 130
 	    catch (Exception $e)
131 131
 	    {
132
-	        $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
132
+	        $this->displayExitError('Add handler : get host by IP/Name ', $e->getMessage());
133 133
 	    }
134 134
 	    
135 135
 	    
136 136
 	    // if one unique host found -> put id text input
137
-	    if (count($hosts)==1) {
137
+	    if (count($hosts) == 1) {
138 138
 	        $this->view->hostname=$hosts[0]->name;
139 139
 	        //$hostid=$hosts[0]->id;
140 140
 	        // Tell JS to get services when page is loaded
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	    }
144 144
 	    else
145 145
 	    {
146
-	        foreach($hosts as $key=>$val)
146
+	        foreach ($hosts as $key=>$val)
147 147
 	        {
148
-	            array_push($this->view->hostlist,$hosts[$key]->name);
148
+	            array_push($this->view->hostlist, $hosts[$key]->name);
149 149
 	        }
150 150
 	    }
151 151
 	    
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
 	            $currentObjectTypeEnum
185 185
 	        );
186 186
 	        $oid_index++;
187
-	        array_push($this->view->objectList,$currentObject);
187
+	        array_push($this->view->objectList, $currentObject);
188 188
 	        // set currrent object to null in allObjects
189 189
 	        if (isset($allObjects[$val->oid]))
190 190
 	        {
191 191
 	            $allObjects[$val->oid]=null;
192 192
 	        }
193 193
 	    }
194
-	    if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
194
+	    if ($allObjects != null) // in case trap doesn't have objects or is not resolved
195 195
 	    {
196 196
 	        foreach ($allObjects as $key => $val)
197 197
 	        {
198
-	            if ($val==null) { continue; }
198
+	            if ($val == null) { continue; }
199 199
 	            array_push($this->view->objectList, array(
200 200
 	                $oid_index,
201 201
 	                $key,
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 	    // Check if hostname still exists
224 224
 	    $host_get=$this->getUIDatabase()->getHostByName($this->view->hostname);
225 225
 	    
226
-	    if (count($host_get)==0)
226
+	    if (count($host_get) == 0)
227 227
 	    {
228
-	        $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
228
+	        $this->view->warning_message='Host '.$this->view->hostname.' doesn\'t exists anymore';
229 229
 	        $this->view->serviceGet=false;
230 230
 	    }
231 231
 	    else
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 	        // Tell JS to get services when page is loaded
234 234
 	        $this->view->serviceGet=true;
235 235
 	        // get service id for form to set :
236
-	        $serviceID=$this->getUIDatabase()->getServiceIDByName($this->view->hostname,$ruleDetail->service_name);
237
-	        if (count($serviceID) ==0)
236
+	        $serviceID=$this->getUIDatabase()->getServiceIDByName($this->view->hostname, $ruleDetail->service_name);
237
+	        if (count($serviceID) == 0)
238 238
 	        {
239
-	            $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
239
+	            $this->view->warning_message=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore';
240 240
 	        }
241 241
 	        else
242 242
 	        {
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 	{
254 254
 	    // Check if groupe exists
255 255
 	    $group_get=$this->getUIDatabase()->getHostGroupByName($this->view->hostgroupname);
256
-	    if (count($group_get)==0)
256
+	    if (count($group_get) == 0)
257 257
 	    {
258
-	        $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
258
+	        $this->view->warning_message='HostGroup '.$this->view->hostgroupname.' doesn\'t exists anymore';
259 259
 	        $this->view->serviceGroupGet=false;
260 260
 	    }
261 261
 	    else
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
 	        
274 274
 	        // Tell JS to get services when page is loaded
275 275
 	        $this->view->serviceGroupGet=true;
276
-	        if ($foundGrpService==0)
276
+	        if ($foundGrpService == 0)
277 277
 	        {
278
-	            $this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
278
+	            $this->view->warning_message.=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore';
279 279
 	        }
280 280
 	    }
281 281
 	}
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
 	    $index=1;
294 294
 	    // check in display & rule for : OID(<oid>)
295 295
 	    $matches=array();
296
-	    while ( preg_match('/_OID\(([\.0-9\*]+)\)/',$display,$matches) ||
297
-	        preg_match('/_OID\(([\.0-9\*]+)\)/',$rule,$matches))
296
+	    while (preg_match('/_OID\(([\.0-9\*]+)\)/', $display, $matches) ||
297
+	        preg_match('/_OID\(([\.0-9\*]+)\)/', $rule, $matches))
298 298
 	    {
299 299
 	        $curOid=$matches[1];
300 300
 	        
301
-	        if ( (preg_match('/\*/',$curOid) == 0 ) 
301
+	        if ((preg_match('/\*/', $curOid) == 0) 
302 302
 	            && ($object=$this->getMIB()->translateOID($curOid)) != null)
303 303
 	        {
304 304
 	            array_push($curObjectList, array(
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 	                'not found'
324 324
 	            ));
325 325
 	        }
326
-	        $curOid = preg_replace('/\*/','\*',$curOid);
327
-	        $display=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$display);
328
-	        $rule=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$rule);
326
+	        $curOid=preg_replace('/\*/', '\*', $curOid);
327
+	        $display=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $display);
328
+	        $rule=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $rule);
329 329
 	        $index++;
330 330
 	    }
331 331
 	    return $curObjectList;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		$this->checkConfigPermission();
341 341
 		// set up tab
342 342
 		$this->prepareTabs();
343
-		$this->getTabs()->add('get',array(
343
+		$this->getTabs()->add('get', array(
344 344
 			'active'	=> true,
345 345
 			'label'		=> $this->translate('Add handler'),
346 346
 			'url'		=> Url::fromRequest()
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		
354 354
 		//$this->view->trapvalues=false; // Set to true to display 'value' colum in objects
355 355
 		
356
-		if (($trapid = $this->params->get('fromid')) !== null) {
356
+		if (($trapid=$this->params->get('fromid')) !== null) {
357 357
 		    /********** Setup from existing trap ***************/
358 358
             $this->add_from_existing($trapid);
359 359
 			return;
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
 			$this->view->setRuleMatch=$ruleDetail->action_match;
374 374
 			$this->view->setRuleNoMatch=$ruleDetail->action_nomatch;
375 375
 			$this->view->hostgroupname=$ruleDetail->host_group_name;
376
-			$this->view->modified=gmdate("Y-m-d\TH:i:s\Z",$ruleDetail->modified);
376
+			$this->view->modified=gmdate("Y-m-d\TH:i:s\Z", $ruleDetail->modified);
377 377
 			$this->view->modifier=$ruleDetail->modifier;
378 378
 			
379
-			$this->view->comment = $ruleDetail->comment;
380
-			$this->view->category = $ruleDetail->category;
379
+			$this->view->comment=$ruleDetail->comment;
380
+			$this->view->category=$ruleDetail->category;
381 381
 			
382 382
 			// Warning message if host/service don't exists anymore
383 383
 			$this->view->warning_message='';
@@ -428,28 +428,28 @@  discard block
 block discarded – undo
428 428
 	
429 429
 		$params=array(
430 430
 			// id (also db) => 	array('post' => post id, 'val' => default val, 'db' => send to table)
431
-			'hostgroup'		=>	array('post' => 'hostgroup',                    'db'=>false),
432
-			'db_rule'		=>	array('post' => 'db_rule',                      'db'=>false),
433
-			'hostid'		=>	array('post' => 'hostid',                       'db'=>false),
434
-			'host_name'		=>	array('post' => 'hostname',      'val' => null,  'db'=>true),
435
-			'host_group_name'=>	array('post' => null,            'val' => null,  'db'=>true),
436
-			'serviceid'		=>	array('post' => 'serviceid',                     'db'=>false),
437
-			'service_name'	=>	array('post' => 'serviceName',                    'db'=>true),
438
-		    'comment'       =>  array('post' => 'comment',       'val' => '',    'db'=>true),
439
-		    'rule_type'     =>  array('post' => 'category',       'val' => 0,    'db'=>true),
440
-			'trap_oid'		=>	array('post' => 'oid',                            'db'=>true),
441
-			'revert_ok'		=>	array('post' => 'revertOK',      'val' => 0,      'db'=>true),
442
-			'display'		=>	array('post' => 'display',        'val' => '',     'db'=>true),
443
-			'rule'			=>	array('post' => 'rule',          'val' => '',        'db'=>true),			
444
-			'action_match'	=>	array('post' => 'ruleMatch',       'val' => -1,    'db'=>true),
445
-			'action_nomatch'=>	array('post' => 'ruleNoMatch',    'val' => -1,    'db'=>true),					
446
-			'ip4'			=>	array('post' => null,             'val' => null,  'db'=>true),
447
-			'ip6'			=>	array('post' => null,             'val' => null,  'db'=>true),
448
-		    'action_form'	=>	array('post' => 'action_form',    'val' => null, 'db'=>false)
431
+			'hostgroup'		=>	array('post' => 'hostgroup', 'db'=>false),
432
+			'db_rule'		=>	array('post' => 'db_rule', 'db'=>false),
433
+			'hostid'		=>	array('post' => 'hostid', 'db'=>false),
434
+			'host_name'		=>	array('post' => 'hostname', 'val' => null, 'db'=>true),
435
+			'host_group_name'=>	array('post' => null, 'val' => null, 'db'=>true),
436
+			'serviceid'		=>	array('post' => 'serviceid', 'db'=>false),
437
+			'service_name'	=>	array('post' => 'serviceName', 'db'=>true),
438
+		    'comment'       =>  array('post' => 'comment', 'val' => '', 'db'=>true),
439
+		    'rule_type'     =>  array('post' => 'category', 'val' => 0, 'db'=>true),
440
+			'trap_oid'		=>	array('post' => 'oid', 'db'=>true),
441
+			'revert_ok'		=>	array('post' => 'revertOK', 'val' => 0, 'db'=>true),
442
+			'display'		=>	array('post' => 'display', 'val' => '', 'db'=>true),
443
+			'rule'			=>	array('post' => 'rule', 'val' => '', 'db'=>true),			
444
+			'action_match'	=>	array('post' => 'ruleMatch', 'val' => -1, 'db'=>true),
445
+			'action_nomatch'=>	array('post' => 'ruleNoMatch', 'val' => -1, 'db'=>true),					
446
+			'ip4'			=>	array('post' => null, 'val' => null, 'db'=>true),
447
+			'ip6'			=>	array('post' => null, 'val' => null, 'db'=>true),
448
+		    'action_form'	=>	array('post' => 'action_form', 'val' => null, 'db'=>false)
449 449
 		);
450 450
 		
451 451
 		if (isset($postData[$params['action_form']['post']]) 
452
-			&& $postData[$params['action_form']['post']] == 'delete' )
452
+			&& $postData[$params['action_form']['post']] == 'delete')
453 453
 		{
454 454
 			try
455 455
 			{
@@ -469,16 +469,16 @@  discard block
 block discarded – undo
469 469
 		}		
470 470
 		foreach (array_keys($params) as $key)
471 471
 		{
472
-			if ($params[$key]['post']==null) continue; // data not sent in post vars
473
-			if (! isset($postData[$params[$key]['post']]))
472
+			if ($params[$key]['post'] == null) continue; // data not sent in post vars
473
+			if (!isset($postData[$params[$key]['post']]))
474 474
 			{
475 475
 				// should not happen as the js checks data
476
-				$this->_helper->json(array('status'=>'No ' . $key));
476
+				$this->_helper->json(array('status'=>'No '.$key));
477 477
 			}
478 478
 			else
479 479
 			{
480 480
 				$data=$postData[$params[$key]['post']];
481
-				if ($data!=null && $data !="")
481
+				if ($data != null && $data != "")
482 482
 				{
483 483
 					$params[$key]['val']=$postData[$params[$key]['post']];
484 484
 				}
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
 
488 488
 		try 
489 489
 		{
490
-			$isHostGroup=($params['hostgroup']['val'] == 1)?true:false;
491
-			if (! $isHostGroup ) 
490
+			$isHostGroup=($params['hostgroup']['val'] == 1) ?true:false;
491
+			if (!$isHostGroup) 
492 492
 			{  // checks if selection by host 
493 493
 			    $hostAddr=$this->getUIDatabase()->getHostInfoByID($params['hostid']['val']);
494 494
 				$params['ip4']['val']=$hostAddr->ip4;
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 				}
502 502
 				if (!is_numeric($params['serviceid']['val']))
503 503
 				{
504
-				    $this->_helper->json(array('status'=>"Invalid service id ". $params['serviceid']['val']));
504
+				    $this->_helper->json(array('status'=>"Invalid service id ".$params['serviceid']['val']));
505 505
 				    return;
506 506
 				}
507 507
 				$serviceName=$this->getUIDatabase()->getObjectNameByid($params['serviceid']['val']);
@@ -520,15 +520,15 @@  discard block
 block discarded – undo
520 520
 					return;					
521 521
 				}
522 522
 				// Put param in correct column (group_name)
523
-				$params['host_group_name']['val'] = $params['host_name']['val'];
523
+				$params['host_group_name']['val']=$params['host_name']['val'];
524 524
 				$params['host_name']['val']=null;
525 525
 			}
526 526
 			$dbparams=array();
527 527
 			foreach ($params as $key=>$val)
528 528
 			{
529
-				if ($val['db']==true )
529
+				if ($val['db'] == true)
530 530
 				{
531
-					$dbparams[$key] = $val['val'];
531
+					$dbparams[$key]=$val['val'];
532 532
 				}
533 533
 			}
534 534
 			// echo '<br>';	print_r($dbparams);echo '<br>';
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 			}
540 540
 			else
541 541
 			{
542
-			    $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']);
542
+			    $this->getUIDatabase()->updateHandlerRule($dbparams, $params['db_rule']['val']);
543 543
 				$ruleID=$params['db_rule']['val'];
544 544
 			}
545 545
 		}
@@ -558,10 +558,10 @@  discard block
 block discarded – undo
558 558
 	*/
559 559
 	protected function getTrapDetail($trapid) 
560 560
 	{
561
-		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
561
+		if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); }
562 562
 		$queryArray=$this->getModuleConfig()->trapDetailQuery();
563 563
 		
564
-		$dbConn = $this->getUIDatabase()->getDbConn();
564
+		$dbConn=$this->getUIDatabase()->getDbConn();
565 565
 		if ($dbConn === null) throw new \ErrorException('uncatched db error');
566 566
 		// ***************  Get main data
567 567
 		// extract columns and titles;
@@ -571,19 +571,19 @@  discard block
 block discarded – undo
571 571
 		}
572 572
 		try
573 573
 		{		
574
-		    $query = $dbConn->select()
575
-				->from($this->getModuleConfig()->getTrapTableName(),$elmts)
576
-				->where('id=?',$trapid);
574
+		    $query=$dbConn->select()
575
+				->from($this->getModuleConfig()->getTrapTableName(), $elmts)
576
+				->where('id=?', $trapid);
577 577
 				$trapDetail=$dbConn->fetchRow($query);
578
-			if ( $trapDetail == null ) 
578
+			if ($trapDetail == null) 
579 579
 			{
580
-			    $trapDetail = 'NULL';
580
+			    $trapDetail='NULL';
581 581
 			    throw new Exception('No traps was found with id = '.$trapid);
582 582
 			}
583 583
 		}
584 584
 		catch (Exception $e)
585 585
 		{
586
-			$this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage());
586
+			$this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail, true), $e->getMessage());
587 587
 			return;
588 588
 		}
589 589
 
@@ -597,10 +597,10 @@  discard block
 block discarded – undo
597 597
 	*/
598 598
 	protected function getTrapobjects($trapid)
599 599
 	{	
600
-		if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id');  }
600
+		if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); }
601 601
 		$queryArrayData=$this->getModuleConfig()->trapDataDetailQuery();
602 602
 		
603
-		$dbConn = $this->getUIDatabase()->getDbConn();
603
+		$dbConn=$this->getUIDatabase()->getDbConn();
604 604
 		if ($dbConn === null) throw new \ErrorException('uncatched db error');
605 605
 		// ***************  Get object data
606 606
 		// extract columns and titles;
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
 		}
611 611
 		try
612 612
 		{		
613
-		    $query = $dbConn->select()
614
-				->from($this->moduleConfig->getTrapDataTableName(),$data_elmts)
615
-				->where('trap_id=?',$trapid);
613
+		    $query=$dbConn->select()
614
+				->from($this->moduleConfig->getTrapDataTableName(), $data_elmts)
615
+				->where('trap_id=?', $trapid);
616 616
 				$trapDetail=$dbConn->fetchAll($query);
617 617
 			// if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid);
618 618
 		}
619 619
 		catch (Exception $e)
620 620
 		{
621
-			$this->displayExitError('Add handler : get trap data detail : ',$e->getMessage());
621
+			$this->displayExitError('Add handler : get trap data detail : ', $e->getMessage());
622 622
 			return array();
623 623
 		}
624 624
 
@@ -632,24 +632,24 @@  discard block
 block discarded – undo
632 632
 	*/
633 633
 	protected function getRuleDetail($ruleid) 
634 634
 	{
635
-		if (!preg_match('/^[0-9]+$/',$ruleid)) { throw new Exception('Invalid id');  }
635
+		if (!preg_match('/^[0-9]+$/', $ruleid)) { throw new Exception('Invalid id'); }
636 636
 		$queryArray=$this->getModuleConfig()->ruleDetailQuery();
637 637
 		
638
-		$dbConn = $this->getUIDatabase()->getDbConn();
638
+		$dbConn=$this->getUIDatabase()->getDbConn();
639 639
 		if ($dbConn === null) throw new \ErrorException('uncatched db error');
640 640
 		// ***************  Get main data
641 641
 		try
642 642
 		{		
643
-		    $query = $dbConn->select()
644
-				->from($this->getModuleConfig()->getTrapRuleName(),$queryArray)
645
-				->where('id=?',$ruleid);
643
+		    $query=$dbConn->select()
644
+				->from($this->getModuleConfig()->getTrapRuleName(), $queryArray)
645
+				->where('id=?', $ruleid);
646 646
 			$ruleDetail=$dbConn->fetchRow($query);
647
-			if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid);
647
+			if ($ruleDetail == null) throw new Exception('No rule was found with id = '.$ruleid);
648 648
 		}
649 649
 		catch (Exception $e)
650 650
 		{
651
-			$this->displayExitError('Update handler : get rule detail',$e->getMessage());
652
-			throw new Exception('Error : ' . $e->getMessage());
651
+			$this->displayExitError('Update handler : get rule detail', $e->getMessage());
652
+			throw new Exception('Error : '.$e->getMessage());
653 653
 		}
654 654
 
655 655
 		return $ruleDetail;
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	{
663 663
 		return $this->getTabs()->add('status', array(
664 664
 			'label' => $this->translate('Trap handlers'),
665
-			'url'   => $this->getModuleConfig()->urlPath() . '/handler')
665
+			'url'   => $this->getModuleConfig()->urlPath().'/handler')
666 666
 		);
667 667
 	} 
668 668
 	
Please login to merge, or discard this patch.