From ff9c60902bc2d366207fc59a53b22aee887a71f0 Mon Sep 17 00:00:00 2001 From: iglocska Date: Fri, 6 Nov 2020 10:45:00 +0100 Subject: [PATCH] fix: encryption modifications - added a limited edit function - changed the index to make more sense - as reported by cert.pl --- src/Controller/EncryptionKeysController.php | 17 +++++++ templates/EncryptionKeys/add.php | 51 +++++++++++---------- templates/EncryptionKeys/index.php | 13 +++--- 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/src/Controller/EncryptionKeysController.php b/src/Controller/EncryptionKeysController.php index 32c7d3b..648a074 100644 --- a/src/Controller/EncryptionKeysController.php +++ b/src/Controller/EncryptionKeysController.php @@ -54,4 +54,21 @@ class EncryptionKeysController extends AppController $this->set(compact('dropdownData')); $this->set('metaGroup', 'ContactDB'); } + + public function edit($id = false) + { + $params = [ + 'fields' => [ + 'type', 'encryption_key', 'revoked' + ], + 'redirect' => $this->referer() + ]; + $this->CRUD->edit($id, $params); + if ($this->ParamHandler->isRest()) { + return $this->restResponsePayload; + } + $this->set('dropdownData', []); + $this->set('metaGroup', 'ContactDB'); + $this->render('add'); + } } diff --git a/templates/EncryptionKeys/add.php b/templates/EncryptionKeys/add.php index 6ebf1ab..6a80c39 100644 --- a/templates/EncryptionKeys/add.php +++ b/templates/EncryptionKeys/add.php @@ -1,54 +1,59 @@ element('genericElements/Form/genericForm', array( - 'data' => array( +echo $this->element('genericElements/Form/genericForm', [ + 'data' => [ 'title' => __('Add new encryption key'), 'description' => __('Alignments indicate that an individual belongs to an organisation in one way or another. The type of relationship is defined by the type field.'), 'model' => 'Organisations', - 'fields' => array( - array( + 'fields' => [ + [ 'field' => 'owner_type', 'label' => __('Owner type'), 'options' => array_combine(array_keys($dropdownData), array_keys($dropdownData)), 'type' => 'dropdown' - ), - array( + ], + [ 'field' => 'organisation_id', 'label' => __('Owner organisation'), - 'options' => $dropdownData['organisation'], + 'options' => $dropdownData['organisation'] ?? [], 'type' => 'dropdown', 'stateDependence' => [ 'source' => '#owner_type-field', 'option' => 'organisation' ] - ), - array( + ], + [ 'field' => 'individual_id', 'label' => __('Owner individual'), - 'options' => $dropdownData['individual'], + 'options' => $dropdownData['individual'] ?? [], 'type' => 'dropdown', 'stateDependence' => [ 'source' => '#owner_type-field', 'option' => 'individual' ] - ), - array( + ], + [ 'field' => 'uuid', 'type' => 'uuid' - ), - array( + ], + [ 'field' => 'type', - 'options' => array('pgp' => 'PGP', 'smime' => 'S/MIME'), + 'options' => ['pgp' => 'PGP', 'smime' => 'S/MIME'], 'type' => 'dropdown' - ), - array( + ], + [ 'field' => 'encryption_key', 'label' => __('Public key'), 'type' => 'textarea', 'rows' => 8 - ) - ), - 'submit' => array( + ], + [ + 'field' => 'revoked', + 'label' => __('Revoked'), + 'type' => 'checkbox' + ] + ], + 'submit' => [ 'action' => $this->request->getParam('action') - ) - ) -)); + ] + ] +]); diff --git a/templates/EncryptionKeys/index.php b/templates/EncryptionKeys/index.php index 106b5ee..de4584e 100644 --- a/templates/EncryptionKeys/index.php +++ b/templates/EncryptionKeys/index.php @@ -56,12 +56,6 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'data_path' => 'revoked', 'element' => 'boolean' ], - [ - 'name' => __('Expires'), - 'sort' => 'expires', - 'data_path' => 'expires', - 'element' => 'timestamp' - ], [ 'name' => __('Key'), 'data_path' => 'encryption_key' @@ -72,10 +66,15 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'pull' => 'right', 'actions' => [ [ - 'onclick' => 'populateAndLoadModal(\'/encryptionKeys/edit/[onclick_params_data_path]\');', + 'onclick' => 'populateAndLoadModal(\'/encryptionKeys/view/[onclick_params_data_path]\');', 'onclick_params_data_path' => 'id', 'icon' => 'eye' ], + [ + 'onclick' => 'populateAndLoadModal(\'/encryptionKeys/edit/[onclick_params_data_path]\');', + 'onclick_params_data_path' => 'id', + 'icon' => 'edit' + ], [ 'onclick' => 'populateAndLoadModal(\'/encryptionKeys/delete/[onclick_params_data_path]\');', 'onclick_params_data_path' => 'id',