예제 #1
0
 /**
  * Reads the configuration array.
  *
  * @param  array|file  Conf array or file path to configuration
  * @param  string      Name of array containing the configuration
  * @return bool        true on success or false on failure
  *
  * @access public
  * @see    LiveUser::factory
  */
 function readConfig($conf)
 {
     if (array_key_exists('authContainers', $conf)) {
         $this->_authContainers =& $conf['authContainers'];
     }
     if (array_key_exists('permContainer', $conf)) {
         $this->_permContainer =& $conf['permContainer'];
     }
     $this->_options = LiveUser::arrayMergeClobber($this->_options, $conf);
     if (array_key_exists('cookie', $this->_options) && $this->_options['cookie']) {
         $cookie_default = array('name' => 'ludata', 'lifetime' => '365', 'path' => '/', 'domain' => '', 'secret' => 'secret');
         if (is_array($this->_options['cookie'])) {
             $this->_options['cookie'] = LiveUser::arrayMergeClobber($cookie_default, $this->_options['cookie']);
         } else {
             $this->_options['cookie'] = $cookie_default;
         }
     }
     return true;
 }
예제 #2
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;
 }
예제 #3
0
 /**
  * Reads the configuration.
  *
  * @param  array|file  Conf array or file path to configuration
  * @param  string      Name of array containing the configuration
  * @return boolean     true on success or false on failure
  *
  * @access public
  */
 function readConfig(&$conf)
 {
     // probably a futile attempt at working out reference issues in arrays
     $options = $conf;
     if (array_key_exists('debug', $conf) && is_object($conf['debug'])) {
         $options['debug'] = true;
     }
     if (array_key_exists('authContainers', $conf)) {
         $this->_authContainers = $conf['authContainers'];
         unset($options['authContainers']);
     }
     if (array_key_exists('permContainer', $conf)) {
         $this->_permContainer = $conf['permContainer'];
         unset($options['permContainer']);
     }
     $this->_options = LiveUser::arrayMergeClobber($this->_options, $options);
     if (array_key_exists('cookie', $this->_options) && $this->_options['cookie']) {
         $cookie_default = array('name' => 'ludata', 'lifetime' => '365', 'path' => '/', 'domain' => '', 'secret' => 'secret');
         if (is_array($this->_options['cookie'])) {
             $this->_options['cookie'] = LiveUser::arrayMergeClobber($cookie_default, $this->_options['cookie']);
         } else {
             $this->_options['cookie'] = $cookie_default;
         }
     }
     return true;
 }
예제 #4
0
파일: Storage.php 프로젝트: Zunair/xataface
 /**
  *
  *
  *
  * @param array &$storageConf Array with the storage configuration
  * @return boolean true on success, false on failure.
  *
  * @access public
  */
 function init(&$storageConf)
 {
     if (is_array($storageConf)) {
         $keys = array_keys($storageConf);
         foreach ($keys as $key) {
             if (isset($this->{$key})) {
                 $this->{$key} =& $storageConf[$key];
             }
         }
     }
     require_once 'LiveUser/Perm/Storage/Globals.php';
     if (empty($this->tables)) {
         $this->tables = $GLOBALS['_LiveUser']['perm']['tables'];
     } else {
         $this->tables = LiveUser::arrayMergeClobber($GLOBALS['_LiveUser']['perm']['tables'], $this->tables);
     }
     if (empty($this->fields)) {
         $this->fields = $GLOBALS['_LiveUser']['perm']['fields'];
     } else {
         $this->fields = LiveUser::arrayMergeClobber($GLOBALS['_LiveUser']['perm']['fields'], $this->fields);
     }
     if (empty($this->alias)) {
         $this->alias = $GLOBALS['_LiveUser']['perm']['alias'];
     } else {
         $this->alias = LiveUser::arrayMergeClobber($GLOBALS['_LiveUser']['perm']['alias'], $this->alias);
     }
     return true;
 }
예제 #5
0
 /**
  * Load the storage container
  *
  * @param   array  array containing the configuration.
  * @param   string name of the container that should be used
  * @return  bool true on success or false on failure
  *
  * @access public
  */
 function init($conf, $containerName)
 {
     $this->containerName = $containerName;
     if (is_array($conf)) {
         $keys = array_keys($conf);
         foreach ($keys as $key) {
             if (isset($this->{$key})) {
                 $this->{$key} =& $conf[$key];
             }
         }
     }
     if (array_key_exists('storage', $conf) && is_array($conf['storage'])) {
         $keys = array_keys($conf['storage']);
         foreach ($keys as $key) {
             if (isset($this->{$key})) {
                 $this->{$key} =& $conf['storage'][$key];
             }
         }
     }
     require_once 'LiveUser/Auth/Storage/Globals.php';
     if (empty($this->tables)) {
         $this->tables = $GLOBALS['_LiveUser']['auth']['tables'];
     } else {
         $this->tables = LiveUser::arrayMergeClobber($GLOBALS['_LiveUser']['auth']['tables'], $this->tables);
     }
     if (empty($this->fields)) {
         $this->fields = $GLOBALS['_LiveUser']['auth']['fields'];
     } else {
         $this->fields = LiveUser::arrayMergeClobber($GLOBALS['_LiveUser']['auth']['fields'], $this->fields);
     }
     if (empty($this->alias)) {
         $this->alias = $GLOBALS['_LiveUser']['auth']['alias'];
     } else {
         $this->alias = LiveUser::arrayMergeClobber($GLOBALS['_LiveUser']['auth']['alias'], $this->alias);
     }
 }
예제 #6
0
 /**
  * Initializes database storage container.
  * Goes through the storage config and turns each value into
  * a var
  *
  * @param array Storage Configuration
  * @param array containing the database structure (tables, fields, alias)
  * @return bool true on success and false on failure
  *
  * @access public
  */
 function init(&$storageConf, $structure)
 {
     if (is_array($storageConf)) {
         $keys = array_keys($storageConf);
         foreach ($keys as $key) {
             if (isset($this->{$key})) {
                 $this->{$key} =& $storageConf[$key];
             }
         }
     }
     if (empty($this->tables)) {
         $this->tables = $structure['tables'];
     } else {
         $this->tables = LiveUser::arrayMergeClobber($structure['tables'], $this->tables);
     }
     if (empty($this->fields)) {
         $this->fields = $structure['fields'];
     } else {
         $this->fields = LiveUser::arrayMergeClobber($structure['fields'], $this->fields);
     }
     if (empty($this->alias)) {
         $this->alias = $structure['alias'];
     } else {
         $this->alias = LiveUser::arrayMergeClobber($structure['alias'], $this->alias);
     }
     return true;
 }
예제 #7
0
 /**
  * Clobbers two arrays together
  * taken from the user notes of array_merge_recursive
  * used in LiveUser::_readConfig()
  * may be called statically
  *
  * @access public
  * @param  array    array that should be clobbered
  * @param  array    array that should be clobbered
  *
  * @return mixed array on success and false on error
  * @author kc@hireability.com
  */
 function arrayMergeClobber($a1, $a2)
 {
     if (!is_array($a1) || !is_array($a2)) {
         return false;
     }
     foreach ($a2 as $key => $val) {
         if (is_array($val) && isset($a1[$key]) && is_array($a1[$key])) {
             $a1[$key] = LiveUser::arrayMergeClobber($a1[$key], $val);
         } else {
             $a1[$key] = $val;
         }
     }
     return $a1;
 }
예제 #8
0
 /**
  * Merges the current configuration array with configuration array pases
  * along with the method call.
  *
  * @param  array   configuration array
  * @return boolean true upon success, false otherwise
  */
 function setConfArray($conf)
 {
     if (!is_array($conf)) {
         return false;
     }
     $this->_conf = LiveUser::arrayMergeClobber($this->_conf, $conf);
     return true;
 }