aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/SubAdmin.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-01-29 10:38:05 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-01-29 20:47:35 +0100
commit15abcff2a199f9d80baabbc39778765a2458acd2 (patch)
treec535c00106a36d2b9b4a225172da1939ee100779 /lib/private/SubAdmin.php
parent754932c7569f61fddd152151fcdcae6dbce9e834 (diff)
downloadnextcloud-server-15abcff2a199f9d80baabbc39778765a2458acd2.tar.gz
nextcloud-server-15abcff2a199f9d80baabbc39778765a2458acd2.zip
Expose subadmin to OCP
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/SubAdmin.php')
-rw-r--r--lib/private/SubAdmin.php35
1 files changed, 13 insertions, 22 deletions
diff --git a/lib/private/SubAdmin.php b/lib/private/SubAdmin.php
index 44d79d8994e..f79a0b1ae5a 100644
--- a/lib/private/SubAdmin.php
+++ b/lib/private/SubAdmin.php
@@ -29,13 +29,14 @@
namespace OC;
use OC\Hooks\PublicEmitter;
+use OCP\Group\ISubAdmin;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IDBConnection;
-class SubAdmin extends PublicEmitter {
+class SubAdmin extends PublicEmitter implements ISubAdmin {
/** @var IUserManager */
private $userManager;
@@ -70,9 +71,8 @@ class SubAdmin extends PublicEmitter {
* add a SubAdmin
* @param IUser $user user to be SubAdmin
* @param IGroup $group group $user becomes subadmin of
- * @return bool
*/
- public function createSubAdmin(IUser $user, IGroup $group) {
+ public function createSubAdmin(IUser $user, IGroup $group): void {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('group_admin')
@@ -84,16 +84,14 @@ class SubAdmin extends PublicEmitter {
$this->emit('\OC\SubAdmin', 'postCreateSubAdmin', [$user, $group]);
\OC_Hook::emit("OC_SubAdmin", "post_createSubAdmin", ["gid" => $group->getGID()]);
- return true;
}
/**
* delete a SubAdmin
* @param IUser $user the user that is the SubAdmin
* @param IGroup $group the group
- * @return bool
*/
- public function deleteSubAdmin(IUser $user, IGroup $group) {
+ public function deleteSubAdmin(IUser $user, IGroup $group): void {
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('group_admin')
@@ -103,7 +101,6 @@ class SubAdmin extends PublicEmitter {
$this->emit('\OC\SubAdmin', 'postDeleteSubAdmin', [$user, $group]);
\OC_Hook::emit("OC_SubAdmin", "post_deleteSubAdmin", ["gid" => $group->getGID()]);
- return true;
}
/**
@@ -111,7 +108,7 @@ class SubAdmin extends PublicEmitter {
* @param IUser $user the SubAdmin
* @return IGroup[]
*/
- public function getSubAdminsGroups(IUser $user) {
+ public function getSubAdminsGroups(IUser $user): array {
$qb = $this->dbConn->getQueryBuilder();
$result = $qb->select('gid')
@@ -136,7 +133,7 @@ class SubAdmin extends PublicEmitter {
* @param IUser $user
* @return array ['displayName' => displayname]
*/
- public function getSubAdminsGroupsName(IUser $user) {
+ public function getSubAdminsGroupsName(IUser $user): array {
return array_map(function($group) {
return array('displayName' => $group->getDisplayName());
}, $this->getSubAdminsGroups($user));
@@ -147,7 +144,7 @@ class SubAdmin extends PublicEmitter {
* @param IGroup $group the group
* @return IUser[]
*/
- public function getGroupsSubAdmins(IGroup $group) {
+ public function getGroupsSubAdmins(IGroup $group): array {
$qb = $this->dbConn->getQueryBuilder();
$result = $qb->select('uid')
@@ -171,7 +168,7 @@ class SubAdmin extends PublicEmitter {
* get all SubAdmins
* @return array
*/
- public function getAllSubAdmins() {
+ public function getAllSubAdmins(): array {
$qb = $this->dbConn->getQueryBuilder();
$result = $qb->select('*')
@@ -200,7 +197,7 @@ class SubAdmin extends PublicEmitter {
* @param IGroup $group
* @return bool
*/
- public function isSubAdminOfGroup(IUser $user, IGroup $group) {
+ public function isSubAdminOfGroup(IUser $user, IGroup $group): bool {
$qb = $this->dbConn->getQueryBuilder();
/*
@@ -224,7 +221,7 @@ class SubAdmin extends PublicEmitter {
* @param IUser $user
* @return bool
*/
- public function isSubAdmin(IUser $user) {
+ public function isSubAdmin(IUser $user): bool {
// Check if the user is already an admin
if ($this->groupManager->isAdmin($user->getUID())) {
return true;
@@ -250,7 +247,7 @@ class SubAdmin extends PublicEmitter {
* @param IUser $user
* @return bool
*/
- public function isUserAccessible($subadmin, $user) {
+ public function isUserAccessible(IUser $subadmin, IUser $user): bool {
if(!$this->isSubAdmin($subadmin)) {
return false;
}
@@ -269,30 +266,24 @@ class SubAdmin extends PublicEmitter {
/**
* delete all SubAdmins by $user
* @param IUser $user
- * @return boolean
*/
- private function post_deleteUser($user) {
+ private function post_deleteUser(IUser $user) {
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('group_admin')
->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
->execute();
-
- return true;
}
/**
* delete all SubAdmins by $group
* @param IGroup $group
- * @return boolean
*/
- private function post_deleteGroup($group) {
+ private function post_deleteGroup(IGroup $group) {
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('group_admin')
->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
->execute();
-
- return true;
}
}