Take IUser instead of User

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
Lukas Reschke 2017-07-19 15:44:38 +02:00 committed by Roeland Jago Douma
parent 084bac3530
commit b4d4db0e39
No known key found for this signature in database
GPG Key ID: F941078878347C0C
4 changed files with 13 additions and 12 deletions

View File

@ -29,6 +29,7 @@
namespace OC\Group;
use OCP\IGroup;
use OCP\IUser;
class Group implements IGroup {
/** @var null|string */
@ -119,10 +120,10 @@ class Group implements IGroup {
/**
* check if a user is in the group
*
* @param \OC\User\User $user
* @param IUser $user
* @return bool
*/
public function inGroup($user) {
public function inGroup(IUser $user) {
if (isset($this->users[$user->getUID()])) {
return true;
}
@ -138,9 +139,9 @@ class Group implements IGroup {
/**
* add a user to the group
*
* @param \OC\User\User $user
* @param IUser $user
*/
public function addUser($user) {
public function addUser(IUser $user) {
if ($this->inGroup($user)) {
return;
}

View File

@ -246,10 +246,10 @@ class Manager extends PublicEmitter implements IGroupManager {
}
/**
* @param \OC\User\User|null $user
* @param IUser|null $user
* @return \OC\Group\Group[]
*/
public function getUserGroups($user) {
public function getUserGroups(IUser $user= null) {
if (!$user instanceof IUser) {
return [];
}
@ -303,10 +303,10 @@ class Manager extends PublicEmitter implements IGroupManager {
/**
* get a list of group ids for a user
* @param \OC\User\User $user
* @param IUser $user
* @return array with group ids
*/
public function getUserGroupIds($user) {
public function getUserGroupIds(IUser $user) {
return array_map(function($value) {
return (string) $value;
}, array_keys($this->getUserGroups($user)));

View File

@ -60,7 +60,7 @@ interface IGroup {
* @return bool
* @since 8.0.0
*/
public function inGroup($user);
public function inGroup(IUser $user);
/**
* add a user to the group
@ -68,7 +68,7 @@ interface IGroup {
* @param \OCP\IUser $user
* @since 8.0.0
*/
public function addUser($user);
public function addUser(IUser $user);
/**
* remove a user from the group

View File

@ -100,14 +100,14 @@ interface IGroupManager {
* @return \OCP\IGroup[]
* @since 8.0.0
*/
public function getUserGroups($user);
public function getUserGroups(IUser $user = null);
/**
* @param \OCP\IUser $user
* @return array with group names
* @since 8.0.0
*/
public function getUserGroupIds($user);
public function getUserGroupIds(IUser $user);
/**
* get a list of all display names in a group