cvs: pear /Perm_LiveUser LiveUser.php

From: Date: Mon, 08 Nov 2004 15:50:13 +0000
Subject: cvs: pear /Perm_LiveUser LiveUser.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-25775@lists.php.net to get a copy of this message
lsmith Mon Nov 8 10:50:13 2004 EDT Modified files: /pear/Perm_LiveUser LiveUser.php Log: - refactored client part to the new layout (using storage containers) http://cvs.php.net/diff.php/pear/Perm_LiveUser/LiveUser.php?r1=1.135&r2=1.136&ty=u Index: pear/Perm_LiveUser/LiveUser.php diff -u pear/Perm_LiveUser/LiveUser.php:1.135 pear/Perm_LiveUser/LiveUser.php:1.136 --- pear/Perm_LiveUser/LiveUser.php:1.135 Tue Nov 2 09:10:17 2004 +++ pear/Perm_LiveUser/LiveUser.php Mon Nov 8 10:50:12 2004 @@ -118,7 +118,7 @@ * @author Lukas Smith <smith@backendmedia.com> * @author Pierre-Alain Joye <pajoye@php.net> * @author Arnaud Limbourg <arnaud@php.net> - * @version $Id: LiveUser.php,v 1.135 2004/11/02 14:10:17 dufuz Exp $ + * @version $Id: LiveUser.php,v 1.136 2004/11/08 15:50:12 lsmith Exp $ * @package LiveUser */ class LiveUser @@ -531,7 +531,7 @@ */ function &authFactory($conf) { - $classname = 'LiveUser_Auth_Container_' . $conf['type']; + $classname = 'LiveUser_Auth_' . $conf['type']; if (!LiveUser::loadClass($classname)) { return false; } @@ -549,13 +549,35 @@ */ function &permFactory($conf) { - $classname = 'LiveUser_Perm_Container_' . $conf['type']; + $classname = 'LiveUser_Perm_' . $conf['type']; if (!LiveUser::loadClass($classname)) { return false; } - $perm = &new $classname($conf); + $perm = &new $classname($conf['stack']); return $perm; } + /** + * Returns an instance of a storage Container + * + * @access protected + * @param array configuration array to pass to the storage container + * @return object|false will return an instance of a Storage container + * or false upon error + */ + function &storageFactory($confArray) + { + end($confArray); + $storageName = 'LiveUser_Perm_Storage_' . key($confArray); + $res = LiveUser::loadClass($storageName); + if (!$res) { + PEAR_ErrorStack::staticPush(LIVEUSER_ERROR_FAILED_INSTANTIATION, array('class' => $storageName)); + return false; + } + $storageConf = array_pop($confArray); + $storage = &new $storageName($storageConf, $confArray); + + return $storage; + } /** * Clobbers two arrays together @@ -836,6 +858,8 @@ // If there's no session yet, start it now @session_start(); + // get values from the superglobals + // Determine if user wanted to log out $this->processLogout($logout, $handle, $passwd); @@ -1051,7 +1075,6 @@ //loop into auth containers while ($userFound == false && $backend_cnt > $counter) { $auth = &$this->authFactory($this->authContainers[$backends[$counter]]); - $auth->login($this->_handle, $this->_passwd, true); if ($auth->loggedIn) { $this->status = LIVEUSER_STATUS_OK; @@ -1088,8 +1111,8 @@ && isset($_SESSION[$this->_options['session']['varname']]['auth_name']) && strlen($_SESSION[$this->_options['session']['varname']]['auth_name']) > 0 ) { - $name = $_SESSION[$this->_options['session']['varname']]['auth_name']; - $this->_auth = &$this->authFactory($this->authContainers[$name]); + $this->_auth->backendArrayIndex = $_SESSION[$this->_options['session']['varname']]['auth_name']; + $this->_auth = &$this->authFactory($this->authContainers[$_SESSION[$this->_options['session']['varname']]['auth_name']]); $this->_auth->unfreeze($_SESSION[$this->_options['session']['varname']]['auth']); if (isset($_SESSION[$this->_options['session']['varname']]['perm']) @@ -1097,10 +1120,9 @@ ) { $this->_perm = &$this->permFactory($this->permContainer); if ($this->_options['cache_perm']) { - $propertyValues = $_SESSION[$this->_options['session']['varname']]['perm']; - $this->_perm->unfreeze($propertyValues); + $this->_perm->unfreeze(); } else { - $res = $this->_perm->init($this->_auth->authUserId); + $res = $this->_perm->init($this->_auth->authUserId, $this->_auth->backendArrayIndex); } } return true; @@ -1125,9 +1147,8 @@ if (is_object($this->_perm)) { $propertyValues = true; if ($this->_options['cache_perm']) { - $propertyValues = $this->_perm->freeze(); + $this->_perm->freeze(); } - $_SESSION[$this->_options['session']['varname']]['perm'] = $propertyValues; } return true; }

« previous php.pear.cvs (#25775) next »