diff options
-rw-r--r-- | lib/private/files/storage/local.php | 77 | ||||
-rw-r--r-- | lib/private/files/storage/mappedlocal.php | 65 | ||||
-rw-r--r-- | lib/private/group/backend.php | 32 | ||||
-rw-r--r-- | lib/private/group/group.php | 8 | ||||
-rw-r--r-- | lib/private/group/interface.php | 2 | ||||
-rw-r--r-- | lib/private/group/manager.php | 2 | ||||
-rw-r--r-- | lib/private/user/backend.php | 45 | ||||
-rw-r--r-- | lib/private/user/interface.php | 4 | ||||
-rw-r--r-- | lib/private/user/manager.php | 6 | ||||
-rw-r--r-- | lib/private/user/user.php | 14 |
10 files changed, 159 insertions, 96 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index 1c5fafc12fa..7b4abf08f44 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -35,7 +35,7 @@ if (\OC_Util::runningOnWindows()) { } public function mkdir($path) { - return @mkdir($this->datadir . $path, 0777, true); + return @mkdir($this->getSourcePath($path), 0777, true); } public function rmdir($path) { @@ -44,7 +44,7 @@ if (\OC_Util::runningOnWindows()) { } try { $it = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($this->datadir . $path), + new \RecursiveDirectoryIterator($this->getSourcePath($path)), \RecursiveIteratorIterator::CHILD_FIRST ); /** @@ -68,30 +68,30 @@ if (\OC_Util::runningOnWindows()) { } $it->next(); } - return rmdir($this->datadir . $path); + return rmdir($this->getSourcePath($path)); } catch (\UnexpectedValueException $e) { return false; } } public function opendir($path) { - return opendir($this->datadir . $path); + return opendir($this->getSourcePath($path)); } public function is_dir($path) { if (substr($path, -1) == '/') { $path = substr($path, 0, -1); } - return is_dir($this->datadir . $path); + return is_dir($this->getSourcePath($path)); } public function is_file($path) { - return is_file($this->datadir . $path); + return is_file($this->getSourcePath($path)); } public function stat($path) { clearstatcache(); - $fullPath = $this->datadir . $path; + $fullPath = $this->getSourcePath($path); $statResult = stat($fullPath); if (PHP_INT_SIZE === 4 && !$this->is_dir($path)) { $filesize = $this->filesize($path); @@ -102,9 +102,9 @@ if (\OC_Util::runningOnWindows()) { } public function filetype($path) { - $filetype = filetype($this->datadir . $path); + $filetype = filetype($this->getSourcePath($path)); if ($filetype == 'link') { - $filetype = filetype(realpath($this->datadir . $path)); + $filetype = filetype(realpath($this->getSourcePath($path))); } return $filetype; } @@ -113,7 +113,7 @@ if (\OC_Util::runningOnWindows()) { if ($this->is_dir($path)) { return 0; } - $fullPath = $this->datadir . $path; + $fullPath = $this->getSourcePath($path); if (PHP_INT_SIZE === 4) { $helper = new \OC\LargeFileHelper; return $helper->getFilesize($fullPath); @@ -122,19 +122,19 @@ if (\OC_Util::runningOnWindows()) { } public function isReadable($path) { - return is_readable($this->datadir . $path); + return is_readable($this->getSourcePath($path)); } public function isUpdatable($path) { - return is_writable($this->datadir . $path); + return is_writable($this->getSourcePath($path)); } public function file_exists($path) { - return file_exists($this->datadir . $path); + return file_exists($this->getSourcePath($path)); } public function filemtime($path) { - return filemtime($this->datadir . $path); + return filemtime($this->getSourcePath($path)); } public function touch($path, $mtime = null) { @@ -145,30 +145,30 @@ if (\OC_Util::runningOnWindows()) { return false; } if (!is_null($mtime)) { - $result = touch($this->datadir . $path, $mtime); + $result = touch($this->getSourcePath($path), $mtime); } else { - $result = touch($this->datadir . $path); + $result = touch($this->getSourcePath($path)); } if ($result) { - clearstatcache(true, $this->datadir . $path); + clearstatcache(true, $this->getSourcePath($path)); } return $result; } public function file_get_contents($path) { - return file_get_contents($this->datadir . $path); + return file_get_contents($this->getSourcePath($path)); } - public function file_put_contents($path, $data) { //trigger_error("$path = ".var_export($path, 1)); - return file_put_contents($this->datadir . $path, $data); + public function file_put_contents($path, $data) { + return file_put_contents($this->getSourcePath($path), $data); } public function unlink($path) { if ($this->is_dir($path)) { return $this->rmdir($path); } else if ($this->is_file($path)) { - return unlink($this->datadir . $path); + return unlink($this->getSourcePath($path)); } else { return false; } @@ -200,27 +200,27 @@ if (\OC_Util::runningOnWindows()) { $this->unlink($path2); } - return rename($this->datadir . $path1, $this->datadir . $path2); + return rename($this->getSourcePath($path1), $this->getSourcePath($path2)); } public function copy($path1, $path2) { if ($this->is_dir($path1)) { return parent::copy($path1, $path2); } else { - return copy($this->datadir . $path1, $this->datadir . $path2); + return copy($this->getSourcePath($path1), $this->getSourcePath($path2)); } } public function fopen($path, $mode) { - return fopen($this->datadir . $path, $mode); + return fopen($this->getSourcePath($path), $mode); } public function hash($type, $path, $raw = false) { - return hash_file($type, $this->datadir . $path, $raw); + return hash_file($type, $this->getSourcePath($path), $raw); } public function free_space($path) { - $space = @disk_free_space($this->datadir . $path); + $space = @disk_free_space($this->getSourcePath($path)); if ($space === false || is_null($space)) { return \OCP\Files\FileInfo::SPACE_UNKNOWN; } @@ -232,11 +232,11 @@ if (\OC_Util::runningOnWindows()) { } public function getLocalFile($path) { - return $this->datadir . $path; + return $this->getSourcePath($path); } public function getLocalFolder($path) { - return $this->datadir . $path; + return $this->getSourcePath($path); } /** @@ -244,12 +244,16 @@ if (\OC_Util::runningOnWindows()) { */ protected function searchInDir($query, $dir = '') { $files = array(); - foreach (scandir($this->datadir . $dir) as $item) { - if ($item == '.' || $item == '..') continue; + $physicalDir = $this->getSourcePath($dir); + foreach (scandir($physicalDir) as $item) { + if ($item == '.' || $item == '..') + continue; + $physicalItem = $physicalDir . '/' . $item; + if (strstr(strtolower($item), strtolower($query)) !== false) { $files[] = $dir . '/' . $item; } - if (is_dir($this->datadir . $dir . '/' . $item)) { + if (is_dir($physicalItem)) { $files = array_merge($files, $this->searchInDir($query, $dir . '/' . $item)); } } @@ -272,6 +276,17 @@ if (\OC_Util::runningOnWindows()) { } /** + * Get the source path (on disk) of a given path + * + * @param string $path + * @return string + */ + protected function getSourcePath($path) { + $fullPath = $this->datadir . $path; + return $fullPath; + } + + /** * {@inheritdoc} */ public function isLocal() { diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php index c232c0298b1..1b26e3ac0f9 100644 --- a/lib/private/files/storage/mappedlocal.php +++ b/lib/private/files/storage/mappedlocal.php @@ -31,7 +31,7 @@ class MappedLocal extends \OC\Files\Storage\Common { } public function mkdir($path) { - return @mkdir($this->buildPath($path), 0777, true); + return @mkdir($this->getSourcePath($path), 0777, true); } public function rmdir($path) { @@ -40,7 +40,7 @@ class MappedLocal extends \OC\Files\Storage\Common { } try { $it = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($this->buildPath($path)), + new \RecursiveDirectoryIterator($this->getSourcePath($path)), \RecursiveIteratorIterator::CHILD_FIRST ); /** @@ -64,7 +64,7 @@ class MappedLocal extends \OC\Files\Storage\Common { } $it->next(); } - if ($result = @rmdir($this->buildPath($path))) { + if ($result = @rmdir($this->getSourcePath($path))) { $this->cleanMapper($path); } return $result; @@ -75,7 +75,7 @@ class MappedLocal extends \OC\Files\Storage\Common { public function opendir($path) { $files = array('.', '..'); - $physicalPath = $this->buildPath($path); + $physicalPath = $this->getSourcePath($path); $logicalPath = $this->mapper->physicalToLogic($physicalPath); $dh = opendir($physicalPath); @@ -101,15 +101,15 @@ class MappedLocal extends \OC\Files\Storage\Common { if (substr($path, -1) == '/') { $path = substr($path, 0, -1); } - return is_dir($this->buildPath($path)); + return is_dir($this->getSourcePath($path)); } public function is_file($path) { - return is_file($this->buildPath($path)); + return is_file($this->getSourcePath($path)); } public function stat($path) { - $fullPath = $this->buildPath($path); + $fullPath = $this->getSourcePath($path); $statResult = stat($fullPath); if (PHP_INT_SIZE === 4 && !$this->is_dir($path)) { $filesize = $this->filesize($path); @@ -120,9 +120,9 @@ class MappedLocal extends \OC\Files\Storage\Common { } public function filetype($path) { - $filetype = filetype($this->buildPath($path)); + $filetype = filetype($this->getSourcePath($path)); if ($filetype == 'link') { - $filetype = filetype(realpath($this->buildPath($path))); + $filetype = filetype(realpath($this->getSourcePath($path))); } return $filetype; } @@ -131,7 +131,7 @@ class MappedLocal extends \OC\Files\Storage\Common { if ($this->is_dir($path)) { return 0; } - $fullPath = $this->buildPath($path); + $fullPath = $this->getSourcePath($path); if (PHP_INT_SIZE === 4) { $helper = new \OC\LargeFileHelper; return $helper->getFilesize($fullPath); @@ -140,19 +140,19 @@ class MappedLocal extends \OC\Files\Storage\Common { } public function isReadable($path) { - return is_readable($this->buildPath($path)); + return is_readable($this->getSourcePath($path)); } public function isUpdatable($path) { - return is_writable($this->buildPath($path)); + return is_writable($this->getSourcePath($path)); } public function file_exists($path) { - return file_exists($this->buildPath($path)); + return file_exists($this->getSourcePath($path)); } public function filemtime($path) { - return filemtime($this->buildPath($path)); + return filemtime($this->getSourcePath($path)); } public function touch($path, $mtime = null) { @@ -160,23 +160,23 @@ class MappedLocal extends \OC\Files\Storage\Common { // If mtime is nil the current time is set. // note that the access time of the file always changes to the current time. if (!is_null($mtime)) { - $result = touch($this->buildPath($path), $mtime); + $result = touch($this->getSourcePath($path), $mtime); } else { - $result = touch($this->buildPath($path)); + $result = touch($this->getSourcePath($path)); } if ($result) { - clearstatcache(true, $this->buildPath($path)); + clearstatcache(true, $this->getSourcePath($path)); } return $result; } public function file_get_contents($path) { - return file_get_contents($this->buildPath($path)); + return file_get_contents($this->getSourcePath($path)); } public function file_put_contents($path, $data) { - return file_put_contents($this->buildPath($path), $data); + return file_put_contents($this->getSourcePath($path), $data); } public function unlink($path) { @@ -208,8 +208,8 @@ class MappedLocal extends \OC\Files\Storage\Common { $this->unlink($path2); } - $physicPath1 = $this->buildPath($path1); - $physicPath2 = $this->buildPath($path2); + $physicPath1 = $this->getSourcePath($path1); + $physicPath2 = $this->getSourcePath($path2); if ($return = rename($physicPath1, $physicPath2)) { // mapper needs to create copies or all children $this->copyMapping($path1, $path2); @@ -237,7 +237,7 @@ class MappedLocal extends \OC\Files\Storage\Common { closedir($dir); return true; } else { - if ($return = copy($this->buildPath($path1), $this->buildPath($path2))) { + if ($return = copy($this->getSourcePath($path1), $this->getSourcePath($path2))) { $this->copyMapping($path1, $path2); } return $return; @@ -245,7 +245,7 @@ class MappedLocal extends \OC\Files\Storage\Common { } public function fopen($path, $mode) { - return fopen($this->buildPath($path), $mode); + return fopen($this->getSourcePath($path), $mode); } /** @@ -256,7 +256,7 @@ class MappedLocal extends \OC\Files\Storage\Common { private function delTree($dir, $isLogicPath = true) { $dirRelative = $dir; if ($isLogicPath) { - $dir = $this->buildPath($dir); + $dir = $this->getSourcePath($dir); } if (!file_exists($dir)) { return true; @@ -288,11 +288,11 @@ class MappedLocal extends \OC\Files\Storage\Common { } public function hash($type, $path, $raw = false) { - return hash_file($type, $this->buildPath($path), $raw); + return hash_file($type, $this->getSourcePath($path), $raw); } public function free_space($path) { - return @disk_free_space($this->buildPath($path)); + return @disk_free_space($this->getSourcePath($path)); } public function search($query) { @@ -300,11 +300,11 @@ class MappedLocal extends \OC\Files\Storage\Common { } public function getLocalFile($path) { - return $this->buildPath($path); + return $this->getSourcePath($path); } public function getLocalFolder($path) { - return $this->buildPath($path); + return $this->getSourcePath($path); } /** @@ -312,7 +312,7 @@ class MappedLocal extends \OC\Files\Storage\Common { */ protected function searchInDir($query, $dir = '') { $files = array(); - $physicalDir = $this->buildPath($dir); + $physicalDir = $this->getSourcePath($dir); foreach (scandir($physicalDir) as $item) { if ($item == '.' || $item == '..') continue; @@ -341,14 +341,15 @@ class MappedLocal extends \OC\Files\Storage\Common { } /** + * Get the source path (on disk) of a given path + * * @param string $path - * @param bool $create * @return string */ - private function buildPath($path, $create = true) { + protected function getSourcePath($path) { $path = $this->stripLeading($path); $fullPath = $this->datadir . $path; - return $this->mapper->logicToPhysical($fullPath, $create); + return $this->mapper->logicToPhysical($fullPath, true); } /** diff --git a/lib/private/group/backend.php b/lib/private/group/backend.php index ab694268bb3..9348463a53c 100644 --- a/lib/private/group/backend.php +++ b/lib/private/group/backend.php @@ -23,29 +23,51 @@ /** * error code for functions not provided by the group backend + * @deprecated Use \OC_Group_Backend::NOT_IMPLEMENTED instead */ define('OC_GROUP_BACKEND_NOT_IMPLEMENTED', -501); /** * actions that user backends can define */ +/** @deprecated Use \OC_Group_Backend::CREATE_GROUP instead */ define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001); +/** @deprecated Use \OC_Group_Backend::DELETE_GROUP instead */ define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010); +/** @deprecated Use \OC_Group_Backend::ADD_TO_GROUP instead */ define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00000100); +/** @deprecated Use \OC_Group_Backend::REMOVE_FROM_GOUP instead */ define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00001000); +/** @deprecated Obsolete */ define('OC_GROUP_BACKEND_GET_DISPLAYNAME', 0x00010000); //OBSOLETE +/** @deprecated Use \OC_Group_Backend::COUNT_USERS instead */ define('OC_GROUP_BACKEND_COUNT_USERS', 0x00100000); /** * Abstract base class for user management */ abstract class OC_Group_Backend implements OC_Group_Interface { + /** + * error code for functions not provided by the group backend + */ + const NOT_IMPLEMENTED = -501; + + /** + * actions that user backends can define + */ + const CREATE_GROUP = 0x00000001; + const DELETE_GROUP = 0x00000010; + const ADD_TO_GROUP = 0x00000100; + const REMOVE_FROM_GOUP = 0x00001000; + //OBSOLETE const GET_DISPLAYNAME = 0x00010000; + const COUNT_USERS = 0x00100000; + protected $possibleActions = array( - OC_GROUP_BACKEND_CREATE_GROUP => 'createGroup', - OC_GROUP_BACKEND_DELETE_GROUP => 'deleteGroup', - OC_GROUP_BACKEND_ADD_TO_GROUP => 'addToGroup', - OC_GROUP_BACKEND_REMOVE_FROM_GOUP => 'removeFromGroup', - OC_GROUP_BACKEND_COUNT_USERS => 'countUsersInGroup', + self::CREATE_GROUP => 'createGroup', + self::DELETE_GROUP => 'deleteGroup', + self::ADD_TO_GROUP => 'addToGroup', + self::REMOVE_FROM_GOUP => 'removeFromGroup', + self::COUNT_USERS => 'countUsersInGroup', ); /** diff --git a/lib/private/group/group.php b/lib/private/group/group.php index 6f8b84dff1a..6111051ea09 100644 --- a/lib/private/group/group.php +++ b/lib/private/group/group.php @@ -118,7 +118,7 @@ class Group implements IGroup { $this->emitter->emit('\OC\Group', 'preAddUser', array($this, $user)); } foreach ($this->backends as $backend) { - if ($backend->implementsActions(OC_GROUP_BACKEND_ADD_TO_GROUP)) { + if ($backend->implementsActions(\OC_Group_Backend::ADD_TO_GROUP)) { $backend->addToGroup($user->getUID(), $this->gid); if ($this->users) { $this->users[$user->getUID()] = $user; @@ -142,7 +142,7 @@ class Group implements IGroup { $this->emitter->emit('\OC\Group', 'preRemoveUser', array($this, $user)); } foreach ($this->backends as $backend) { - if ($backend->implementsActions(OC_GROUP_BACKEND_REMOVE_FROM_GOUP) and $backend->inGroup($user->getUID(), $this->gid)) { + if ($backend->implementsActions(\OC_Group_Backend::REMOVE_FROM_GOUP) and $backend->inGroup($user->getUID(), $this->gid)) { $backend->removeFromGroup($user->getUID(), $this->gid); $result = true; } @@ -191,7 +191,7 @@ class Group implements IGroup { public function count($search = '') { $users = false; foreach ($this->backends as $backend) { - if($backend->implementsActions(OC_GROUP_BACKEND_COUNT_USERS)) { + if($backend->implementsActions(\OC_Group_Backend::COUNT_USERS)) { if($users === false) { //we could directly add to a bool variable, but this would //be ugly @@ -234,7 +234,7 @@ class Group implements IGroup { $this->emitter->emit('\OC\Group', 'preDelete', array($this)); } foreach ($this->backends as $backend) { - if ($backend->implementsActions(OC_GROUP_BACKEND_DELETE_GROUP)) { + if ($backend->implementsActions(\OC_Group_Backend::DELETE_GROUP)) { $result = true; $backend->deleteGroup($this->gid); } diff --git a/lib/private/group/interface.php b/lib/private/group/interface.php index ee5c2d635d6..ee2d718e5dd 100644 --- a/lib/private/group/interface.php +++ b/lib/private/group/interface.php @@ -28,7 +28,7 @@ interface OC_Group_Interface { * @return boolean * * Returns the supported actions as int to be - * compared with OC_GROUP_BACKEND_CREATE_GROUP etc. + * compared with \OC_Group_Backend::CREATE_GROUP etc. */ public function implementsActions($actions); diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php index 417be79ab30..be7bf972693 100644 --- a/lib/private/group/manager.php +++ b/lib/private/group/manager.php @@ -134,7 +134,7 @@ class Manager extends PublicEmitter implements IGroupManager { } else { $this->emit('\OC\Group', 'preCreate', array($gid)); foreach ($this->backends as $backend) { - if ($backend->implementsActions(OC_GROUP_BACKEND_CREATE_GROUP)) { + if ($backend->implementsActions(\OC_Group_Backend::CREATE_GROUP)) { $backend->createGroup($gid); $group = $this->getGroupObject($gid); $this->emit('\OC\Group', 'postCreate', array($group)); diff --git a/lib/private/user/backend.php b/lib/private/user/backend.php index 1f0a524117d..5e0eef4771a 100644 --- a/lib/private/user/backend.php +++ b/lib/private/user/backend.php @@ -25,19 +25,28 @@ /** * error code for functions not provided by the user backend + * @deprecated Use \OC_User_Backend::NOT_IMPLEMENTED instead */ define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501); /** * actions that user backends can define */ +/** @deprecated Use \OC_User_Backend::CREATE_USER instead */ define('OC_USER_BACKEND_CREATE_USER', 1 << 0); +/** @deprecated Use \OC_User_Backend::SET_PASSWORD instead */ define('OC_USER_BACKEND_SET_PASSWORD', 1 << 4); +/** @deprecated Use \OC_User_Backend::CHECK_PASSWORD instead */ define('OC_USER_BACKEND_CHECK_PASSWORD', 1 << 8); +/** @deprecated Use \OC_User_Backend::GET_HOME instead */ define('OC_USER_BACKEND_GET_HOME', 1 << 12); +/** @deprecated Use \OC_User_Backend::GET_DISPLAYNAME instead */ define('OC_USER_BACKEND_GET_DISPLAYNAME', 1 << 16); +/** @deprecated Use \OC_User_Backend::SET_DISPLAYNAME instead */ define('OC_USER_BACKEND_SET_DISPLAYNAME', 1 << 20); +/** @deprecated Use \OC_User_Backend::PROVIDE_AVATAR instead */ define('OC_USER_BACKEND_PROVIDE_AVATAR', 1 << 24); +/** @deprecated Use \OC_User_Backend::COUNT_USERS instead */ define('OC_USER_BACKEND_COUNT_USERS', 1 << 28); /** @@ -47,16 +56,32 @@ define('OC_USER_BACKEND_COUNT_USERS', 1 << 28); * Subclass this for your own backends, and see OC_User_Example for descriptions */ abstract class OC_User_Backend implements OC_User_Interface { + /** + * error code for functions not provided by the user backend + */ + const NOT_IMPLEMENTED = -501; + + /** + * actions that user backends can define + */ + const CREATE_USER = 1; // 1 << 0 + const SET_PASSWORD = 16; // 1 << 4 + const CHECK_PASSWORD = 256; // 1 << 8 + const GET_HOME = 4096; // 1 << 12 + const GET_DISPLAYNAME = 65536; // 1 << 16 + const SET_DISPLAYNAME = 1048576; // 1 << 20 + const PROVIDE_AVATAR = 16777216; // 1 << 24 + const COUNT_USERS = 268435456; // 1 << 28 protected $possibleActions = array( - OC_USER_BACKEND_CREATE_USER => 'createUser', - OC_USER_BACKEND_SET_PASSWORD => 'setPassword', - OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword', - OC_USER_BACKEND_GET_HOME => 'getHome', - OC_USER_BACKEND_GET_DISPLAYNAME => 'getDisplayName', - OC_USER_BACKEND_SET_DISPLAYNAME => 'setDisplayName', - OC_USER_BACKEND_PROVIDE_AVATAR => 'canChangeAvatar', - OC_USER_BACKEND_COUNT_USERS => 'countUsers', + self::CREATE_USER => 'createUser', + self::SET_PASSWORD => 'setPassword', + self::CHECK_PASSWORD => 'checkPassword', + self::GET_HOME => 'getHome', + self::GET_DISPLAYNAME => 'getDisplayName', + self::SET_DISPLAYNAME => 'setDisplayName', + self::PROVIDE_AVATAR => 'canChangeAvatar', + self::COUNT_USERS => 'countUsers', ); /** @@ -64,7 +89,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * @return int bitwise-or'ed actions * * Returns the supported actions as int to be - * compared with OC_USER_BACKEND_CREATE_USER etc. + * compared with self::CREATE_USER etc. */ public function getSupportedActions() { $actions = 0; @@ -83,7 +108,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * @return boolean * * Returns the supported actions as int to be - * compared with OC_USER_BACKEND_CREATE_USER etc. + * compared with self::CREATE_USER etc. */ public function implementsActions($actions) { return (bool)($this->getSupportedActions() & $actions); diff --git a/lib/private/user/interface.php b/lib/private/user/interface.php index 4cdc47479a3..624d36e6fe5 100644 --- a/lib/private/user/interface.php +++ b/lib/private/user/interface.php @@ -25,11 +25,11 @@ interface OC_User_Interface { /** * Check if backend implements actions - * @param $actions bitwise-or'ed actions + * @param int $actions bitwise-or'ed actions * @return boolean * * Returns the supported actions as int to be - * compared with OC_USER_BACKEND_CREATE_USER etc. + * compared with \OC_User_Backend::CREATE_USER etc. */ public function implementsActions($actions); diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php index 4d1612a35ce..0c01f957bd3 100644 --- a/lib/private/user/manager.php +++ b/lib/private/user/manager.php @@ -143,7 +143,7 @@ class Manager extends PublicEmitter implements IUserManager { */ public function checkPassword($loginname, $password) { foreach ($this->backends as $backend) { - if ($backend->implementsActions(\OC_USER_BACKEND_CHECK_PASSWORD)) { + if ($backend->implementsActions(\OC_User_Backend::CHECK_PASSWORD)) { $uid = $backend->checkPassword($loginname, $password); if ($uid !== false) { return $this->getUserObject($uid, $backend); @@ -246,7 +246,7 @@ class Manager extends PublicEmitter implements IUserManager { $this->emit('\OC\User', 'preCreateUser', array($uid, $password)); foreach ($this->backends as $backend) { - if ($backend->implementsActions(\OC_USER_BACKEND_CREATE_USER)) { + if ($backend->implementsActions(\OC_User_Backend::CREATE_USER)) { $backend->createUser($uid, $password); $user = $this->getUserObject($uid, $backend); $this->emit('\OC\User', 'postCreateUser', array($user, $password)); @@ -264,7 +264,7 @@ class Manager extends PublicEmitter implements IUserManager { public function countUsers() { $userCountStatistics = array(); foreach ($this->backends as $backend) { - if ($backend->implementsActions(\OC_USER_BACKEND_COUNT_USERS)) { + if ($backend->implementsActions(\OC_User_Backend::COUNT_USERS)) { $backendusers = $backend->countUsers(); if($backendusers !== false) { if(isset($userCountStatistics[get_class($backend)])) { diff --git a/lib/private/user/user.php b/lib/private/user/user.php index 729abdc6227..9ad2f5f0d3a 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -90,7 +90,7 @@ class User implements IUser { public function getDisplayName() { if (!isset($this->displayName)) { $displayName = ''; - if ($this->backend and $this->backend->implementsActions(OC_USER_BACKEND_GET_DISPLAYNAME)) { + if ($this->backend and $this->backend->implementsActions(\OC_User_Backend::GET_DISPLAYNAME)) { // get display name and strip whitespace from the beginning and end of it $backendDisplayName = $this->backend->getDisplayName($this->uid); if (is_string($backendDisplayName)) { @@ -115,7 +115,7 @@ class User implements IUser { */ public function setDisplayName($displayName) { $displayName = trim($displayName); - if ($this->backend->implementsActions(\OC_USER_BACKEND_SET_DISPLAYNAME) && !empty($displayName)) { + if ($this->backend->implementsActions(\OC_User_Backend::SET_DISPLAYNAME) && !empty($displayName)) { $this->displayName = $displayName; $result = $this->backend->setDisplayName($this->uid, $displayName); return $result !== false; @@ -170,7 +170,7 @@ class User implements IUser { if ($this->emitter) { $this->emitter->emit('\OC\User', 'preSetPassword', array($this, $password, $recoveryPassword)); } - if ($this->backend->implementsActions(\OC_USER_BACKEND_SET_PASSWORD)) { + if ($this->backend->implementsActions(\OC_User_Backend::SET_PASSWORD)) { $result = $this->backend->setPassword($this->uid, $password); if ($this->emitter) { $this->emitter->emit('\OC\User', 'postSetPassword', array($this, $password, $recoveryPassword)); @@ -188,7 +188,7 @@ class User implements IUser { */ public function getHome() { if (!$this->home) { - if ($this->backend->implementsActions(\OC_USER_BACKEND_GET_HOME) and $home = $this->backend->getHome($this->uid)) { + if ($this->backend->implementsActions(\OC_User_Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) { $this->home = $home; } elseif ($this->config) { $this->home = $this->config->getSystemValue('datadirectory') . '/' . $this->uid; @@ -205,7 +205,7 @@ class User implements IUser { * @return bool */ public function canChangeAvatar() { - if ($this->backend->implementsActions(\OC_USER_BACKEND_PROVIDE_AVATAR)) { + if ($this->backend->implementsActions(\OC_User_Backend::PROVIDE_AVATAR)) { return $this->backend->canChangeAvatar($this->uid); } return true; @@ -217,7 +217,7 @@ class User implements IUser { * @return bool */ public function canChangePassword() { - return $this->backend->implementsActions(\OC_USER_BACKEND_SET_PASSWORD); + return $this->backend->implementsActions(\OC_User_Backend::SET_PASSWORD); } /** @@ -229,7 +229,7 @@ class User implements IUser { if ($this->config and $this->config->getSystemValue('allow_user_to_change_display_name') === false) { return false; } else { - return $this->backend->implementsActions(\OC_USER_BACKEND_SET_DISPLAYNAME); + return $this->backend->implementsActions(\OC_User_Backend::SET_DISPLAYNAME); } } |