Convert group Database backend

This now uses the new interfaces

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-04-23 14:39:30 +02:00
parent 5fcd97dcb6
commit 961b27eeb0
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 21 additions and 7 deletions

View File

@ -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;
}