private function getAdministeredGroups() { $this->requireLogin(); if (class_exists('\\OC_SubAdmin', true)) { return \OC_SubAdmin::getSubAdminsGroups($this->getUserId()); } // Nextcloud 9 $subadmin = new \OC\SubAdmin(\OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->getDatabaseConnection()); $ocgroups = $subadmin->getSubAdminsGroups($this->user); $groups = array(); foreach ($ocgroups as $ocgroup) { $groups[] = $ocgroup->getGID(); } return $groups; }
public function testHooks() { $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn); $test = $this; $u = $this->users[0]; $g = $this->groups[0]; $count = 0; $subAdmin->listen('\\OC\\SubAdmin', 'postCreateSubAdmin', function ($user, $group) use($test, $u, $g, &$count) { $test->assertEquals($u->getUID(), $user->getUID()); $test->assertEquals($g->getGID(), $group->getGID()); $count++; }); $subAdmin->listen('\\OC\\SubAdmin', 'postDeleteSubAdmin', function ($user, $group) use($test, $u, $g, &$count) { $test->assertEquals($u->getUID(), $user->getUID()); $test->assertEquals($g->getGID(), $group->getGID()); $count++; }); $this->assertTrue($subAdmin->createSubAdmin($u, $g)); $this->assertEquals(1, $count); $this->assertTrue($subAdmin->deleteSubAdmin($u, $g)); $this->assertEquals(2, $count); }