public function checkPermissions($actor, $permissions, $owner)
    {
        $result = true;

        //all must be false in order to return false
        foreach ($permissions as $value) {
            $value = pick($value, self::GUEST);

            switch ($value) {
                //public
                case self::GUEST :
                    $result = true;
                    break;
                //registered
                case self::REG :
                    $result = !$actor->guest();
                    break;
                //follower
                case self::FOLLOWER :
                    $result = $actor->following($owner) || $actor->leading($owner) || $actor->administrator($owner);
                    break;
                //leader
                case self::LEADER :
                    $result = $actor->leading($owner) || $actor->administrator($owner);
                    break;
                //mutual
                case self::MUTUAL :
                    $result = $actor->mutuallyLeading($owner) || $actor->administrator($owner);
                    break;
                case self::ADMIN :
                    $result = $actor->administrator($owner);
                    break;
                default :
                     $result = $actor->id == $value;
            }

            if ($result === true) {
                break;
            }
        }

        return $result;
    }
public function checkPermissions($actor, $permissions, $owner)
    {
        $result = true;

        //all must be false in order to return false
        foreach ($permissions as $value) {
            $value = pick($value, self::GUEST);

            switch ($value) {
                //public
                case self::GUEST :
                    $result = true;
                    break;
                //registered
                case self::REG :
                    $result = !$actor->guest();
                    break;
                //follower
                case self::FOLLOWER :
                    $result = $actor->following($owner) || $actor->leading($owner) || $actor->administrator($owner);
                    break;
                //leader
                case self::LEADER :
                    $result = $actor->leading($owner) || $actor->administrator($owner);
                    break;
                //mutual
                case self::MUTUAL :
                    $result = $actor->mutuallyLeading($owner) || $actor->administrator($owner);
                    break;
                case self::ADMIN :
                    $result = $actor->administrator($owner);
                    break;
                default :
                     $result = $actor->id == $value;
            }

            if ($result === true) {
                break;
            }
        }

        return $result;
    }
public function checkPermissions ( $ actor , $ permissions , $ owner ) { $ result = true ; //all must be false in order to return false foreach ( $ permissions as $ value ) { $ value = pick ( $ value , self :: GUEST ) ; switch ( $ value ) { //public case self :: GUEST : $ result = true ; break ; //registered case self :: REG : $ result = ! $ actor -> guest ( ) ; break ; //follower case self :: FOLLOWER : $ result = $ actor -> following ( $ owner ) || $ actor -> leading ( $ owner ) || $ actor -> administrator ( $ owner ) ; break ; //leader case self :: LEADER : $ result = $ actor -> leading ( $ owner ) || $ actor -> administrator ( $ owner ) ; break ; //mutual case self :: MUTUAL : $ result = $ actor -> mutuallyLeading ( $ owner ) || $ actor -> administrator ( $ owner ) ; break ; case self :: ADMIN : $ result = $ actor -> administrator ( $ owner ) ; break ; default : $ result = $ actor -> id == $ value ; } if ( $ result === true ) { break ; } } return $ result ; }
Checks an array of permissions against an accessor using the socialgraph between the
accessor and actor.

@param ComActorsDomainEntityActor $actor       The actor who's trying to perform an operation
@param array                      $permissions An array of permissions
@param ComActorsDomainEntityActor $owner       If one of the permision

@return bool
Checks an array of permissions against an accessor using the socialgraph between the accessor and actor .