implement getHome in OC_User

remotes/origin/stable45
Georg Ehrke 14 years ago
parent 80374c7cb2
commit 5a4854079f
  1. 21
      lib/user.php
  2. 11
      lib/user/backend.php
  3. 13
      lib/user/database.php
  4. 10
      lib/user/example.php
  5. 13
      lib/user/http.php
  6. 7
      lib/user/interface.php

@ -332,6 +332,27 @@ class OC_User {
}
}
/**
* @brief Check if the password is correct
* @param $uid The username
* @param $password The password
* @returns string
*
* Check if the password is correct without logging in the user
* returns the user id or false
*/
public static function getHome($uid){
foreach(self::$_usedBackends as $backend){
if($backend->implementsActions(OC_USER_BACKEND_GET_HOME)){
$result=$backend->getHome($uid);
if($result){
return $result;
}
}
}
return OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/' . $user;
}
/**
* @brief Get a list of all users
* @returns array with all uids

@ -34,6 +34,7 @@ define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501);
define('OC_USER_BACKEND_CREATE_USER', 0x000001);
define('OC_USER_BACKEND_SET_PASSWORD', 0x000010);
define('OC_USER_BACKEND_CHECK_PASSWORD', 0x000100);
define('OC_USER_BACKEND_GET_HOME', 0x001000);
/**
@ -48,6 +49,7 @@ abstract class OC_User_Backend implements OC_User_Interface {
OC_USER_BACKEND_CREATE_USER => 'createUser',
OC_USER_BACKEND_SET_PASSWORD => 'setPassword',
OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword',
OC_USER_BACKEND_GET_HOME => 'getHome',
);
/**
@ -109,4 +111,13 @@ abstract class OC_User_Backend implements OC_User_Interface {
public function userExists($uid){
return false;
}
/**
* @brief get the user's home directory
* @param string $uid the username
* @return boolean
*/
public function getHome($uid){
return false;
}
}

@ -175,4 +175,17 @@ class OC_User_Database extends OC_User_Backend {
return $result->numRows() > 0;
}
/**
* @brief get the user's home directory
* @param string $uid the username
* @return boolean
*/
public function getHome($uid){
if($this->userExists($uid)){
return OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/' . $user;
}else{
return false;
}
}
}

@ -57,4 +57,14 @@ abstract class OC_User_Example extends OC_User_Backend {
* returns the user id or false
*/
abstract public function checkPassword($uid, $password);
/**
* @brief get the user's home directory
* @param $uid The username
* @returns string
*
* get the user's home directory
* returns the path or false
*/
abstract public function getHome($uid);
}

@ -90,4 +90,17 @@ class OC_User_HTTP extends OC_User_Backend {
public function userExists($uid){
return $this->matchUrl($uid);
}
/**
* @brief get the user's home directory
* @param string $uid the username
* @return boolean
*/
public function getHome($uid){
if($this->userExists($uid)){
return OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/' . $user;
}else{
return false;
}
}
}

@ -57,4 +57,11 @@ interface OC_User_Interface {
*/
public function userExists($uid);
/**
* @brief get the user's home directory
* @param string $uid the username
* @return boolean
*/
public function getHome($uid);
}
Loading…
Cancel
Save