Prado\Security\TUser::isInRole PHP Method

isInRole() public method

public isInRole ( $role ) : boolean
return boolean whether the user is of this role
    public function isInRole($role)
    {
        foreach ($this->getRoles() as $r) {
            if (strcasecmp($role, $r) === 0) {
                return true;
            }
        }
        return false;
    }

Usage Example

Esempio n. 1
0
 public function testIsInRole()
 {
     $user = new TUser(self::$mgr);
     $user->setRoles(array('Administrator', 'Writer'));
     // Roles are case insensitive
     self::assertTrue($user->IsInRole('writer'));
     self::assertTrue($user->IsInRole('Writer'));
     self::assertFalse($user->isInRole('Reader'));
 }