summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-10-29 11:18:01 +0100
committerGitHub <noreply@github.com>2020-10-29 11:18:01 +0100
commit7ed11b6dfafb8793751f80a55f38e6242805386d (patch)
tree047de0138349c09a73b622ac55679b4060521d8d /lib/private
parent28e2551313062e04748b32433648bc0177c4a54b (diff)
parent765ee60eeacc8f9f41cb145b67821a192330daea (diff)
downloadnextcloud-server-7ed11b6dfafb8793751f80a55f38e6242805386d.tar.gz
nextcloud-server-7ed11b6dfafb8793751f80a55f38e6242805386d.zip
Merge pull request #23765 from nextcloud/techdebt/noid/sudadmin-events-into-typed-events
Add typed events for adding and removing a subadmin
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Group/Manager.php4
-rw-r--r--lib/private/SubAdmin.php18
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php
index 6056bcdb3e3..3d7c1ff176f 100644
--- a/lib/private/Group/Manager.php
+++ b/lib/private/Group/Manager.php
@@ -41,6 +41,7 @@
namespace OC\Group;
use OC\Hooks\PublicEmitter;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\GroupInterface;
use OCP\IGroup;
use OCP\IGroupManager;
@@ -416,7 +417,8 @@ class Manager extends PublicEmitter implements IGroupManager {
$this->subAdmin = new \OC\SubAdmin(
$this->userManager,
$this,
- \OC::$server->getDatabaseConnection()
+ \OC::$server->getDatabaseConnection(),
+ \OC::$server->get(IEventDispatcher::class)
);
}
diff --git a/lib/private/SubAdmin.php b/lib/private/SubAdmin.php
index a9e3855639c..3239fb27af8 100644
--- a/lib/private/SubAdmin.php
+++ b/lib/private/SubAdmin.php
@@ -32,6 +32,9 @@
namespace OC;
use OC\Hooks\PublicEmitter;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Group\Events\SubAdminAddedEvent;
+use OCP\Group\Events\SubAdminRemovedEvent;
use OCP\Group\ISubAdmin;
use OCP\IDBConnection;
use OCP\IGroup;
@@ -50,6 +53,9 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
/** @var IDBConnection */
private $dbConn;
+ /** @var IEventDispatcher */
+ private $eventDispatcher;
+
/**
* @param IUserManager $userManager
* @param IGroupManager $groupManager
@@ -57,10 +63,12 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
*/
public function __construct(IUserManager $userManager,
IGroupManager $groupManager,
- IDBConnection $dbConn) {
+ IDBConnection $dbConn,
+ IEventDispatcher $eventDispatcher) {
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->dbConn = $dbConn;
+ $this->eventDispatcher = $eventDispatcher;
$this->userManager->listen('\OC\User', 'postDelete', function ($user) {
$this->post_deleteUser($user);
@@ -85,8 +93,10 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
])
->execute();
+ /** @depreacted 21.0.0 - use type SubAdminAddedEvent instead */
$this->emit('\OC\SubAdmin', 'postCreateSubAdmin', [$user, $group]);
- \OC_Hook::emit("OC_SubAdmin", "post_createSubAdmin", ["gid" => $group->getGID()]);
+ $event = new SubAdminAddedEvent($group, $user);
+ $this->eventDispatcher->dispatchTyped($event);
}
/**
@@ -102,8 +112,10 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
->execute();
+ /** @depreacted 21.0.0 - use type SubAdminRemovedEvent instead */
$this->emit('\OC\SubAdmin', 'postDeleteSubAdmin', [$user, $group]);
- \OC_Hook::emit("OC_SubAdmin", "post_deleteSubAdmin", ["gid" => $group->getGID()]);
+ $event = new SubAdminRemovedEvent($group, $user);
+ $this->eventDispatcher->dispatchTyped($event);
}
/**