Class: RoleAuth

public    class RoleAuth extends Auth

Role-based user authentication component. This component implements user access by clasifyng users in groups where each grouphas a set of roles. Later in your script you require one or more roles for the user.If you add new groups to your application then you just add some roles to those groupsand you don't have to modify your sorce code.

Auth
   |
  +-- RoleAuth

Author(s): Julio César Carrascal Urquijo <jcesar@phreaker.net>
Version: 2.4
Methods inherited from Auth auth, startsession, forcelogin, logout, refreshinfo, _callback, _connect, _findbyusername, _findbyid, _checksession
Fields inherited from Auth $user, $isidentified, $cachelevel, $dbdriver, $hostname, $username, $password, $database, $_conn, $_options

Public Method Summary

void RoleAuth([ string $options ])
Constructor.
void requireRoles()
Require that the user has all roles passed as parameters.
void requireAtLeast()
Require that the user has at least one of the roles passed as parameters.

Private Method Summary

array _getRoles(int $userId)
Search for the roles a user.

Public Method Details

RoleAuth

public    void RoleAuth( [ string $options ] );

Constructor.

Parameters:
string $options = >>null<<
  => val.
Returns: void

requireRoles

public    void requireRoles(  );

Require that the user has all roles passed as parameters. Force the user to identify himself (If he hasn't do it before) and ensures thathe has each specified role. You can pass all the roles you need at once.

Returns: void
See Also: requireAtLeast()

requireAtLeast

public    void requireAtLeast(  );

Require that the user has at least one of the roles passed as parameters. Force the user to identify himself (If he hasn't do it before) and ensures that hehas "at least" one of the specified roles. You can pass all the roles you need atonce.

Returns: void
See Also: requireRoles()

Private Method Details

_getRoles

private    array _getRoles( int $userId );

Search for the roles a user. Those roles are in relation to groups it belongs to. Returns an associative arrayfor easy access.

Parameters:
int $userId
  the user.
Returns: array
role1 => true, role2 => true.