@@ -119,7 +119,7 @@ |
||
119 | 119 | // for batch inserts the same way. This code adds a number of literals instead of the actual values |
120 | 120 | // so that they can be bound right before insert and still get escaped correctly |
121 | 121 | foreach ($batchData as $type => $data) { |
122 | - $param = ':data_' . str_replace('/', '_', $type); |
|
122 | + $param = ':data_'.str_replace('/', '_', $type); |
|
123 | 123 | $rows[] = [$this->id, $type, $date, new Expression($param)]; |
124 | 124 | $params[$param] = [Helper::serialize($data, $compact), \PDO::PARAM_LOB]; |
125 | 125 | } |
@@ -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 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | static public function routeFilter() |
78 | 78 | { |
79 | - $routes = AuditEntry::getDb()->cache(function () { |
|
79 | + $routes = AuditEntry::getDb()->cache(function() { |
|
80 | 80 | return AuditEntry::find()->distinct(true) |
81 | 81 | ->select('route')->where(['is not', 'route', null]) |
82 | 82 | ->groupBy('route')->orderBy('route ASC')->column(); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | static public function methodFilter() |
91 | 91 | { |
92 | - $methods = AuditEntry::getDb()->cache(function () { |
|
92 | + $methods = AuditEntry::getDb()->cache(function() { |
|
93 | 93 | return AuditEntry::find()->distinct(true) |
94 | 94 | ->select('request_method')->where(['is not', 'request_method', null]) |
95 | 95 | ->groupBy('request_method')->orderBy('request_method ASC')->column(); |
@@ -106,9 +106,9 @@ |
||
106 | 106 | if (strlen($this->user_id)) { |
107 | 107 | if (!is_numeric($userId) && $callback = Audit::getInstance()->userFilterCallback) { |
108 | 108 | $userId = call_user_func($callback, $userId); |
109 | + } else { |
|
110 | + $userId = intval($this->user_id) ?: 0; |
|
109 | 111 | } |
110 | - else |
|
111 | - $userId = intval($this->user_id) ?: 0; |
|
112 | 112 | } |
113 | 113 | $query->andFilterWhere(['user_id' => $userId]); |
114 | 114 | } |
@@ -93,7 +93,7 @@ |
||
93 | 93 | */ |
94 | 94 | static protected function filterData() |
95 | 95 | { |
96 | - return AuditEntry::getDb()->cache(function () { |
|
96 | + return AuditEntry::getDb()->cache(function() { |
|
97 | 97 | return AuditError::find()->distinct(true) |
98 | 98 | ->select(['hash', 'message', 'file'])->asArray()->all(); |
99 | 99 | }, 30); |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This model allows for storing of javascript logging entries linked to a specific audit entry |
|
4 | - */ |
|
3 | + * This model allows for storing of javascript logging entries linked to a specific audit entry |
|
4 | + */ |
|
5 | 5 | |
6 | 6 | namespace bedezign\yii2\audit\models; |
7 | 7 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function typeFilter() |
70 | 70 | { |
71 | - $types = AuditJavascript::getDb()->cache(function () { |
|
71 | + $types = AuditJavascript::getDb()->cache(function() { |
|
72 | 72 | return AuditJavascript::find()->distinct(true) |
73 | 73 | ->select('type') |
74 | 74 | ->where(['entry_id' => $this->entry_id]) |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function originFilter() |
85 | 85 | { |
86 | - $origin = AuditJavascript::getDb()->cache(function () { |
|
86 | + $origin = AuditJavascript::getDb()->cache(function() { |
|
87 | 87 | return AuditJavascript::find()->distinct(true) |
88 | 88 | ->select('origin') |
89 | 89 | ->where(['entry_id' => $this->entry_id]) |
@@ -57,8 +57,9 @@ |
||
57 | 57 | |
58 | 58 | // adjust the query by adding the filters |
59 | 59 | $userId = $this->user_id; |
60 | - if (strlen($this->user_id)) |
|
61 | - $userId = intval($this->user_id) ?: 0; |
|
60 | + if (strlen($this->user_id)) { |
|
61 | + $userId = intval($this->user_id) ?: 0; |
|
62 | + } |
|
62 | 63 | |
63 | 64 | $query->andFilterWhere(['id' => $this->id]); |
64 | 65 | $query->andFilterWhere(['entry_id' => $this->entry_id]); |
@@ -36,7 +36,7 @@ |
||
36 | 36 | */ |
37 | 37 | public function getLabel() |
38 | 38 | { |
39 | - return $this->getName() . ' <small>(' . count($this->data) . ')</small>'; |
|
39 | + return $this->getName().' <small>('.count($this->data).')</small>'; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,8 +46,9 @@ |
||
46 | 46 | public function trackData($type, $data) |
47 | 47 | { |
48 | 48 | $this->module->getEntry(true); |
49 | - if (!is_array($this->data)) |
|
50 | - $this->data = []; |
|
49 | + if (!is_array($this->data)) { |
|
50 | + $this->data = []; |
|
51 | + } |
|
51 | 52 | |
52 | 53 | $this->data[] = ['type' => $type, 'data' => $data]; |
53 | 54 | } |
@@ -63,9 +63,9 @@ |
||
63 | 63 | { |
64 | 64 | if (Yii::$app->requestedAction) { |
65 | 65 | if (Yii::$app->requestedAction instanceof InlineAction) { |
66 | - return get_class(Yii::$app->requestedAction->controller) . '::' . Yii::$app->requestedAction->actionMethod . '()'; |
|
66 | + return get_class(Yii::$app->requestedAction->controller).'::'.Yii::$app->requestedAction->actionMethod.'()'; |
|
67 | 67 | } |
68 | - return get_class(Yii::$app->requestedAction) . '::run()'; |
|
68 | + return get_class(Yii::$app->requestedAction).'::run()'; |
|
69 | 69 | } |
70 | 70 | return null; |
71 | 71 | } |
@@ -12,8 +12,8 @@ |
||
12 | 12 | $style = YII_DEBUG ? '' : 'color:transparent;'; |
13 | 13 | } |
14 | 14 | if (Access::checkAccess()) { |
15 | - echo Html::a('audit-' . $auditEntry->id, ['/audit/entry/view', 'id' => $auditEntry->id], ['style' => $style]); |
|
15 | + echo Html::a('audit-'.$auditEntry->id, ['/audit/entry/view', 'id' => $auditEntry->id], ['style' => $style]); |
|
16 | 16 | } else { |
17 | - echo Html::tag('span', 'audit-' . $auditEntry->id, ['style' => $style]); |
|
17 | + echo Html::tag('span', 'audit-'.$auditEntry->id, ['style' => $style]); |
|
18 | 18 | } |
19 | 19 | } |