From b981b3f942c8d12bf6b25ebe237f52b657f1e95b Mon Sep 17 00:00:00 2001 From: iglocska Date: Thu, 25 Nov 2021 00:43:22 +0100 Subject: [PATCH 1/3] fix: [conflict] resolved in user_org update script --- config/Migrations/20211123152707_user_org.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/config/Migrations/20211123152707_user_org.php b/config/Migrations/20211123152707_user_org.php index d51fd1e..47d8a5b 100644 --- a/config/Migrations/20211123152707_user_org.php +++ b/config/Migrations/20211123152707_user_org.php @@ -18,7 +18,6 @@ final class UserOrg extends AbstractMigration */ public function change(): void { -<<<<<<< HEAD $exists = $this->table('users')->hasColumn('organisation_id'); if (!$exists) { $this->table('users') @@ -31,17 +30,6 @@ final class UserOrg extends AbstractMigration ->addIndex('organisation_id') ->update(); } -======= - $alignments = $this->table('users') - ->addColumn('organisation_id', 'integer', [ - 'default' => null, - 'null' => true, - 'signed' => false, - 'length' => 10 - ]) - ->addIndex('organisation_id') - ->update(); ->>>>>>> main $q1 = $this->getQueryBuilder(); $org_id = $q1->select(['min(id)'])->from('organisations')->execute()->fetchAll()[0][0]; if (!empty($org_id)) { From a4f6e06e7aff9bec638abf08211a81b7ba0e647d Mon Sep 17 00:00:00 2001 From: iglocska Date: Thu, 25 Nov 2021 00:55:36 +0100 Subject: [PATCH 2/3] fix: [roles index] correctly allow site admins to modify / remove roles --- templates/Roles/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/Roles/index.php b/templates/Roles/index.php index 204d1d9..e710fd6 100644 --- a/templates/Roles/index.php +++ b/templates/Roles/index.php @@ -79,13 +79,13 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'open_modal' => '/roles/edit/[onclick_params_data_path]', 'modal_params_data_path' => 'id', 'icon' => 'edit', - 'requirement' => !empty($loggedUser['role']['perm_site_admin']) + 'requirement' => !empty($loggedUser['role']['perm_admin']) ], [ 'open_modal' => '/roles/delete/[onclick_params_data_path]', 'modal_params_data_path' => 'id', 'icon' => 'trash', - 'requirement' => !empty($loggedUser['role']['perm_site_admin']) + 'requirement' => !empty($loggedUser['role']['perm_admin']) ], ] ] From cc5c750de8d01374b0540a380fb48a6e0e52dcd6 Mon Sep 17 00:00:00 2001 From: iglocska Date: Thu, 25 Nov 2021 00:57:31 +0100 Subject: [PATCH 3/3] 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 settings --- .../20211124234433_audit_changed.php | 28 +++++++++++++++++++ src/Controller/AppController.php | 4 +-- src/Controller/AuditLogsController.php | 2 +- .../Component/RestResponseComponent.php | 4 +-- src/Controller/UsersController.php | 6 ++-- src/Model/Behavior/AuditLogBehavior.php | 4 +-- src/Model/Table/AuditLogsTable.php | 10 +++---- templates/AuditLogs/index.php | 6 ++-- 8 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 config/Migrations/20211124234433_audit_changed.php diff --git a/config/Migrations/20211124234433_audit_changed.php b/config/Migrations/20211124234433_audit_changed.php new file mode 100644 index 0000000..607c630 --- /dev/null +++ b/config/Migrations/20211124234433_audit_changed.php @@ -0,0 +1,28 @@ +table('audit_logs')->hasColumn('change'); + if ($exists) { + $this->table('audit_logs') + ->renameColumn('change', 'changed') + ->update(); + } + } +} diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index cdd85e2..7afab70 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -160,7 +160,7 @@ class AppController extends Controller 'model' => 'Users', 'model_id' => $user['id'], 'model_title' => $user['username'], - 'change' => [] + 'changed' => [] ]); if (!empty($user)) { $this->Authentication->setIdentity($user); @@ -172,7 +172,7 @@ class AppController extends Controller 'model' => 'Users', 'model_id' => $user['id'], 'model_title' => $user['name'], - 'change' => [] + 'changed' => [] ]); } } diff --git a/src/Controller/AuditLogsController.php b/src/Controller/AuditLogsController.php index 9717416..27bee73 100644 --- a/src/Controller/AuditLogsController.php +++ b/src/Controller/AuditLogsController.php @@ -23,7 +23,7 @@ class AuditLogsController extends AppController 'quickFilters' => $this->quickFilterFields, 'afterFind' => function($data) { $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; } ]); diff --git a/src/Controller/Component/RestResponseComponent.php b/src/Controller/Component/RestResponseComponent.php index 4a7346f..50fb40c 100644 --- a/src/Controller/Component/RestResponseComponent.php +++ b/src/Controller/Component/RestResponseComponent.php @@ -718,11 +718,11 @@ class RestResponseComponent extends Component 'operators' => array('equal'), 'help' => __('A valid x509 certificate ') ), - 'change' => array( + 'changed' => array( 'input' => 'text', 'type' => 'string', 'operators' => array('equal'), - 'help' => __('The text contained in the change field') + 'help' => __('The text contained in the changed field') ), 'change_pw' => array( 'input' => 'radio', diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php index 0f81751..6331d7b 100644 --- a/src/Controller/UsersController.php +++ b/src/Controller/UsersController.php @@ -170,7 +170,7 @@ class UsersController extends AppController 'model' => 'Users', 'model_id' => $user['id'], 'model_title' => $user['name'], - 'change' => [] + 'changed' => [] ]); $target = $this->Authentication->getLoginRedirect() ?? '/instance/home'; return $this->redirect($target); @@ -181,7 +181,7 @@ class UsersController extends AppController 'model' => 'Users', 'model_id' => 0, 'model_title' => 'unknown_user', - 'change' => [] + 'changed' => [] ]); $this->Flash->error(__('Invalid username or password')); } @@ -199,7 +199,7 @@ class UsersController extends AppController 'model' => 'Users', 'model_id' => $user['id'], 'model_title' => $user['name'], - 'change' => [] + 'changed' => [] ]); $this->Authentication->logout(); $this->Flash->success(__('Goodbye.')); diff --git a/src/Model/Behavior/AuditLogBehavior.php b/src/Model/Behavior/AuditLogBehavior.php index 26d354c..55df5e8 100644 --- a/src/Model/Behavior/AuditLogBehavior.php +++ b/src/Model/Behavior/AuditLogBehavior.php @@ -110,7 +110,7 @@ class AuditLogBehavior extends Behavior 'model' => $entity->getSource(), 'model_id' => $id, 'model_title' => $modelTitle, - 'change' => $changedFields + 'changed' => $changedFields ]); } @@ -134,7 +134,7 @@ class AuditLogBehavior extends Behavior 'model' => $entity->getSource(), 'model_id' => $this->old->id, 'model_title' => $modelTitle, - 'change' => $this->changedFields($entity) + 'changed' => $this->changedFields($entity) ]); } diff --git a/src/Model/Table/AuditLogsTable.php b/src/Model/Table/AuditLogsTable.php index b65b5b2..efd6339 100644 --- a/src/Model/Table/AuditLogsTable.php +++ b/src/Model/Table/AuditLogsTable.php @@ -91,12 +91,12 @@ class AuditLogsTable extends AppTable $data['model_title'] = mb_substr($data['model_title'], 0, 252) . '...'; } - if (isset($data['change'])) { - $change = json_encode($data['change'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); - if ($this->compressionEnabled && strlen($change) >= self::BROTLI_MIN_LENGTH) { - $change = self::BROTLI_HEADER . brotli_compress($change, 4, BROTLI_TEXT); + if (isset($data['changed'])) { + $changed = json_encode($data['changed'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + if ($this->compressionEnabled && strlen($changed) >= self::BROTLI_MIN_LENGTH) { + $changed = self::BROTLI_HEADER . brotli_compress($changed, 4, BROTLI_TEXT); } - $data['change'] = $change; + $data['changed'] = $changed; } } diff --git a/templates/AuditLogs/index.php b/templates/AuditLogs/index.php index a121e4f..c4657cb 100644 --- a/templates/AuditLogs/index.php +++ b/templates/AuditLogs/index.php @@ -49,9 +49,9 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'data_path' => 'request_action', ], [ - 'name' => __('Change'), - 'sort' => 'change', - 'data_path' => 'change', + 'name' => __('Changed'), + 'sort' => 'changed', + 'data_path' => 'changed', 'element' => 'json' ], ],