diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-04-23 14:39:30 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-04-23 14:39:30 +0200 |
commit | 961b27eeb0ee1ec1bd472c73bd587e8636bb074d (patch) | |
tree | 4b3e1a2cdbfa3d99fdee9b50003adcc4239fa837 /lib/private/Group | |
parent | 5fcd97dcb6121f6be6c8c44c99f556c8c6ded804 (diff) | |
download | nextcloud-server-961b27eeb0ee1ec1bd472c73bd587e8636bb074d.tar.gz nextcloud-server-961b27eeb0ee1ec1bd472c73bd587e8636bb074d.zip |
Convert group Database backend
This now uses the new interfaces
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Group')
-rw-r--r-- | lib/private/Group/Database.php | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php index abd7f6ee6ee..639df3de0de 100644 --- a/lib/private/Group/Database.php +++ b/lib/private/Group/Database.php @@ -40,12 +40,23 @@ namespace OC\Group; +use OCP\Group\Backend\ABackend; +use OCP\Group\Backend\IAddToGroupBackend; +use OCP\Group\Backend\ICountUsersBackend; +use OCP\Group\Backend\ICreateGroupBackend; +use OCP\Group\Backend\IDeleteGroupBackend; +use OCP\Group\Backend\IRemoveFromGroupBackend; use OCP\IDBConnection; /** * Class for group management in a SQL Database (e.g. MySQL, SQLite) */ -class Database extends Backend { +class Database extends ABackend + implements IAddToGroupBackend, + ICountUsersBackend, + ICreateGroupBackend, + IDeleteGroupBackend, + IRemoveFromGroupBackend { /** @var string[] */ private $groupCache = []; @@ -79,7 +90,7 @@ class Database extends Backend { * Tries to create a new group. If the group name already exists, false will * be returned. */ - public function createGroup( $gid ) { + public function createGroup(string $gid): bool { $this->fixDI(); // Add group @@ -100,7 +111,7 @@ class Database extends Backend { * * Deletes a group and removes it from the group_user-table */ - public function deleteGroup( $gid ) { + public function deleteGroup(string $gid): bool { $this->fixDI(); // Delete the group @@ -160,7 +171,7 @@ class Database extends Backend { * * Adds a user to a group. */ - public function addToGroup( $uid, $gid ) { + public function addToGroup(string $uid, string $gid): bool { $this->fixDI(); // No duplicate entries! @@ -184,7 +195,7 @@ class Database extends Backend { * * removes the user from a group. */ - public function removeFromGroup( $uid, $gid ) { + public function removeFromGroup(string $uid, string $gid): bool { $this->fixDI(); $qb = $this->dbConn->getQueryBuilder(); @@ -333,9 +344,9 @@ class Database extends Backend { * get the number of all users matching the search string in a group * @param string $gid * @param string $search - * @return int|false + * @return int */ - public function countUsersInGroup($gid, $search = '') { + public function countUsersInGroup(string $gid, string $search = ''): int { $this->fixDI(); $query = $this->dbConn->getQueryBuilder(); @@ -355,7 +366,10 @@ class Database extends Backend { if ($count !== false) { $count = (int)$count; + } else { + $count = 0; } + return $count; } |