Merge pull request #21718 from owncloud/groupanduserinterface
Groupanduserinterface
This commit is contained in:
commit
1f0af76eb2
8 changed files with 153 additions and 129 deletions
|
@ -53,7 +53,7 @@ define('OC_GROUP_BACKEND_COUNT_USERS', 0x00100000);
|
||||||
/**
|
/**
|
||||||
* Abstract base class for user management
|
* Abstract base class for user management
|
||||||
*/
|
*/
|
||||||
abstract class OC_Group_Backend implements OC_Group_Interface {
|
abstract class OC_Group_Backend implements \OCP\GroupInterface {
|
||||||
/**
|
/**
|
||||||
* error code for functions not provided by the group backend
|
* error code for functions not provided by the group backend
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,63 +24,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface OC_Group_Interface {
|
/**
|
||||||
/**
|
* Interface OC_Group_Interface
|
||||||
* Check if backend implements actions
|
* @deprecated use the public \OCP\GroupInterface instead
|
||||||
* @param int $actions bitwise-or'ed actions
|
|
||||||
* @return boolean
|
|
||||||
*
|
|
||||||
* Returns the supported actions as int to be
|
|
||||||
* compared with \OC_Group_Backend::CREATE_GROUP etc.
|
|
||||||
*/
|
*/
|
||||||
public function implementsActions($actions);
|
interface OC_Group_Interface extends \OCP\GroupInterface {}
|
||||||
|
|
||||||
/**
|
|
||||||
* is user in group?
|
|
||||||
* @param string $uid uid of the user
|
|
||||||
* @param string $gid gid of the group
|
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* Checks whether the user is member of a group or not.
|
|
||||||
*/
|
|
||||||
public function inGroup($uid, $gid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all groups a user belongs to
|
|
||||||
* @param string $uid Name of the user
|
|
||||||
* @return array an array of group names
|
|
||||||
*
|
|
||||||
* This function fetches all groups a user belongs to. It does not check
|
|
||||||
* if the user exists at all.
|
|
||||||
*/
|
|
||||||
public function getUserGroups($uid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a list of all groups
|
|
||||||
* @param string $search
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return array an array of group names
|
|
||||||
*
|
|
||||||
* Returns a list with all groups
|
|
||||||
*/
|
|
||||||
public function getGroups($search = '', $limit = -1, $offset = 0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* check if a group exists
|
|
||||||
* @param string $gid
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function groupExists($gid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a list of all users in a group
|
|
||||||
* @param string $gid
|
|
||||||
* @param string $search
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return array an array of user ids
|
|
||||||
*/
|
|
||||||
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -76,13 +76,13 @@ class OC_User {
|
||||||
/**
|
/**
|
||||||
* Adds the backend to the list of used backends
|
* Adds the backend to the list of used backends
|
||||||
*
|
*
|
||||||
* @param string|OC_User_Interface $backend default: database The backend to use for user management
|
* @param string|\OCP\UserInterface $backend default: database The backend to use for user management
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* Set the User Authentication Module
|
* Set the User Authentication Module
|
||||||
*/
|
*/
|
||||||
public static function useBackend($backend = 'database') {
|
public static function useBackend($backend = 'database') {
|
||||||
if ($backend instanceof OC_User_Interface) {
|
if ($backend instanceof \OCP\UserInterface) {
|
||||||
self::$_usedBackends[get_class($backend)] = $backend;
|
self::$_usedBackends[get_class($backend)] = $backend;
|
||||||
\OC::$server->getUserManager()->registerBackend($backend);
|
\OC::$server->getUserManager()->registerBackend($backend);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -63,7 +63,7 @@ define('OC_USER_BACKEND_COUNT_USERS', 1 << 28);
|
||||||
* Abstract base class for user management. Provides methods for querying backend
|
* Abstract base class for user management. Provides methods for querying backend
|
||||||
* capabilities.
|
* capabilities.
|
||||||
*/
|
*/
|
||||||
abstract class OC_User_Backend implements OC_User_Interface {
|
abstract class OC_User_Backend implements \OCP\UserInterface {
|
||||||
/**
|
/**
|
||||||
* error code for functions not provided by the user backend
|
* error code for functions not provided by the user backend
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -25,62 +25,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface OC_User_Interface {
|
/**
|
||||||
|
* Interface OC_User_Interface
|
||||||
/**
|
* @deprecated use the public \OCP\UserInterface instead
|
||||||
* Check if backend implements 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.
|
|
||||||
*/
|
*/
|
||||||
public function implementsActions($actions);
|
interface OC_User_Interface extends \OCP\UserInterface {}
|
||||||
|
|
||||||
/**
|
|
||||||
* delete a user
|
|
||||||
* @param string $uid The username of the user to delete
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function deleteUser($uid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of all users
|
|
||||||
*
|
|
||||||
* @param string $search
|
|
||||||
* @param null|int $limit
|
|
||||||
* @param null|int $offset
|
|
||||||
* @return string[] an array of all uids
|
|
||||||
*/
|
|
||||||
public function getUsers($search = '', $limit = null, $offset = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* check if a user exists
|
|
||||||
* @param string $uid the username
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function userExists($uid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get display name of the user
|
|
||||||
* @param string $uid user ID of the user
|
|
||||||
* @return string display name
|
|
||||||
*/
|
|
||||||
public function getDisplayName($uid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of all display names and user ids.
|
|
||||||
*
|
|
||||||
* @param string $search
|
|
||||||
* @param string|null $limit
|
|
||||||
* @param string|null $offset
|
|
||||||
* @return array an array of all displayNames (value) and the corresponding uids (key)
|
|
||||||
*/
|
|
||||||
public function getDisplayNames($search = '', $limit = null, $offset = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a user list is available or not
|
|
||||||
* @return boolean if users can be listed or not
|
|
||||||
*/
|
|
||||||
public function hasUserListings();
|
|
||||||
}
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ use OCP\IImage;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\UserInterface;
|
||||||
|
|
||||||
class User implements IUser {
|
class User implements IUser {
|
||||||
/** @var string $uid */
|
/** @var string $uid */
|
||||||
|
@ -43,7 +44,7 @@ class User implements IUser {
|
||||||
/** @var string $displayName */
|
/** @var string $displayName */
|
||||||
private $displayName;
|
private $displayName;
|
||||||
|
|
||||||
/** @var \OC_User_Interface $backend */
|
/** @var UserInterface $backend */
|
||||||
private $backend;
|
private $backend;
|
||||||
|
|
||||||
/** @var bool $enabled */
|
/** @var bool $enabled */
|
||||||
|
@ -69,7 +70,7 @@ class User implements IUser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $uid
|
* @param string $uid
|
||||||
* @param \OC_User_Interface $backend
|
* @param UserInterface $backend
|
||||||
* @param \OC\Hooks\Emitter $emitter
|
* @param \OC\Hooks\Emitter $emitter
|
||||||
* @param IConfig|null $config
|
* @param IConfig|null $config
|
||||||
* @param IURLGenerator $urlGenerator
|
* @param IURLGenerator $urlGenerator
|
||||||
|
|
|
@ -32,9 +32,75 @@
|
||||||
namespace OCP;
|
namespace OCP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface GroupInterface
|
* TODO actually this is a IGroupBackend
|
||||||
*
|
*
|
||||||
* @package OCP
|
* @package OCP
|
||||||
* @since 4.5.0
|
* @since 4.5.0
|
||||||
*/
|
*/
|
||||||
interface GroupInterface extends \OC_Group_Interface {}
|
interface GroupInterface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if backend implements actions
|
||||||
|
* @param int $actions bitwise-or'ed actions
|
||||||
|
* @return boolean
|
||||||
|
* @since 4.5.0
|
||||||
|
*
|
||||||
|
* Returns the supported actions as int to be
|
||||||
|
* compared with \OC_Group_Backend::CREATE_GROUP etc.
|
||||||
|
*/
|
||||||
|
public function implementsActions($actions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is user in group?
|
||||||
|
* @param string $uid uid of the user
|
||||||
|
* @param string $gid gid of the group
|
||||||
|
* @return bool
|
||||||
|
* @since 4.5.0
|
||||||
|
*
|
||||||
|
* Checks whether the user is member of a group or not.
|
||||||
|
*/
|
||||||
|
public function inGroup($uid, $gid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all groups a user belongs to
|
||||||
|
* @param string $uid Name of the user
|
||||||
|
* @return array an array of group names
|
||||||
|
* @since 4.5.0
|
||||||
|
*
|
||||||
|
* This function fetches all groups a user belongs to. It does not check
|
||||||
|
* if the user exists at all.
|
||||||
|
*/
|
||||||
|
public function getUserGroups($uid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a list of all groups
|
||||||
|
* @param string $search
|
||||||
|
* @param int $limit
|
||||||
|
* @param int $offset
|
||||||
|
* @return array an array of group names
|
||||||
|
* @since 4.5.0
|
||||||
|
*
|
||||||
|
* Returns a list with all groups
|
||||||
|
*/
|
||||||
|
public function getGroups($search = '', $limit = -1, $offset = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if a group exists
|
||||||
|
* @param string $gid
|
||||||
|
* @return bool
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
public function groupExists($gid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a list of all users in a group
|
||||||
|
* @param string $gid
|
||||||
|
* @param string $search
|
||||||
|
* @param int $limit
|
||||||
|
* @param int $offset
|
||||||
|
* @return array an array of user ids
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -32,9 +32,75 @@
|
||||||
namespace OCP;
|
namespace OCP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface UserInterface
|
* TODO actually this is a IUserBackend
|
||||||
*
|
*
|
||||||
* @package OCP
|
* @package OCP
|
||||||
* @since 4.5.0
|
* @since 4.5.0
|
||||||
*/
|
*/
|
||||||
interface UserInterface extends \OC_User_Interface {}
|
interface UserInterface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if backend implements 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.
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
public function implementsActions($actions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete a user
|
||||||
|
* @param string $uid The username of the user to delete
|
||||||
|
* @return bool
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
public function deleteUser($uid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all users
|
||||||
|
*
|
||||||
|
* @param string $search
|
||||||
|
* @param null|int $limit
|
||||||
|
* @param null|int $offset
|
||||||
|
* @return string[] an array of all uids
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
public function getUsers($search = '', $limit = null, $offset = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if a user exists
|
||||||
|
* @param string $uid the username
|
||||||
|
* @return boolean
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
public function userExists($uid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get display name of the user
|
||||||
|
* @param string $uid user ID of the user
|
||||||
|
* @return string display name
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
public function getDisplayName($uid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all display names and user ids.
|
||||||
|
*
|
||||||
|
* @param string $search
|
||||||
|
* @param string|null $limit
|
||||||
|
* @param string|null $offset
|
||||||
|
* @return array an array of all displayNames (value) and the corresponding uids (key)
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
public function getDisplayNames($search = '', $limit = null, $offset = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a user list is available or not
|
||||||
|
* @return boolean if users can be listed or not
|
||||||
|
* @since 4.5.0
|
||||||
|
*/
|
||||||
|
public function hasUserListings();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue