View Single Post
Old 09-03-2009, 09:31 AM   #15 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Nevermind. I just learned about serialize and unserialize.

Here's the function I did for isAllowed.
php Code:
public function isAllowed($resource)
    {
   
        $isAllowed = false;
   
        if(is_string($resource))
        {
       
            $permissions = $this->permList->getPermission($resource);
           
            $usergroup = $this->user->group();
            $userid = $this->user->id();
           
            // If the usergroup id exists in the allowed groups
            if(array_search($usergroup->id(), $permissions['AllowedGroups']))
            {
           
                $isAllowed = true;
               
                // If the user id exists in the disallowed users
                if(array_search($userid, $permissions['DisallowedUsers']))
                {
               
                    $isAllowed = false;
               
                }
           
            }
           
            // If the usergroup id did not exist in the allowed groups
            else
            {
           
                $isAllowed = false;
               
                // If the user id exists in the allowed users
                if(array_search($userid, $permissions['AllowedUsers']))
                {
               
                    $isAllowed = true;
               
                }
           
            }
       
        }
       
        return $isAllowed;
   
    }

That way I can check
1. If the usergroup exists in AllowedGroups - allow
but if the userid exists in DisallowedUsers - deny
2. If the usergroup does not exist in AllowedGroups - deny
but if the userid exists in AllowedUsers - allow

I think..

My only question now is.. how would I let my users set a permission that only users on their friendlist is allowed to see something??
__________________
Tanax is offline  
Reply With Quote