Work with rights (roles) and the owner of the record.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • roman042
    Member
    • Jun 2017
    • 64

    Work with rights (roles) and the owner of the record.

    Hello! Sorry for my English
    How to make the creator always see the records he created, regardless of who they were assigned to and to which groups.

    In the espocrm/application/Espo/Core/AclManager.php file, I found a function that checks the read permissions (when I set the true read-write right, they appear but I do not appear in the list of entries).

    public function check(User $user, $subject, $action = null)
    {

    //test
    return true;

    if (is_string($subject)) {
    return $this->checkScope($user, $subject, $action);
    } else {
    $entity = $subject;
    if ($entity instanceof Entity) {
    return $this->checkEntity($user, $entity, $action);
    }
    }
    }

    In setting up the roles, I would very much like to see the essence of the Creator of the record.
    Then it would be possible to fine-tune the right to write.
    Last edited by roman042; 06-05-2017, 04:57 AM.
  • roman042
    Member
    • Jun 2017
    • 64

    #2
    Found in the application/Espo/Core/Acl/Base.php file:
    function checkIsOwner
    made changes:

    public function checkIsOwner(User $user, Entity $entity)
    {
    if ($entity->hasAttribute('assignedUserId')) {
    if ($entity->has('assignedUserId')) {
    if ($user->id === $entity->get('assignedUserId')) {
    return true;
    }
    }
    } else if ($entity->hasAttribute('createdById')) {
    if ($entity->has('createdById')) {
    if ($user->id === $entity->get('createdById')) {
    return true;
    }
    }
    }

    //Если создатель то права на чтение
    if ($entity->has('createdById')) {
    if ($user->id === $entity->get('createdById')) {
    return true;
    }
    }

    if ($entity->hasAttribute('assignedUsersIds') && $entity->hasRelation('assignedUsers')) {
    if ($entity->hasLinkMultipleId('assignedUsers', $user->id)) {
    return true;
    }
    }

    return false;
    }

    Rights to read appeared (a direct link is available), but the list of entries does not appear
    How to show in the list of records?

    Comment

    • tanya
      Senior Member
      • Jun 2014
      • 4308

      #3
      For which entity do you need this? Some acls are overwitten in crm module

      Comment

      • roman042
        Member
        • Jun 2017
        • 64

        #4
        Originally posted by tanya
        For which entity do you need this? Some acls are overwitten in crm module
        For Case and Tasks

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #5
          You need to owerride SelectManager as well (application/Espo/Core/SelectManagers/Base.php accessOnlyOwn method)
          But try to do it in upgrade safe way

          Comment

          Working...