Skip to content
Snippets Groups Projects
Commit 5a485407 authored by Georg Ehrke's avatar Georg Ehrke
Browse files

implement getHome in OC_User

parent 80374c7c
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
}
\ No newline at end of file
......@@ -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);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment