@@ -373,12 +373,12 @@ |
||
| 373 | 373 | |
| 374 | 374 | // We now need one more iteration to add core classes to the panels added via the merge, if needed |
| 375 | 375 | array_walk($this->panels, function(&$value, $key) { |
| 376 | - if (!isset($value['class'])) { |
|
| 377 | - if (isset($this->_corePanels[$key])) |
|
| 378 | - $value = ArrayHelper::merge($value, $this->_corePanels[$key]); |
|
| 379 | - else |
|
| 380 | - throw new InvalidConfigException("Invalid configuration for '$key'. No 'class' specified."); |
|
| 381 | - } |
|
| 376 | + if (!isset($value['class'])) { |
|
| 377 | + if (isset($this->_corePanels[$key])) |
|
| 378 | + $value = ArrayHelper::merge($value, $this->_corePanels[$key]); |
|
| 379 | + else |
|
| 380 | + throw new InvalidConfigException("Invalid configuration for '$key'. No 'class' specified."); |
|
| 381 | + } |
|
| 382 | 382 | }); |
| 383 | 383 | } |
| 384 | 384 | |
@@ -239,8 +239,9 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | public function registerFunction($name, $callback) |
| 241 | 241 | { |
| 242 | - if (isset($this->_panelFunctions[$name])) |
|
| 243 | - throw new InvalidParamException("The '$name'-function has already been defined."); |
|
| 242 | + if (isset($this->_panelFunctions[$name])) { |
|
| 243 | + throw new InvalidParamException("The '$name'-function has already been defined."); |
|
| 244 | + } |
|
| 244 | 245 | |
| 245 | 246 | $this->_panelFunctions[$name] = $callback; |
| 246 | 247 | } |
@@ -260,8 +261,9 @@ discard block |
||
| 260 | 261 | */ |
| 261 | 262 | public function __call($name, $params) |
| 262 | 263 | { |
| 263 | - if (!isset($this->_panelFunctions[$name])) |
|
| 264 | - throw new \yii\base\InvalidCallException("Unknown panel function '$name'"); |
|
| 264 | + if (!isset($this->_panelFunctions[$name])) { |
|
| 265 | + throw new \yii\base\InvalidCallException("Unknown panel function '$name'"); |
|
| 266 | + } |
|
| 265 | 267 | |
| 266 | 268 | return call_user_func_array($this->_panelFunctions[$name], $params); |
| 267 | 269 | } |
@@ -333,13 +335,15 @@ discard block |
||
| 333 | 335 | public function getPanel($identifier) |
| 334 | 336 | { |
| 335 | 337 | $config = null; |
| 336 | - if (isset($this->panels[$identifier])) |
|
| 337 | - $config = $this->panels[$identifier]; |
|
| 338 | - elseif (isset($this->_corePanels[$identifier])) |
|
| 339 | - $config = $this->_corePanels[$identifier]; |
|
| 338 | + if (isset($this->panels[$identifier])) { |
|
| 339 | + $config = $this->panels[$identifier]; |
|
| 340 | + } elseif (isset($this->_corePanels[$identifier])) { |
|
| 341 | + $config = $this->_corePanels[$identifier]; |
|
| 342 | + } |
|
| 340 | 343 | |
| 341 | - if (!$config) |
|
| 342 | - throw new InvalidConfigException("'$identifier' is not a valid panel identifier"); |
|
| 344 | + if (!$config) { |
|
| 345 | + throw new InvalidConfigException("'$identifier' is not a valid panel identifier"); |
|
| 346 | + } |
|
| 343 | 347 | |
| 344 | 348 | if (is_array($config)) { |
| 345 | 349 | $config['module'] = $this; |
@@ -360,11 +364,11 @@ discard block |
||
| 360 | 364 | foreach ($this->panels as $key => $value) { |
| 361 | 365 | if (is_numeric($key)) { |
| 362 | 366 | // The $value contains the identifier of a core panel |
| 363 | - if (!isset($this->_corePanels[$value])) |
|
| 364 | - throw new InvalidConfigException("'$value' is not a valid panel identifier"); |
|
| 367 | + if (!isset($this->_corePanels[$value])) { |
|
| 368 | + throw new InvalidConfigException("'$value' is not a valid panel identifier"); |
|
| 369 | + } |
|
| 365 | 370 | $panels[$value] = $this->_corePanels[$value]; |
| 366 | - } |
|
| 367 | - else { |
|
| 371 | + } else { |
|
| 368 | 372 | // The key contains the identifier and the value is either a class name or a full array |
| 369 | 373 | $panels[$key] = is_string($value) ? ['class' => $value] : $value; |
| 370 | 374 | } |
@@ -374,10 +378,11 @@ discard block |
||
| 374 | 378 | // We now need one more iteration to add core classes to the panels added via the merge, if needed |
| 375 | 379 | array_walk($this->panels, function(&$value, $key) { |
| 376 | 380 | if (!isset($value['class'])) { |
| 377 | - if (isset($this->_corePanels[$key])) |
|
| 378 | - $value = ArrayHelper::merge($value, $this->_corePanels[$key]); |
|
| 379 | - else |
|
| 380 | - throw new InvalidConfigException("Invalid configuration for '$key'. No 'class' specified."); |
|
| 381 | + if (isset($this->_corePanels[$key])) { |
|
| 382 | + $value = ArrayHelper::merge($value, $this->_corePanels[$key]); |
|
| 383 | + } else { |
|
| 384 | + throw new InvalidConfigException("Invalid configuration for '$key'. No 'class' specified."); |
|
| 385 | + } |
|
| 381 | 386 | } |
| 382 | 387 | }); |
| 383 | 388 | } |
@@ -389,18 +394,21 @@ discard block |
||
| 389 | 394 | { |
| 390 | 395 | foreach (Yii::$app->modules as $name => $module) { |
| 391 | 396 | $class = null; |
| 392 | - if (is_string($module)) |
|
| 393 | - $class = $module; |
|
| 394 | - elseif (is_array($module)) { |
|
| 395 | - if (isset($module['class'])) |
|
| 396 | - $class = $module['class']; |
|
| 397 | - } else |
|
| 398 | - /** @var Module $module */ |
|
| 397 | + if (is_string($module)) { |
|
| 398 | + $class = $module; |
|
| 399 | + } elseif (is_array($module)) { |
|
| 400 | + if (isset($module['class'])) { |
|
| 401 | + $class = $module['class']; |
|
| 402 | + } |
|
| 403 | + } else { |
|
| 404 | + /** @var Module $module */ |
|
| 399 | 405 | $class = $module::className(); |
| 406 | + } |
|
| 400 | 407 | |
| 401 | 408 | $parts = explode('\\', $class); |
| 402 | - if ($class && strtolower(end($parts)) == 'audit') |
|
| 403 | - return $name; |
|
| 409 | + if ($class && strtolower(end($parts)) == 'audit') { |
|
| 410 | + return $name; |
|
| 411 | + } |
|
| 404 | 412 | } |
| 405 | 413 | return null; |
| 406 | 414 | } |
@@ -436,18 +444,21 @@ discard block |
||
| 436 | 444 | $len = strlen($compare); |
| 437 | 445 | if ($compare[$len - 1] == '*') { |
| 438 | 446 | $compare = rtrim($compare, '*'); |
| 439 | - if (substr($route, 0, $len - 1) === $compare) |
|
| 440 | - return true; |
|
| 447 | + if (substr($route, 0, $len - 1) === $compare) { |
|
| 448 | + return true; |
|
| 449 | + } |
|
| 441 | 450 | } |
| 442 | 451 | |
| 443 | 452 | if ($compare[0] == '*') { |
| 444 | 453 | $compare = ltrim($compare, '*'); |
| 445 | - if (substr($route, - ($len - 1)) === $compare) |
|
| 446 | - return true; |
|
| 454 | + if (substr($route, - ($len - 1)) === $compare) { |
|
| 455 | + return true; |
|
| 456 | + } |
|
| 447 | 457 | } |
| 448 | 458 | |
| 449 | - if ($route === $compare) |
|
| 450 | - return true; |
|
| 459 | + if ($route === $compare) { |
|
| 460 | + return true; |
|
| 461 | + } |
|
| 451 | 462 | } |
| 452 | 463 | return false; |
| 453 | 464 | } |
@@ -36,13 +36,15 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function export() |
| 38 | 38 | { |
| 39 | - if (!\Yii::$app) |
|
| 40 | - // Things like this can happen in tests etc, but it is too late for us to do anything about that. |
|
| 39 | + if (!\Yii::$app) { |
|
| 40 | + // Things like this can happen in tests etc, but it is too late for us to do anything about that. |
|
| 41 | 41 | return; |
| 42 | + } |
|
| 42 | 43 | |
| 43 | 44 | $module = $this->module; |
| 44 | - if (!$module->entry || empty($module->panels)) |
|
| 45 | - return; |
|
| 45 | + if (!$module->entry || empty($module->panels)) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 46 | 48 | |
| 47 | 49 | $entry = $module->entry; |
| 48 | 50 | |
@@ -53,11 +55,12 @@ discard block |
||
| 53 | 55 | $records = array_filter($records); |
| 54 | 56 | |
| 55 | 57 | if (!empty($records)) { |
| 56 | - if ($module->batchSave) |
|
| 57 | - $entry->addBatchData($records, false); |
|
| 58 | - else { |
|
| 59 | - foreach ($records as $type => $record) |
|
| 60 | - $entry->addData($type, $record, false); |
|
| 58 | + if ($module->batchSave) { |
|
| 59 | + $entry->addBatchData($records, false); |
|
| 60 | + } else { |
|
| 61 | + foreach ($records as $type => $record) { |
|
| 62 | + $entry->addData($type, $record, false); |
|
| 63 | + } |
|
| 61 | 64 | } |
| 62 | 65 | } |
| 63 | 66 | $this->messages = []; |
@@ -14,8 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | try { |
| 16 | 16 | parent::__construct($wsdl, $options); |
| 17 | - } |
|
| 18 | - catch (\SoapFault $e) { |
|
| 17 | + } catch (\SoapFault $e) { |
|
| 19 | 18 | // Catches errors like being unable to read the WSDL and so on |
| 20 | 19 | $this->logSoapFault($e); |
| 21 | 20 | throw $e; |
@@ -46,22 +45,24 @@ discard block |
||
| 46 | 45 | try { |
| 47 | 46 | $result = parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers); |
| 48 | 47 | $this->_data['duration'] = microtime(true) - $started; |
| 49 | - if ($output_headers) |
|
| 50 | - $this->_data['output_headers'] = (array) $output_headers; |
|
| 48 | + if ($output_headers) { |
|
| 49 | + $this->_data['output_headers'] = (array) $output_headers; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - if (is_soap_fault($result)) |
|
| 53 | - // Cover non-exception variant |
|
| 52 | + if (is_soap_fault($result)) { |
|
| 53 | + // Cover non-exception variant |
|
| 54 | 54 | return $this->logSoapFault($result); |
| 55 | + } |
|
| 55 | 56 | |
| 56 | 57 | $this->_data['result_object'] = $result; |
| 57 | 58 | $this->finalize(); |
| 58 | 59 | |
| 59 | 60 | return $result; |
| 60 | - } |
|
| 61 | - catch (\Exception $error) { |
|
| 61 | + } catch (\Exception $error) { |
|
| 62 | 62 | $this->_data['duration'] = microtime(true) - $started; |
| 63 | - if ($output_headers) |
|
| 64 | - $this->_data['output_headers'] = (array) $output_headers; |
|
| 63 | + if ($output_headers) { |
|
| 64 | + $this->_data['output_headers'] = (array) $output_headers; |
|
| 65 | + } |
|
| 65 | 66 | |
| 66 | 67 | $this->logSoapFault($error); |
| 67 | 68 | throw $error; |
@@ -82,8 +83,9 @@ discard block |
||
| 82 | 83 | |
| 83 | 84 | public function __setCookie ($name, $value = null) |
| 84 | 85 | { |
| 85 | - if (!isset($this->_data['cookies'])) |
|
| 86 | - $this->_data['cookies'] = []; |
|
| 86 | + if (!isset($this->_data['cookies'])) { |
|
| 87 | + $this->_data['cookies'] = []; |
|
| 88 | + } |
|
| 87 | 89 | $this->_data['cookies'][$name] = $value; |
| 88 | 90 | |
| 89 | 91 | parent::__setCookie($name, $value); |
@@ -99,7 +101,8 @@ discard block |
||
| 99 | 101 | protected function finalize() |
| 100 | 102 | { |
| 101 | 103 | $_panel = Audit::getInstance()->getPanel('audit/soap'); |
| 102 | - if ($_panel) |
|
| 103 | - $_panel->logSoapRequest($this->_data); |
|
| 104 | + if ($_panel) { |
|
| 105 | + $_panel->logSoapRequest($this->_data); |
|
| 106 | + } |
|
| 104 | 107 | } |
| 105 | 108 | } |
| 106 | 109 | \ No newline at end of file |
@@ -37,13 +37,15 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function beforeSave($insert) |
| 39 | 39 | { |
| 40 | - if ($insert && $this->hasAttribute('created')) |
|
| 41 | - $this->created = date('Y-m-d H:i:s'); |
|
| 40 | + if ($insert && $this->hasAttribute('created')) { |
|
| 41 | + $this->created = date('Y-m-d H:i:s'); |
|
| 42 | + } |
|
| 42 | 43 | |
| 43 | - if ($this->autoSerialize) |
|
| 44 | - foreach ($this->serializeAttributes as $attribute) |
|
| 44 | + if ($this->autoSerialize) { |
|
| 45 | + foreach ($this->serializeAttributes as $attribute) |
|
| 45 | 46 | if ($this->hasAttribute($attribute)) |
| 46 | 47 | $this->$attribute = [Helper::serialize($this->$attribute, false), \PDO::PARAM_LOB]; |
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | return parent::beforeSave($insert); |
| 49 | 51 | } |
@@ -56,12 +58,13 @@ discard block |
||
| 56 | 58 | { |
| 57 | 59 | parent::afterSave($insert, $changedAttributes); |
| 58 | 60 | |
| 59 | - if ($this->autoSerialize) |
|
| 60 | - foreach ($this->serializeAttributes as $attribute) |
|
| 61 | + if ($this->autoSerialize) { |
|
| 62 | + foreach ($this->serializeAttributes as $attribute) |
|
| 61 | 63 | if ($this->hasAttribute($attribute)) { |
| 62 | 64 | if (is_array($this->$attribute)) { |
| 63 | 65 | // Get rid of the extra PDO parameter type if needed |
| 64 | 66 | $array = $this->$attribute; |
| 67 | + } |
|
| 65 | 68 | $this->$attribute = $array[0]; |
| 66 | 69 | } |
| 67 | 70 | $this->$attribute = Helper::unserialize($this->$attribute); |
@@ -75,9 +78,10 @@ discard block |
||
| 75 | 78 | { |
| 76 | 79 | parent::afterFind(); |
| 77 | 80 | |
| 78 | - if ($this->autoSerialize) |
|
| 79 | - foreach ($this->serializeAttributes as $attribute) |
|
| 81 | + if ($this->autoSerialize) { |
|
| 82 | + foreach ($this->serializeAttributes as $attribute) |
|
| 80 | 83 | if ($this->hasAttribute($attribute)) |
| 81 | 84 | $this->$attribute = Helper::unserialize($this->$attribute); |
| 85 | + } |
|
| 82 | 86 | } |
| 83 | 87 | } |
| 84 | 88 | \ No newline at end of file |
@@ -101,8 +101,9 @@ |
||
| 101 | 101 | public function cleanup($maxAge = null) |
| 102 | 102 | { |
| 103 | 103 | $maxAge = $maxAge !== null ? $maxAge : $this->maxAge; |
| 104 | - if ($maxAge === null) |
|
| 105 | - return false; |
|
| 104 | + if ($maxAge === null) { |
|
| 105 | + return false; |
|
| 106 | + } |
|
| 106 | 107 | return AuditData::deleteAll('type = :type AND created <= :created', [ |
| 107 | 108 | ':type' => $this->id, |
| 108 | 109 | ':created' => date('Y-m-d 23:59:59', strtotime("-$maxAge days")), |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | public function actionView($id, $panel = '') |
| 47 | 47 | { |
| 48 | 48 | list($model, $panels) = $this->loadData($id); |
| 49 | - if (isset($panels[$panel])) |
|
| 50 | - $activePanel = $panel; |
|
| 51 | - else { |
|
| 49 | + if (isset($panels[$panel])) { |
|
| 50 | + $activePanel = $panel; |
|
| 51 | + } else { |
|
| 52 | 52 | reset($panels); |
| 53 | 53 | $activePanel = key($panels); |
| 54 | 54 | } |
@@ -97,9 +97,10 @@ discard block |
||
| 97 | 97 | $panels = $this->module->loadPanels($this->module->getPanelIdentifiers()); |
| 98 | 98 | $activePanels = []; |
| 99 | 99 | $data = ArrayHelper::getColumn($model->data, 'data'); |
| 100 | - foreach ($panels as $panelId => $panel) |
|
| 101 | - if ($panel->hasEntryData($model)) { |
|
| 100 | + foreach ($panels as $panelId => $panel) { |
|
| 101 | + if ($panel->hasEntryData($model)) { |
|
| 102 | 102 | $panel->tag = $id; |
| 103 | + } |
|
| 103 | 104 | $panel->model = $model; |
| 104 | 105 | $panel->load(isset($data[$panelId]) ? $data[$panelId] : null); |
| 105 | 106 | $activePanels[$panelId] = $panel; |
@@ -51,21 +51,28 @@ |
||
| 51 | 51 | $javascript->origin .= ':' . $value; |
| 52 | 52 | }, |
| 53 | 53 | 'data' => function ($value) use ($javascript) { |
| 54 | - if (count($value)) $javascript->data = $value; |
|
| 54 | + if (count($value)) { |
|
| 55 | + $javascript->data = $value; |
|
| 56 | + } |
|
| 55 | 57 | }, |
| 56 | 58 | ]; |
| 57 | 59 | |
| 58 | - foreach ($map as $key => $target) |
|
| 59 | - if (isset($data[$key])) { |
|
| 60 | + foreach ($map as $key => $target) { |
|
| 61 | + if (isset($data[$key])) { |
|
| 60 | 62 | if (is_callable($target)) $target($data[$key]); |
| 61 | - else $javascript->$target = $data[$key]; |
|
| 63 | + } |
|
| 64 | + else { |
|
| 65 | + $javascript->$target = $data[$key]; |
|
| 66 | + } |
|
| 62 | 67 | } |
| 63 | 68 | |
| 64 | - if (!$javascript->type) |
|
| 65 | - $javascript->type = 'unknown'; |
|
| 69 | + if (!$javascript->type) { |
|
| 70 | + $javascript->type = 'unknown'; |
|
| 71 | + } |
|
| 66 | 72 | |
| 67 | - if ($javascript->save()) |
|
| 68 | - return ['result' => 'ok', 'entry' => $data['auditEntry']]; |
|
| 73 | + if ($javascript->save()) { |
|
| 74 | + return ['result' => 'ok', 'entry' => $data['auditEntry']]; |
|
| 75 | + } |
|
| 69 | 76 | |
| 70 | 77 | return ['result' => 'error', 'errors' => $javascript->getErrors()]; |
| 71 | 78 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | // and the '.svn' will match all files and directories named exactly '.svn'. |
| 27 | 27 | // Note, the '/' characters in a pattern matches both '/' and '\'. |
| 28 | 28 | // See helpers/FileHelper::findFiles() description for more details on pattern matching rules. |
| 29 | - 'only' => ['*.php', '*.js'], |
|
| 29 | + 'only' => ['*.php', '*.js'], |
|
| 30 | 30 | // array, list of patterns that specify which files (not directories) should be processed. |
| 31 | 31 | // If empty or not set, all files will be processed. |
| 32 | 32 | // Please refer to "except" for details about the patterns. |
@@ -50,8 +50,9 @@ |
||
| 50 | 50 | public static function create($initialise = true) |
| 51 | 51 | { |
| 52 | 52 | $entry = new static; |
| 53 | - if ($initialise) |
|
| 54 | - $entry->record(); |
|
| 53 | + if ($initialise) { |
|
| 54 | + $entry->record(); |
|
| 55 | + } |
|
| 55 | 56 | |
| 56 | 57 | return $entry; |
| 57 | 58 | } |