@@ -6,8 +6,8 @@  | 
                                                    ||
| 6 | 6 |  $this->providePermission('trapdirector/config', $this->translate('Allow to create and modify traps services')); | 
                                                        
| 7 | 7 | |
| 8 | 8 |  $this->provideConfigTab('config', array( | 
                                                        
| 9 | - 'title' => 'Configuration',  | 
                                                        |
| 10 | - 'url' => 'settings'  | 
                                                        |
| 9 | + 'title' => 'Configuration',  | 
                                                        |
| 10 | + 'url' => 'settings'  | 
                                                        |
| 11 | 11 | ));  | 
                                                        
| 12 | 12 | |
| 13 | 13 |  $section = $this->menuSection(N_('Traps'),array ( | 
                                                        
@@ -10,22 +10,22 @@  | 
                                                    ||
| 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 | ));  | 
                                                        
@@ -17,10 +17,10 @@  | 
                                                    ||
| 17 | 17 | class StatusCommand extends Command  | 
                                                        
| 18 | 18 |  { | 
                                                        
| 19 | 19 | /**  | 
                                                        
| 20 | - * Get database counts  | 
                                                        |
| 21 | - *  | 
                                                        |
| 22 | - * Get number of traps, rules  | 
                                                        |
| 23 | - */  | 
                                                        |
| 20 | + * Get database counts  | 
                                                        |
| 21 | + *  | 
                                                        |
| 22 | + * Get number of traps, rules  | 
                                                        |
| 23 | + */  | 
                                                        |
| 24 | 24 | public function dbAction()  | 
                                                        
| 25 | 25 |  	{ | 
                                                        
| 26 | 26 |  		$db_prefix=$this->Config()->get('config', 'database_prefix'); | 
                                                        
@@ -24,21 +24,21 @@  | 
                                                    ||
| 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)  | 
                                                        
@@ -40,8 +40,7 @@  | 
                                                    ||
| 40 | 40 |  			$query = $dataBase->select()->from($Config->getTrapRuleName(),array('COUNT(*)'));			 | 
                                                        
| 41 | 41 |  			printf("Number of rules : %s\n", $dataBase->fetchOne($query) ); | 
                                                        
| 42 | 42 | |
| 43 | - }  | 
                                                        |
| 44 | - catch (Exception $e)  | 
                                                        |
| 43 | + } catch (Exception $e)  | 
                                                        |
| 45 | 44 |  		{ | 
                                                        
| 46 | 45 |  			printf('Error in DB : %s\n', $e->getMessage()); | 
                                                        
| 47 | 46 | }  | 
                                                        
@@ -17,16 +17,16 @@ discard block  | 
                                                    ||
| 17 | 17 | class TrapsCommand extends Command  | 
                                                        
| 18 | 18 |  { | 
                                                        
| 19 | 19 | /**  | 
                                                        
| 20 | - * Delete old traps  | 
                                                        |
| 21 | - *  | 
                                                        |
| 22 | - * USAGE  | 
                                                        |
| 23 | - *  | 
                                                        |
| 24 | - * icingali trapdirector traps rotate [options]  | 
                                                        |
| 25 | - *  | 
                                                        |
| 26 | - * OPTIONS  | 
                                                        |
| 27 | - *  | 
                                                        |
| 28 | - * --days remove traps older than <n> days  | 
                                                        |
| 29 | - */  | 
                                                        |
| 20 | + * Delete old traps  | 
                                                        |
| 21 | + *  | 
                                                        |
| 22 | + * USAGE  | 
                                                        |
| 23 | + *  | 
                                                        |
| 24 | + * icingali trapdirector traps rotate [options]  | 
                                                        |
| 25 | + *  | 
                                                        |
| 26 | + * OPTIONS  | 
                                                        |
| 27 | + *  | 
                                                        |
| 28 | + * --days remove traps older than <n> days  | 
                                                        |
| 29 | + */  | 
                                                        |
| 30 | 30 | public function rotateAction()  | 
                                                        
| 31 | 31 |  	{ | 
                                                        
| 32 | 32 | $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName());  | 
                                                        
@@ -56,13 +56,13 @@ discard block  | 
                                                    ||
| 56 | 56 | }  | 
                                                        
| 57 | 57 | |
| 58 | 58 | /**  | 
                                                        
| 59 | - * Reset services to OK state if timeout is passed  | 
                                                        |
| 60 | - *  | 
                                                        |
| 61 | - * USAGE  | 
                                                        |
| 62 | - *  | 
                                                        |
| 63 | - * icingali trapdirector traps reset_services  | 
                                                        |
| 64 | - *  | 
                                                        |
| 65 | - */  | 
                                                        |
| 59 | + * Reset services to OK state if timeout is passed  | 
                                                        |
| 60 | + *  | 
                                                        |
| 61 | + * USAGE  | 
                                                        |
| 62 | + *  | 
                                                        |
| 63 | + * icingali trapdirector traps reset_services  | 
                                                        |
| 64 | + *  | 
                                                        |
| 65 | + */  | 
                                                        |
| 66 | 66 | public function resetOKAction()  | 
                                                        
| 67 | 67 |  	{ | 
                                                        
| 68 | 68 | $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName());  | 
                                                        
@@ -30,16 +30,16 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | |
@@ -42,14 +42,12 @@ discard block  | 
                                                    ||
| 42 | 42 | if ($days=='<default>')  | 
                                                        
| 43 | 43 |  			{ | 
                                                        
| 44 | 44 | $trap->eraseOldTraps();  | 
                                                        
| 45 | - }  | 
                                                        |
| 46 | - else  | 
                                                        |
| 45 | + } else  | 
                                                        |
| 47 | 46 |  			{ | 
                                                        
| 48 | 47 | $trap->eraseOldTraps($days);  | 
                                                        
| 49 | 48 | }  | 
                                                        
| 50 | 49 | |
| 51 | - }  | 
                                                        |
| 52 | - catch (Exception $e)  | 
                                                        |
| 50 | + } catch (Exception $e)  | 
                                                        |
| 53 | 51 |  		{ | 
                                                        
| 54 | 52 | echo 'Error in updating : ' . $e->getMessage();  | 
                                                        
| 55 | 53 | }  | 
                                                        
@@ -74,8 +72,7 @@ discard block  | 
                                                    ||
| 74 | 72 | try  | 
                                                        
| 75 | 73 |  		{ | 
                                                        
| 76 | 74 | $trap->reset_services();  | 
                                                        
| 77 | - }  | 
                                                        |
| 78 | - catch (Exception $e)  | 
                                                        |
| 75 | + } catch (Exception $e)  | 
                                                        |
| 79 | 76 |  		{ | 
                                                        
| 80 | 77 | echo 'ERROR : '. $e->getMessage();  | 
                                                        
| 81 | 78 | }  | 
                                                        
@@ -32,13 +32,13 @@ discard block  | 
                                                    ||
| 32 | 32 | |
| 33 | 33 | public function setDefaultIDODB($idoDbName)  | 
                                                        
| 34 | 34 |  	{ | 
                                                        
| 35 | - $this->idoDbName=$idoDbName;  | 
                                                        |
| 36 | - return $this;  | 
                                                        |
| 35 | + $this->idoDbName=$idoDbName;  | 
                                                        |
| 36 | + return $this;  | 
                                                        |
| 37 | 37 | }  | 
                                                        
| 38 | 38 | |
| 39 | - public function createElements(array $formData)  | 
                                                        |
| 40 | -    { | 
                                                        |
| 41 | - $this->addElement(  | 
                                                        |
| 39 | + public function createElements(array $formData)  | 
                                                        |
| 40 | +	{ | 
                                                        |
| 41 | + $this->addElement(  | 
                                                        |
| 42 | 42 | 'select',  | 
                                                        
| 43 | 43 | 'config_database',  | 
                                                        
| 44 | 44 | array(  | 
                                                        
@@ -72,14 +72,14 @@ discard block  | 
                                                    ||
| 72 | 72 | )  | 
                                                        
| 73 | 73 | );  | 
                                                        
| 74 | 74 | $this->addElement(  | 
                                                        
| 75 | - 'text',  | 
                                                        |
| 76 | - 'config_icingaweb2_etc',  | 
                                                        |
| 77 | - array(  | 
                                                        |
| 78 | - 'required' => true,  | 
                                                        |
| 79 | -                    'label'             => $this->translate('icingaweb2 config dir'), | 
                                                        |
| 75 | + 'text',  | 
                                                        |
| 76 | + 'config_icingaweb2_etc',  | 
                                                        |
| 77 | + array(  | 
                                                        |
| 78 | + 'required' => true,  | 
                                                        |
| 79 | +					'label'             => $this->translate('icingaweb2 config dir'), | 
                                                        |
| 80 | 80 | 'value' => $this->icinga_base_path,  | 
                                                        
| 81 | - )  | 
                                                        |
| 82 | - );  | 
                                                        |
| 81 | + )  | 
                                                        |
| 82 | + );  | 
                                                        |
| 83 | 83 | $retval=0;  | 
                                                        
| 84 | 84 | $output=array();  | 
                                                        
| 85 | 85 |  		$snmptranslate=exec('which snmptranslate',$output,$retval); | 
                                                        
@@ -88,68 +88,68 @@ discard block  | 
                                                    ||
| 88 | 88 | $snmptranslate='/usr/bin/snmptranslate';  | 
                                                        
| 89 | 89 | }  | 
                                                        
| 90 | 90 | $this->addElement(  | 
                                                        
| 91 | - 'text',  | 
                                                        |
| 92 | - 'config_snmptranslate',  | 
                                                        |
| 93 | - array(  | 
                                                        |
| 94 | - 'required' => true,  | 
                                                        |
| 95 | -                    'label'             => $this->translate('snmptranslate binary with path'), | 
                                                        |
| 91 | + 'text',  | 
                                                        |
| 92 | + 'config_snmptranslate',  | 
                                                        |
| 93 | + array(  | 
                                                        |
| 94 | + 'required' => true,  | 
                                                        |
| 95 | +					'label'             => $this->translate('snmptranslate binary with path'), | 
                                                        |
| 96 | 96 | 'value' => $snmptranslate,  | 
                                                        
| 97 | - )  | 
                                                        |
| 98 | - );  | 
                                                        |
| 97 | + )  | 
                                                        |
| 98 | + );  | 
                                                        |
| 99 | 99 | $this->addElement(  | 
                                                        
| 100 | - 'text',  | 
                                                        |
| 101 | - 'config_snmptranslate_dirs',  | 
                                                        |
| 102 | - array(  | 
                                                        |
| 103 | - 'required' => true,  | 
                                                        |
| 104 | -                    'label'         => $this->translate('Path for mibs'), | 
                                                        |
| 100 | + 'text',  | 
                                                        |
| 101 | + 'config_snmptranslate_dirs',  | 
                                                        |
| 102 | + array(  | 
                                                        |
| 103 | + 'required' => true,  | 
                                                        |
| 104 | +					'label'         => $this->translate('Path for mibs'), | 
                                                        |
| 105 | 105 | 'value' => $this->module_base_path.'/mibs',  | 
                                                        
| 106 | - )  | 
                                                        |
| 107 | - );  | 
                                                        |
| 106 | + )  | 
                                                        |
| 107 | + );  | 
                                                        |
| 108 | 108 | $this->addElement(  | 
                                                        
| 109 | - 'text',  | 
                                                        |
| 110 | - 'config_icingacmd',  | 
                                                        |
| 111 | - array(  | 
                                                        |
| 112 | - 'required' => true,  | 
                                                        |
| 113 | -                    'label'         => $this->translate('icingacmd with path'), | 
                                                        |
| 109 | + 'text',  | 
                                                        |
| 110 | + 'config_icingacmd',  | 
                                                        |
| 111 | + array(  | 
                                                        |
| 112 | + 'required' => true,  | 
                                                        |
| 113 | +					'label'         => $this->translate('icingacmd with path'), | 
                                                        |
| 114 | 114 | 'value' => '/var/run/icinga2/cmd/icinga2.cmd',  | 
                                                        
| 115 | - )  | 
                                                        |
| 116 | - );  | 
                                                        |
| 115 | + )  | 
                                                        |
| 116 | + );  | 
                                                        |
| 117 | 117 | $this->addElement(  | 
                                                        
| 118 | - 'text',  | 
                                                        |
| 119 | - 'config_icingaAPI_host',  | 
                                                        |
| 120 | - array(  | 
                                                        |
| 121 | - 'required' => false,  | 
                                                        |
| 122 | -		        'label'         => $this->translate('icinga2 API Host IP'), | 
                                                        |
| 123 | - 'value' => '',  | 
                                                        |
| 124 | - )  | 
                                                        |
| 118 | + 'text',  | 
                                                        |
| 119 | + 'config_icingaAPI_host',  | 
                                                        |
| 120 | + array(  | 
                                                        |
| 121 | + 'required' => false,  | 
                                                        |
| 122 | +				'label'         => $this->translate('icinga2 API Host IP'), | 
                                                        |
| 123 | + 'value' => '',  | 
                                                        |
| 124 | + )  | 
                                                        |
| 125 | 125 | );  | 
                                                        
| 126 | 126 | $this->addElement(  | 
                                                        
| 127 | - 'text',  | 
                                                        |
| 128 | - 'config_icingaAPI_port',  | 
                                                        |
| 129 | - array(  | 
                                                        |
| 130 | - 'required' => false,  | 
                                                        |
| 131 | -		        'label'         => $this->translate('icinga2 API TCP Port'), | 
                                                        |
| 132 | - 'value' => '5665',  | 
                                                        |
| 133 | - )  | 
                                                        |
| 134 | - );  | 
                                                        |
| 127 | + 'text',  | 
                                                        |
| 128 | + 'config_icingaAPI_port',  | 
                                                        |
| 129 | + array(  | 
                                                        |
| 130 | + 'required' => false,  | 
                                                        |
| 131 | +				'label'         => $this->translate('icinga2 API TCP Port'), | 
                                                        |
| 132 | + 'value' => '5665',  | 
                                                        |
| 133 | + )  | 
                                                        |
| 134 | + );  | 
                                                        |
| 135 | 135 | $this->addElement(  | 
                                                        
| 136 | - 'text',  | 
                                                        |
| 137 | - 'config_icingaAPI_user',  | 
                                                        |
| 138 | - array(  | 
                                                        |
| 139 | - 'required' => false,  | 
                                                        |
| 140 | -		        'label'         => $this->translate('icinga2 API username'), | 
                                                        |
| 141 | - 'value' => '',  | 
                                                        |
| 142 | - )  | 
                                                        |
| 143 | - );  | 
                                                        |
| 136 | + 'text',  | 
                                                        |
| 137 | + 'config_icingaAPI_user',  | 
                                                        |
| 138 | + array(  | 
                                                        |
| 139 | + 'required' => false,  | 
                                                        |
| 140 | +				'label'         => $this->translate('icinga2 API username'), | 
                                                        |
| 141 | + 'value' => '',  | 
                                                        |
| 142 | + )  | 
                                                        |
| 143 | + );  | 
                                                        |
| 144 | 144 | $this->addElement(  | 
                                                        
| 145 | - 'text',  | 
                                                        |
| 146 | - 'config_icingaAPI_password',  | 
                                                        |
| 147 | - array(  | 
                                                        |
| 148 | - 'required' => false,  | 
                                                        |
| 149 | -		        'label'         => $this->translate('icinga2 API password'), | 
                                                        |
| 150 | - 'value' => '',  | 
                                                        |
| 151 | - )  | 
                                                        |
| 152 | - );  | 
                                                        |
| 145 | + 'text',  | 
                                                        |
| 146 | + 'config_icingaAPI_password',  | 
                                                        |
| 147 | + array(  | 
                                                        |
| 148 | + 'required' => false,  | 
                                                        |
| 149 | +				'label'         => $this->translate('icinga2 API password'), | 
                                                        |
| 150 | + 'value' => '',  | 
                                                        |
| 151 | + )  | 
                                                        |
| 152 | + );  | 
                                                        |
| 153 | 153 | /*$this->addElement(  | 
                                                        
| 154 | 154 | 'radio',  | 
                                                        
| 155 | 155 | 'config_icinga2api_use',  | 
                                                        
@@ -159,7 +159,7 @@ discard block  | 
                                                    ||
| 159 | 159 |  		        'value'			=> array('Yes', 'No'),//array('1' => 'Yes', '0' => 'No'), | 
                                                        
| 160 | 160 | )  | 
                                                        
| 161 | 161 | );*/  | 
                                                        
| 162 | - // For Icinga2 API connexion  | 
                                                        |
| 162 | + // For Icinga2 API connexion  | 
                                                        |
| 163 | 163 |  	//	$icinga2API=new Fieldset('Icinga2 API connection'); | 
                                                        
| 164 | 164 |  	/* 	$icinga2API_select=new radioBtn('icinga2API_use'); | 
                                                        
| 165 | 165 |  		$icinga2API_select->setLabel('Use icinga2 API instead of cmd file?'); | 
                                                        
@@ -169,30 +169,30 @@ discard block  | 
                                                    ||
| 169 | 169 | ]);  | 
                                                        
| 170 | 170 | $icinga2API->add($icinga2API_select);  | 
                                                        
| 171 | 171 | $this->add($icinga2API); */  | 
                                                        
| 172 | - }  | 
                                                        |
| 172 | + }  | 
                                                        |
| 173 | 173 | |
| 174 | 174 | |
| 175 | - public function render(Zend_View_Interface $view = NULL)  | 
                                                        |
| 176 | -    { | 
                                                        |
| 175 | + public function render(Zend_View_Interface $view = NULL)  | 
                                                        |
| 176 | +	{ | 
                                                        |
| 177 | 177 | |
| 178 | 178 | |
| 179 | - //return $html;  | 
                                                        |
| 180 | - return parent::render($view);  | 
                                                        |
| 181 | - }  | 
                                                        |
| 179 | + //return $html;  | 
                                                        |
| 180 | + return parent::render($view);  | 
                                                        |
| 181 | + }  | 
                                                        |
| 182 | 182 | |
| 183 | - /**  | 
                                                        |
| 184 | -     * {@inheritdoc} | 
                                                        |
| 185 | - */  | 
                                                        |
| 186 | - public function onSuccess()  | 
                                                        |
| 187 | -    { | 
                                                        |
| 188 | - parent::onSuccess();  | 
                                                        |
| 189 | - }  | 
                                                        |
| 183 | + /**  | 
                                                        |
| 184 | +	 * {@inheritdoc} | 
                                                        |
| 185 | + */  | 
                                                        |
| 186 | + public function onSuccess()  | 
                                                        |
| 187 | +	{ | 
                                                        |
| 188 | + parent::onSuccess();  | 
                                                        |
| 189 | + }  | 
                                                        |
| 190 | 190 | |
| 191 | - /**  | 
                                                        |
| 192 | -     * {@inheritdoc} | 
                                                        |
| 193 | - */  | 
                                                        |
| 191 | + /**  | 
                                                        |
| 192 | +	 * {@inheritdoc} | 
                                                        |
| 193 | + */  | 
                                                        |
| 194 | 194 | public function save()  | 
                                                        
| 195 | -    { | 
                                                        |
| 195 | +	{ | 
                                                        |
| 196 | 196 | parent::save();  | 
                                                        
| 197 | 197 | }  | 
                                                        
| 198 | 198 | }  | 
                                                        
@@ -18,7 +18,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | |
@@ -39,8 +39,8 @@ discard block  | 
                                                    ||
| 39 | 39 | }  | 
                                                        
| 40 | 40 | |
| 41 | 41 | /**  | 
                                                        
| 42 | - * Trap detail page  | 
                                                        |
| 43 | - */  | 
                                                        |
| 42 | + * Trap detail page  | 
                                                        |
| 43 | + */  | 
                                                        |
| 44 | 44 | public function trapdetailAction()  | 
                                                        
| 45 | 45 |  	{ | 
                                                        
| 46 | 46 | |
@@ -141,22 +141,22 @@ discard block  | 
                                                    ||
| 141 | 141 | */  | 
                                                        
| 142 | 142 | public function hostsAction()  | 
                                                        
| 143 | 143 |  	{ | 
                                                        
| 144 | - $this->checkReadPermission();  | 
                                                        |
| 145 | -	    $this->prepareTabs()->activate('hosts'); | 
                                                        |
| 144 | + $this->checkReadPermission();  | 
                                                        |
| 145 | +		$this->prepareTabs()->activate('hosts'); | 
                                                        |
| 146 | 146 | |
| 147 | - $db = $this->getDb();  | 
                                                        |
| 148 | - $this->getTrapHostListTable()->setConnection($db);  | 
                                                        |
| 147 | + $db = $this->getDb();  | 
                                                        |
| 148 | + $this->getTrapHostListTable()->setConnection($db);  | 
                                                        |
| 149 | 149 | |
| 150 | - // Apply pagination limits  | 
                                                        |
| 151 | - $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(),$this->getModuleConfig()->itemListDisplay());  | 
                                                        |
| 150 | + // Apply pagination limits  | 
                                                        |
| 151 | + $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(),$this->getModuleConfig()->itemListDisplay());  | 
                                                        |
| 152 | 152 | |
| 153 | - // Set Filter  | 
                                                        |
| 154 | - //$postData=$this->getRequest()->getPost();  | 
                                                        |
| 155 | - $filter=array();  | 
                                                        |
| 156 | -	    $filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; | 
                                                        |
| 157 | -	    $filter['done']=$this->params->get('done'); | 
                                                        |
| 158 | - $this->view->filter=$filter;  | 
                                                        |
| 159 | - $this->view->table->updateFilter(Url::fromRequest(),$filter);  | 
                                                        |
| 153 | + // Set Filter  | 
                                                        |
| 154 | + //$postData=$this->getRequest()->getPost();  | 
                                                        |
| 155 | + $filter=array();  | 
                                                        |
| 156 | +		$filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; | 
                                                        |
| 157 | +		$filter['done']=$this->params->get('done'); | 
                                                        |
| 158 | + $this->view->filter=$filter;  | 
                                                        |
| 159 | + $this->view->table->updateFilter(Url::fromRequest(),$filter);  | 
                                                        |
| 160 | 160 | }  | 
                                                        
| 161 | 161 | |
| 162 | 162 | public function deleteAction()  | 
                                                        
@@ -176,12 +176,12 @@ discard block  | 
                                                    ||
| 176 | 176 |  		return $this->getTabs()->add('traps', array( | 
                                                        
| 177 | 177 |  			'label'	=> $this->translate('Traps'), | 
                                                        
| 178 | 178 | 'url' => $this->getModuleConfig()->urlPath() . '/received')  | 
                                                        
| 179 | - )  | 
                                                        |
| 180 | -		    ->add('hosts', array( | 
                                                        |
| 181 | -		        'label' => $this->translate('Hosts'), | 
                                                        |
| 182 | - 'url' => $this->getModuleConfig()->urlPath() . '/received/hosts')  | 
                                                        |
| 183 | - )  | 
                                                        |
| 184 | -		    ->add('delete', array( | 
                                                        |
| 179 | + )  | 
                                                        |
| 180 | +			->add('hosts', array( | 
                                                        |
| 181 | +				'label' => $this->translate('Hosts'), | 
                                                        |
| 182 | + 'url' => $this->getModuleConfig()->urlPath() . '/received/hosts')  | 
                                                        |
| 183 | + )  | 
                                                        |
| 184 | +			->add('delete', array( | 
                                                        |
| 185 | 185 |  			'label' => $this->translate('Delete'), | 
                                                        
| 186 | 186 | 'url' => $this->getModuleConfig()->urlPath() . '/received/delete')  | 
                                                        
| 187 | 187 | );  | 
                                                        
@@ -20,19 +20,19 @@ discard block  | 
                                                    ||
| 20 | 20 | $this->checkReadPermission();  | 
                                                        
| 21 | 21 |  		$this->prepareTabs()->activate('traps'); | 
                                                        
| 22 | 22 | |
| 23 | - $db = $this->getDb();  | 
                                                        |
| 23 | + $db=$this->getDb();  | 
                                                        |
| 24 | 24 | $this->getTrapListTable()->setConnection($db);  | 
                                                        
| 25 | 25 | |
| 26 | 26 | // Apply pagination limits  | 
                                                        
| 27 | - $this->view->table=$this->applyPaginationLimits($this->getTrapListTable(),$this->getModuleConfig()->itemListDisplay());  | 
                                                        |
| 27 | + $this->view->table=$this->applyPaginationLimits($this->getTrapListTable(), $this->getModuleConfig()->itemListDisplay());  | 
                                                        |
| 28 | 28 | |
| 29 | 29 | // Set Filter  | 
                                                        
| 30 | 30 | //$postData=$this->getRequest()->getPost();  | 
                                                        
| 31 | 31 | $filter=array();  | 
                                                        
| 32 | -		$filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; | 
                                                        |
| 32 | +		$filter['q']=$this->params->get('q'); //(isset($postData['q']))?$postData['q']:''; | 
                                                        |
| 33 | 33 |  		$filter['done']=$this->params->get('done'); | 
                                                        
| 34 | 34 | $this->view->filter=$filter;  | 
                                                        
| 35 | - $this->view->table->updateFilter(Url::fromRequest(),$filter);  | 
                                                        |
| 35 | + $this->view->table->updateFilter(Url::fromRequest(), $filter);  | 
                                                        |
| 36 | 36 | |
| 37 | 37 | //$this->view->filterEditor = $this->getTrapListTable()->getFilterEditor($this->getRequest());  | 
                                                        
| 38 | 38 | |
@@ -46,7 +46,7 @@ discard block  | 
                                                    ||
| 46 | 46 | |
| 47 | 47 | $this->checkReadPermission();  | 
                                                        
| 48 | 48 | // set up tab  | 
                                                        
| 49 | -		$this->getTabs()->add('get',array( | 
                                                        |
| 49 | +		$this->getTabs()->add('get', array( | 
                                                        |
| 50 | 50 | 'active' => true,  | 
                                                        
| 51 | 51 |  			'label'		=> $this->translate('Detailed status'), | 
                                                        
| 52 | 52 | 'url' => Url::fromRequest()  | 
                                                        
@@ -56,11 +56,11 @@ discard block  | 
                                                    ||
| 56 | 56 | $this->view->trapid=$trapid;  | 
                                                        
| 57 | 57 | $queryArray=$this->getModuleConfig()->trapDetailQuery();  | 
                                                        
| 58 | 58 | |
| 59 | - $db = $this->getDb()->getConnection();  | 
                                                        |
| 59 | + $db=$this->getDb()->getConnection();  | 
                                                        |
| 60 | 60 | |
| 61 | 61 | // URL to add a handler  | 
                                                        
| 62 | 62 | $this->view->addHandlerUrl=Url::fromPath(  | 
                                                        
| 63 | - $this->getModuleConfig()->urlPath() . '/handler/add',  | 
                                                        |
| 63 | + $this->getModuleConfig()->urlPath().'/handler/add',  | 
                                                        |
| 64 | 64 |  			array('fromid' => $trapid)); | 
                                                        
| 65 | 65 | // *************** Get main data  | 
                                                        
| 66 | 66 | // extract columns and titles;  | 
                                                        
@@ -72,28 +72,28 @@ discard block  | 
                                                    ||
| 72 | 72 | // Do DB query for trap.  | 
                                                        
| 73 | 73 | try  | 
                                                        
| 74 | 74 |  		{ | 
                                                        
| 75 | - $query = $db->select()  | 
                                                        |
| 76 | - ->from($this->moduleConfig->getTrapTableName(),$elmts)  | 
                                                        |
| 77 | -				->where('id=?',$trapid); | 
                                                        |
| 75 | + $query=$db->select()  | 
                                                        |
| 76 | + ->from($this->moduleConfig->getTrapTableName(), $elmts)  | 
                                                        |
| 77 | +				->where('id=?', $trapid); | 
                                                        |
| 78 | 78 | $trapDetail=$db->fetchRow($query);  | 
                                                        
| 79 | -			if ( $trapDetail == null) throw new Exception('No traps was found with id = '.$trapid); | 
                                                        |
| 79 | +			if ($trapDetail == null) throw new Exception('No traps was found with id = '.$trapid); | 
                                                        |
| 80 | 80 | }  | 
                                                        
| 81 | 81 | catch (Exception $e)  | 
                                                        
| 82 | 82 |  		{ | 
                                                        
| 83 | -			$this->displayExitError('Trap detail',$e->getMessage()); | 
                                                        |
| 83 | +			$this->displayExitError('Trap detail', $e->getMessage()); | 
                                                        |
| 84 | 84 | return;  | 
                                                        
| 85 | 85 | }  | 
                                                        
| 86 | 86 | |
| 87 | 87 | // Store result in array (with Titles).  | 
                                                        
| 88 | 88 |  		foreach ($queryArray as $key => $val) { | 
                                                        
| 89 | 89 |  			if ($key == 'timestamp') { | 
                                                        
| 90 | -				$cval=strftime('%c',$trapDetail->$key); | 
                                                        |
| 90 | +				$cval=strftime('%c', $trapDetail->$key); | 
                                                        |
| 91 | 91 |  			} else { | 
                                                        
| 92 | 92 | $cval=$trapDetail->$key;  | 
                                                        
| 93 | 93 | }  | 
                                                        
| 94 | - array_push($queryArray[$key],$cval);  | 
                                                        |
| 94 | + array_push($queryArray[$key], $cval);  | 
                                                        |
| 95 | 95 | }  | 
                                                        
| 96 | - $this->view->rowset = $queryArray;  | 
                                                        |
| 96 | + $this->view->rowset=$queryArray;  | 
                                                        |
| 97 | 97 | |
| 98 | 98 | // ************** Check for additionnal data  | 
                                                        
| 99 | 99 | |
@@ -105,17 +105,17 @@ discard block  | 
                                                    ||
| 105 | 105 | }  | 
                                                        
| 106 | 106 | try  | 
                                                        
| 107 | 107 |  		{		 | 
                                                        
| 108 | - $query = $db->select()  | 
                                                        |
| 109 | - ->from($this->moduleConfig->getTrapDataTableName(),$data_elmts)  | 
                                                        |
| 110 | -				->where('trap_id=?',$trapid); | 
                                                        |
| 108 | + $query=$db->select()  | 
                                                        |
| 109 | + ->from($this->moduleConfig->getTrapDataTableName(), $data_elmts)  | 
                                                        |
| 110 | +				->where('trap_id=?', $trapid); | 
                                                        |
| 111 | 111 | $trapDetail=$db->fetchAll($query);  | 
                                                        
| 112 | 112 | }  | 
                                                        
| 113 | 113 | catch (Exception $e)  | 
                                                        
| 114 | 114 |  		{ | 
                                                        
| 115 | -			$this->displayExitError('Trap detail',$e->getMessage()); | 
                                                        |
| 115 | +			$this->displayExitError('Trap detail', $e->getMessage()); | 
                                                        |
| 116 | 116 | }  | 
                                                        
| 117 | 117 | // TODO : code this in a better & simpler way  | 
                                                        
| 118 | - if ($trapDetail == null )  | 
                                                        |
| 118 | + if ($trapDetail == null)  | 
                                                        |
| 119 | 119 |  		{ | 
                                                        
| 120 | 120 | $this->view->data=false;  | 
                                                        
| 121 | 121 | }  | 
                                                        
@@ -127,9 +127,9 @@ discard block  | 
                                                    ||
| 127 | 127 | foreach ($trapDetail as $key => $val)  | 
                                                        
| 128 | 128 |  			{	 | 
                                                        
| 129 | 129 | $trapval[$key]=array();  | 
                                                        
| 130 | - foreach (array_keys($queryArrayData) as $vkey )  | 
                                                        |
| 130 | + foreach (array_keys($queryArrayData) as $vkey)  | 
                                                        |
| 131 | 131 |  				{ | 
                                                        
| 132 | - array_push($trapval[$key],$val->$vkey);  | 
                                                        |
| 132 | + array_push($trapval[$key], $val->$vkey);  | 
                                                        |
| 133 | 133 | }  | 
                                                        
| 134 | 134 | }  | 
                                                        
| 135 | 135 | $this->view->data_val=$trapval;  | 
                                                        
@@ -145,19 +145,19 @@ discard block  | 
                                                    ||
| 145 | 145 | $this->checkReadPermission();  | 
                                                        
| 146 | 146 |  	    $this->prepareTabs()->activate('hosts'); | 
                                                        
| 147 | 147 | |
| 148 | - $db = $this->getDb();  | 
                                                        |
| 148 | + $db=$this->getDb();  | 
                                                        |
| 149 | 149 | $this->getTrapHostListTable()->setConnection($db);  | 
                                                        
| 150 | 150 | |
| 151 | 151 | // Apply pagination limits  | 
                                                        
| 152 | - $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(),$this->getModuleConfig()->itemListDisplay());  | 
                                                        |
| 152 | + $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(), $this->getModuleConfig()->itemListDisplay());  | 
                                                        |
| 153 | 153 | |
| 154 | 154 | // Set Filter  | 
                                                        
| 155 | 155 | //$postData=$this->getRequest()->getPost();  | 
                                                        
| 156 | 156 | $filter=array();  | 
                                                        
| 157 | -	    $filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; | 
                                                        |
| 157 | +	    $filter['q']=$this->params->get('q'); //(isset($postData['q']))?$postData['q']:''; | 
                                                        |
| 158 | 158 |  	    $filter['done']=$this->params->get('done'); | 
                                                        
| 159 | 159 | $this->view->filter=$filter;  | 
                                                        
| 160 | - $this->view->table->updateFilter(Url::fromRequest(),$filter);  | 
                                                        |
| 160 | + $this->view->table->updateFilter(Url::fromRequest(), $filter);  | 
                                                        |
| 161 | 161 | }  | 
                                                        
| 162 | 162 | |
| 163 | 163 | public function deleteAction()  | 
                                                        
@@ -176,15 +176,15 @@ discard block  | 
                                                    ||
| 176 | 176 |  	{ | 
                                                        
| 177 | 177 |  		return $this->getTabs()->add('traps', array( | 
                                                        
| 178 | 178 |  			'label'	=> $this->translate('Traps'), | 
                                                        
| 179 | - 'url' => $this->getModuleConfig()->urlPath() . '/received')  | 
                                                        |
| 179 | + 'url' => $this->getModuleConfig()->urlPath().'/received')  | 
                                                        |
| 180 | 180 | )  | 
                                                        
| 181 | 181 |  		    ->add('hosts', array( | 
                                                        
| 182 | 182 |  		        'label' => $this->translate('Hosts'), | 
                                                        
| 183 | - 'url' => $this->getModuleConfig()->urlPath() . '/received/hosts')  | 
                                                        |
| 183 | + 'url' => $this->getModuleConfig()->urlPath().'/received/hosts')  | 
                                                        |
| 184 | 184 | )  | 
                                                        
| 185 | 185 |  		    ->add('delete', array( | 
                                                        
| 186 | 186 |  			'label' => $this->translate('Delete'), | 
                                                        
| 187 | - 'url' => $this->getModuleConfig()->urlPath() . '/received/delete')  | 
                                                        |
| 187 | + 'url' => $this->getModuleConfig()->urlPath().'/received/delete')  | 
                                                        |
| 188 | 188 | );  | 
                                                        
| 189 | 189 | }  | 
                                                        
| 190 | 190 | |
@@ -211,14 +211,14 @@ discard block  | 
                                                    ||
| 211 | 211 |  			$this->_helper->json(array('status'=>'Missing variables')); | 
                                                        
| 212 | 212 | return;  | 
                                                        
| 213 | 213 | }  | 
                                                        
| 214 | - if ($action =="count")  | 
                                                        |
| 214 | + if ($action == "count")  | 
                                                        |
| 215 | 215 |  		{ | 
                                                        
| 216 | -			$this->_helper->json(array('status'=>'OK','count'=>$this->countTrap($ip,$oid))); | 
                                                        |
| 216 | +			$this->_helper->json(array('status'=>'OK', 'count'=>$this->countTrap($ip, $oid))); | 
                                                        |
| 217 | 217 | return;  | 
                                                        
| 218 | 218 | }  | 
                                                        
| 219 | - if ($action =="delete")  | 
                                                        |
| 219 | + if ($action == "delete")  | 
                                                        |
| 220 | 220 |  		{ | 
                                                        
| 221 | -			$this->_helper->json(array('status'=>'OK','count'=>$this->deleteTrap($ip,$oid))); | 
                                                        |
| 221 | +			$this->_helper->json(array('status'=>'OK', 'count'=>$this->deleteTrap($ip, $oid))); | 
                                                        |
| 222 | 222 | return;  | 
                                                        
| 223 | 223 | }  | 
                                                        
| 224 | 224 |  		$this->_helper->json(array('status'=>'unknown action')); | 
                                                        
@@ -76,9 +76,10 @@ discard block  | 
                                                    ||
| 76 | 76 | ->from($this->moduleConfig->getTrapTableName(),$elmts)  | 
                                                        
| 77 | 77 |  				->where('id=?',$trapid); | 
                                                        
| 78 | 78 | $trapDetail=$db->fetchRow($query);  | 
                                                        
| 79 | -			if ( $trapDetail == null) throw new Exception('No traps was found with id = '.$trapid); | 
                                                        |
| 80 | - }  | 
                                                        |
| 81 | - catch (Exception $e)  | 
                                                        |
| 79 | +			if ( $trapDetail == null) { | 
                                                        |
| 80 | +				throw new Exception('No traps was found with id = '.$trapid); | 
                                                        |
| 81 | + }  | 
                                                        |
| 82 | + } catch (Exception $e)  | 
                                                        |
| 82 | 83 |  		{ | 
                                                        
| 83 | 84 |  			$this->displayExitError('Trap detail',$e->getMessage()); | 
                                                        
| 84 | 85 | return;  | 
                                                        
@@ -109,8 +110,7 @@ discard block  | 
                                                    ||
| 109 | 110 | ->from($this->moduleConfig->getTrapDataTableName(),$data_elmts)  | 
                                                        
| 110 | 111 |  				->where('trap_id=?',$trapid); | 
                                                        
| 111 | 112 | $trapDetail=$db->fetchAll($query);  | 
                                                        
| 112 | - }  | 
                                                        |
| 113 | - catch (Exception $e)  | 
                                                        |
| 113 | + } catch (Exception $e)  | 
                                                        |
| 114 | 114 |  		{ | 
                                                        
| 115 | 115 |  			$this->displayExitError('Trap detail',$e->getMessage()); | 
                                                        
| 116 | 116 | }  | 
                                                        
@@ -118,8 +118,7 @@ discard block  | 
                                                    ||
| 118 | 118 | if ($trapDetail == null )  | 
                                                        
| 119 | 119 |  		{ | 
                                                        
| 120 | 120 | $this->view->data=false;  | 
                                                        
| 121 | - }  | 
                                                        |
| 122 | - else  | 
                                                        |
| 121 | + } else  | 
                                                        |
| 123 | 122 |  		{ | 
                                                        
| 124 | 123 | $this->view->data=true;  | 
                                                        
| 125 | 124 | // Store result in array.  | 
                                                        
@@ -205,8 +204,7 @@ discard block  | 
                                                    ||
| 205 | 204 | $ip=$postData['IP'];  | 
                                                        
| 206 | 205 | $oid=$postData['OID'];  | 
                                                        
| 207 | 206 | $action=$postData['action'];  | 
                                                        
| 208 | - }  | 
                                                        |
| 209 | - else  | 
                                                        |
| 207 | + } else  | 
                                                        |
| 210 | 208 |  		{ | 
                                                        
| 211 | 209 |  			$this->_helper->json(array('status'=>'Missing variables')); | 
                                                        
| 212 | 210 | return;  | 
                                                        
@@ -12,7 +12,7 @@  | 
                                                    ||
| 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()  | 
                                                        
@@ -21,13 +21,13 @@ discard block  | 
                                                    ||
| 21 | 21 | protected $lastHost;  | 
                                                        
| 22 | 22 | // Filters  | 
                                                        
| 23 | 23 | |
| 24 | - protected $filter;  | 
                                                        |
| 25 | - protected $enforcedFilters = array();  | 
                                                        |
| 26 | - protected $searchColumns = array();  | 
                                                        |
| 24 | + protected $filter;  | 
                                                        |
| 25 | + protected $enforcedFilters = array();  | 
                                                        |
| 26 | + protected $searchColumns = array();  | 
                                                        |
| 27 | 27 | |
| 28 | 28 |  	protected function getTitles() { | 
                                                        
| 29 | 29 | // TODO : check moduleconfig is set  | 
                                                        
| 30 | - return $this->moduleConfig->getTrapHostListTitles();  | 
                                                        |
| 30 | + return $this->moduleConfig->getTrapHostListTitles();  | 
                                                        |
| 31 | 31 | }  | 
                                                        
| 32 | 32 | |
| 33 | 33 | // ****************** Render table in html  | 
                                                        
@@ -35,45 +35,45 @@ discard block  | 
                                                    ||
| 35 | 35 | // Host grouping  | 
                                                        
| 36 | 36 | protected function renderHostIfNew($IP,$hostname)  | 
                                                        
| 37 | 37 |  	{ | 
                                                        
| 38 | - $view = $this->getView();  | 
                                                        |
| 38 | + $view = $this->getView();  | 
                                                        |
| 39 | 39 | |
| 40 | -	    if ($this->lastHost === $IP) { | 
                                                        |
| 41 | - return;  | 
                                                        |
| 42 | - }  | 
                                                        |
| 40 | +		if ($this->lastHost === $IP) { | 
                                                        |
| 41 | + return;  | 
                                                        |
| 42 | + }  | 
                                                        |
| 43 | 43 | |
| 44 | - if ($this->lastHost === null)  | 
                                                        |
| 45 | -	    { | 
                                                        |
| 46 | - $htm = "<thead>\n <tr>\n";  | 
                                                        |
| 47 | -	    } else { | 
                                                        |
| 48 | - $htm = "</tbody>\n<thead>\n <tr>\n";  | 
                                                        |
| 49 | - }  | 
                                                        |
| 44 | + if ($this->lastHost === null)  | 
                                                        |
| 45 | +		{ | 
                                                        |
| 46 | + $htm = "<thead>\n <tr>\n";  | 
                                                        |
| 47 | +		} else { | 
                                                        |
| 48 | + $htm = "</tbody>\n<thead>\n <tr>\n";  | 
                                                        |
| 49 | + }  | 
                                                        |
| 50 | 50 | |
| 51 | - if ($this->columnCount === null)  | 
                                                        |
| 52 | -	    { | 
                                                        |
| 53 | - $this->columnCount = count($this->getTitles());  | 
                                                        |
| 54 | - }  | 
                                                        |
| 51 | + if ($this->columnCount === null)  | 
                                                        |
| 52 | +		{ | 
                                                        |
| 53 | + $this->columnCount = count($this->getTitles());  | 
                                                        |
| 54 | + }  | 
                                                        |
| 55 | 55 | |
| 56 | - $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($IP);  | 
                                                        |
| 57 | - if ($hostname != null)  | 
                                                        |
| 58 | -	    { | 
                                                        |
| 59 | -	        $htm .= ' ('.$hostname.')'; | 
                                                        |
| 60 | - }  | 
                                                        |
| 61 | - $htm .= '</th>' . "\n";  | 
                                                        |
| 62 | -	    if ($this->lastHost === null) { | 
                                                        |
| 63 | - $htm .= " </tr>\n";  | 
                                                        |
| 64 | -	    } else { | 
                                                        |
| 65 | - $htm .= " </tr>\n</thead>\n";  | 
                                                        |
| 66 | - }  | 
                                                        |
| 56 | + $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($IP);  | 
                                                        |
| 57 | + if ($hostname != null)  | 
                                                        |
| 58 | +		{ | 
                                                        |
| 59 | +			$htm .= ' ('.$hostname.')'; | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | + $htm .= '</th>' . "\n";  | 
                                                        |
| 62 | +		if ($this->lastHost === null) { | 
                                                        |
| 63 | + $htm .= " </tr>\n";  | 
                                                        |
| 64 | +		} else { | 
                                                        |
| 65 | + $htm .= " </tr>\n</thead>\n";  | 
                                                        |
| 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 | - public function __toString()  | 
                                                        |
| 74 | -    { | 
                                                        |
| 75 | - return $this->render();  | 
                                                        |
| 76 | - }  | 
                                                        |
| 73 | + public function __toString()  | 
                                                        |
| 74 | +	{ | 
                                                        |
| 75 | + return $this->render();  | 
                                                        |
| 76 | + }  | 
                                                        |
| 77 | 77 | |
| 78 | 78 | public function render()  | 
                                                        
| 79 | 79 |  	{ | 
                                                        
@@ -139,9 +139,9 @@ discard block  | 
                                                    ||
| 139 | 139 | |
| 140 | 140 | }  | 
                                                        
| 141 | 141 | |
| 142 | - public function count()  | 
                                                        |
| 143 | -    {   | 
                                                        |
| 144 | - $db=$this->db();  | 
                                                        |
| 142 | + public function count()  | 
                                                        |
| 143 | +	{   | 
                                                        |
| 144 | + $db=$this->db();  | 
                                                        |
| 145 | 145 | |
| 146 | 146 | $query = $this->getBaseQuery();  | 
                                                        
| 147 | 147 | $this->applyFiltersToQuery($query);  | 
                                                        
@@ -149,16 +149,16 @@ discard block  | 
                                                    ||
| 149 | 149 | |
| 150 | 150 | return count($values);  | 
                                                        
| 151 | 151 | |
| 152 | - //return $db->fetchOne($query);  | 
                                                        |
| 153 | - }  | 
                                                        |
| 152 | + //return $db->fetchOne($query);  | 
                                                        |
| 153 | + }  | 
                                                        |
| 154 | 154 | |
| 155 | - public function getPaginator()  | 
                                                        |
| 156 | -    { | 
                                                        |
| 157 | - $paginator = new Paginator();  | 
                                                        |
| 158 | - $paginator->setQuery($this);  | 
                                                        |
| 155 | + public function getPaginator()  | 
                                                        |
| 156 | +	{ | 
                                                        |
| 157 | + $paginator = new Paginator();  | 
                                                        |
| 158 | + $paginator->setQuery($this);  | 
                                                        |
| 159 | 159 | |
| 160 | - return $paginator;  | 
                                                        |
| 161 | - }  | 
                                                        |
| 160 | + return $paginator;  | 
                                                        |
| 161 | + }  | 
                                                        |
| 162 | 162 | |
| 163 | 163 | // ****************** DB connection and query  | 
                                                        
| 164 | 164 | |
@@ -168,24 +168,24 @@ discard block  | 
                                                    ||
| 168 | 168 | |
| 169 | 169 | $query = $this->getBaseQuery();  | 
                                                        
| 170 | 170 | $this->applyFiltersToQuery($query);  | 
                                                        
| 171 | -       if ($this->hasLimit() || $this->hasOffset()) { | 
                                                        |
| 172 | - $query->limit($this->getLimit(), $this->getOffset());  | 
                                                        |
| 173 | - }  | 
                                                        |
| 171 | +	   if ($this->hasLimit() || $this->hasOffset()) { | 
                                                        |
| 172 | + $query->limit($this->getLimit(), $this->getOffset());  | 
                                                        |
| 173 | + }  | 
                                                        |
| 174 | 174 | |
| 175 | 175 | return $db->fetchAll($query);  | 
                                                        
| 176 | 176 | }  | 
                                                        
| 177 | 177 | |
| 178 | - public function getBaseQuery()  | 
                                                        |
| 179 | -    { | 
                                                        |
| 178 | + public function getBaseQuery()  | 
                                                        |
| 179 | +	{ | 
                                                        |
| 180 | 180 | $db=$this->db();  | 
                                                        
| 181 | 181 | $query = $db->select()->from(  | 
                                                        
| 182 | - $this->moduleConfig->getTrapTableName(),  | 
                                                        |
| 183 | - $this->moduleConfig->getTrapHostListDisplayColumns()  | 
                                                        |
| 184 | -		    )->group(array('t.source_ip','t.source_name','t.trap_oid')) | 
                                                        |
| 185 | -		    ->order('t.source_ip'); | 
                                                        |
| 182 | + $this->moduleConfig->getTrapTableName(),  | 
                                                        |
| 183 | + $this->moduleConfig->getTrapHostListDisplayColumns()  | 
                                                        |
| 184 | +			)->group(array('t.source_ip','t.source_name','t.trap_oid')) | 
                                                        |
| 185 | +			->order('t.source_ip'); | 
                                                        |
| 186 | 186 | |
| 187 | - return $query;  | 
                                                        |
| 188 | - }  | 
                                                        |
| 187 | + return $query;  | 
                                                        |
| 188 | + }  | 
                                                        |
| 189 | 189 | |
| 190 | 190 | // ****************** Filters  | 
                                                        
| 191 | 191 | |
@@ -215,39 +215,39 @@ discard block  | 
                                                    ||
| 215 | 215 | $this->filter_done=(isset($filter['done']))?$this->filter_done=$filter['done']:0;  | 
                                                        
| 216 | 216 | }  | 
                                                        
| 217 | 217 | |
| 218 | - protected function getSearchColumns()  | 
                                                        |
| 219 | -    { | 
                                                        |
| 220 | - return $this->getColumns();  | 
                                                        |
| 221 | - }  | 
                                                        |
| 218 | + protected function getSearchColumns()  | 
                                                        |
| 219 | +	{ | 
                                                        |
| 220 | + return $this->getColumns();  | 
                                                        |
| 221 | + }  | 
                                                        |
| 222 | 222 | |
| 223 | 223 | public function getColumns()  | 
                                                        
| 224 | 224 |  	{ | 
                                                        
| 225 | 225 | return $this->moduleConfig->getTrapListDisplayColumns();  | 
                                                        
| 226 | 226 | }  | 
                                                        
| 227 | 227 | |
| 228 | - public function setFilter($filter)  | 
                                                        |
| 229 | -    { | 
                                                        |
| 230 | - $this->filter = $filter;  | 
                                                        |
| 231 | - return $this;  | 
                                                        |
| 232 | - }  | 
                                                        |
| 228 | + public function setFilter($filter)  | 
                                                        |
| 229 | +	{ | 
                                                        |
| 230 | + $this->filter = $filter;  | 
                                                        |
| 231 | + return $this;  | 
                                                        |
| 232 | + }  | 
                                                        |
| 233 | 233 | |
| 234 | 234 | public function getFilterEditor(Request $request)  | 
                                                        
| 235 | -    { | 
                                                        |
| 236 | -        $filterEditor = Widget::create('filterEditor') | 
                                                        |
| 237 | - ->setColumns(array_keys($this->getColumns()))  | 
                                                        |
| 238 | - ->setSearchColumns(array_keys($this->getSearchColumns()))  | 
                                                        |
| 239 | -            ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') | 
                                                        |
| 240 | -            ->ignoreParams('page') | 
                                                        |
| 241 | - ->handleRequest($request);  | 
                                                        |
| 235 | +	{ | 
                                                        |
| 236 | +		$filterEditor = Widget::create('filterEditor') | 
                                                        |
| 237 | + ->setColumns(array_keys($this->getColumns()))  | 
                                                        |
| 238 | + ->setSearchColumns(array_keys($this->getSearchColumns()))  | 
                                                        |
| 239 | +			->preserveParams('limit', 'sort', 'dir', 'view', 'backend') | 
                                                        |
| 240 | +			->ignoreParams('page') | 
                                                        |
| 241 | + ->handleRequest($request);  | 
                                                        |
| 242 | 242 | |
| 243 | - $filter = $filterEditor->getFilter();  | 
                                                        |
| 244 | - $this->setFilter($filter);  | 
                                                        |
| 243 | + $filter = $filterEditor->getFilter();  | 
                                                        |
| 244 | + $this->setFilter($filter);  | 
                                                        |
| 245 | 245 | |
| 246 | - return $filterEditor;  | 
                                                        |
| 247 | - }  | 
                                                        |
| 246 | + return $filterEditor;  | 
                                                        |
| 247 | + }  | 
                                                        |
| 248 | 248 | |
| 249 | - protected function applyFiltersToQuery($query)  | 
                                                        |
| 250 | -    { | 
                                                        |
| 249 | + protected function applyFiltersToQuery($query)  | 
                                                        |
| 250 | +	{ | 
                                                        |
| 251 | 251 | |
| 252 | 252 | $sql='';  | 
                                                        
| 253 | 253 | if ($this->filter_query != '')  | 
                                                        
@@ -268,8 +268,8 @@ discard block  | 
                                                    ||
| 268 | 268 | $sql.="(status != 'done')";  | 
                                                        
| 269 | 269 | }  | 
                                                        
| 270 | 270 | if ($sql != '') $query->where($sql);  | 
                                                        
| 271 | - return $query;  | 
                                                        |
| 272 | - }  | 
                                                        |
| 271 | + return $query;  | 
                                                        |
| 272 | + }  | 
                                                        |
| 273 | 273 | |
| 274 | 274 | }  | 
                                                        
| 275 | 275 | |
@@ -256,7 +256,9 @@ discard block  | 
                                                    ||
| 256 | 256 | $first=1;  | 
                                                        
| 257 | 257 | foreach($this->moduleConfig->getTrapListSearchColumns() as $column)  | 
                                                        
| 258 | 258 |  			{ | 
                                                        
| 259 | - if ($first==0) $sql.=' OR ';  | 
                                                        |
| 259 | +				if ($first==0) { | 
                                                        |
| 260 | + $sql.=' OR ';  | 
                                                        |
| 261 | + }  | 
                                                        |
| 260 | 262 | $first=0;  | 
                                                        
| 261 | 263 | $sql.=" ".$column." LIKE '%".$this->filter_query."%' ";  | 
                                                        
| 262 | 264 | }  | 
                                                        
@@ -264,10 +266,14 @@ discard block  | 
                                                    ||
| 264 | 266 | }  | 
                                                        
| 265 | 267 | if ($this->filter_done == 1)  | 
                                                        
| 266 | 268 |  		{ | 
                                                        
| 267 | - if ($sql != '') $sql.=' AND ';  | 
                                                        |
| 269 | +			if ($sql != '') { | 
                                                        |
| 270 | + $sql.=' AND ';  | 
                                                        |
| 271 | + }  | 
                                                        |
| 268 | 272 | $sql.="(status != 'done')";  | 
                                                        
| 269 | 273 | }  | 
                                                        
| 270 | - if ($sql != '') $query->where($sql);  | 
                                                        |
| 274 | +		if ($sql != '') { | 
                                                        |
| 275 | + $query->where($sql);  | 
                                                        |
| 276 | + }  | 
                                                        |
| 271 | 277 | return $query;  | 
                                                        
| 272 | 278 | }  | 
                                                        
| 273 | 279 | |
@@ -22,8 +22,8 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | }  | 
                                                        
@@ -26,7 +26,7 @@ discard block  | 
                                                    ||
| 26 | 26 | |
| 27 | 27 | // view limits  | 
                                                        
| 28 | 28 | protected $limit;  | 
                                                        
| 29 | - protected $offset;  | 
                                                        |
| 29 | + protected $offset;  | 
                                                        |
| 30 | 30 | |
| 31 | 31 | // Used for rendering days in list  | 
                                                        
| 32 | 32 | protected $columnCount;  | 
                                                        
@@ -34,55 +34,55 @@ discard block  | 
                                                    ||
| 34 | 34 | |
| 35 | 35 | // Filters  | 
                                                        
| 36 | 36 | |
| 37 | - protected $filter;  | 
                                                        |
| 38 | - protected $enforcedFilters = array();  | 
                                                        |
| 39 | - protected $searchColumns = array();  | 
                                                        |
| 37 | + protected $filter;  | 
                                                        |
| 38 | + protected $enforcedFilters = array();  | 
                                                        |
| 39 | + protected $searchColumns = array();  | 
                                                        |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | // Must return titles in array ( id => display_name )  | 
                                                        
| 43 | 43 | abstract protected function getTitles();  | 
                                                        
| 44 | 44 | // ****************** Day header  | 
                                                        
| 45 | - protected function renderDayIfNew($timestamp)  | 
                                                        |
| 46 | -    { | 
                                                        |
| 47 | - $view = $this->getView();  | 
                                                        |
| 45 | + protected function renderDayIfNew($timestamp)  | 
                                                        |
| 46 | +	{ | 
                                                        |
| 47 | + $view = $this->getView();  | 
                                                        |
| 48 | 48 | |
| 49 | 49 | // Check for date local format  | 
                                                        
| 50 | -        if (in_array(setlocale(LC_ALL, 0), array('en_US.UTF-8', 'C'))) { | 
                                                        |
| 51 | -            $day = date('l, jS F Y', (int) $timestamp); | 
                                                        |
| 52 | -        } else { | 
                                                        |
| 53 | -            $day = strftime('%A, %e. %B, %Y', (int) $timestamp); | 
                                                        |
| 54 | - }  | 
                                                        |
| 55 | -  | 
                                                        |
| 56 | -        if ($this->lastDay === $day) { | 
                                                        |
| 57 | - return;  | 
                                                        |
| 58 | - }  | 
                                                        |
| 59 | -  | 
                                                        |
| 60 | -        if ($this->lastDay === null) { | 
                                                        |
| 61 | - $htm = "<thead>\n <tr>\n";  | 
                                                        |
| 62 | -        } else { | 
                                                        |
| 63 | - $htm = "</tbody>\n<thead>\n <tr>\n";  | 
                                                        |
| 64 | - }  | 
                                                        |
| 65 | -  | 
                                                        |
| 66 | -        if ($this->columnCount === null) { | 
                                                        |
| 67 | - $this->columnCount = count($this->getTitles());  | 
                                                        |
| 68 | - }  | 
                                                        |
| 69 | -  | 
                                                        |
| 70 | - $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($day) . '</th>' . "\n";  | 
                                                        |
| 71 | -        if ($this->lastDay === null) { | 
                                                        |
| 72 | - $htm .= " </tr>\n";  | 
                                                        |
| 73 | -        } else { | 
                                                        |
| 74 | - $htm .= " </tr>\n</thead>\n";  | 
                                                        |
| 75 | - }  | 
                                                        |
| 76 | -  | 
                                                        |
| 77 | - $this->lastDay = $day;  | 
                                                        |
| 78 | -  | 
                                                        |
| 79 | - return $htm . "<tbody>\n";  | 
                                                        |
| 80 | - }  | 
                                                        |
| 50 | +		if (in_array(setlocale(LC_ALL, 0), array('en_US.UTF-8', 'C'))) { | 
                                                        |
| 51 | +			$day = date('l, jS F Y', (int) $timestamp); | 
                                                        |
| 52 | +		} else { | 
                                                        |
| 53 | +			$day = strftime('%A, %e. %B, %Y', (int) $timestamp); | 
                                                        |
| 54 | + }  | 
                                                        |
| 55 | +  | 
                                                        |
| 56 | +		if ($this->lastDay === $day) { | 
                                                        |
| 57 | + return;  | 
                                                        |
| 58 | + }  | 
                                                        |
| 59 | +  | 
                                                        |
| 60 | +		if ($this->lastDay === null) { | 
                                                        |
| 61 | + $htm = "<thead>\n <tr>\n";  | 
                                                        |
| 62 | +		} else { | 
                                                        |
| 63 | + $htm = "</tbody>\n<thead>\n <tr>\n";  | 
                                                        |
| 64 | + }  | 
                                                        |
| 65 | +  | 
                                                        |
| 66 | +		if ($this->columnCount === null) { | 
                                                        |
| 67 | + $this->columnCount = count($this->getTitles());  | 
                                                        |
| 68 | + }  | 
                                                        |
| 69 | +  | 
                                                        |
| 70 | + $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($day) . '</th>' . "\n";  | 
                                                        |
| 71 | +		if ($this->lastDay === null) { | 
                                                        |
| 72 | + $htm .= " </tr>\n";  | 
                                                        |
| 73 | +		} else { | 
                                                        |
| 74 | + $htm .= " </tr>\n</thead>\n";  | 
                                                        |
| 75 | + }  | 
                                                        |
| 76 | +  | 
                                                        |
| 77 | + $this->lastDay = $day;  | 
                                                        |
| 78 | +  | 
                                                        |
| 79 | + return $htm . "<tbody>\n";  | 
                                                        |
| 80 | + }  | 
                                                        |
| 81 | 81 | // ****************** Render table in html  | 
                                                        
| 82 | - public function __toString()  | 
                                                        |
| 83 | -    { | 
                                                        |
| 84 | - return $this->render();  | 
                                                        |
| 85 | - }  | 
                                                        |
| 82 | + public function __toString()  | 
                                                        |
| 83 | +	{ | 
                                                        |
| 84 | + return $this->render();  | 
                                                        |
| 85 | + }  | 
                                                        |
| 86 | 86 | |
| 87 | 87 | abstract public function render();  | 
                                                        
| 88 | 88 | |
@@ -92,76 +92,76 @@ discard block  | 
                                                    ||
| 92 | 92 | $this->moduleConfig = $conf;  | 
                                                        
| 93 | 93 | }  | 
                                                        
| 94 | 94 | // ****************** View get/set  | 
                                                        
| 95 | - protected function getView()  | 
                                                        |
| 96 | -    { | 
                                                        |
| 97 | -        if ($this->view === null) { | 
                                                        |
| 98 | - $this->view = Icinga::app()->getViewRenderer()->view;  | 
                                                        |
| 99 | - }  | 
                                                        |
| 100 | - return $this->view;  | 
                                                        |
| 101 | - }  | 
                                                        |
| 95 | + protected function getView()  | 
                                                        |
| 96 | +	{ | 
                                                        |
| 97 | +		if ($this->view === null) { | 
                                                        |
| 98 | + $this->view = Icinga::app()->getViewRenderer()->view;  | 
                                                        |
| 99 | + }  | 
                                                        |
| 100 | + return $this->view;  | 
                                                        |
| 101 | + }  | 
                                                        |
| 102 | 102 | |
| 103 | - public function setView($view)  | 
                                                        |
| 104 | -    { | 
                                                        |
| 105 | - $this->view = $view;  | 
                                                        |
| 106 | - }  | 
                                                        |
| 103 | + public function setView($view)  | 
                                                        |
| 104 | +	{ | 
                                                        |
| 105 | + $this->view = $view;  | 
                                                        |
| 106 | + }  | 
                                                        |
| 107 | 107 | |
| 108 | 108 | // Limits  | 
                                                        
| 109 | 109 | |
| 110 | - public function limit($count = null, $offset = null)  | 
                                                        |
| 111 | -    { | 
                                                        |
| 112 | - $this->limit = $count;  | 
                                                        |
| 113 | - $this->offset = $offset;  | 
                                                        |
| 110 | + public function limit($count = null, $offset = null)  | 
                                                        |
| 111 | +	{ | 
                                                        |
| 112 | + $this->limit = $count;  | 
                                                        |
| 113 | + $this->offset = $offset;  | 
                                                        |
| 114 | 114 | |
| 115 | - return $this;  | 
                                                        |
| 116 | - }  | 
                                                        |
| 115 | + return $this;  | 
                                                        |
| 116 | + }  | 
                                                        |
| 117 | 117 | |
| 118 | - public function hasLimit()  | 
                                                        |
| 119 | -    { | 
                                                        |
| 120 | - return $this->limit !== null;  | 
                                                        |
| 121 | - }  | 
                                                        |
| 118 | + public function hasLimit()  | 
                                                        |
| 119 | +	{ | 
                                                        |
| 120 | + return $this->limit !== null;  | 
                                                        |
| 121 | + }  | 
                                                        |
| 122 | 122 | |
| 123 | - public function getLimit()  | 
                                                        |
| 124 | -    { | 
                                                        |
| 125 | - return $this->limit;  | 
                                                        |
| 126 | - }  | 
                                                        |
| 123 | + public function getLimit()  | 
                                                        |
| 124 | +	{ | 
                                                        |
| 125 | + return $this->limit;  | 
                                                        |
| 126 | + }  | 
                                                        |
| 127 | 127 | |
| 128 | - public function hasOffset()  | 
                                                        |
| 129 | -    { | 
                                                        |
| 130 | - return $this->offset !== null;  | 
                                                        |
| 131 | - }  | 
                                                        |
| 128 | + public function hasOffset()  | 
                                                        |
| 129 | +	{ | 
                                                        |
| 130 | + return $this->offset !== null;  | 
                                                        |
| 131 | + }  | 
                                                        |
| 132 | 132 | |
| 133 | - public function getOffset()  | 
                                                        |
| 134 | -    { | 
                                                        |
| 135 | - return $this->offset;  | 
                                                        |
| 136 | - }  | 
                                                        |
| 133 | + public function getOffset()  | 
                                                        |
| 134 | +	{ | 
                                                        |
| 135 | + return $this->offset;  | 
                                                        |
| 136 | + }  | 
                                                        |
| 137 | 137 | |
| 138 | 138 | abstract function count();  | 
                                                        
| 139 | 139 | |
| 140 | - public function getPaginator()  | 
                                                        |
| 141 | -    { | 
                                                        |
| 142 | - $paginator = new Paginator();  | 
                                                        |
| 143 | - $paginator->setQuery($this);  | 
                                                        |
| 140 | + public function getPaginator()  | 
                                                        |
| 141 | +	{ | 
                                                        |
| 142 | + $paginator = new Paginator();  | 
                                                        |
| 143 | + $paginator->setQuery($this);  | 
                                                        |
| 144 | 144 | |
| 145 | - return $paginator;  | 
                                                        |
| 146 | - }  | 
                                                        |
| 145 | + return $paginator;  | 
                                                        |
| 146 | + }  | 
                                                        |
| 147 | 147 | |
| 148 | 148 | // ****************** DB connection and query  | 
                                                        
| 149 | 149 | |
| 150 | - public function setConnection(Selectable $connection)  | 
                                                        |
| 151 | -    { | 
                                                        |
| 152 | - $this->connection = $connection;  | 
                                                        |
| 153 | - return $this;  | 
                                                        |
| 154 | - }  | 
                                                        |
| 150 | + public function setConnection(Selectable $connection)  | 
                                                        |
| 151 | +	{ | 
                                                        |
| 152 | + $this->connection = $connection;  | 
                                                        |
| 153 | + return $this;  | 
                                                        |
| 154 | + }  | 
                                                        |
| 155 | 155 | |
| 156 | - protected function connection()  | 
                                                        |
| 157 | -    { | 
                                                        |
| 158 | - return $this->connection;  | 
                                                        |
| 159 | - }  | 
                                                        |
| 156 | + protected function connection()  | 
                                                        |
| 157 | +	{ | 
                                                        |
| 158 | + return $this->connection;  | 
                                                        |
| 159 | + }  | 
                                                        |
| 160 | 160 | |
| 161 | - protected function db()  | 
                                                        |
| 162 | -    { | 
                                                        |
| 163 | - return $this->connection()->getConnection();  | 
                                                        |
| 164 | - }  | 
                                                        |
| 161 | + protected function db()  | 
                                                        |
| 162 | +	{ | 
                                                        |
| 163 | + return $this->connection()->getConnection();  | 
                                                        |
| 164 | + }  | 
                                                        |
| 165 | 165 | |
| 166 | 166 | protected function getTable()  | 
                                                        
| 167 | 167 |  	{ | 
                                                        
@@ -169,52 +169,52 @@ discard block  | 
                                                    ||
| 169 | 169 | |
| 170 | 170 | $query = $this->getBaseQuery();  | 
                                                        
| 171 | 171 | |
| 172 | -       if ($this->hasLimit() || $this->hasOffset()) { | 
                                                        |
| 173 | - $query->limit($this->getLimit(), $this->getOffset());  | 
                                                        |
| 174 | - }  | 
                                                        |
| 172 | +	   if ($this->hasLimit() || $this->hasOffset()) { | 
                                                        |
| 173 | + $query->limit($this->getLimit(), $this->getOffset());  | 
                                                        |
| 174 | + }  | 
                                                        |
| 175 | 175 | |
| 176 | 176 | return $db->fetchAll($query);  | 
                                                        
| 177 | 177 | }  | 
                                                        
| 178 | 178 | |
| 179 | - abstract public function getBaseQuery();  | 
                                                        |
| 179 | + abstract public function getBaseQuery();  | 
                                                        |
| 180 | 180 | |
| 181 | 181 | // ****************** Filters  | 
                                                        
| 182 | 182 | |
| 183 | - protected function getSearchColumns()  | 
                                                        |
| 184 | -    { | 
                                                        |
| 185 | - return $this->getColumns();  | 
                                                        |
| 186 | - }  | 
                                                        |
| 183 | + protected function getSearchColumns()  | 
                                                        |
| 184 | +	{ | 
                                                        |
| 185 | + return $this->getColumns();  | 
                                                        |
| 186 | + }  | 
                                                        |
| 187 | 187 | |
| 188 | 188 | abstract public function getColumns();  | 
                                                        
| 189 | 189 | |
| 190 | - public function setFilter($filter)  | 
                                                        |
| 191 | -    { | 
                                                        |
| 192 | - $this->filter = $filter;  | 
                                                        |
| 193 | - return $this;  | 
                                                        |
| 194 | - }  | 
                                                        |
| 190 | + public function setFilter($filter)  | 
                                                        |
| 191 | +	{ | 
                                                        |
| 192 | + $this->filter = $filter;  | 
                                                        |
| 193 | + return $this;  | 
                                                        |
| 194 | + }  | 
                                                        |
| 195 | 195 | |
| 196 | 196 | public function getFilterEditor(Request $request)  | 
                                                        
| 197 | -    { | 
                                                        |
| 198 | -        $filterEditor = Widget::create('filterEditor') | 
                                                        |
| 199 | - ->setColumns(array_keys($this->getColumns()))  | 
                                                        |
| 200 | - ->setSearchColumns(array_keys($this->getSearchColumns()))  | 
                                                        |
| 201 | -            ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') | 
                                                        |
| 202 | -            ->ignoreParams('page') | 
                                                        |
| 203 | - ->handleRequest($request);  | 
                                                        |
| 197 | +	{ | 
                                                        |
| 198 | +		$filterEditor = Widget::create('filterEditor') | 
                                                        |
| 199 | + ->setColumns(array_keys($this->getColumns()))  | 
                                                        |
| 200 | + ->setSearchColumns(array_keys($this->getSearchColumns()))  | 
                                                        |
| 201 | +			->preserveParams('limit', 'sort', 'dir', 'view', 'backend') | 
                                                        |
| 202 | +			->ignoreParams('page') | 
                                                        |
| 203 | + ->handleRequest($request);  | 
                                                        |
| 204 | 204 | |
| 205 | - $filter = $filterEditor->getFilter();  | 
                                                        |
| 206 | - $this->setFilter($filter);  | 
                                                        |
| 205 | + $filter = $filterEditor->getFilter();  | 
                                                        |
| 206 | + $this->setFilter($filter);  | 
                                                        |
| 207 | 207 | |
| 208 | - return $filterEditor;  | 
                                                        |
| 209 | - }  | 
                                                        |
| 208 | + return $filterEditor;  | 
                                                        |
| 209 | + }  | 
                                                        |
| 210 | 210 | |
| 211 | 211 | protected function renderFilter($filter)  | 
                                                        
| 212 | 212 |  	{ // TODO : create a better filter wher user can choose host/oid to filter | 
                                                        
| 213 | 213 | }  | 
                                                        
| 214 | 214 | |
| 215 | - protected function applyFiltersToQuery($query)  | 
                                                        |
| 216 | -    { | 
                                                        |
| 217 | - /*  | 
                                                        |
| 215 | + protected function applyFiltersToQuery($query)  | 
                                                        |
| 216 | +	{ | 
                                                        |
| 217 | + /*  | 
                                                        |
| 218 | 218 | $filter = null;  | 
                                                        
| 219 | 219 | $enforced = $this->enforcedFilters;  | 
                                                        
| 220 | 220 |          if ($this->filter && ! $this->filter->isEmpty()) { | 
                                                        
@@ -230,8 +230,8 @@ discard block  | 
                                                    ||
| 230 | 230 | $query->where($this->renderFilter($filter));  | 
                                                        
| 231 | 231 | }  | 
                                                        
| 232 | 232 | */  | 
                                                        
| 233 | - return $query;  | 
                                                        |
| 234 | - }  | 
                                                        |
| 233 | + return $query;  | 
                                                        |
| 234 | + }  | 
                                                        |
| 235 | 235 | |
| 236 | 236 | }  | 
                                                        
| 237 | 237 | |
@@ -35,8 +35,8 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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;  | 
                                                        
@@ -31,9 +31,9 @@ discard block  | 
                                                    ||
| 31 | 31 | |
| 32 | 32 | // Filters  | 
                                                        
| 33 | 33 | |
| 34 | - protected $filter;  | 
                                                        |
| 35 | - protected $enforcedFilters = array();  | 
                                                        |
| 36 | - protected $searchColumns = array();  | 
                                                        |
| 34 | + protected $filter;  | 
                                                        |
| 35 | + protected $enforcedFilters = array();  | 
                                                        |
| 36 | + protected $searchColumns = array();  | 
                                                        |
| 37 | 37 | |
| 38 | 38 |  	protected function getTitles() { | 
                                                        
| 39 | 39 | return $this->moduleConfig->getHandlerListTitles();  | 
                                                        
@@ -45,10 +45,10 @@ discard block  | 
                                                    ||
| 45 | 45 | $this->doTranslate=true;  | 
                                                        
| 46 | 46 | }  | 
                                                        
| 47 | 47 | // ****************** Render table in html  | 
                                                        
| 48 | - public function __toString()  | 
                                                        |
| 49 | -    { | 
                                                        |
| 50 | - return $this->render();  | 
                                                        |
| 51 | - }  | 
                                                        |
| 48 | + public function __toString()  | 
                                                        |
| 49 | +	{ | 
                                                        |
| 50 | + return $this->render();  | 
                                                        |
| 51 | + }  | 
                                                        |
| 52 | 52 | |
| 53 | 53 | public function render()  | 
                                                        
| 54 | 54 |  	{ | 
                                                        
@@ -153,30 +153,30 @@ discard block  | 
                                                    ||
| 153 | 153 | |
| 154 | 154 | }  | 
                                                        
| 155 | 155 | |
| 156 | - public function count()  | 
                                                        |
| 157 | -    { | 
                                                        |
| 158 | - $db = $this->connection()->getConnection();  | 
                                                        |
| 159 | - $query = clone($this->getBaseQuery());  | 
                                                        |
| 160 | -        $query->reset('order')->columns(array('COUNT(*)')); | 
                                                        |
| 161 | - $this->applyFiltersToQuery($query);  | 
                                                        |
| 156 | + public function count()  | 
                                                        |
| 157 | +	{ | 
                                                        |
| 158 | + $db = $this->connection()->getConnection();  | 
                                                        |
| 159 | + $query = clone($this->getBaseQuery());  | 
                                                        |
| 160 | +		$query->reset('order')->columns(array('COUNT(*)')); | 
                                                        |
| 161 | + $this->applyFiltersToQuery($query);  | 
                                                        |
| 162 | 162 | |
| 163 | 163 | $db=$this->db();  | 
                                                        
| 164 | 164 | |
| 165 | 165 | $query = $db->select()->from(  | 
                                                        
| 166 | - $this->moduleConfig->getTrapRuleName(),  | 
                                                        |
| 167 | -            array('COUNT(*)') | 
                                                        |
| 168 | - );  | 
                                                        |
| 166 | + $this->moduleConfig->getTrapRuleName(),  | 
                                                        |
| 167 | +			array('COUNT(*)') | 
                                                        |
| 168 | + );  | 
                                                        |
| 169 | 169 | |
| 170 | - return $db->fetchOne($query);  | 
                                                        |
| 171 | - }  | 
                                                        |
| 170 | + return $db->fetchOne($query);  | 
                                                        |
| 171 | + }  | 
                                                        |
| 172 | 172 | |
| 173 | - public function getPaginator()  | 
                                                        |
| 174 | -    { | 
                                                        |
| 175 | - $paginator = new Paginator();  | 
                                                        |
| 176 | - $paginator->setQuery($this);  | 
                                                        |
| 173 | + public function getPaginator()  | 
                                                        |
| 174 | +	{ | 
                                                        |
| 175 | + $paginator = new Paginator();  | 
                                                        |
| 176 | + $paginator->setQuery($this);  | 
                                                        |
| 177 | 177 | |
| 178 | - return $paginator;  | 
                                                        |
| 179 | - }  | 
                                                        |
| 178 | + return $paginator;  | 
                                                        |
| 179 | + }  | 
                                                        |
| 180 | 180 | |
| 181 | 181 | // ****************** DB connection and query  | 
                                                        
| 182 | 182 | |
@@ -186,63 +186,63 @@ discard block  | 
                                                    ||
| 186 | 186 | |
| 187 | 187 | $query = $this->getBaseQuery();  | 
                                                        
| 188 | 188 | |
| 189 | -       if ($this->hasLimit() || $this->hasOffset()) { | 
                                                        |
| 190 | - $query->limit($this->getLimit(), $this->getOffset());  | 
                                                        |
| 191 | - }  | 
                                                        |
| 189 | +	   if ($this->hasLimit() || $this->hasOffset()) { | 
                                                        |
| 190 | + $query->limit($this->getLimit(), $this->getOffset());  | 
                                                        |
| 191 | + }  | 
                                                        |
| 192 | 192 | |
| 193 | 193 | return $db->fetchAll($query);  | 
                                                        
| 194 | 194 | }  | 
                                                        
| 195 | 195 | |
| 196 | - public function getBaseQuery()  | 
                                                        |
| 197 | -    { | 
                                                        |
| 196 | + public function getBaseQuery()  | 
                                                        |
| 197 | +	{ | 
                                                        |
| 198 | 198 | $db=$this->db();  | 
                                                        
| 199 | 199 | |
| 200 | 200 | $query = $db->select()->from(  | 
                                                        
| 201 | - $this->moduleConfig->getTrapRuleName(),  | 
                                                        |
| 202 | - $this->moduleConfig->getHandlerListDisplayColumns()  | 
                                                        |
| 203 | -        )->order('host_name DESC,trap_oid DESC'); | 
                                                        |
| 201 | + $this->moduleConfig->getTrapRuleName(),  | 
                                                        |
| 202 | + $this->moduleConfig->getHandlerListDisplayColumns()  | 
                                                        |
| 203 | +		)->order('host_name DESC,trap_oid DESC'); | 
                                                        |
| 204 | 204 | |
| 205 | - return $query;  | 
                                                        |
| 206 | - }  | 
                                                        |
| 205 | + return $query;  | 
                                                        |
| 206 | + }  | 
                                                        |
| 207 | 207 | |
| 208 | 208 | // ****************** Filters  | 
                                                        
| 209 | 209 | |
| 210 | - protected function getSearchColumns()  | 
                                                        |
| 211 | -    { | 
                                                        |
| 212 | - return $this->getColumns();  | 
                                                        |
| 213 | - }  | 
                                                        |
| 210 | + protected function getSearchColumns()  | 
                                                        |
| 211 | +	{ | 
                                                        |
| 212 | + return $this->getColumns();  | 
                                                        |
| 213 | + }  | 
                                                        |
| 214 | 214 | |
| 215 | 215 | public function getColumns()  | 
                                                        
| 216 | 216 |  	{ | 
                                                        
| 217 | 217 | return $this->moduleConfig->getHandlerListDisplayColumns();  | 
                                                        
| 218 | 218 | }  | 
                                                        
| 219 | 219 | |
| 220 | - public function setFilter($filter)  | 
                                                        |
| 221 | -    { | 
                                                        |
| 222 | - $this->filter = $filter;  | 
                                                        |
| 223 | - return $this;  | 
                                                        |
| 224 | - }  | 
                                                        |
| 220 | + public function setFilter($filter)  | 
                                                        |
| 221 | +	{ | 
                                                        |
| 222 | + $this->filter = $filter;  | 
                                                        |
| 223 | + return $this;  | 
                                                        |
| 224 | + }  | 
                                                        |
| 225 | 225 | |
| 226 | 226 | public function getFilterEditor(Request $request)  | 
                                                        
| 227 | -    { | 
                                                        |
| 228 | -        $filterEditor = Widget::create('filterEditor') | 
                                                        |
| 229 | - ->setColumns(array_keys($this->getColumns()))  | 
                                                        |
| 230 | - ->setSearchColumns(array_keys($this->getSearchColumns()))  | 
                                                        |
| 231 | -            ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') | 
                                                        |
| 232 | -            ->ignoreParams('page') | 
                                                        |
| 233 | - ->handleRequest($request);  | 
                                                        |
| 227 | +	{ | 
                                                        |
| 228 | +		$filterEditor = Widget::create('filterEditor') | 
                                                        |
| 229 | + ->setColumns(array_keys($this->getColumns()))  | 
                                                        |
| 230 | + ->setSearchColumns(array_keys($this->getSearchColumns()))  | 
                                                        |
| 231 | +			->preserveParams('limit', 'sort', 'dir', 'view', 'backend') | 
                                                        |
| 232 | +			->ignoreParams('page') | 
                                                        |
| 233 | + ->handleRequest($request);  | 
                                                        |
| 234 | 234 | |
| 235 | - $filter = $filterEditor->getFilter();  | 
                                                        |
| 236 | - $this->setFilter($filter);  | 
                                                        |
| 235 | + $filter = $filterEditor->getFilter();  | 
                                                        |
| 236 | + $this->setFilter($filter);  | 
                                                        |
| 237 | 237 | |
| 238 | - return $filterEditor;  | 
                                                        |
| 239 | - }  | 
                                                        |
| 238 | + return $filterEditor;  | 
                                                        |
| 239 | + }  | 
                                                        |
| 240 | 240 | |
| 241 | - protected function applyFiltersToQuery($query)  | 
                                                        |
| 242 | -    { | 
                                                        |
| 241 | + protected function applyFiltersToQuery($query)  | 
                                                        |
| 242 | +	{ | 
                                                        |
| 243 | 243 | // TODO : implement  | 
                                                        
| 244 | 244 | |
| 245 | - /*$filter = null;  | 
                                                        |
| 245 | + /*$filter = null;  | 
                                                        |
| 246 | 246 | $enforced = $this->enforcedFilters;  | 
                                                        
| 247 | 247 |          if ($this->filter && ! $this->filter->isEmpty()) { | 
                                                        
| 248 | 248 | $filter = $this->filter;  | 
                                                        
@@ -257,8 +257,8 @@ discard block  | 
                                                    ||
| 257 | 257 | }  | 
                                                        
| 258 | 258 | */  | 
                                                        
| 259 | 259 | |
| 260 | - return $query;  | 
                                                        |
| 261 | - }  | 
                                                        |
| 260 | + return $query;  | 
                                                        |
| 261 | + }  | 
                                                        |
| 262 | 262 | |
| 263 | 263 | }  | 
                                                        
| 264 | 264 | |
@@ -32,8 +32,8 @@ discard block  | 
                                                    ||
| 32 | 32 | // Filters  | 
                                                        
| 33 | 33 | |
| 34 | 34 | protected $filter;  | 
                                                        
| 35 | - protected $enforcedFilters = array();  | 
                                                        |
| 36 | - protected $searchColumns = array();  | 
                                                        |
| 35 | + protected $enforcedFilters=array();  | 
                                                        |
| 36 | + protected $searchColumns=array();  | 
                                                        |
| 37 | 37 | |
| 38 | 38 |  	protected function getTitles() { | 
                                                        
| 39 | 39 | return $this->moduleConfig->getHandlerListTitles();  | 
                                                        
@@ -53,34 +53,34 @@ discard block  | 
                                                    ||
| 53 | 53 | public function render()  | 
                                                        
| 54 | 54 |  	{ | 
                                                        
| 55 | 55 | $data=$this->getTable();  | 
                                                        
| 56 | - $view = $this->getView();  | 
                                                        |
| 57 | - $this->columnCount = count($this->getTitles());  | 
                                                        |
| 56 | + $view=$this->getView();  | 
                                                        |
| 57 | + $this->columnCount=count($this->getTitles());  | 
                                                        |
| 58 | 58 | $this->lastDay=null;  | 
                                                        
| 59 | 59 | // Table start  | 
                                                        
| 60 | - $htm = '<table class="simple common-table table-row-selectable">';  | 
                                                        |
| 60 | + $htm='<table class="simple common-table table-row-selectable">';  | 
                                                        |
| 61 | 61 | |
| 62 | 62 | // Titles  | 
                                                        
| 63 | - $htm .= "<thead>\n <tr>\n";  | 
                                                        |
| 64 | - $titles = $this->getTitles();  | 
                                                        |
| 63 | + $htm.="<thead>\n <tr>\n";  | 
                                                        |
| 64 | + $titles=$this->getTitles();  | 
                                                        |
| 65 | 65 | foreach ($titles as $title)  | 
                                                        
| 66 | 66 |  		{ | 
                                                        
| 67 | - $htm .= ' <th>' . $view->escape($view->translate($title)) . "</th>\n";  | 
                                                        |
| 67 | + $htm.=' <th>'.$view->escape($view->translate($title))."</th>\n";  | 
                                                        |
| 68 | 68 | }  | 
                                                        
| 69 | - $htm .= " </tr>\n</thead>\n";  | 
                                                        |
| 69 | + $htm.=" </tr>\n</thead>\n";  | 
                                                        |
| 70 | 70 | |
| 71 | 71 | // Rows  | 
                                                        
| 72 | - $htm .= "<tbody>\n";  | 
                                                        |
| 72 | + $htm.="<tbody>\n";  | 
                                                        |
| 73 | 73 | |
| 74 | 74 | foreach ($data as $row)  | 
                                                        
| 75 | 75 |  		{ | 
                                                        
| 76 | - $firstCol = true;  | 
                                                        |
| 76 | + $firstCol=true;  | 
                                                        |
| 77 | 77 | // Put date header  | 
                                                        
| 78 | 78 | //$htm .= $this->renderDayIfNew($row->timestamp);  | 
                                                        
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | // Render row  | 
                                                        
| 82 | - $htm .= '<tr '.' >';  | 
                                                        |
| 83 | - foreach ( $titles as $rowkey => $title)  | 
                                                        |
| 82 | + $htm.='<tr '.' >';  | 
                                                        |
| 83 | + foreach ($titles as $rowkey => $title)  | 
                                                        |
| 84 | 84 |  			{ | 
                                                        
| 85 | 85 | // Check missing value  | 
                                                        
| 86 | 86 | if (property_exists($row, $rowkey))  | 
                                                        
@@ -93,7 +93,7 @@ discard block  | 
                                                    ||
| 93 | 93 | break;  | 
                                                        
| 94 | 94 | case 'trap_oid': // try to traslate oids.  | 
                                                        
| 95 | 95 | |
| 96 | - if ($this->doTranslate==true)  | 
                                                        |
| 96 | + if ($this->doTranslate == true)  | 
                                                        |
| 97 | 97 |  							{ | 
                                                        
| 98 | 98 | $oidName=$this->MIB->translateOID($row->$rowkey);  | 
                                                        
| 99 | 99 | if (isset($oidName['name']))  | 
                                                        
@@ -102,52 +102,52 @@ discard block  | 
                                                    ||
| 102 | 102 | }  | 
                                                        
| 103 | 103 | else  | 
                                                        
| 104 | 104 |  								{ | 
                                                        
| 105 | - $val = $row->$rowkey;  | 
                                                        |
| 105 | + $val=$row->$rowkey;  | 
                                                        |
| 106 | 106 | }  | 
                                                        
| 107 | 107 | }  | 
                                                        
| 108 | 108 | else  | 
                                                        
| 109 | 109 |  							{ | 
                                                        
| 110 | - $val = $row->$rowkey;  | 
                                                        |
| 110 | + $val=$row->$rowkey;  | 
                                                        |
| 111 | 111 | }  | 
                                                        
| 112 | 112 | break;  | 
                                                        
| 113 | 113 | case 'host_name': // switch to hostgroup if name is null  | 
                                                        
| 114 | 114 | if ($row->$rowkey == null)  | 
                                                        
| 115 | 115 |  							{ | 
                                                        
| 116 | - $val = $row->host_group_name;  | 
                                                        |
| 116 | + $val=$row->host_group_name;  | 
                                                        |
| 117 | 117 | }  | 
                                                        
| 118 | 118 | else  | 
                                                        
| 119 | 119 |  							{ | 
                                                        
| 120 | - $val = $row->$rowkey;  | 
                                                        |
| 120 | + $val=$row->$rowkey;  | 
                                                        |
| 121 | 121 | }  | 
                                                        
| 122 | 122 | break;  | 
                                                        
| 123 | 123 | default:  | 
                                                        
| 124 | - $val = $row->$rowkey;  | 
                                                        |
| 124 | + $val=$row->$rowkey;  | 
                                                        |
| 125 | 125 | }  | 
                                                        
| 126 | - if ($rowkey == 'trap_oid' && $this->doTranslate==true)  | 
                                                        |
| 126 | + if ($rowkey == 'trap_oid' && $this->doTranslate == true)  | 
                                                        |
| 127 | 127 |  					{					 | 
                                                        
| 128 | 128 | |
| 129 | 129 | }  | 
                                                        
| 130 | 130 |  				} else { | 
                                                        
| 131 | - $val = '-';  | 
                                                        |
| 131 | + $val='-';  | 
                                                        |
| 132 | 132 | }  | 
                                                        
| 133 | 133 |  				if ($firstCol == true) { // Put link in first column for trap detail. | 
                                                        
| 134 | - $htm .= '<td>'  | 
                                                        |
| 134 | + $htm.='<td>'  | 
                                                        |
| 135 | 135 | . $view->qlink(  | 
                                                        
| 136 | 136 | $view->escape($val),  | 
                                                        
| 137 | 137 | Url::fromPath(  | 
                                                        
| 138 | - $this->moduleConfig->urlPath() . '/handler/add',  | 
                                                        |
| 138 | + $this->moduleConfig->urlPath().'/handler/add',  | 
                                                        |
| 139 | 139 |  										array('ruleid' => $row->id) | 
                                                        
| 140 | 140 | )  | 
                                                        
| 141 | 141 | )  | 
                                                        
| 142 | 142 | . '</td>';  | 
                                                        
| 143 | 143 |  				} else { | 
                                                        
| 144 | - $htm .= '<td>' . $view->escape($val) . '</td>';  | 
                                                        |
| 144 | + $htm.='<td>'.$view->escape($val).'</td>';  | 
                                                        |
| 145 | 145 | }  | 
                                                        
| 146 | 146 | $firstCol=false;  | 
                                                        
| 147 | 147 | }  | 
                                                        
| 148 | - $htm .= "<tr>\n";  | 
                                                        |
| 148 | + $htm.="<tr>\n";  | 
                                                        |
| 149 | 149 | }  | 
                                                        
| 150 | - $htm .= "</tbody></table>\n";  | 
                                                        |
| 150 | + $htm.="</tbody></table>\n";  | 
                                                        |
| 151 | 151 | //$htm .= "Filter : " . $this->filter."<br>\n";  | 
                                                        
| 152 | 152 | return $htm;  | 
                                                        
| 153 | 153 | |
@@ -155,14 +155,14 @@ discard block  | 
                                                    ||
| 155 | 155 | |
| 156 | 156 | public function count()  | 
                                                        
| 157 | 157 |      { | 
                                                        
| 158 | - $db = $this->connection()->getConnection();  | 
                                                        |
| 159 | - $query = clone($this->getBaseQuery());  | 
                                                        |
| 158 | + $db=$this->connection()->getConnection();  | 
                                                        |
| 159 | + $query=clone($this->getBaseQuery());  | 
                                                        |
| 160 | 160 |          $query->reset('order')->columns(array('COUNT(*)')); | 
                                                        
| 161 | 161 | $this->applyFiltersToQuery($query);  | 
                                                        
| 162 | 162 | |
| 163 | 163 | $db=$this->db();  | 
                                                        
| 164 | 164 | |
| 165 | - $query = $db->select()->from(  | 
                                                        |
| 165 | + $query=$db->select()->from(  | 
                                                        |
| 166 | 166 | $this->moduleConfig->getTrapRuleName(),  | 
                                                        
| 167 | 167 |              array('COUNT(*)') | 
                                                        
| 168 | 168 | );  | 
                                                        
@@ -172,7 +172,7 @@ discard block  | 
                                                    ||
| 172 | 172 | |
| 173 | 173 | public function getPaginator()  | 
                                                        
| 174 | 174 |      { | 
                                                        
| 175 | - $paginator = new Paginator();  | 
                                                        |
| 175 | + $paginator=new Paginator();  | 
                                                        |
| 176 | 176 | $paginator->setQuery($this);  | 
                                                        
| 177 | 177 | |
| 178 | 178 | return $paginator;  | 
                                                        
@@ -184,7 +184,7 @@ discard block  | 
                                                    ||
| 184 | 184 |  	{ | 
                                                        
| 185 | 185 | $db=$this->db();  | 
                                                        
| 186 | 186 | |
| 187 | - $query = $this->getBaseQuery();  | 
                                                        |
| 187 | + $query=$this->getBaseQuery();  | 
                                                        |
| 188 | 188 | |
| 189 | 189 |         if ($this->hasLimit() || $this->hasOffset()) { | 
                                                        
| 190 | 190 | $query->limit($this->getLimit(), $this->getOffset());  | 
                                                        
@@ -197,7 +197,7 @@ discard block  | 
                                                    ||
| 197 | 197 |      { | 
                                                        
| 198 | 198 | $db=$this->db();  | 
                                                        
| 199 | 199 | |
| 200 | - $query = $db->select()->from(  | 
                                                        |
| 200 | + $query=$db->select()->from(  | 
                                                        |
| 201 | 201 | $this->moduleConfig->getTrapRuleName(),  | 
                                                        
| 202 | 202 | $this->moduleConfig->getHandlerListDisplayColumns()  | 
                                                        
| 203 | 203 |          )->order('host_name DESC,trap_oid DESC'); | 
                                                        
@@ -219,20 +219,20 @@ discard block  | 
                                                    ||
| 219 | 219 | |
| 220 | 220 | public function setFilter($filter)  | 
                                                        
| 221 | 221 |      { | 
                                                        
| 222 | - $this->filter = $filter;  | 
                                                        |
| 222 | + $this->filter=$filter;  | 
                                                        |
| 223 | 223 | return $this;  | 
                                                        
| 224 | 224 | }  | 
                                                        
| 225 | 225 | |
| 226 | 226 | public function getFilterEditor(Request $request)  | 
                                                        
| 227 | 227 |      { | 
                                                        
| 228 | -        $filterEditor = Widget::create('filterEditor') | 
                                                        |
| 228 | +        $filterEditor=Widget::create('filterEditor') | 
                                                        |
| 229 | 229 | ->setColumns(array_keys($this->getColumns()))  | 
                                                        
| 230 | 230 | ->setSearchColumns(array_keys($this->getSearchColumns()))  | 
                                                        
| 231 | 231 |              ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') | 
                                                        
| 232 | 232 |              ->ignoreParams('page') | 
                                                        
| 233 | 233 | ->handleRequest($request);  | 
                                                        
| 234 | 234 | |
| 235 | - $filter = $filterEditor->getFilter();  | 
                                                        |
| 235 | + $filter=$filterEditor->getFilter();  | 
                                                        |
| 236 | 236 | $this->setFilter($filter);  | 
                                                        
| 237 | 237 | |
| 238 | 238 | return $filterEditor;  | 
                                                        
@@ -99,13 +99,11 @@ discard block  | 
                                                    ||
| 99 | 99 | if (isset($oidName['name']))  | 
                                                        
| 100 | 100 |  								{ | 
                                                        
| 101 | 101 | $val=$oidName['name'];  | 
                                                        
| 102 | - }  | 
                                                        |
| 103 | - else  | 
                                                        |
| 102 | + } else  | 
                                                        |
| 104 | 103 |  								{ | 
                                                        
| 105 | 104 | $val = $row->$rowkey;  | 
                                                        
| 106 | 105 | }  | 
                                                        
| 107 | - }  | 
                                                        |
| 108 | - else  | 
                                                        |
| 106 | + } else  | 
                                                        |
| 109 | 107 |  							{ | 
                                                        
| 110 | 108 | $val = $row->$rowkey;  | 
                                                        
| 111 | 109 | }  | 
                                                        
@@ -114,8 +112,7 @@ discard block  | 
                                                    ||
| 114 | 112 | if ($row->$rowkey == null)  | 
                                                        
| 115 | 113 |  							{ | 
                                                        
| 116 | 114 | $val = $row->host_group_name;  | 
                                                        
| 117 | - }  | 
                                                        |
| 118 | - else  | 
                                                        |
| 115 | + } else  | 
                                                        |
| 119 | 116 |  							{ | 
                                                        
| 120 | 117 | $val = $row->$rowkey;  | 
                                                        
| 121 | 118 | }  |