ref
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Entities;
|
||||
|
||||
use Espo\Core\ORM\Entity;
|
||||
|
||||
class Subscription extends Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'Subscription';
|
||||
}
|
||||
@@ -35,6 +35,7 @@ use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Entities\Subscription;
|
||||
use Espo\Entities\User;
|
||||
use Espo\Entities\Note;
|
||||
use Espo\Entities\Email;
|
||||
@@ -50,8 +51,6 @@ use Espo\Core\Utils\Acl\UserAclManagerProvider;
|
||||
|
||||
class RecordService
|
||||
{
|
||||
private const SUBSCRIPTION_ENTITY_TYPE = 'Subscription';
|
||||
|
||||
private EntityManager $entityManager;
|
||||
private User $user;
|
||||
private Metadata $metadata;
|
||||
@@ -180,7 +179,7 @@ class RecordService
|
||||
$subscriptionBuilder
|
||||
->leftJoin('createdBy')
|
||||
->join(
|
||||
self::SUBSCRIPTION_ENTITY_TYPE,
|
||||
Subscription::ENTITY_TYPE,
|
||||
'subscription',
|
||||
[
|
||||
'entityType:' => 'parentType',
|
||||
@@ -316,7 +315,7 @@ class RecordService
|
||||
|
||||
$subscriptionSuperBuilder
|
||||
->join(
|
||||
self::SUBSCRIPTION_ENTITY_TYPE,
|
||||
Subscription::ENTITY_TYPE,
|
||||
'subscription',
|
||||
[
|
||||
'entityType:' => 'superParentType',
|
||||
@@ -325,7 +324,7 @@ class RecordService
|
||||
]
|
||||
)
|
||||
->leftJoin(
|
||||
self::SUBSCRIPTION_ENTITY_TYPE,
|
||||
Subscription::ENTITY_TYPE,
|
||||
'subscriptionExclude',
|
||||
[
|
||||
'entityType:' => 'parentType',
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\ApplicationUser;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Record\ServiceContainer as RecordServiceContainer;
|
||||
|
||||
use Espo\Entities\Subscription;
|
||||
use Espo\Modules\Crm\Entities\Account;
|
||||
use Espo\Repositories\EmailAddress as EmailAddressRepository;
|
||||
|
||||
@@ -99,8 +100,6 @@ class Service
|
||||
*/
|
||||
private $auditedFieldsCache = [];
|
||||
|
||||
private const SUBSCRIPTION_ENTITY_TYPE = 'Subscription';
|
||||
|
||||
/**
|
||||
* When a record is re-assigned, ACL will be recalculated for related notes
|
||||
* created within the period.
|
||||
@@ -189,7 +188,7 @@ class Service
|
||||
}
|
||||
|
||||
return (bool) $this->entityManager
|
||||
->getRDBRepository(self::SUBSCRIPTION_ENTITY_TYPE)
|
||||
->getRDBRepository(Subscription::ENTITY_TYPE)
|
||||
->select(['id'])
|
||||
->where([
|
||||
'userId' => $userId,
|
||||
@@ -264,7 +263,7 @@ class Service
|
||||
|
||||
$delete = $this->entityManager->getQueryBuilder()
|
||||
->delete()
|
||||
->from(self::SUBSCRIPTION_ENTITY_TYPE)
|
||||
->from(Subscription::ENTITY_TYPE)
|
||||
->where([
|
||||
'userId' => $userIdList,
|
||||
'entityId' => $entity->getId(),
|
||||
@@ -277,7 +276,7 @@ class Service
|
||||
$collection = new EntityCollection();
|
||||
|
||||
foreach ($userIdList as $userId) {
|
||||
$subscription = $this->entityManager->getNewEntity(self::SUBSCRIPTION_ENTITY_TYPE);
|
||||
$subscription = $this->entityManager->getNewEntity(Subscription::ENTITY_TYPE);
|
||||
|
||||
$subscription->set([
|
||||
'userId' => $userId,
|
||||
@@ -334,7 +333,7 @@ class Service
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->entityManager->createEntity(self::SUBSCRIPTION_ENTITY_TYPE, [
|
||||
$this->entityManager->createEntity(Subscription::ENTITY_TYPE, [
|
||||
'entityId' => $entity->getId(),
|
||||
'entityType' => $entity->getEntityType(),
|
||||
'userId' => $userId,
|
||||
@@ -351,7 +350,7 @@ class Service
|
||||
|
||||
$delete = $this->entityManager->getQueryBuilder()
|
||||
->delete()
|
||||
->from(self::SUBSCRIPTION_ENTITY_TYPE)
|
||||
->from(Subscription::ENTITY_TYPE)
|
||||
->where([
|
||||
'userId' => $userId,
|
||||
'entityId' => $entity->getId(),
|
||||
@@ -372,7 +371,7 @@ class Service
|
||||
|
||||
$delete = $this->entityManager->getQueryBuilder()
|
||||
->delete()
|
||||
->from(self::SUBSCRIPTION_ENTITY_TYPE)
|
||||
->from(Subscription::ENTITY_TYPE)
|
||||
->where([
|
||||
'entityId' => $entity->getId(),
|
||||
'entityType' => $entity->getEntityType(),
|
||||
@@ -1030,7 +1029,7 @@ class Service
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->select(['id'])
|
||||
->join(
|
||||
self::SUBSCRIPTION_ENTITY_TYPE,
|
||||
Subscription::ENTITY_TYPE,
|
||||
'subscription',
|
||||
[
|
||||
'subscription.userId=:' => 'user.id',
|
||||
@@ -1068,7 +1067,7 @@ class Service
|
||||
}
|
||||
|
||||
$builder->join(
|
||||
self::SUBSCRIPTION_ENTITY_TYPE,
|
||||
Subscription::ENTITY_TYPE,
|
||||
'subscription',
|
||||
[
|
||||
'subscription.userId=:' => 'user.id',
|
||||
@@ -1116,7 +1115,7 @@ class Service
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->select(['id', 'name'])
|
||||
->join(
|
||||
self::SUBSCRIPTION_ENTITY_TYPE,
|
||||
Subscription::ENTITY_TYPE,
|
||||
'subscription',
|
||||
[
|
||||
'subscription.userId=:' => 'user.id',
|
||||
@@ -1173,7 +1172,7 @@ class Service
|
||||
$builder = $this->entityManager
|
||||
->getQueryBuilder()
|
||||
->select()
|
||||
->from(self::SUBSCRIPTION_ENTITY_TYPE)
|
||||
->from(Subscription::ENTITY_TYPE)
|
||||
->select('userId')
|
||||
->where([
|
||||
'entityId' => $parentId,
|
||||
|
||||
Reference in New Issue
Block a user