acl read only

This commit is contained in:
yuri
2018-03-27 17:22:28 +03:00
parent 4cef5c547e
commit 28465cf2bf
2 changed files with 29 additions and 0 deletions
+23
View File
@@ -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';
}
}
}
}
}
}
+6
View File
@@ -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];
}
}
}
}