chg: [audit log] change field renamed to changed
- change is a reserved keyword - this way quoting of field names is no longer needed in the cakePHP settingspull/79/head
parent
a4f6e06e7a
commit
cc5c750de8
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class AuditChanged extends AbstractMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Change Method.
|
||||||
|
*
|
||||||
|
* Write your reversible migrations using this method.
|
||||||
|
*
|
||||||
|
* More information on writing migrations is available here:
|
||||||
|
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||||
|
*
|
||||||
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||||
|
* with the Table class.
|
||||||
|
*/
|
||||||
|
public function change(): void
|
||||||
|
{
|
||||||
|
$exists = $this->table('audit_logs')->hasColumn('change');
|
||||||
|
if ($exists) {
|
||||||
|
$this->table('audit_logs')
|
||||||
|
->renameColumn('change', 'changed')
|
||||||
|
->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -160,7 +160,7 @@ class AppController extends Controller
|
||||||
'model' => 'Users',
|
'model' => 'Users',
|
||||||
'model_id' => $user['id'],
|
'model_id' => $user['id'],
|
||||||
'model_title' => $user['username'],
|
'model_title' => $user['username'],
|
||||||
'change' => []
|
'changed' => []
|
||||||
]);
|
]);
|
||||||
if (!empty($user)) {
|
if (!empty($user)) {
|
||||||
$this->Authentication->setIdentity($user);
|
$this->Authentication->setIdentity($user);
|
||||||
|
@ -172,7 +172,7 @@ class AppController extends Controller
|
||||||
'model' => 'Users',
|
'model' => 'Users',
|
||||||
'model_id' => $user['id'],
|
'model_id' => $user['id'],
|
||||||
'model_title' => $user['name'],
|
'model_title' => $user['name'],
|
||||||
'change' => []
|
'changed' => []
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class AuditLogsController extends AppController
|
||||||
'quickFilters' => $this->quickFilterFields,
|
'quickFilters' => $this->quickFilterFields,
|
||||||
'afterFind' => function($data) {
|
'afterFind' => function($data) {
|
||||||
$data['request_ip'] = inet_ntop(stream_get_contents($data['request_ip']));
|
$data['request_ip'] = inet_ntop(stream_get_contents($data['request_ip']));
|
||||||
$data['change'] = stream_get_contents($data['change']);
|
$data['changed'] = stream_get_contents($data['changed']);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -718,11 +718,11 @@ class RestResponseComponent extends Component
|
||||||
'operators' => array('equal'),
|
'operators' => array('equal'),
|
||||||
'help' => __('A valid x509 certificate ')
|
'help' => __('A valid x509 certificate ')
|
||||||
),
|
),
|
||||||
'change' => array(
|
'changed' => array(
|
||||||
'input' => 'text',
|
'input' => 'text',
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'operators' => array('equal'),
|
'operators' => array('equal'),
|
||||||
'help' => __('The text contained in the change field')
|
'help' => __('The text contained in the changed field')
|
||||||
),
|
),
|
||||||
'change_pw' => array(
|
'change_pw' => array(
|
||||||
'input' => 'radio',
|
'input' => 'radio',
|
||||||
|
|
|
@ -170,7 +170,7 @@ class UsersController extends AppController
|
||||||
'model' => 'Users',
|
'model' => 'Users',
|
||||||
'model_id' => $user['id'],
|
'model_id' => $user['id'],
|
||||||
'model_title' => $user['name'],
|
'model_title' => $user['name'],
|
||||||
'change' => []
|
'changed' => []
|
||||||
]);
|
]);
|
||||||
$target = $this->Authentication->getLoginRedirect() ?? '/instance/home';
|
$target = $this->Authentication->getLoginRedirect() ?? '/instance/home';
|
||||||
return $this->redirect($target);
|
return $this->redirect($target);
|
||||||
|
@ -181,7 +181,7 @@ class UsersController extends AppController
|
||||||
'model' => 'Users',
|
'model' => 'Users',
|
||||||
'model_id' => 0,
|
'model_id' => 0,
|
||||||
'model_title' => 'unknown_user',
|
'model_title' => 'unknown_user',
|
||||||
'change' => []
|
'changed' => []
|
||||||
]);
|
]);
|
||||||
$this->Flash->error(__('Invalid username or password'));
|
$this->Flash->error(__('Invalid username or password'));
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ class UsersController extends AppController
|
||||||
'model' => 'Users',
|
'model' => 'Users',
|
||||||
'model_id' => $user['id'],
|
'model_id' => $user['id'],
|
||||||
'model_title' => $user['name'],
|
'model_title' => $user['name'],
|
||||||
'change' => []
|
'changed' => []
|
||||||
]);
|
]);
|
||||||
$this->Authentication->logout();
|
$this->Authentication->logout();
|
||||||
$this->Flash->success(__('Goodbye.'));
|
$this->Flash->success(__('Goodbye.'));
|
||||||
|
|
|
@ -110,7 +110,7 @@ class AuditLogBehavior extends Behavior
|
||||||
'model' => $entity->getSource(),
|
'model' => $entity->getSource(),
|
||||||
'model_id' => $id,
|
'model_id' => $id,
|
||||||
'model_title' => $modelTitle,
|
'model_title' => $modelTitle,
|
||||||
'change' => $changedFields
|
'changed' => $changedFields
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class AuditLogBehavior extends Behavior
|
||||||
'model' => $entity->getSource(),
|
'model' => $entity->getSource(),
|
||||||
'model_id' => $this->old->id,
|
'model_id' => $this->old->id,
|
||||||
'model_title' => $modelTitle,
|
'model_title' => $modelTitle,
|
||||||
'change' => $this->changedFields($entity)
|
'changed' => $this->changedFields($entity)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,12 +91,12 @@ class AuditLogsTable extends AppTable
|
||||||
$data['model_title'] = mb_substr($data['model_title'], 0, 252) . '...';
|
$data['model_title'] = mb_substr($data['model_title'], 0, 252) . '...';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data['change'])) {
|
if (isset($data['changed'])) {
|
||||||
$change = json_encode($data['change'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
$changed = json_encode($data['changed'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
if ($this->compressionEnabled && strlen($change) >= self::BROTLI_MIN_LENGTH) {
|
if ($this->compressionEnabled && strlen($changed) >= self::BROTLI_MIN_LENGTH) {
|
||||||
$change = self::BROTLI_HEADER . brotli_compress($change, 4, BROTLI_TEXT);
|
$changed = self::BROTLI_HEADER . brotli_compress($changed, 4, BROTLI_TEXT);
|
||||||
}
|
}
|
||||||
$data['change'] = $change;
|
$data['changed'] = $changed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ echo $this->element('genericElements/IndexTable/index_table', [
|
||||||
'data_path' => 'request_action',
|
'data_path' => 'request_action',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => __('Change'),
|
'name' => __('Changed'),
|
||||||
'sort' => 'change',
|
'sort' => 'changed',
|
||||||
'data_path' => 'change',
|
'data_path' => 'changed',
|
||||||
'element' => 'json'
|
'element' => 'json'
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue