diff options
Diffstat (limited to 'lib/private/user')
-rw-r--r-- | lib/private/user/backend.php | 4 | ||||
-rw-r--r-- | lib/private/user/database.php | 42 | ||||
-rw-r--r-- | lib/private/user/dummy.php | 2 | ||||
-rw-r--r-- | lib/private/user/example.php | 22 | ||||
-rw-r--r-- | lib/private/user/http.php | 10 | ||||
-rw-r--r-- | lib/private/user/interface.php | 18 | ||||
-rw-r--r-- | lib/private/user/manager.php | 16 | ||||
-rw-r--r-- | lib/private/user/session.php | 6 | ||||
-rw-r--r-- | lib/private/user/user.php | 18 |
9 files changed, 68 insertions, 70 deletions
diff --git a/lib/private/user/backend.php b/lib/private/user/backend.php index f4e5618e04a..8d2f0e935de 100644 --- a/lib/private/user/backend.php +++ b/lib/private/user/backend.php @@ -103,7 +103,7 @@ abstract class OC_User_Backend implements OC_User_Interface { /** * @brief Get a list of all users - * @returns array with all uids + * @return array an array of all uids * * Get a list of all users. */ @@ -140,7 +140,7 @@ abstract class OC_User_Backend implements OC_User_Interface { /** * @brief Get a list of all display names - * @returns array with all displayNames (value) and the corresponding uids (key) + * @return array an array of all displayNames (value) and the corresponding uids (key) * * Get a list of all display names and user ids. */ diff --git a/lib/private/user/database.php b/lib/private/user/database.php index 681f03981f5..747895a8a95 100644 --- a/lib/private/user/database.php +++ b/lib/private/user/database.php @@ -57,9 +57,9 @@ class OC_User_Database extends OC_User_Backend { /** * @brief Create a new user - * @param $uid The username of the user to create - * @param $password The password of the new user - * @returns true/false + * @param string $uid The username of the user to create + * @param string $password The password of the new user + * @return bool * * Creates a new user. Basic checking of username is done in OC_User * itself, not in its subclasses. @@ -79,8 +79,8 @@ class OC_User_Database extends OC_User_Backend { /** * @brief delete a user - * @param $uid The username of the user to delete - * @returns true/false + * @param string $uid The username of the user to delete + * @return bool * * Deletes a user */ @@ -98,9 +98,9 @@ class OC_User_Database extends OC_User_Backend { /** * @brief Set password - * @param $uid The username - * @param $password The new password - * @returns true/false + * @param string $uid The username + * @param string $password The new password + * @return bool * * Change the password of a user */ @@ -119,9 +119,9 @@ class OC_User_Database extends OC_User_Backend { /** * @brief Set display name - * @param $uid The username - * @param $displayName The new display name - * @returns true/false + * @param string $uid The username + * @param string $displayName The new display name + * @return bool * * Change the display name of a user */ @@ -139,7 +139,7 @@ class OC_User_Database extends OC_User_Backend { /** * @brief get display name of the user - * @param $uid user ID of the user + * @param string $uid user ID of the user * @return string display name */ public function getDisplayName($uid) { @@ -149,7 +149,7 @@ class OC_User_Database extends OC_User_Backend { /** * @brief Get a list of all display names - * @returns array with all displayNames (value) and the correspondig uids (key) + * @return array an array of all displayNames (value) and the correspondig uids (key) * * Get a list of all display names and user ids. */ @@ -169,9 +169,9 @@ class OC_User_Database extends OC_User_Backend { /** * @brief Check if the password is correct - * @param $uid The username - * @param $password The password - * @returns string + * @param string $uid The username + * @param string $password The password + * @return string * * Check if the password is correct without logging in the user * returns the user id or false @@ -183,14 +183,14 @@ class OC_User_Database extends OC_User_Backend { $row = $result->fetchRow(); if ($row) { $storedHash = $row['password']; - if ($storedHash[0] == '$') { //the new phpass based hashing + if ($storedHash[0] === '$') { //the new phpass based hashing $hasher = $this->getHasher(); if ($hasher->CheckPassword($password . OC_Config::getValue('passwordsalt', ''), $storedHash)) { return $row['uid']; } //old sha1 based hashing - } elseif (sha1($password) == $storedHash) { + } elseif (sha1($password) === $storedHash) { //upgrade to new hashing $this->setPassword($row['uid'], $password); return $row['uid']; @@ -203,7 +203,7 @@ class OC_User_Database extends OC_User_Backend { /** * @brief Load an user in the cache * @param string $uid the username - * @returns boolean + * @return boolean */ private function loadUser($uid) { if (empty($this->cache[$uid])) { @@ -226,7 +226,7 @@ class OC_User_Database extends OC_User_Backend { /** * @brief Get a list of all users - * @returns array with all uids + * @return array an array of all uids * * Get a list of all users. */ @@ -273,7 +273,7 @@ class OC_User_Database extends OC_User_Backend { /** * counts the users in the database * - * @return int | bool + * @return int|bool */ public function countUsers() { $query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); diff --git a/lib/private/user/dummy.php b/lib/private/user/dummy.php index 2fb51d02de3..d2ada37c80f 100644 --- a/lib/private/user/dummy.php +++ b/lib/private/user/dummy.php @@ -127,7 +127,7 @@ class OC_User_Dummy extends OC_User_Backend { /** * counts the users in the database * - * @return int | bool + * @return int|bool */ public function countUsers() { return 0; diff --git a/lib/private/user/example.php b/lib/private/user/example.php index b2d0dc25410..4bf3652330e 100644 --- a/lib/private/user/example.php +++ b/lib/private/user/example.php @@ -28,9 +28,9 @@ abstract class OC_User_Example extends OC_User_Backend { /** * @brief Create a new user - * @param $uid The username of the user to create - * @param $password The password of the new user - * @returns true/false + * @param string $uid The username of the user to create + * @param string $password The password of the new user + * @return bool * * Creates a new user. Basic checking of username is done in OC_User * itself, not in its subclasses. @@ -39,9 +39,9 @@ abstract class OC_User_Example extends OC_User_Backend { /** * @brief Set password - * @param $uid The username - * @param $password The new password - * @returns true/false + * @param string $uid The username + * @param string $password The new password + * @return bool * * Change the password of a user */ @@ -49,9 +49,9 @@ abstract class OC_User_Example extends OC_User_Backend { /** * @brief Check if the password is correct - * @param $uid The username - * @param $password The password - * @returns string + * @param string $uid The username + * @param string $password The password + * @return string * * Check if the password is correct without logging in the user * returns the user id or false @@ -60,8 +60,8 @@ abstract class OC_User_Example extends OC_User_Backend { /** * @brief get the user's home directory - * @param $uid The username - * @returns string + * @param string $uid The username + * @return string * * get the user's home directory * returns the path or false diff --git a/lib/private/user/http.php b/lib/private/user/http.php index a0394521012..67f7156b498 100644 --- a/lib/private/user/http.php +++ b/lib/private/user/http.php @@ -27,7 +27,7 @@ class OC_User_HTTP extends OC_User_Backend { /** * split http://user@host/path into a user and url part - * @param string path + * @param string $url * @return array */ private function parseUrl($url) { @@ -46,7 +46,7 @@ class OC_User_HTTP extends OC_User_Backend { /** * check if an url is a valid login - * @param string url + * @param string $url * @return boolean */ private function matchUrl($url) { @@ -55,9 +55,9 @@ class OC_User_HTTP extends OC_User_Backend { /** * @brief Check if the password is correct - * @param $uid The username - * @param $password The password - * @returns string + * @param string $uid The username + * @param string $password The password + * @return string * * Check if the password is correct without logging in the user * returns the user id or false diff --git a/lib/private/user/interface.php b/lib/private/user/interface.php index cdcab3e5d00..e130e5b569c 100644 --- a/lib/private/user/interface.php +++ b/lib/private/user/interface.php @@ -26,27 +26,23 @@ interface OC_User_Interface { /** * @brief Check if backend implements actions * @param $actions bitwise-or'ed actions - * @returns boolean + * @return boolean * * Returns the supported actions as int to be * compared with OC_USER_BACKEND_CREATE_USER etc. - * @return boolean */ public function implementsActions($actions); /** * @brief delete a user - * @param $uid The username of the user to delete - * @returns true/false - * - * Deletes a user - * @return boolean + * @param string $uid The username of the user to delete + * @return bool */ public function deleteUser($uid); /** * @brief Get a list of all users - * @returns array with all uids + * @return array an array of all uids * * Get a list of all users. */ @@ -61,14 +57,14 @@ interface OC_User_Interface { /** * @brief get display name of the user - * @param $uid user ID of the user - * @return display name + * @param string $uid user ID of the user + * @return string display name */ public function getDisplayName($uid); /** * @brief Get a list of all display names - * @returns array with all displayNames (value) and the corresponding uids (key) + * @return array an array of all displayNames (value) and the corresponding uids (key) * * Get a list of all display names and user ids. */ diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php index 14698452e88..0fcf1ceb6ab 100644 --- a/lib/private/user/manager.php +++ b/lib/private/user/manager.php @@ -26,7 +26,7 @@ use OC\Hooks\PublicEmitter; */ class Manager extends PublicEmitter { /** - * @var \OC_User_Backend[] $backends + * @var \OC_User_Interface[] $backends */ private $backends = array(); @@ -57,7 +57,7 @@ class Manager extends PublicEmitter { /** * register a user backend * - * @param \OC_User_Backend $backend + * @param \OC_User_Interface $backend */ public function registerBackend($backend) { $this->backends[] = $backend; @@ -66,7 +66,7 @@ class Manager extends PublicEmitter { /** * remove a user backend * - * @param \OC_User_Backend $backend + * @param \OC_User_Interface $backend */ public function removeBackend($backend) { $this->cachedUsers = array(); @@ -105,7 +105,7 @@ class Manager extends PublicEmitter { * get or construct the user object * * @param string $uid - * @param \OC_User_Backend $backend + * @param \OC_User_Interface $backend * @return \OC\User\User */ protected function getUserObject($uid, $backend) { @@ -174,12 +174,12 @@ class Manager extends PublicEmitter { $backendUsers = $backend->getUsers($pattern, $limit, $offset); if (is_array($backendUsers)) { foreach ($backendUsers as $uid) { - $users[] = $this->getUserObject($uid, $backend); + $users[$uid] = $this->getUserObject($uid, $backend); } } } - usort($users, function ($a, $b) { + uasort($users, function ($a, $b) { /** * @var \OC\User\User $a * @var \OC\User\User $b @@ -222,7 +222,7 @@ class Manager extends PublicEmitter { * @param string $uid * @param string $password * @throws \Exception - * @return bool | \OC\User\User the created user of false + * @return bool|\OC\User\User the created user of false */ public function createUser($uid, $password) { $l = \OC_L10N::get('lib'); @@ -261,7 +261,7 @@ class Manager extends PublicEmitter { /** * returns how many users per backend exist (if supported by backend) * - * @return array with backend class as key and count number as value + * @return array an array of backend class as key and count number as value */ public function countUsers() { $userCountStatistics = array(); diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 1740bad5abe..3d10b134b83 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -82,7 +82,7 @@ class Session implements Emitter, \OCP\IUserSession { /** * set the currently active user * - * @param \OC\User\User $user + * @param \OC\User\User|null $user */ public function setUser($user) { if (is_null($user)) { @@ -115,7 +115,7 @@ class Session implements Emitter, \OCP\IUserSession { /** * set the login name * - * @param string $loginName for the logged in user + * @param string|null $loginName for the logged in user */ public function setLoginName($loginName) { if (is_null($loginName)) { @@ -191,7 +191,7 @@ class Session implements Emitter, \OCP\IUserSession { $expires = time() + \OC_Config::getValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15); setcookie("oc_username", $username, $expires, \OC::$WEBROOT, '', $secure_cookie); setcookie("oc_token", $token, $expires, \OC::$WEBROOT, '', $secure_cookie, true); - setcookie("oc_remember_login", true, $expires, \OC::$WEBROOT, '', $secure_cookie); + setcookie("oc_remember_login", "1", $expires, \OC::$WEBROOT, '', $secure_cookie); } /** diff --git a/lib/private/user/user.php b/lib/private/user/user.php index ef5364cbf7b..bc5c541e521 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -23,7 +23,7 @@ class User { private $displayName; /** - * @var \OC_User_Backend $backend + * @var \OC_User_Interface $backend */ private $backend; @@ -33,7 +33,7 @@ class User { private $enabled; /** - * @var Emitter | Manager $emitter + * @var Emitter|Manager $emitter */ private $emitter; @@ -49,17 +49,12 @@ class User { /** * @param string $uid - * @param \OC_User_Backend $backend + * @param \OC_User_Interface $backend * @param \OC\Hooks\Emitter $emitter * @param \OC\AllConfig $config */ public function __construct($uid, $backend, $emitter = null, $config = null) { $this->uid = $uid; - if ($backend and $backend->implementsActions(OC_USER_BACKEND_GET_DISPLAYNAME)) { - $this->displayName = $backend->getDisplayName($uid); - } else { - $this->displayName = $uid; - } $this->backend = $backend; $this->emitter = $emitter; $this->config = $config; @@ -86,6 +81,13 @@ class User { * @return string */ public function getDisplayName() { + if (!isset($this->displayName)) { + if ($this->backend and $this->backend->implementsActions(OC_USER_BACKEND_GET_DISPLAYNAME)) { + $this->displayName = $this->backend->getDisplayName($this->uid); + } else { + $this->displayName = $this->uid; + } + } return $this->displayName; } |