EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
remove options
Yuri Kuznetsov46a9a1d1f5ee
diff --git a/application/Espo/Core/MassAction/Actions/MassDelete.php b/application/Espo/Core/MassAction/Actions/MassDelete.phpindex 94b8fc27f5..2b45ba73b0 100644--- a/application/Espo/Core/MassAction/Actions/MassDelete.php+++ b/application/Espo/Core/MassAction/Actions/MassDelete.php@@ -29,6 +29,7 @@namespace Espo\Core\MassAction\Actions;+use Espo\Core\ORM\Repository\Option\RemoveOption;use Espo\Core\ORM\Repository\Option\SaveOption;use Espo\Core\Record\ActionHistory\Action;use Espo\Core\Utils\Log;@@ -92,8 +93,9 @@ class MassDelete implements MassActiontry {$repository->remove($entity, [- SaveOption::MASS_UPDATE => true,- SaveOption::MODIFIED_BY_ID => $this->user->getId(),+ RemoveOption::MASS_REMOVE => true,+ RemoveOption::MODIFIED_BY_ID => $this->user->getId(),+ SaveOption::MASS_UPDATE => true, // Legacy.]);} catch (Exception $e) {$this->log->info("Mass delete exception. Record: {id}.", [@@ -104,7 +106,6 @@ class MassDelete implements MassActioncontinue;}- /** @var string $id */$id = $entity->getId();$ids[] = $id;diff --git a/application/Espo/Core/ORM/Repository/Option/RemoveOption.php b/application/Espo/Core/ORM/Repository/Option/RemoveOption.phpnew file mode 100644index 0000000000..fe691fa15a--- /dev/null+++ b/application/Espo/Core/ORM/Repository/Option/RemoveOption.php@@ -0,0 +1,59 @@+<?php+/************************************************************************+ * This file is part of EspoCRM.+ *+ * EspoCRM – Open Source CRM application.+ * Copyright (C) 2014-2025 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko+ * 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\ORM\Repository\Option;++/**+ * Save options.+ *+ * @since 9.2.0+ */+class RemoveOption+{+ /**+ * Silent. Boolean.+ * Skip stream notes, notifications, webhooks.+ */+ public const SILENT = 'silent';++ /**+ * Called from a Record service.+ */+ public const API = 'api';++ /**+ * When saved in Mass-Remove.+ */+ public const MASS_REMOVE = 'massRemove';++ /**+ * Override modified-by. String.+ */+ public const MODIFIED_BY_ID = 'modifiedById';+}diff --git a/application/Espo/Core/Record/Service.php b/application/Espo/Core/Record/Service.phpindex 3eb967cdf7..1e79aefafa 100644--- a/application/Espo/Core/Record/Service.php+++ b/application/Espo/Core/Record/Service.php@@ -41,6 +41,7 @@ use Espo\Core\Exceptions\NotFoundSilent;use Espo\Core\FieldSanitize\SanitizeManager;use Espo\Core\ORM\Defs\AttributeParam;use Espo\Core\ORM\Entity as CoreEntity;+use Espo\Core\ORM\Repository\Option\RemoveOption;use Espo\Core\ORM\Repository\Option\SaveContext;use Espo\Core\ORM\Repository\Option\SaveOption;use Espo\Core\Record\Access\LinkCheck;@@ -797,7 +798,7 @@ class Service implements Crud,/** @noinspection PhpDeprecationInspection */$this->beforeDeleteEntity($entity);- $this->getRepository()->remove($entity);+ $this->getRepository()->remove($entity, [RemoveOption::API => true]);/** @noinspection PhpDeprecationInspection */$this->afterDeleteEntity($entity);