cache the home folder of a User

This commit is contained in:
Robin Appelman 2013-12-11 16:22:26 +01:00
parent 050f87c9e4
commit 366d75e947
2 changed files with 73 additions and 67 deletions

View File

@ -121,7 +121,7 @@ class OC_User_Database extends OC_User_Backend {
*/
public function setDisplayName($uid, $displayName) {
if ($this->userExists($uid)) {
$query = OC_DB::prepare( 'UPDATE `*PREFIX*users` SET `displayname` = ? WHERE `uid` = ?' );
$query = OC_DB::prepare('UPDATE `*PREFIX*users` SET `displayname` = ? WHERE LOWER(`uid`) = ?');
$query->execute(array($displayName, $uid));
return true;
} else {
@ -132,10 +132,9 @@ class OC_User_Database extends OC_User_Backend {
/**
* @brief get display name of the user
* @param $uid user ID of the user
* @return display name
* @return string display name
*/
public function getDisplayName($uid) {
if( $this->userExists($uid) ) {
$query = OC_DB::prepare('SELECT `displayname` FROM `*PREFIX*users` WHERE `uid` = ?');
$result = $query->execute(array($uid))->fetchAll();
$displayName = trim($result[0]['displayname'], ' ');
@ -145,7 +144,6 @@ class OC_User_Database extends OC_User_Backend {
return $uid;
}
}
}
/**
* @brief Get a list of all display names

View File

@ -37,6 +37,11 @@ class User {
*/
private $emitter;
/**
* @var string $home
*/
private $home;
/**
* @param string $uid
* @param \OC_User_Backend $backend
@ -133,10 +138,13 @@ class User {
* @return string
*/
public function getHome() {
if (!$this->home) {
if ($this->backend->implementsActions(\OC_USER_BACKEND_GET_HOME) and $home = $this->backend->getHome($this->uid)) {
return $home;
$this->home = $home;
}
return \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $this->uid; //TODO switch to Config object once implemented
$this->home = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $this->uid; //TODO switch to Config object once implemented
}
return $this->home;
}
/**