From 28465cf2bf83556563d0047fb4d83854dbebc08f Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 27 Mar 2018 17:22:28 +0300 Subject: [PATCH] acl read only --- application/Espo/Core/Acl/Table.php | 23 +++++++++++++++++++++++ client/src/views/user/modals/access.js | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/application/Espo/Core/Acl/Table.php b/application/Espo/Core/Acl/Table.php index 3cf2ad5c3e..fdd0d75c4c 100644 --- a/application/Espo/Core/Acl/Table.php +++ b/application/Espo/Core/Acl/Table.php @@ -210,6 +210,7 @@ class Table $this->applyDisabled($aclTable, $fieldTable); $this->applyMandatory($aclTable, $fieldTable); $this->applyAdditional($aclTable, $fieldTable, $valuePermissionLists); + $this->applyReadOnlyFields($fieldTable); } else { $aclTable = (object) []; foreach ($this->getScopeList() as $scope) { @@ -714,4 +715,26 @@ class Table { $this->fileManager->putPhpContents($this->cacheFilePath, $this->data, true); } + + protected function applyReadOnlyFields(&$fieldTable) + { + $scopeList = $this->getScopeWithAclList(); + foreach ($scopeList as $scope) { + if (!property_exists($fieldTable, $scope)) continue; + $fieldList = array_keys($this->getMetadata()->get(['entityDefs', $scope, 'fields'], [])); + foreach ($fieldList as $field) { + if ($this->getMetadata()->get(['entityDefs', $scope, 'fields', $field, 'readOnly'])) { + if (property_exists($fieldTable->$scope, $field)) { + $fieldTable->$scope->$field->edit = 'no'; + } else { + $fieldTable->$scope->$field = (object) []; + foreach ($this->fieldActionList as $action) { + $fieldTable->$scope->$field->$action = 'yes'; + } + $fieldTable->$scope->$field->edit = 'no'; + } + } + } + } + } } diff --git a/client/src/views/user/modals/access.js b/client/src/views/user/modals/access.js index 9c727c9edc..e42fb7f90c 100644 --- a/client/src/views/user/modals/access.js +++ b/client/src/views/user/modals/access.js @@ -72,6 +72,12 @@ Espo.define('views/user/modals/access', 'views/modal', function (Dep) { if (this.getMetadata().get(['app', 'acl', 'mandatory', 'scopeFieldLevel', scope, field]) !== null) { delete scopeData[field]; } + + if (this.getMetadata().get(['entityDefs', scope, 'fields', field, 'readOnly'])) { + if (scopeData[field].edit === 'no' && scopeData[field].read === 'yes') { + delete scopeData[field]; + } + } } }