corporate » labs » forge
E29 Incorporated

E29 Product Documentation


 

Serenity::user()

The ACL system has not been completely finished, however all 
functions listed here are marked as stable.

This class controls user sessions, logins and basic permission control.

Serenity::user()->set_expiration()

void Serenity::user()->set_expiration( $seconds );

Call this before calling check_session() or create_session() to change the session expiration time. The default is 3600 seconds.

Example

// Set expiration to 7200
Serenity::user()->set_expiration( 7200 );

Serenity::user()->check_session()

void Serenity::user()->check_session();

This function should always be called in the constructor of your application, before any other user logic. The function checks for a valid session, and if found, populates the member array.

Example

Serenity::user()->check_session();
 
// Login?
if( !Serenity::user()->is_logged_in() )
{
   print "Not logged in.";
}

Serenity::user()->create_session()

void Serenity::user()->create_session( &$userDB );

Normally, applications don't have to call this function directly. If you need to create a session, call authenticate() instead on the user login.

Serenity::user()->authenticate()

bool Serenity::user()->authenticate( $useremail, $password );

Instead of using create_session(), use this function once a member logs in to use their SSO method and create a session.

Example

if( !Serenity::user()->authenticate( $useremail, $password ) )
{
    // Show login form again
}
else
{
    // Do some member stuff
}

Serenity::user()->load_user_role()

void Serenity::user()->load_user_role();

If using the ACL permission matrix, call this function to load the user's role from the ACL table.

Example

Serenity::user()->load_user_role();
 
// Are they an admin?
if( Serenity::user()->is_admin() )
{
    print "Im an admin";
}

Serenity::user()->is_logged_in()

bool Serenity::user()->is_logged_in();

Helper function to see if the person is logged in.

Example

if( !Serenity::user()->is_logged_in() )
{
    // Show the login form
}

How to access ACL permissions

This class provides a dynamic __call() function to access ACL permissions. For instance, to access the is_admin column in the table, you would access:

Serenity::user()->is_admin();

To access any column in the table, just call it as if it were a function.

 
developers/serenityap/api/serenity-user.html.txt · Last modified: 2008/07/21 18:03 (external edit)