mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
type fixes
This commit is contained in:
@@ -78,20 +78,20 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
|
||||
$parent = null;
|
||||
|
||||
$hasParent = false;
|
||||
$parentType = $entity->get('parentType');
|
||||
$parentId = $entity->get('parentId');
|
||||
|
||||
if ($entity->get('parentId') && $entity->get('parentType')) {
|
||||
$hasParent = true;
|
||||
$relatedType = $entity->get('relatedType');
|
||||
$relatedId = $entity->get('relatedId');
|
||||
|
||||
$parent = $this->entityManager->getEntity($entity->get('parentType'), $entity->get('parentId'));
|
||||
if ($parentId && $parentType) {
|
||||
$parent = $this->entityManager->getEntityById($parentType, $parentId);
|
||||
}
|
||||
else if ($entity->get('relatedId') && $entity->get('relatedType')) {
|
||||
$hasParent = true;
|
||||
|
||||
$parent = $this->entityManager->getEntity($entity->get('relatedType'), $entity->get('relatedId'));
|
||||
else if ($relatedId && $relatedType) {
|
||||
$parent = $this->entityManager->getEntityById($relatedType, $relatedId);
|
||||
}
|
||||
|
||||
if (!$parent || !$hasParent) {
|
||||
if (!$parent) {
|
||||
if ($this->defaultAccessChecker->checkEntityRead($user, $entity, $data)) {
|
||||
return true;
|
||||
}
|
||||
@@ -132,8 +132,8 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
{
|
||||
if ($note->getTargetType() === Note::TARGET_TEAMS) {
|
||||
$intersect = array_intersect(
|
||||
$note->getLinkMultipleIdList('teams'),
|
||||
$user->getLinkMultipleIdList('teams')
|
||||
$note->getLinkMultipleIdList('teams') ?? [],
|
||||
$user->getLinkMultipleIdList('teams') ?? []
|
||||
);
|
||||
|
||||
if (count($intersect)) {
|
||||
|
||||
@@ -104,6 +104,7 @@ class AccessChecker implements AccessEntityCREDSChecker
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @var string[] */
|
||||
$assignedUserIdList = $entity->getLinkMultipleIdList('assignedUsers');
|
||||
|
||||
if (
|
||||
|
||||
@@ -44,6 +44,7 @@ class OwnershipChecker implements OwnershipOwnChecker
|
||||
{
|
||||
public function checkOwn(User $user, Entity $entity): bool
|
||||
{
|
||||
/** @var string[] */
|
||||
$userTeamIdList = $user->getLinkMultipleIdList('teams');
|
||||
|
||||
return in_array($entity->getId(), $userTeamIdList);
|
||||
|
||||
@@ -54,8 +54,8 @@ class OwnershipChecker implements OwnershipOwnChecker, OwnershipTeamChecker
|
||||
assert($entity instanceof CoreEntity);
|
||||
|
||||
$intersect = array_intersect(
|
||||
$user->getLinkMultipleIdList('teams'),
|
||||
$entity->getLinkMultipleIdList('teams')
|
||||
$user->getLinkMultipleIdList('teams') ?? [],
|
||||
$entity->getLinkMultipleIdList('teams') ?? []
|
||||
);
|
||||
|
||||
if (count($intersect)) {
|
||||
|
||||
@@ -79,20 +79,21 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
}
|
||||
|
||||
$parent = null;
|
||||
$hasParent = false;
|
||||
|
||||
if ($entity->get('parentId') && $entity->get('parentType')) {
|
||||
$hasParent = true;
|
||||
$parentType = $entity->get('parentType');
|
||||
$parentId = $entity->get('parentId');
|
||||
|
||||
$parent = $this->entityManager->getEntity($entity->get('parentType'), $entity->get('parentId'));
|
||||
$relatedType = $entity->get('relatedType');
|
||||
$relatedId = $entity->get('relatedId');
|
||||
|
||||
if ($parentId && $parentType) {
|
||||
$parent = $this->entityManager->getEntityById($parentType, $parentId);
|
||||
}
|
||||
else if ($entity->get('relatedId') && $entity->get('relatedType')) {
|
||||
$hasParent = true;
|
||||
|
||||
$parent = $this->entityManager->getEntity($entity->get('relatedType'), $entity->get('relatedId'));
|
||||
else if ($relatedId && $relatedType) {
|
||||
$parent = $this->entityManager->getEntityById($relatedType, $relatedId);
|
||||
}
|
||||
|
||||
if (!$hasParent) {
|
||||
if (!$parent) {
|
||||
if ($entity->get('createdById') === $user->getId()) {
|
||||
return true;
|
||||
}
|
||||
@@ -137,8 +138,8 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
|
||||
if ($note->getTargetType() === Note::TARGET_PORTALS) {
|
||||
$intersect = array_intersect(
|
||||
$note->getLinkMultipleIdList('portals'),
|
||||
$user->getLinkMultipleIdList('portals')
|
||||
$note->getLinkMultipleIdList('portals') ?? [],
|
||||
$user->getLinkMultipleIdList('portals') ?? []
|
||||
);
|
||||
|
||||
if (count($intersect)) {
|
||||
|
||||
@@ -40,6 +40,9 @@ class LinkMultipleType
|
||||
return false;
|
||||
}
|
||||
|
||||
return count($entity->getLinkMultipleIdList($field)) > 0;
|
||||
/** @var string[] */
|
||||
$idList = $entity->getLinkMultipleIdList($field);
|
||||
|
||||
return count($idList) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class CheckEmailAccounts implements Preparator
|
||||
continue;
|
||||
}
|
||||
|
||||
$jobEntity = $this->entityManager->getEntity(JobEntity::ENTITY_TYPE);
|
||||
$jobEntity = $this->entityManager->getNewEntity(JobEntity::ENTITY_TYPE);
|
||||
|
||||
$jobEntity->set([
|
||||
'name' => $data->getName(),
|
||||
|
||||
@@ -91,7 +91,7 @@ class CheckInboundEmails implements Preparator
|
||||
continue;
|
||||
}
|
||||
|
||||
$jobEntity = $this->entityManager->getEntity(JobEntity::ENTITY_TYPE);
|
||||
$jobEntity = $this->entityManager->getNewEntity(JobEntity::ENTITY_TYPE);
|
||||
|
||||
$jobEntity->set([
|
||||
'name' => $data->getName(),
|
||||
|
||||
@@ -40,7 +40,8 @@ class CheckNewExtensionVersion extends CheckNewVersion
|
||||
return;
|
||||
}
|
||||
|
||||
$job = $this->entityManager->getEntity('Job');
|
||||
$job = $this->entityManager->getNewEntity('Job');
|
||||
|
||||
$job->set([
|
||||
'name' => 'Check for new versions of installed extensions (job)',
|
||||
'serviceName' => 'AdminNotifications',
|
||||
|
||||
@@ -62,7 +62,7 @@ class CheckNewVersion implements JobDataLess
|
||||
return;
|
||||
}
|
||||
|
||||
$job = $this->entityManager->getEntity('Job');
|
||||
$job = $this->entityManager->getNewEntity('Job');
|
||||
|
||||
$job->set([
|
||||
'name' => 'Check for New Version (job)',
|
||||
|
||||
@@ -53,10 +53,10 @@ class OnlyOwn implements Filter
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->id);
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->getId());
|
||||
|
||||
$queryBuilder->where([
|
||||
'emailUser.userId' => $this->user->id,
|
||||
'emailUser.userId' => $this->user->getId(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,16 +53,14 @@ class OnlyTeam implements Filter
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->id);
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->getId());
|
||||
|
||||
$queryBuilder->distinct();
|
||||
|
||||
$queryBuilder->leftJoin('teams', 'teamsAccess');
|
||||
|
||||
$queryBuilder->where([
|
||||
'OR' => [
|
||||
'teamsAccessMiddle.teamId' => $this->user->getLinkMultipleIdList('teams'),
|
||||
'emailUser.userId' => $this->user->id,
|
||||
'emailUser.userId' => $this->user->getId(),
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -53,14 +53,15 @@ class PortalOnlyAccount implements Filter
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->id);
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->getId());
|
||||
|
||||
$queryBuilder->distinct();
|
||||
|
||||
$orGroup = [
|
||||
'emailUser.userId' => $this->user->id,
|
||||
'emailUser.userId' => $this->user->getId(),
|
||||
];
|
||||
|
||||
/** @var string[] */
|
||||
$accountIdList = $this->user->getLinkMultipleIdList('accounts');
|
||||
|
||||
if (count($accountIdList)) {
|
||||
|
||||
@@ -53,12 +53,12 @@ class PortalOnlyContact implements Filter
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->id);
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->getId());
|
||||
|
||||
$queryBuilder->distinct();
|
||||
|
||||
$orGroup = [
|
||||
'emailUser.userId' => $this->user->id,
|
||||
'emailUser.userId' => $this->user->getId(),
|
||||
];
|
||||
|
||||
$contactId = $this->user->get('contactId');
|
||||
|
||||
@@ -70,7 +70,7 @@ class Main implements AdditionalApplier
|
||||
|
||||
protected function joinEmailUser(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->id);
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->getId());
|
||||
|
||||
if ($queryBuilder->build()->getSelect() === []) {
|
||||
$queryBuilder->select('*');
|
||||
|
||||
@@ -56,7 +56,7 @@ class IsImportantIsFalse implements ItemConverter
|
||||
|
||||
public function convert(QueryBuilder $queryBuilder, Item $item): WhereClauseItem
|
||||
{
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->id);
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->getId());
|
||||
|
||||
return WhereClause::fromRaw([
|
||||
'emailUser.isImportant' => false,
|
||||
|
||||
@@ -56,7 +56,7 @@ class IsImportantIsTrue implements ItemConverter
|
||||
|
||||
public function convert(QueryBuilder $queryBuilder, Item $item): WhereClauseItem
|
||||
{
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->id);
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->getId());
|
||||
|
||||
return WhereClause::fromRaw([
|
||||
'emailUser.isImportant' => true,
|
||||
|
||||
@@ -56,7 +56,7 @@ class IsNotReadIsFalse implements ItemConverter
|
||||
|
||||
public function convert(QueryBuilder $queryBuilder, Item $item): WhereClauseItem
|
||||
{
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->id);
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->getId());
|
||||
|
||||
return WhereClause::fromRaw([
|
||||
'emailUser.isRead' => true,
|
||||
|
||||
@@ -56,13 +56,13 @@ class IsNotReadIsTrue implements ItemConverter
|
||||
|
||||
public function convert(QueryBuilder $queryBuilder, Item $item): WhereClauseItem
|
||||
{
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->id);
|
||||
$this->joinHelper->joinEmailUser($queryBuilder, $this->user->getId());
|
||||
|
||||
return WhereClause::fromRaw([
|
||||
'emailUser.isRead' => false,
|
||||
'OR' => [
|
||||
'sentById' => null,
|
||||
'sentById!=' => $this->user->id
|
||||
'sentById!=' => $this->user->getId()
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class OnlyMyTeam implements Filter
|
||||
|
||||
public function apply(SelectBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void
|
||||
{
|
||||
/** @var string[] */
|
||||
$teamIdList = $this->user->getLinkMultipleIdList('teams');
|
||||
|
||||
if (count($teamIdList) === 0) {
|
||||
|
||||
Reference in New Issue
Block a user