From 3dacf149de2ac560328242666473533c81c4b418 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 1 Sep 2012 02:48:54 +0200 Subject: allow configuring user backends in config.php --- lib/user.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/user.php') diff --git a/lib/user.php b/lib/user.php index c432f6074a6..305fb8ed3a2 100644 --- a/lib/user.php +++ b/lib/user.php @@ -39,6 +39,8 @@ class OC_User { // The backend used for user management private static $_usedBackends = array(); + + private static $_setupedBackends = array(); // Backends available (except database) private static $_backends = array(); @@ -114,6 +116,28 @@ class OC_User { self::$_usedBackends=array(); } + /** + * setup the configured backends in config.php + */ + public static function setupBackends(){ + $backends=OC_Config::getValue('user_backends',array()); + foreach($backends as $i=>$config){ + $class=$config['class']; + $arguments=$config['arguments']; + if(class_exists($class) and array_search($i,self::$_setupedBackends)===false){ + // make a reflection object + $reflectionObj = new ReflectionClass($class); + + // use Reflection to create a new instance, using the $args + $backend = $reflectionObj->newInstanceArgs($arguments); + self::useBackend($backend); + $_setupedBackends[]=$i; + }else{ + OC_Log::write('core','User backend '.$class.' not found.',OC_Log::ERROR); + } + } + } + /** * @brief Create a new user * @param $uid The username of the user to create @@ -253,6 +277,7 @@ class OC_User { public static function isLoggedIn(){ if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) { OC_App::loadApps(array('authentication')); + self::setupBackends(); if (self::userExists($_SESSION['user_id']) ){ return true; } -- cgit v1.2.3