@@ -131,9 +131,11 @@ discard block |
||
| 131 | 131 | $this->icingaAPI = new Icinga2API($host,$port); |
| 132 | 132 | $this->icingaAPI->setCredentials($user, $pass); |
| 133 | 133 | list($ret,$message) = $this->icingaAPI->test($this->getModuleConfig()->getapiUserPermissions()); |
| 134 | - if ($ret === TRUE) // On error, switch to ido DB |
|
| 134 | + if ($ret === TRUE) { |
|
| 135 | + // On error, switch to ido DB |
|
| 135 | 136 | { |
| 136 | 137 | $this->apiMode = FALSE; |
| 138 | + } |
|
| 137 | 139 | return $this->getUIDatabase(); |
| 138 | 140 | } |
| 139 | 141 | $this->apiMode = TRUE; |
@@ -213,7 +215,9 @@ discard block |
||
| 213 | 215 | if ($this->MIBData == null) |
| 214 | 216 | { |
| 215 | 217 | $dbConn = $this->getUIDatabase()->getDbConn(); |
| 216 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 218 | + if ($dbConn === null) { |
|
| 219 | + throw new \ErrorException('uncatched db error'); |
|
| 220 | + } |
|
| 217 | 221 | $this->MIBData=new MIBLoader( |
| 218 | 222 | $this->Config()->get('config', 'snmptranslate'), |
| 219 | 223 | $this->Config()->get('config', 'snmptranslate_dirs'), |
@@ -283,7 +287,9 @@ discard block |
||
| 283 | 287 | $catString=''; |
| 284 | 288 | foreach ($catArray as $index => $value) |
| 285 | 289 | { |
| 286 | - if ($catString != '' ) $catString .= '!'; |
|
| 290 | + if ($catString != '' ) { |
|
| 291 | + $catString .= '!'; |
|
| 292 | + } |
|
| 287 | 293 | $catString .= $index . ':' . $value; |
| 288 | 294 | } |
| 289 | 295 | $this->getUIDatabase()->setDBConfigValue('handler_categories', $catString); |
@@ -293,8 +299,12 @@ discard block |
||
| 293 | 299 | { |
| 294 | 300 | $catArray = $this->getHandlersCategory(); |
| 295 | 301 | $i=1; |
| 296 | - while (isset($catArray[$i]) && $i < 100) $i++; |
|
| 297 | - if ($i == 100) throw new ProgrammingError('Category array error'); |
|
| 302 | + while (isset($catArray[$i]) && $i < 100) { |
|
| 303 | + $i++; |
|
| 304 | + } |
|
| 305 | + if ($i == 100) { |
|
| 306 | + throw new ProgrammingError('Category array error'); |
|
| 307 | + } |
|
| 298 | 308 | $catArray[$i] = $catName; |
| 299 | 309 | $this->setHandlerCategory($catArray); |
| 300 | 310 | } |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | /** Get instance of TrapModuleConfig class |
| 52 | - * @return TrapModuleConfig |
|
| 53 | - */ |
|
| 52 | + * @return TrapModuleConfig |
|
| 53 | + */ |
|
| 54 | 54 | public function getModuleConfig() |
| 55 | 55 | { |
| 56 | 56 | if ($this->moduleConfig == Null) |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function getTrapHostListTable() |
| 84 | 84 | { |
| 85 | - if ($this->trapTableHostList == Null) |
|
| 85 | + if ($this->trapTableHostList == Null) |
|
| 86 | 86 | { |
| 87 | - $this->trapTableHostList = new TrapTableHostList(); |
|
| 88 | - $this->trapTableHostList->setConfig($this->getModuleConfig()); |
|
| 89 | - } |
|
| 90 | - return $this->trapTableHostList; |
|
| 87 | + $this->trapTableHostList = new TrapTableHostList(); |
|
| 88 | + $this->trapTableHostList->setConfig($this->getModuleConfig()); |
|
| 89 | + } |
|
| 90 | + return $this->trapTableHostList; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function getUIDatabase() |
| 110 | 110 | { |
| 111 | - if ($this->UIDatabase == Null) |
|
| 112 | - { |
|
| 113 | - $this->UIDatabase = new UIDatabase($this); |
|
| 111 | + if ($this->UIDatabase == Null) |
|
| 112 | + { |
|
| 113 | + $this->UIDatabase = new UIDatabase($this); |
|
| 114 | 114 | |
| 115 | - } |
|
| 116 | - return $this->UIDatabase; |
|
| 115 | + } |
|
| 116 | + return $this->UIDatabase; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -122,41 +122,41 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function getIdoConn() |
| 124 | 124 | { |
| 125 | - if ($this->icingaAPI === NULL) |
|
| 126 | - { |
|
| 127 | - $host = $this->Config()->get('config', 'icingaAPI_host'); |
|
| 128 | - if ($host == '') |
|
| 129 | - { |
|
| 130 | - $this->apiMode = FALSE; |
|
| 131 | - return $this->getUIDatabase(); |
|
| 132 | - } |
|
| 133 | - $port = $this->Config()->get('config', 'icingaAPI_port'); |
|
| 134 | - $user = $this->Config()->get('config', 'icingaAPI_user'); |
|
| 135 | - $pass = $this->Config()->get('config', 'icingaAPI_password'); |
|
| 136 | - $this->icingaAPI = new Icinga2API($host,$port); |
|
| 137 | - $this->icingaAPI->setCredentials($user, $pass); |
|
| 138 | - list($ret,$message) = $this->icingaAPI->test($this->getModuleConfig()->getapiUserPermissions()); |
|
| 139 | - if ($ret === TRUE) // On error, switch to ido DB |
|
| 140 | - { |
|
| 141 | - $this->apiMode = FALSE; |
|
| 142 | - return $this->getUIDatabase(); |
|
| 143 | - } |
|
| 144 | - $this->apiMode = TRUE; |
|
| 125 | + if ($this->icingaAPI === NULL) |
|
| 126 | + { |
|
| 127 | + $host = $this->Config()->get('config', 'icingaAPI_host'); |
|
| 128 | + if ($host == '') |
|
| 129 | + { |
|
| 130 | + $this->apiMode = FALSE; |
|
| 131 | + return $this->getUIDatabase(); |
|
| 132 | + } |
|
| 133 | + $port = $this->Config()->get('config', 'icingaAPI_port'); |
|
| 134 | + $user = $this->Config()->get('config', 'icingaAPI_user'); |
|
| 135 | + $pass = $this->Config()->get('config', 'icingaAPI_password'); |
|
| 136 | + $this->icingaAPI = new Icinga2API($host,$port); |
|
| 137 | + $this->icingaAPI->setCredentials($user, $pass); |
|
| 138 | + list($ret,$message) = $this->icingaAPI->test($this->getModuleConfig()->getapiUserPermissions()); |
|
| 139 | + if ($ret === TRUE) // On error, switch to ido DB |
|
| 140 | + { |
|
| 141 | + $this->apiMode = FALSE; |
|
| 142 | + return $this->getUIDatabase(); |
|
| 143 | + } |
|
| 144 | + $this->apiMode = TRUE; |
|
| 145 | 145 | |
| 146 | - } |
|
| 147 | - return $this->icingaAPI; |
|
| 146 | + } |
|
| 147 | + return $this->icingaAPI; |
|
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null) |
|
| 152 | - { |
|
| 153 | - $limit = $this->params->get('limit', $limit); |
|
| 154 | - $page = $this->params->get('page', $offset); |
|
| 151 | + protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null) |
|
| 152 | + { |
|
| 153 | + $limit = $this->params->get('limit', $limit); |
|
| 154 | + $page = $this->params->get('page', $offset); |
|
| 155 | 155 | |
| 156 | - $paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0); |
|
| 156 | + $paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0); |
|
| 157 | 157 | |
| 158 | - return $paginatable; |
|
| 159 | - } |
|
| 158 | + return $paginatable; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | 161 | public function displayExitError($source,$message) |
| 162 | 162 | { // TODO : check better ways to transmit data (with POST ?) |
@@ -165,33 +165,33 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | protected function checkReadPermission() |
| 167 | 167 | { |
| 168 | - if (! $this->Auth()->hasPermission('trapdirector/view')) { |
|
| 169 | - $this->displayExitError('Permissions','No permission fo view content'); |
|
| 170 | - } |
|
| 168 | + if (! $this->Auth()->hasPermission('trapdirector/view')) { |
|
| 169 | + $this->displayExitError('Permissions','No permission fo view content'); |
|
| 170 | + } |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | protected function checkConfigPermission() |
| 174 | 174 | { |
| 175 | - if (! $this->Auth()->hasPermission('trapdirector/config')) { |
|
| 176 | - $this->displayExitError('Permissions','No permission fo configure'); |
|
| 177 | - } |
|
| 175 | + if (! $this->Auth()->hasPermission('trapdirector/config')) { |
|
| 176 | + $this->displayExitError('Permissions','No permission fo configure'); |
|
| 177 | + } |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Check if user has write permission |
|
| 182 | - * @param number $check optional : if set to 1, return true (user has permission) or false instead of displaying error page |
|
| 183 | - * @return boolean : user has permission |
|
| 184 | - */ |
|
| 180 | + /** |
|
| 181 | + * Check if user has write permission |
|
| 182 | + * @param number $check optional : if set to 1, return true (user has permission) or false instead of displaying error page |
|
| 183 | + * @return boolean : user has permission |
|
| 184 | + */ |
|
| 185 | 185 | protected function checkModuleConfigPermission($check=0) |
| 186 | 186 | { |
| 187 | - if (! $this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 188 | - if ($check == 0) |
|
| 189 | - { |
|
| 190 | - $this->displayExitError('Permissions','No permission fo configure module'); |
|
| 191 | - } |
|
| 192 | - return false; |
|
| 193 | - } |
|
| 194 | - return true; |
|
| 187 | + if (! $this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 188 | + if ($check == 0) |
|
| 189 | + { |
|
| 190 | + $this->displayExitError('Permissions','No permission fo configure module'); |
|
| 191 | + } |
|
| 192 | + return false; |
|
| 193 | + } |
|
| 194 | + return true; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /************************* Trap class get **********************/ |
@@ -211,18 +211,18 @@ discard block |
||
| 211 | 211 | /************************** MIB related **************************/ |
| 212 | 212 | |
| 213 | 213 | /** Get MIBLoader class |
| 214 | - * @return MIBLoader class |
|
| 215 | - */ |
|
| 214 | + * @return MIBLoader class |
|
| 215 | + */ |
|
| 216 | 216 | protected function getMIB() |
| 217 | 217 | { |
| 218 | 218 | if ($this->MIBData == null) |
| 219 | 219 | { |
| 220 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 221 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 220 | + $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 221 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 222 | 222 | $this->MIBData=new MIBLoader( |
| 223 | 223 | $this->Config()->get('config', 'snmptranslate'), |
| 224 | 224 | $this->Config()->get('config', 'snmptranslate_dirs'), |
| 225 | - $dbConn, |
|
| 225 | + $dbConn, |
|
| 226 | 226 | $this->getModuleConfig() |
| 227 | 227 | ); |
| 228 | 228 | } |
@@ -232,13 +232,13 @@ discard block |
||
| 232 | 232 | /************************** Database queries *******************/ |
| 233 | 233 | |
| 234 | 234 | /** Check if director is installed |
| 235 | - * @return bool true/false |
|
| 236 | - */ |
|
| 235 | + * @return bool true/false |
|
| 236 | + */ |
|
| 237 | 237 | protected function isDirectorInstalled() |
| 238 | 238 | { |
| 239 | - $output=array(); |
|
| 240 | - exec('icingacli module list',$output); |
|
| 241 | - foreach ($output as $line) |
|
| 239 | + $output=array(); |
|
| 240 | + exec('icingacli module list',$output); |
|
| 241 | + foreach ($output as $line) |
|
| 242 | 242 | { |
| 243 | 243 | if (preg_match('/^director .*enabled/',$line)) |
| 244 | 244 | { |
@@ -251,72 +251,72 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | /************************ UI elements **************************/ |
| 253 | 253 | |
| 254 | - /** |
|
| 255 | - * get max rows to display before paging. |
|
| 256 | - * @return number |
|
| 257 | - */ |
|
| 254 | + /** |
|
| 255 | + * get max rows to display before paging. |
|
| 256 | + * @return number |
|
| 257 | + */ |
|
| 258 | 258 | public function itemListDisplay() |
| 259 | 259 | { |
| 260 | - return $this->getUIDatabase()->getDBConfigValue('max_rows_in_list'); |
|
| 260 | + return $this->getUIDatabase()->getDBConfigValue('max_rows_in_list'); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | public function setitemListDisplay(int $maxRows) |
| 264 | 264 | { |
| 265 | - return $this->getUIDatabase()->setDBConfigValue('max_rows_in_list',$maxRows); |
|
| 265 | + return $this->getUIDatabase()->setDBConfigValue('max_rows_in_list',$maxRows); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * get Handlers categories list (index => textvalue). |
|
| 270 | - * @return array |
|
| 271 | - */ |
|
| 268 | + /** |
|
| 269 | + * get Handlers categories list (index => textvalue). |
|
| 270 | + * @return array |
|
| 271 | + */ |
|
| 272 | 272 | public function getHandlersCategory() |
| 273 | 273 | { |
| 274 | - //<index>:<name>!<index>:<name> |
|
| 275 | - $catList = $this->getUIDatabase()->getDBConfigValue('handler_categories'); |
|
| 276 | - $catListArray=explode('!',$catList); |
|
| 277 | - $retArray=array(); |
|
| 278 | - foreach ($catListArray as $category) |
|
| 279 | - { |
|
| 280 | - $catArray=explode(':',$category); |
|
| 281 | - $retArray[$catArray[0]] = $catArray[1]; |
|
| 282 | - } |
|
| 283 | - return $retArray; |
|
| 274 | + //<index>:<name>!<index>:<name> |
|
| 275 | + $catList = $this->getUIDatabase()->getDBConfigValue('handler_categories'); |
|
| 276 | + $catListArray=explode('!',$catList); |
|
| 277 | + $retArray=array(); |
|
| 278 | + foreach ($catListArray as $category) |
|
| 279 | + { |
|
| 280 | + $catArray=explode(':',$category); |
|
| 281 | + $retArray[$catArray[0]] = $catArray[1]; |
|
| 282 | + } |
|
| 283 | + return $retArray; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | public function setHandlerCategory(array $catArray) |
| 287 | 287 | { |
| 288 | - $catString=''; |
|
| 289 | - foreach ($catArray as $index => $value) |
|
| 290 | - { |
|
| 291 | - if ($catString != '' ) $catString .= '!'; |
|
| 292 | - $catString .= $index . ':' . $value; |
|
| 293 | - } |
|
| 294 | - $this->getUIDatabase()->setDBConfigValue('handler_categories', $catString); |
|
| 288 | + $catString=''; |
|
| 289 | + foreach ($catArray as $index => $value) |
|
| 290 | + { |
|
| 291 | + if ($catString != '' ) $catString .= '!'; |
|
| 292 | + $catString .= $index . ':' . $value; |
|
| 293 | + } |
|
| 294 | + $this->getUIDatabase()->setDBConfigValue('handler_categories', $catString); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | public function addHandlersCategory(string $catName) |
| 298 | 298 | { |
| 299 | - $catArray = $this->getHandlersCategory(); |
|
| 300 | - $i=1; |
|
| 301 | - while (isset($catArray[$i]) && $i < 100) $i++; |
|
| 302 | - if ($i == 100) throw new ProgrammingError('Category array error'); |
|
| 303 | - $catArray[$i] = $catName; |
|
| 304 | - $this->setHandlerCategory($catArray); |
|
| 299 | + $catArray = $this->getHandlersCategory(); |
|
| 300 | + $i=1; |
|
| 301 | + while (isset($catArray[$i]) && $i < 100) $i++; |
|
| 302 | + if ($i == 100) throw new ProgrammingError('Category array error'); |
|
| 303 | + $catArray[$i] = $catName; |
|
| 304 | + $this->setHandlerCategory($catArray); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | public function delHandlersCategory(int $catIndex) |
| 308 | 308 | { |
| 309 | - $catArray = $this->getHandlersCategory(); |
|
| 310 | - unset($catArray[$catIndex]); |
|
| 311 | - $this->setHandlerCategory($catArray); |
|
| 312 | - $this->getUIDatabase()->updateHandlersOnCategoryDelete($catIndex); |
|
| 309 | + $catArray = $this->getHandlersCategory(); |
|
| 310 | + unset($catArray[$catIndex]); |
|
| 311 | + $this->setHandlerCategory($catArray); |
|
| 312 | + $this->getUIDatabase()->updateHandlersOnCategoryDelete($catIndex); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | public function renameHandlersCategory(int $catIndex, string $catName) |
| 316 | 316 | { |
| 317 | - $catArray = $this->getHandlersCategory(); |
|
| 318 | - $catArray[$catIndex] = $catName; |
|
| 319 | - $this->setHandlerCategory($catArray); |
|
| 317 | + $catArray = $this->getHandlersCategory(); |
|
| 318 | + $catArray[$catIndex] = $catName; |
|
| 319 | + $this->setHandlerCategory($catArray); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | } |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | /** @var Trap $trapClass Trap class for bin/trap_class.php */ |
| 40 | 40 | protected $trapClass; |
| 41 | 41 | /** @var UIDatabase $UIDatabase */ |
| 42 | - protected $UIDatabase = NULL; |
|
| 42 | + protected $UIDatabase=NULL; |
|
| 43 | 43 | /** @var Icinga2API $IcingaAPI */ |
| 44 | - protected $icingaAPI = NULL; |
|
| 44 | + protected $icingaAPI=NULL; |
|
| 45 | 45 | /** @var bool $apiMode connection to icinngaDB is by api (true) od ido DB (false) */ |
| 46 | - protected $apiMode = FALSE; |
|
| 46 | + protected $apiMode=FALSE; |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $this->redirectNow('trapdirector/settings?message=No database prefix'); |
| 62 | 62 | } |
| 63 | - $this->moduleConfig = new TrapModuleConfig($db_prefix); |
|
| 63 | + $this->moduleConfig=new TrapModuleConfig($db_prefix); |
|
| 64 | 64 | } |
| 65 | 65 | return $this->moduleConfig; |
| 66 | 66 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function getTrapListTable() { |
| 73 | 73 | if ($this->trapTableList == Null) { |
| 74 | - $this->trapTableList = new TrapTableList(); |
|
| 74 | + $this->trapTableList=new TrapTableList(); |
|
| 75 | 75 | $this->trapTableList->setConfig($this->getModuleConfig()); |
| 76 | 76 | } |
| 77 | 77 | return $this->trapTableList; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | if ($this->trapTableHostList == Null) |
| 86 | 86 | { |
| 87 | - $this->trapTableHostList = new TrapTableHostList(); |
|
| 87 | + $this->trapTableHostList=new TrapTableHostList(); |
|
| 88 | 88 | $this->trapTableHostList->setConfig($this->getModuleConfig()); |
| 89 | 89 | } |
| 90 | 90 | return $this->trapTableHostList; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | if ($this->handlerTableList == Null) |
| 99 | 99 | { |
| 100 | - $this->handlerTableList = new HandlerTableList(); |
|
| 100 | + $this->handlerTableList=new HandlerTableList(); |
|
| 101 | 101 | $this->handlerTableList->setConfig($this->getModuleConfig()); |
| 102 | 102 | } |
| 103 | 103 | return $this->handlerTableList; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | if ($this->UIDatabase == Null) |
| 112 | 112 | { |
| 113 | - $this->UIDatabase = new UIDatabase($this); |
|
| 113 | + $this->UIDatabase=new UIDatabase($this); |
|
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | return $this->UIDatabase; |
@@ -124,56 +124,56 @@ discard block |
||
| 124 | 124 | { |
| 125 | 125 | if ($this->icingaAPI === NULL) |
| 126 | 126 | { |
| 127 | - $host = $this->Config()->get('config', 'icingaAPI_host'); |
|
| 127 | + $host=$this->Config()->get('config', 'icingaAPI_host'); |
|
| 128 | 128 | if ($host == '') |
| 129 | 129 | { |
| 130 | - $this->apiMode = FALSE; |
|
| 130 | + $this->apiMode=FALSE; |
|
| 131 | 131 | return $this->getUIDatabase(); |
| 132 | 132 | } |
| 133 | - $port = $this->Config()->get('config', 'icingaAPI_port'); |
|
| 134 | - $user = $this->Config()->get('config', 'icingaAPI_user'); |
|
| 135 | - $pass = $this->Config()->get('config', 'icingaAPI_password'); |
|
| 136 | - $this->icingaAPI = new Icinga2API($host,$port); |
|
| 133 | + $port=$this->Config()->get('config', 'icingaAPI_port'); |
|
| 134 | + $user=$this->Config()->get('config', 'icingaAPI_user'); |
|
| 135 | + $pass=$this->Config()->get('config', 'icingaAPI_password'); |
|
| 136 | + $this->icingaAPI=new Icinga2API($host, $port); |
|
| 137 | 137 | $this->icingaAPI->setCredentials($user, $pass); |
| 138 | - list($ret,$message) = $this->icingaAPI->test($this->getModuleConfig()->getapiUserPermissions()); |
|
| 138 | + list($ret, $message)=$this->icingaAPI->test($this->getModuleConfig()->getapiUserPermissions()); |
|
| 139 | 139 | if ($ret === TRUE) // On error, switch to ido DB |
| 140 | 140 | { |
| 141 | - $this->apiMode = FALSE; |
|
| 141 | + $this->apiMode=FALSE; |
|
| 142 | 142 | return $this->getUIDatabase(); |
| 143 | 143 | } |
| 144 | - $this->apiMode = TRUE; |
|
| 144 | + $this->apiMode=TRUE; |
|
| 145 | 145 | |
| 146 | 146 | } |
| 147 | 147 | return $this->icingaAPI; |
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null) |
|
| 151 | + protected function applyPaginationLimits(Paginatable $paginatable, $limit=25, $offset=null) |
|
| 152 | 152 | { |
| 153 | - $limit = $this->params->get('limit', $limit); |
|
| 154 | - $page = $this->params->get('page', $offset); |
|
| 153 | + $limit=$this->params->get('limit', $limit); |
|
| 154 | + $page=$this->params->get('page', $offset); |
|
| 155 | 155 | |
| 156 | 156 | $paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0); |
| 157 | 157 | |
| 158 | 158 | return $paginatable; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function displayExitError($source,$message) |
|
| 161 | + public function displayExitError($source, $message) |
|
| 162 | 162 | { // TODO : check better ways to transmit data (with POST ?) |
| 163 | 163 | $this->redirectNow('trapdirector/error?source='.$source.'&message='.$message); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | protected function checkReadPermission() |
| 167 | 167 | { |
| 168 | - if (! $this->Auth()->hasPermission('trapdirector/view')) { |
|
| 169 | - $this->displayExitError('Permissions','No permission fo view content'); |
|
| 168 | + if (!$this->Auth()->hasPermission('trapdirector/view')) { |
|
| 169 | + $this->displayExitError('Permissions', 'No permission fo view content'); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | protected function checkConfigPermission() |
| 174 | 174 | { |
| 175 | - if (! $this->Auth()->hasPermission('trapdirector/config')) { |
|
| 176 | - $this->displayExitError('Permissions','No permission fo configure'); |
|
| 175 | + if (!$this->Auth()->hasPermission('trapdirector/config')) { |
|
| 176 | + $this->displayExitError('Permissions', 'No permission fo configure'); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
@@ -184,10 +184,10 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function checkModuleConfigPermission($check=0) |
| 186 | 186 | { |
| 187 | - if (! $this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 187 | + if (!$this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 188 | 188 | if ($check == 0) |
| 189 | 189 | { |
| 190 | - $this->displayExitError('Permissions','No permission fo configure module'); |
|
| 190 | + $this->displayExitError('Permissions', 'No permission fo configure module'); |
|
| 191 | 191 | } |
| 192 | 192 | return false; |
| 193 | 193 | } |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | { // TODO : try/catch here ? or within caller |
| 200 | 200 | if ($this->trapClass == null) |
| 201 | 201 | { |
| 202 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 202 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 203 | 203 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 204 | 204 | //$debug_level=4; |
| 205 | - $this->trapClass = new Trap($icingaweb2_etc); |
|
| 205 | + $this->trapClass=new Trap($icingaweb2_etc); |
|
| 206 | 206 | //$Trap->setLogging($debug_level,'syslog'); |
| 207 | 207 | } |
| 208 | 208 | return $this->trapClass; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | if ($this->MIBData == null) |
| 219 | 219 | { |
| 220 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 220 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 221 | 221 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 222 | 222 | $this->MIBData=new MIBLoader( |
| 223 | 223 | $this->Config()->get('config', 'snmptranslate'), |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | protected function isDirectorInstalled() |
| 238 | 238 | { |
| 239 | 239 | $output=array(); |
| 240 | - exec('icingacli module list',$output); |
|
| 240 | + exec('icingacli module list', $output); |
|
| 241 | 241 | foreach ($output as $line) |
| 242 | 242 | { |
| 243 | - if (preg_match('/^director .*enabled/',$line)) |
|
| 243 | + if (preg_match('/^director .*enabled/', $line)) |
|
| 244 | 244 | { |
| 245 | 245 | return true; |
| 246 | 246 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | public function setitemListDisplay(int $maxRows) |
| 264 | 264 | { |
| 265 | - return $this->getUIDatabase()->setDBConfigValue('max_rows_in_list',$maxRows); |
|
| 265 | + return $this->getUIDatabase()->setDBConfigValue('max_rows_in_list', $maxRows); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | public function getHandlersCategory() |
| 273 | 273 | { |
| 274 | 274 | //<index>:<name>!<index>:<name> |
| 275 | - $catList = $this->getUIDatabase()->getDBConfigValue('handler_categories'); |
|
| 276 | - $catListArray=explode('!',$catList); |
|
| 275 | + $catList=$this->getUIDatabase()->getDBConfigValue('handler_categories'); |
|
| 276 | + $catListArray=explode('!', $catList); |
|
| 277 | 277 | $retArray=array(); |
| 278 | 278 | foreach ($catListArray as $category) |
| 279 | 279 | { |
| 280 | - $catArray=explode(':',$category); |
|
| 281 | - $retArray[$catArray[0]] = $catArray[1]; |
|
| 280 | + $catArray=explode(':', $category); |
|
| 281 | + $retArray[$catArray[0]]=$catArray[1]; |
|
| 282 | 282 | } |
| 283 | 283 | return $retArray; |
| 284 | 284 | } |
@@ -288,25 +288,25 @@ discard block |
||
| 288 | 288 | $catString=''; |
| 289 | 289 | foreach ($catArray as $index => $value) |
| 290 | 290 | { |
| 291 | - if ($catString != '' ) $catString .= '!'; |
|
| 292 | - $catString .= $index . ':' . $value; |
|
| 291 | + if ($catString != '') $catString.='!'; |
|
| 292 | + $catString.=$index.':'.$value; |
|
| 293 | 293 | } |
| 294 | 294 | $this->getUIDatabase()->setDBConfigValue('handler_categories', $catString); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | public function addHandlersCategory(string $catName) |
| 298 | 298 | { |
| 299 | - $catArray = $this->getHandlersCategory(); |
|
| 299 | + $catArray=$this->getHandlersCategory(); |
|
| 300 | 300 | $i=1; |
| 301 | 301 | while (isset($catArray[$i]) && $i < 100) $i++; |
| 302 | 302 | if ($i == 100) throw new ProgrammingError('Category array error'); |
| 303 | - $catArray[$i] = $catName; |
|
| 303 | + $catArray[$i]=$catName; |
|
| 304 | 304 | $this->setHandlerCategory($catArray); |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | public function delHandlersCategory(int $catIndex) |
| 308 | 308 | { |
| 309 | - $catArray = $this->getHandlersCategory(); |
|
| 309 | + $catArray=$this->getHandlersCategory(); |
|
| 310 | 310 | unset($catArray[$catIndex]); |
| 311 | 311 | $this->setHandlerCategory($catArray); |
| 312 | 312 | $this->getUIDatabase()->updateHandlersOnCategoryDelete($catIndex); |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | public function renameHandlersCategory(int $catIndex, string $catName) |
| 316 | 316 | { |
| 317 | - $catArray = $this->getHandlersCategory(); |
|
| 318 | - $catArray[$catIndex] = $catName; |
|
| 317 | + $catArray=$this->getHandlersCategory(); |
|
| 318 | + $catArray[$catIndex]=$catName; |
|
| 319 | 319 | $this->setHandlerCategory($catArray); |
| 320 | 320 | } |
| 321 | 321 | |