From 736e92efbc75908a2bf26fe333a03990e3bb8100 Mon Sep 17 00:00:00 2001 From: carlgmathisen <> Date: Sun, 7 Dec 2008 13:05:05 +0000 Subject: work on php style configuration --- framework/Security/TUserManager.php | 49 +++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'framework/Security') diff --git a/framework/Security/TUserManager.php b/framework/Security/TUserManager.php index dbaa5ffb..878ca864 100644 --- a/framework/Security/TUserManager.php +++ b/framework/Security/TUserManager.php @@ -29,6 +29,26 @@ Prado::using('System.Security.TUser'); * * * + * PHP configuration style: + * + * array( + * 'users' => array( + * 'class' => 'System.Security.TUserManager', + * 'properties' => array( + * 'PasswordMode' => 'Clear', + * ), + * 'users' => array( + * array('name'=>'Joe','password'=>'demo'), + * array('name'=>'John','password'=>'demo'), + * ), + * 'roles' => array( + * array('name'=>'Administrator','users'=>'John'), + * array('name'=>'Writer','users'=>'Joe,John'), + * ), + * ), + * ) + * + * * In addition, user information can also be loaded from an external file * specified by {@link setUserFile UserFile} property. Note, the property * only accepts a file path in namespace format. The user file format is @@ -43,6 +63,7 @@ Prado::using('System.Security.TUser'); * how users are authenticated and authorized in a Prado application. * * @author Qiang Xue + * @author Carl Mathisen * @version $Id$ * @package System.Security * @since 3.0 @@ -87,17 +108,13 @@ class TUserManager extends TModule implements IUserManager */ public function init($config) { - $isPhp = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP; - if($isPhp) - $this->loadUserDataFromPhp($config); - else - $this->loadUserDataFromXml($config); - + $this->loadUserData($config); if($this->_userFile!==null) { - if($isPhp) + if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) { - $this->loadUserDataFromPhp($config); + $userFile = include $this->_userFile; + $this->loadUserDataFromPhp($userFile); } else { @@ -108,7 +125,23 @@ class TUserManager extends TModule implements IUserManager } $this->_initialized=true; } + + /* + * Loads user/role information + * @param mixed the variable containing the user information + */ + private function loadUserData($config) + { + if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) + $this->loadUserDataFromPhp($config); + else + $this->loadUserDataFromXml($config); + } + /** + * Loads user/role information from an php array. + * @param array the array containing the user information + */ private function loadUserDataFromPhp($config) { if(isset($config['users']) && is_array($config['users'])) -- cgit v1.2.3