Created a method to check if a user is at least a member of a group.

This commit is contained in:
Pierre HUBERT 2018-12-08 20:50:13 +01:00
parent 774f147041
commit 5ce499f688
2 changed files with 12 additions and 3 deletions

View File

@ -124,4 +124,15 @@ public class GroupInfo {
public void setFollowing(boolean following) { public void setFollowing(boolean following) {
this.following = following; this.following = following;
} }
/**
* Check if the current user is at least a member of the group
*
* @return TRUE if the user is at least a member of the group / FALSE else
*/
public boolean isAtLeastMember(){
return getMembershipLevel() == GroupsMembershipLevels.ADMINISTRATOR
|| getMembershipLevel() == GroupsMembershipLevels.MODERATOR
|| getMembershipLevel() == GroupsMembershipLevels.MEMBER;
}
} }

View File

@ -118,9 +118,7 @@ public class GroupAccessDeniedFragment extends AbstractGroupFragment {
} }
//Check if the user is now at least a member of the group //Check if the user is now at least a member of the group
if(info.getMembershipLevel() == GroupsMembershipLevels.MEMBER if(info.isAtLeastMember()){
|| info.getMembershipLevel() == GroupsMembershipLevels.MODERATOR
|| info.getMembershipLevel() == GroupsMembershipLevels.ADMINISTRATOR){
//Go back to the group //Go back to the group
Objects.requireNonNull(getActivity()) Objects.requireNonNull(getActivity())