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 testGetSubAdminsGroups() { $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn); $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0])); $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[1])); $result = $subAdmin->getSubAdminsGroups($this->users[0]); $this->assertContains($this->groups[0], $result); $this->assertContains($this->groups[1], $result); $this->assertNotContains($this->groups[2], $result); $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0])); $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[1])); }