LiveUser

PEAR::LiveUser authentication and permission framework

AdvancedSearch | AreaMap ]

Search:

  Welcome to LiveUser   Documentation   RoadMap   Wishlist   About  
  Documentation   FAQ   References   Tutorials   Other  

Username:

Password:


Areas In
This Wiki

BEPHPUG

Conferences

emPHPower

LiveUser

Main

MDB2

PDO

PEARThinkTank

PHPSVN

PHPTODO

RDBMS

WebBuilder2

Custom properties

Adding custom properties to the authentication container. Something you probably wish to do is to add more information about my your users. Maybe add a name, e-mail, shoe size, etc.

In the auth-containers array definition you can add custom properties by extending the table's field-array. For each field you add, you also need to add an alias for it and specify its type in the field-array. If you are using MDB2 you can find all supported types in the MDB2::Documentation1 (under Datatypes 2).

Here is a small example, taken from example1 in the LiveUser_Admin documentation:


<?php
$conf =
    array(
        'debug' => true,
        'session'  => array(
            'name'     => 'PHPSESSION',
            'varname'  => 'ludata'
        ),
        'login' => array(
            'force'    => false,
        ),
        'logout' => array(
            'destroy'  => true,
        ),
        'authContainers' => array(
            'DB_Local' => array(
                'type' => $storage,
                'loginTimeout'  => 0,
                'expireTime'    => 3600,
                'idleTime'      => 1800,
                'allowDuplicateHandles' => false,
                'storage' => array(
                    'connection' => $db,
                    'dsn' => $dsn,
                    'prefix' => 'liveuser_',
                    'tables' => array(
                        'users' => array(
                            /**
                             * You can add custom properties by 
                             * extending the table's field-array.
                             */
                            'fields' => array(
                                'name' => false,
                                'email' => false,
                            ),
                        ),
                    ),
                    /**
                     * For each field you add, you also need 
                     * to add an alias for it...
                     */
                    'alias' => array(
                        'name' => 'name',
                        'email' => 'email',
                        'auth_user_id' => 'user_id',
                    ),
                    /**
                     * ...and specify its type in the field-array.
                     */
                    'fields' => array(
                        'name' => 'text',
                        'email' => 'text',
                    ),
                    // 'force_seq' => false
                ),
            )
        ),
        'permContainer' => array(
            'type'  => 'Complex',
            'alias' => array(),
            'storage' => array(
                    'connection' => $db,
                    'dsn' => $dsn,
                    'prefix' => 'liveuser_',
                    'tables' => array(),
                    'fields' => array(),
                    'alias' => array(),
                    // 'force_seq' => false
                ),
            ),
        ),
    );
?>

Don't forget to synchronize your storage container too (eg. by running install.php again). You can now access the new property by using the method getProperty() found in LiveUser.

LiveUser:AuthProperty (66.169.30.131)
Wed, 11 Jul 2007, 19:05
[ Links | Source | History | RSS ]

This site powered by YaWiki 0.22 beta.

Tutorials
Quickstart
Complete
Observers
AdminFilters
Custom properties