Merge branch 'develop' into main

pull/92/head v1.1.1
iglocska 2021-11-25 00:58:17 +01:00
commit a8e03aa996
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
10 changed files with 48 additions and 32 deletions

View File

@ -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)) {

View File

@ -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();
}
}
}

View File

@ -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' => []
]);
}
}

View File

@ -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;
}
]);

View File

@ -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',

View File

@ -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.'));

View File

@ -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)
]);
}

View File

@ -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;
}
}

View File

@ -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'
],
],

View File

@ -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'])
],
]
]