Skip to content

EspoCRM – Open Source CRM Application

disabled restrict

Yuri Kuznetsov018da93de3c2
diff --git a/application/Espo/Core/Acl/GlobalRestriction.php b/application/Espo/Core/Acl/GlobalRestriction.php
index 7e1459fa33..c9124c55e8 100644
--- a/application/Espo/Core/Acl/GlobalRestriction.php
+++ b/application/Espo/Core/Acl/GlobalRestriction.php
@@ -153,6 +153,13 @@ class GlobalRestriction
$value = $this->metadata->get(['entityDefs', $scope, 'fields', $field, $type]);
}
+ if (
+ $type === self::TYPE_FORBIDDEN &&
+ $this->metadata->get("entityDefs.$scope.fields.$field.disabled")
+ ) {
+ $value = true;
+ }
+
if (!$value) {
continue;
}
@@ -161,9 +168,7 @@ class GlobalRestriction
$resultFieldList[] = $field;
- $fieldAttributeList = $this->fieldUtil->getAttributeList($scope, $field);
-
- foreach ($fieldAttributeList as $attribute) {
+ foreach ($this->fieldUtil->getAttributeList($scope, $field) as $attribute) {
$resultAttributeList[] = $attribute;
}
}
diff --git a/application/Espo/Core/Utils/Metadata/AdditionalBuilder/DisableAssignedUser.php b/application/Espo/Core/Utils/Metadata/AdditionalBuilder/DisableAssignedUser.php
new file mode 100644
index 0000000000..d42ec6be10
--- /dev/null
+++ b/application/Espo/Core/Utils/Metadata/AdditionalBuilder/DisableAssignedUser.php
@@ -0,0 +1,78 @@
+<?php
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM – Open Source CRM application.
+ * Copyright (C) 2014-2025 EspoCRM, Inc.
+ * Website: https://www.espocrm.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU Affero General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
+ ************************************************************************/
+
+namespace Espo\Core\Utils\Metadata\AdditionalBuilder;
+
+use Espo\Core\Utils\Metadata\AdditionalBuilder;
+use stdClass;
+
+/**
+ * Disabled AssignedUser fields for entity types with AssignedUsers enabled.
+ * @noinspection PhpUnused
+ */
+class DisableAssignedUser implements AdditionalBuilder
+{
+ public function build(stdClass $data): void
+ {
+ $scopes = $data->scopes ?? null;
+
+ if (!$scopes instanceof stdClass) {
+ return;
+ }
+
+ foreach (get_object_vars($scopes) as $scope => $itemDefs) {
+ if (
+ !($itemDefs->entity ?? false) ||
+ !($itemDefs->assignedUsers ?? false)
+ ) {
+ continue;
+ }
+
+ $entityDefs = $data->entityDefs->$scope ?? null;
+
+ if (!$entityDefs instanceof stdClass) {
+ return;
+ }
+
+ $fieldsDefs = $entityDefs->fields ?? null;
+
+ if (!$fieldsDefs instanceof stdClass) {
+ return;
+ }
+
+ $assignedUserFieldDefs = $fieldsDefs->assignedUser ?? null;
+
+ if (!$assignedUserFieldDefs instanceof stdClass) {
+ return;
+ }
+
+ $assignedUserFieldDefs->disabled = true;
+ }
+ }
+}
diff --git a/application/Espo/Resources/metadata/app/metadata.json b/application/Espo/Resources/metadata/app/metadata.json
index 711292ec86..4994af9be9 100644
--- a/application/Espo/Resources/metadata/app/metadata.json
+++ b/application/Espo/Resources/metadata/app/metadata.json
@@ -51,6 +51,7 @@
"Espo\\Core\\Utils\\Metadata\\AdditionalBuilder\\Fields",
"Espo\\Core\\Utils\\Metadata\\AdditionalBuilder\\FilterFields",
"Espo\\Core\\Utils\\Metadata\\AdditionalBuilder\\DeleteIdField",
+ "Espo\\Core\\Utils\\Metadata\\AdditionalBuilder\\DisableAssignedUser",
"Espo\\Core\\Utils\\Metadata\\AdditionalBuilder\\StreamUpdatedAtField",
"Espo\\Core\\Utils\\Metadata\\AdditionalBuilder\\LogicDefsBc"
]
diff --git a/application/Espo/Resources/metadata/entityDefs/DashboardTemplate.json b/application/Espo/Resources/metadata/entityDefs/DashboardTemplate.json
index 8ef0ee539e..9590319613 100644
--- a/application/Espo/Resources/metadata/entityDefs/DashboardTemplate.json
+++ b/application/Espo/Resources/metadata/entityDefs/DashboardTemplate.json
@@ -13,7 +13,7 @@
},
"dashletsOptions": {
"type": "jsonObject",
- "disabled": true
+ "utility": true
},
"createdAt": {
"type": "datetime",
diff --git a/application/Espo/Resources/metadata/fields/datetimeOptional.json b/application/Espo/Resources/metadata/fields/datetimeOptional.json
index a9bda0f234..ab1d89834e 100644
--- a/application/Espo/Resources/metadata/fields/datetimeOptional.json
+++ b/application/Espo/Resources/metadata/fields/datetimeOptional.json
@@ -83,7 +83,7 @@
"fields": {
"date": {
"type": "date",
- "disabled": true
+ "utility": true
}
},
"validationList": [