diff --git a/lib/user.php b/lib/user.php index 06a56b7f4a62b79c3d6e53df03e83dccbdd70a8e..97ec0c10504744beb1db8ea191d0738346337144 100644 --- a/lib/user.php +++ b/lib/user.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 diff --git a/lib/user/backend.php b/lib/user/backend.php index f67908cdac0f10cb702bfd4f467cb6632f90d39f..36e4bd9f761ae16cb8896faff507206909919d6e 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -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; + } } diff --git a/lib/user/database.php b/lib/user/database.php index dff4d145fc7578d91ee9e9c0a272e65d2f408930..12cd804641bf8e91374a04617eeee5e50f8cc752 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -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; + } + } } diff --git a/lib/user/example.php b/lib/user/example.php index 77246d8136c4bb071e9f5d8298127e5588c7a35f..b2d0dc2541036554630b1e93ca6837eaa05d4439 100644 --- a/lib/user/example.php +++ b/lib/user/example.php @@ -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); } diff --git a/lib/user/http.php b/lib/user/http.php index 009aa30c6f59a151d6b84c13dad895b59a3feb51..87f3347a2363ad9401fb5be063fa200a4b532b61 100644 --- a/lib/user/http.php +++ b/lib/user/http.php @@ -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 diff --git a/lib/user/interface.php b/lib/user/interface.php index a4903898fb1c5f88908d0e1e1c2a8885ed4326e8..5e5efe0010a4295fbfe55671932b11c5fdb9c101 100644 --- a/lib/user/interface.php +++ b/lib/user/interface.php @@ -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