From e44d240f22cf3cd3346c4bd01e4e7ed18cc4e724 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 7 Dec 2017 11:44:02 +0200 Subject: [PATCH] fix acl frontend --- application/Espo/Services/Record.php | 6 ------ client/src/acl-manager.js | 15 +++------------ client/src/acl-portal-manager.js | 2 +- client/src/acl.js | 5 +++-- client/src/acl/email.js | 3 --- client/src/app-portal.js | 2 +- client/src/app.js | 2 +- 7 files changed, 9 insertions(+), 26 deletions(-) diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index ac4a8d82af..dd963c9100 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -247,11 +247,6 @@ class Record extends \Espo\Core\Services\Base } } - protected function loadIsEditable(Entity $entity) - { - $entity->set('isEditable', $this->getAcl()->check($entity, 'edit')); - } - protected function loadLinkMultipleFields(Entity $entity) { $fieldDefs = $this->getMetadata()->get('entityDefs.' . $entity->getEntityType() . '.fields', array()); @@ -330,7 +325,6 @@ class Record extends \Espo\Core\Services\Base $this->loadEmailAddressField($entity); $this->loadPhoneNumberField($entity); $this->loadNotJoinedLinkFields($entity); - $this->loadIsEditable($entity); } public function loadAdditionalFieldsForList(Entity $entity) diff --git a/client/src/acl-manager.js b/client/src/acl-manager.js index a61cfccda6..53c4f09958 100644 --- a/client/src/acl-manager.js +++ b/client/src/acl-manager.js @@ -37,11 +37,12 @@ Espo.define('acl-manager', ['acl'], function (Acl) { - var AclManager = function (user, implementationClassMap) { + var AclManager = function (user, implementationClassMap, aclAllowDeleteCreated) { this.setEmpty(); this.user = user || null; this.implementationClassMap = implementationClassMap || {}; + this.aclAllowDeleteCreated = aclAllowDeleteCreated; } _.extend(AclManager.prototype, { @@ -70,7 +71,7 @@ Espo.define('acl-manager', ['acl'], function (Acl) { if (scope in this.implementationClassMap) { implementationClass = this.implementationClassMap[scope]; } - var obj = new implementationClass(this.getUser(), scope); + var obj = new implementationClass(this.getUser(), scope, this.aclAllowDeleteCreated); this.implementationHash[scope] = obj; } return this.implementationHash[scope]; @@ -126,16 +127,6 @@ Espo.define('acl-manager', ['acl'], function (Acl) { return false; } } - if (action == 'edit') { - if (model.has('isEditable')) { - return model.get('isEditable'); - } - } - if (action == 'delete') { - if (model.has('isRemovable')) { - return model.get('isRemovable'); - } - } var data = (this.data.table || {})[scope]; if (typeof data === 'undefined') { diff --git a/client/src/acl-portal-manager.js b/client/src/acl-portal-manager.js index 85c133cb3c..8bb2d90380 100644 --- a/client/src/acl-portal-manager.js +++ b/client/src/acl-portal-manager.js @@ -46,7 +46,7 @@ Espo.define('acl-portal-manager', ['acl-manager', 'acl-portal'], function (Dep, if (scope in this.implementationClassMap) { implementationClass = this.implementationClassMap[scope]; } - var obj = new implementationClass(this.getUser(), scope); + var obj = new implementationClass(this.getUser(), scope, this.aclAllowDeleteCreated); this.implementationHash[scope] = obj; } return this.implementationHash[scope]; diff --git a/client/src/acl.js b/client/src/acl.js index 7799254b29..261faadd2f 100644 --- a/client/src/acl.js +++ b/client/src/acl.js @@ -28,9 +28,10 @@ Espo.define('acl', [], function () { - var Acl = function (user, scope) { + var Acl = function (user, scope, aclAllowDeleteCreated) { this.user = user || null; this.scope = scope; + this.aclAllowDeleteCreated = aclAllowDeleteCreated; } _.extend(Acl.prototype, { @@ -151,7 +152,7 @@ Espo.define('acl', [], function () { } if (model.has('createdById')) { - if (model.get('createdById') === this.getUser().id) { + if (model.get('createdById') === this.getUser().id && this.aclAllowDeleteCreated) { if (!model.has('assignedUserId')) { return true; } else { diff --git a/client/src/acl/email.js b/client/src/acl/email.js index c1ad42c3f0..4ecef46706 100644 --- a/client/src/acl/email.js +++ b/client/src/acl/email.js @@ -99,8 +99,5 @@ Espo.define('acl/email', 'acl', function (Dep) { return result; } - }); - }); - diff --git a/client/src/app-portal.js b/client/src/app-portal.js index 389af9b5ff..3fddb9582d 100644 --- a/client/src/app-portal.js +++ b/client/src/app-portal.js @@ -35,7 +35,7 @@ Espo.define('app-portal', ['app', 'acl-portal-manager'], function (Dep, AclPorta masterView: 'views/site-portal/master', createAclManager: function () { - return new AclPortalManager(this.user); + return new AclPortalManager(this.user, null, this.settings.get('aclAllowDeleteCreated')); }, }); diff --git a/client/src/app.js b/client/src/app.js index 737e2244c8..91a9ca6e9a 100644 --- a/client/src/app.js +++ b/client/src/app.js @@ -327,7 +327,7 @@ Espo.define( }, createAclManager: function () { - return new AclManager(this.user); + return new AclManager(this.user, null, this.settings.get('aclAllowDeleteCreated')); }, initView: function () {