Example #1
0
 /**
  * Finds and gets full userinfo by filtering inside the auth container
  *
  * @param  array auth params (as for getUsers() from the auth container
  * @return array|bool Array with userinfo if found on success or false otherwise
  *
  * @access private
  */
 function _getUsersByAuth($authParams = array())
 {
     if (!is_object($this->auth) || !is_object($this->perm)) {
         $this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Perm and/or Auth container not set.'));
         return false;
     }
     $first = $authParams['select'] == 'row';
     $authUsers = $this->auth->getUsers($authParams);
     if (!$authUsers) {
         return $authUsers;
     }
     if ($first) {
         $authUsers = array($authUsers);
     }
     $users = array();
     foreach ($authUsers as $authData) {
         $permParams = array('filters' => array('auth_user_id' => $authData['auth_user_id'], 'auth_container_name' => $this->authContainerName), 'select' => 'row');
         $permData = $this->perm->getUsers($permParams);
         if (!$permData) {
             continue;
         }
         if ($first) {
             return LiveUser::arrayMergeClobber($authData, $permData);
         }
         $users[] = LiveUser::arrayMergeClobber($authData, $permData);
     }
     return $users;
 }
Example #2
0
 /**
  * Constructor
  *
  * The second parameters expects an array containing the parameters
  * for the given container.
  *
  * Say you have a conf array like that
  * <code>
  * 'authContainers' => array(
  *     array(
  *         'type'          => 'MDB',
  *         'loginTimeout'  => 0,
  *         'expireTime'    => 3600,
  *         'idleTime'      => 1800,
  *         'passwordEncryptionMode' => 'MD5',
  *         'allowDuplicateHandles' => 0,
  *         'authTable'     => 'users',
  *         'dsn'           => 'type://*****:*****@host/database',
  *         'authTableCols' => array(
  *             'user_id'        => array('name' => 'auth_user_id', 'type' => 'text'),
  *             'handle'         => array('name' => 'handle', 'type' => 'text'),
  *             'passwd'         => array('name' => 'passwd', 'type' => 'text'),
  *             'lastlogin'      => array('name' => 'lastlogin', 'type' => 'timestamp'),
  *             'is_active'      => array('name' => 'is_active', 'type' => 'boolean'),
  *             'owner_user_id'  => array('name' => 'owner_user_id', 'type' => 'integer'),
  *             'owner_group_id' => array('name' => 'owner_group_id', 'type' => 'integer')
  *          )
  *     )
  * ),
  * </code>
  *
  * This class expects only the array containing
  * configuration options of the auth container you wish
  * to administrate. This is done in case you have several
  * MDB based auth containers.
  *
  * See PEAR::MDB documentation for DSN specifications.
  *
  * <code>
  * $conf =
  *     array(
  *         'type'          => 'MDB',
  *         'loginTimeout'  => 0,
  *         'expireTime'    => 3600,
  *         'idleTime'      => 1800,
  *         'allowDuplicateHandles' => 0,
  *         'authTable'     => 'users',
  *         'authTableCols' => array(
  *             'user_id'        => array('name' => 'auth_user_id', 'type' => 'text'),
  *             'handle'         => array('name' => 'handle', 'type' => 'text'),
  *             'passwd'         => array('name' => 'passwd', 'type' => 'text'),
  *             'lastlogin'      => array('name' => 'lastlogin', 'type' => 'timestamp'),
  *             'is_active'      => array('name' => 'is_active', 'type' => 'boolean'),
  *             'owner_user_id'  => array('name' => 'owner_user_id', 'type' => 'integer'),
  *             'owner_group_id' => array('name' => 'owner_group_id', 'type' => 'integer')
  *         )
  *     );
  *
  * $obj = new LiveUser_Admin_Auth_Container_MDB($conf);
  * </code>
  *
  * @access protected
  * @param  array  full liveuser conf array
  * @return void
  */
 function LiveUser_Admin_Auth_Container_MDB(&$connectOptions, $name = null)
 {
     parent::LiveUser_Admin_Auth_Common($connectOptions, $name);
     if (is_array($connectOptions)) {
         $function = 'connect';
         if (isset($connectOptions['function'])) {
             $function = $connectOptions['function'];
             unset($connectOptions['function']);
         }
         foreach ($connectOptions as $key => $value) {
             if (isset($this->{$key})) {
                 $this->{$key} = $value;
             }
         }
         if (isset($connectOptions['connection']) && MDB::isConnection($connectOptions['connection'])) {
             $this->dbc =& $connectOptions['connection'];
             $this->init_ok = true;
         } elseif (isset($connectOptions['dsn'])) {
             $this->dsn = $connectOptions['dsn'];
             $options = null;
             if (isset($connectOptions['options'])) {
                 $options = $connectOptions['options'];
             }
             $options['optimize'] = 'portability';
             if ($function == 'singleton') {
                 $this->dbc =& MDB::singleton($connectOptions['dsn'], $options);
             } else {
                 $this->dbc =& MDB::connect($connectOptions['dsn'], $options);
             }
             if (!MDB::isError($this->dbc)) {
                 $this->init_ok = true;
             }
         }
     }
 }
Example #3
0
 /**
  * Constructor
  *
  * The second parameters expects an array containing the parameters
  * for the given container.
  *
  * This class expects only the array containing
  * configuration options of the auth container you wish
  * to administrate. This is done in case you have several
  * DB based auth containers.
  *
  * See PEAR::DB documentation for DSN specifications.
  *
  * @see    LiveUser::factory The configuration array is explained there
  * @access protected
  * @param  array  full liveuser conf array
  * @return void
  */
 function LiveUser_Admin_Auth_Container_DB(&$connectOptions, $name = null)
 {
     parent::LiveUser_Admin_Auth_Common($connectOptions, $name);
     if (is_array($connectOptions)) {
         if (isset($connectOptions['connection']) && DB::isConnection($connectOptions['connection'])) {
             $this->dbc =& $connectOptions['connection'];
             $this->init_ok = true;
         } elseif (isset($connectOptions['dsn'])) {
             $this->dsn = $connectOptions['dsn'];
             $options = null;
             if (isset($connectOptions['options'])) {
                 $options = $connectOptions['options'];
             }
             $options['portability'] = DB_PORTABILITY_ALL;
             $this->dbc =& DB::connect($connectOptions['dsn'], $options);
             if (!DB::isError($this->dbc)) {
                 $this->init_ok = true;
             }
         }
     }
 }