diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-08-26 16:24:25 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-08-26 16:24:25 +0200 |
commit | 5a4854079fbf9c6b359c1c9afdaeb5c6e19609e8 (patch) | |
tree | 296c65980f5202881c302c1205943e0ba5d23965 /lib | |
parent | 80374c7cb2f3c98e350c95f92a9785aacef5d2c4 (diff) | |
download | nextcloud-server-5a4854079fbf9c6b359c1c9afdaeb5c6e19609e8.tar.gz nextcloud-server-5a4854079fbf9c6b359c1c9afdaeb5c6e19609e8.zip |
implement getHome in OC_User
Diffstat (limited to 'lib')
-rw-r--r-- | lib/user.php | 21 | ||||
-rw-r--r-- | lib/user/backend.php | 11 | ||||
-rw-r--r-- | lib/user/database.php | 13 | ||||
-rw-r--r-- | lib/user/example.php | 10 | ||||
-rw-r--r-- | lib/user/http.php | 13 | ||||
-rw-r--r-- | lib/user/interface.php | 7 |
6 files changed, 75 insertions, 0 deletions
diff --git a/lib/user.php b/lib/user.php index 06a56b7f4a6..97ec0c10504 100644 --- a/lib/user.php +++ b/lib/user.php @@ -333,6 +333,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 f67908cdac0..36e4bd9f761 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 dff4d145fc7..12cd804641b 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 77246d8136c..b2d0dc25410 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 009aa30c6f5..87f3347a236 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 a4903898fb1..5e5efe0010a 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 |