Multiple Assigned Users and Assigned User : OnlyMy

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • item
    Active Community Member
    • Mar 2017
    • 1476

    Multiple Assigned Users and Assigned User : OnlyMy

    Hi,
    As next release will have : Multiple assigned users enabled with parameter in entity manager #3158

    There are something i don't understand and it's just for understand.

    What happend if we use assignedUser and assignedUsers
    If i look this file (maybe wrong file) .. i see the "return" in the if statement "$this->fieldHelper->hasAssignedUsersField()", so never go in the if statement of assignedUser

    Maybe is preferable to remove the "return" ?
    What do you think ? i am wrong or ?

    Best Regards

    application/Espo/Core/Select/Bool/Filters/OnlyMy.php
    PHP Code:
    
            if ($this->fieldHelper->hasAssignedUsersField()) {
                $relationDefs = $this->defs
                    ->getEntity($this->entityType)
                    ->getRelation('assignedUsers');
    
                $middleEntityType = ucfirst($relationDefs->getRelationshipName());
                $key1 = $relationDefs->getMidKey();
                $key2 = $relationDefs->getForeignMidKey();
    
                $subQuery = QueryBuilder::create()
                    ->select('id')
                    ->from($this->entityType)
                    ->leftJoin($middleEntityType, 'assignedUsersMiddle', [
                        "assignedUsersMiddle.$key1:" => 'id',
                        'assignedUsersMiddle.deleted' => false,
                    ])
                    ->where(["assignedUsersMiddle.$key2" => $this->user->getId()])
                    ->build();
    
                $orGroupBuilder->add(
                    Cond::in(
                        Cond::column('id'),
                        $subQuery
                    )
                );
    
                return; // <-- maybe remove "return" ?
            }
    
            if ($this->fieldHelper->hasAssignedUserField()) {
                $orGroupBuilder->add(
                    Cond::equal(
                        Cond::column('assignedUserId'),
                        $this->user->getId()
                    )
                );
    
                return;
            }
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​
  • yuri
    Member
    • Mar 2014
    • 8453

    #2
    Hi,

    Assigned Users were not compatible with Assigned User. If users is enabled, the user is bypassed. It would not be just to remove return.

    You can always define own custom bool and ACL filters.
    Last edited by yuri; 09-30-2024, 07:43 PM.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment


    • item
      item commented
      Editing a comment
      Thank Yuri for clarification.
      I will create my own filter.
Working...