return OC::$server->getUserSession();
}
- /**
- * @return \OC\User\Manager
- * @deprecated Use \OC::$server->getUserManager()
- */
- public static function getManager() {
- return OC::$server->getUserManager();
- }
-
private static $_backends = array();
private static $_usedBackends = array();
public static function useBackend($backend = 'database') {
if ($backend instanceof OC_User_Interface) {
self::$_usedBackends[get_class($backend)] = $backend;
- self::getManager()->registerBackend($backend);
+ \OC::$server->getUserManager()->registerBackend($backend);
} else {
// You'll never know what happens
if (null === $backend OR !is_string($backend)) {
case 'sqlite':
\OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', \OCP\Util::DEBUG);
self::$_usedBackends[$backend] = new OC_User_Database();
- self::getManager()->registerBackend(self::$_usedBackends[$backend]);
+ \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
break;
case 'dummy':
self::$_usedBackends[$backend] = new \Test\Util\User\Dummy();
- self::getManager()->registerBackend(self::$_usedBackends[$backend]);
+ \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
break;
default:
\OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', \OCP\Util::DEBUG);
$className = 'OC_USER_' . strToUpper($backend);
self::$_usedBackends[$backend] = new $className();
- self::getManager()->registerBackend(self::$_usedBackends[$backend]);
+ \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
break;
}
}
*/
public static function clearBackends() {
self::$_usedBackends = array();
- self::getManager()->clearBackends();
+ \OC::$server->getUserManager()->clearBackends();
}
/**
* @deprecated Use \OC::$server->getUserManager()->createUser($uid, $password)
*/
public static function createUser($uid, $password) {
- return self::getManager()->createUser($uid, $password);
+ return \OC::$server->getUserManager()->createUser($uid, $password);
}
/**
* @deprecated Use \OC::$server->getUserManager()->get() and then run delete() on the return
*/
public static function deleteUser($uid) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
return $user->delete();
} else {
if (is_null($displayName)) {
$displayName = $uid;
}
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
return $user->setDisplayName($displayName);
} else {
*/
public static function getDisplayName($uid = null) {
if ($uid) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
return $user->getDisplayName();
} else {
* Change the password of a user
*/
public static function setPassword($uid, $password, $recoveryPassword = null) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
return $user->setPassword($password, $recoveryPassword);
} else {
* Check whether a specified user can change his avatar
*/
public static function canUserChangeAvatar($uid) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
return $user->canChangeAvatar();
} else {
* Check whether a specified user can change his password
*/
public static function canUserChangePassword($uid) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
return $user->canChangePassword();
} else {
* Check whether a specified user can change his display name
*/
public static function canUserChangeDisplayName($uid) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
return $user->canChangeDisplayName();
} else {
* returns the user id or false
*/
public static function checkPassword($uid, $password) {
- $manager = self::getManager();
+ $manager = \OC::$server->getUserManager();
$username = $manager->checkPassword($uid, $password);
if ($username !== false) {
return $username->getUID();
* @deprecated Use \OC::$server->getUserManager->getHome()
*/
public static function getHome($uid) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
return $user->getHome();
} else {
* @param integer $offset
*/
public static function getUsers($search = '', $limit = null, $offset = null) {
- $users = self::getManager()->search($search, $limit, $offset);
+ $users = \OC::$server->getUserManager()->search($search, $limit, $offset);
$uids = array();
foreach ($users as $user) {
$uids[] = $user->getUID();
*/
public static function getDisplayNames($search = '', $limit = null, $offset = null) {
$displayNames = array();
- $users = self::getManager()->searchDisplayName($search, $limit, $offset);
+ $users = \OC::$server->getUserManager()->searchDisplayName($search, $limit, $offset);
foreach ($users as $user) {
$displayNames[$user->getUID()] = $user->getDisplayName();
}
* @return boolean
*/
public static function userExists($uid) {
- return self::getManager()->userExists($uid);
+ return \OC::$server->getUserManager()->userExists($uid);
}
/**
* @param string $uid the user to disable
*/
public static function disableUser($uid) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
$user->setEnabled(false);
}
* @param string $uid
*/
public static function enableUser($uid) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
$user->setEnabled(true);
}
* @return bool
*/
public static function isEnabled($uid) {
- $user = self::getManager()->get($uid);
+ $user = \OC::$server->getUserManager()->get($uid);
if ($user) {
return $user->isEnabled();
} else {