From 8ad80c7a1af3c427de4e6fde371cf8e0bab7a2cf Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 3 Nov 2017 16:48:18 +0200 Subject: [PATCH] acl: aclAllowDeleteCreated --- application/Espo/Core/Acl/Base.php | 6 +++++- application/Espo/Core/defaults/config.php | 1 + application/Espo/Resources/i18n/en_US/Settings.json | 6 ++++-- application/Espo/Resources/layouts/Settings/settings.json | 2 +- .../Espo/Resources/metadata/entityDefs/Settings.json | 4 ++++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/application/Espo/Core/Acl/Base.php b/application/Espo/Core/Acl/Base.php index 6ad078ca2b..a8bd22a5de 100644 --- a/application/Espo/Core/Acl/Base.php +++ b/application/Espo/Core/Acl/Base.php @@ -260,7 +260,11 @@ class Base implements Injectable if (is_object($data)) { if ($data->edit !== 'no' || $data->create !== 'no') { - if ($entity->has('createdById') && $entity->get('createdById') == $user->id) { + if ( + $this->getConfig()->get('aclAllowDeleteCreated') + && + $entity->has('createdById') && $entity->get('createdById') == $user->id + ) { if (!$entity->has('assignedUserId')) { return true; } else { diff --git a/application/Espo/Core/defaults/config.php b/application/Espo/Core/defaults/config.php index cfc64bacca..3a65bc1573 100644 --- a/application/Espo/Core/defaults/config.php +++ b/application/Espo/Core/defaults/config.php @@ -166,6 +166,7 @@ return array ( 'currencyFormat' => 1, 'currencyDecimalPlaces' => null, 'aclStrictMode' => false, + 'aclAllowDeleteCreated' => false, 'isInstalled' => false ); diff --git a/application/Espo/Resources/i18n/en_US/Settings.json b/application/Espo/Resources/i18n/en_US/Settings.json index a1e461c501..95bbf753e5 100644 --- a/application/Espo/Resources/i18n/en_US/Settings.json +++ b/application/Espo/Resources/i18n/en_US/Settings.json @@ -88,7 +88,8 @@ "b2cMode": "B2C Mode", "currencyFormat": "Currency Format", "currencyDecimalPlaces": "Currency Decimal Places", - "aclStrictMode": "ACL Strict Mode" + "aclStrictMode": "ACL Strict Mode", + "aclAllowDeleteCreated": "Allow to remove created records" }, "options": { "weekStart": { @@ -132,7 +133,8 @@ "ldapUserDefaultTeam": "Default team for created user. For more, see user profile.", "b2cMode": "By default EspoCRM is adapted for B2B. You can switch it to B2C.", "currencyDecimalPlaces": "Number of decimal places. If empty then all nonempty decimal places will be displayed.", - "aclStrictMode": "Enabled: Access to scopes will be forbidden if it's not specified in roles.\n\nDisabled: Access to scopes will be allowed if it's not specified in roles." + "aclStrictMode": "Enabled: Access to scopes will be forbidden if it's not specified in roles.\n\nDisabled: Access to scopes will be allowed if it's not specified in roles.", + "aclAllowDeleteCreated": "Users will be able to remove records they created even if they don't have a delete access." }, "labels": { "System": "System", diff --git a/application/Espo/Resources/layouts/Settings/settings.json b/application/Espo/Resources/layouts/Settings/settings.json index 2e5d934570..ec85c84904 100644 --- a/application/Espo/Resources/layouts/Settings/settings.json +++ b/application/Espo/Resources/layouts/Settings/settings.json @@ -5,7 +5,7 @@ [{"name": "useCache"}, {"name": "siteUrl"}], [{"name": "exportDisabled"}, {"name": "globalSearchEntityList"}], [{"name": "followCreatedEntities"}, {"name": "b2cMode"}], - [{"name": "aclStrictMode"}, false] + [{"name": "aclStrictMode"}, {"name": "aclAllowDeleteCreated"}] ] }, { diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json index 9d4b4638aa..37dfba1d00 100644 --- a/application/Espo/Resources/metadata/entityDefs/Settings.json +++ b/application/Espo/Resources/metadata/entityDefs/Settings.json @@ -423,6 +423,10 @@ "type": "bool", "tooltip": true }, + "aclAllowDeleteCreated": { + "type": "bool", + "tooltip": true + }, "lastViewedCount": { "type": "int", "min": 1,