Skip to content

Commit

Permalink
allow a more flexible way of using user backends
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Jul 19, 2012
1 parent e031b9b commit 33b8de9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public static function init(){
$_SESSION['user_id'] = '';
}

OC_User::useBackend( OC_Config::getValue( "userbackend", "database" ));
OC_User::useBackend(new OC_User_Database());
OC_Group::useBackend(new OC_Group_Database());

// Load Apps
Expand Down
38 changes: 21 additions & 17 deletions lib/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class OC_User {
*
* Makes a list of backends that can be used by other modules
*/
public static function registerBackend( $name ){
self::$_backends[] = $name;
public static function registerBackend( $backend ){
self::$_backends[] = $backend;
return true;
}

Expand Down Expand Up @@ -83,22 +83,26 @@ public static function getUsedBackends(){
* Set the User Authentication Module
*/
public static function useBackend( $backend = 'database' ){
// You'll never know what happens
if( null === $backend OR !is_string( $backend )){
$backend = 'database';
}
if($backend instanceof OC_User_Backend){
self::$_usedBackends[get_class($backend)]=$backend;
}else{
// You'll never know what happens
if( null === $backend OR !is_string( $backend )){
$backend = 'database';
}

// Load backend
switch( $backend ){
case 'database':
case 'mysql':
case 'sqlite':
self::$_usedBackends[$backend] = new OC_User_Database();
break;
default:
$className = 'OC_USER_' . strToUpper($backend);
self::$_usedBackends[$backend] = new $className();
break;
// Load backend
switch( $backend ){
case 'database':
case 'mysql':
case 'sqlite':
self::$_usedBackends[$backend] = new OC_User_Database();
break;
default:
$className = 'OC_USER_' . strToUpper($backend);
self::$_usedBackends[$backend] = new $className();
break;
}
}

true;
Expand Down

0 comments on commit 33b8de9

Please sign in to comment.