Centralized membership levels in GroupMember class

This commit is contained in:
Pierre HUBERT 2018-07-05 08:30:46 +02:00
parent a1d078a461
commit d55cca75b2
4 changed files with 15 additions and 22 deletions

View File

@ -20,12 +20,12 @@ class GroupsController {
* API groups membership levels * API groups membership levels
*/ */
const GROUPS_MEMBERSHIP_LEVELS = array( const GROUPS_MEMBERSHIP_LEVELS = array(
GroupInfo::ADMINISTRATOR => "administrator", GroupMember::ADMINISTRATOR => "administrator",
GroupInfo::MODERATOR => "moderator", GroupMember::MODERATOR => "moderator",
GroupInfo::MEMBER => "member", GroupMember::MEMBER => "member",
GroupInfo::INVITED => "invited", GroupMember::INVITED => "invited",
GroupInfo::PENDING => "pending", GroupMember::PENDING => "pending",
GroupInfo::VISITOR => "visitor" GroupMember::VISITOR => "visitor"
); );
/** /**

View File

@ -290,14 +290,14 @@ class GroupsComponent {
$membership_level = $this->getMembershipLevel($userID, $groupID); $membership_level = $this->getMembershipLevel($userID, $groupID);
else else
$membership_level = GroupInfo::VISITOR; //Signed out users are all visitors $membership_level = GroupMember::VISITOR; //Signed out users are all visitors
//Check if the user is a confirmed member of group //Check if the user is a confirmed member of group
if($membership_level == GroupInfo::ADMINISTRATOR) if($membership_level == GroupMember::ADMINISTRATOR)
return GroupInfo::ADMIN_ACCESS; return GroupInfo::ADMIN_ACCESS;
if($membership_level == GroupInfo::MODERATOR) if($membership_level == GroupMember::MODERATOR)
return GroupInfo::MODERATOR_ACCESS; return GroupInfo::MODERATOR_ACCESS;
if($membership_level == GroupInfo::MEMBER) if($membership_level == GroupMember::MEMBER)
return GroupInfo::MEMBER_ACCESS; return GroupInfo::MEMBER_ACCESS;
//Get the visibility level of the group //Get the visibility level of the group
@ -308,8 +308,8 @@ class GroupsComponent {
return GroupInfo::VIEW_ACCESS; return GroupInfo::VIEW_ACCESS;
//Else, all pending and invited membership get limited access //Else, all pending and invited membership get limited access
if($membership_level == GroupInfo::PENDING || if($membership_level == GroupMember::PENDING ||
$membership_level == GroupInfo::INVITED) $membership_level == GroupMember::INVITED)
return GroupInfo::LIMITED_ACCESS; return GroupInfo::LIMITED_ACCESS;
//Private groups gives limited access //Private groups gives limited access

View File

@ -28,14 +28,6 @@ class GroupInfo extends BaseUniqueObject {
const MODERATOR_ACCESS = 4; //Can create posts, even if posts creation is restricted const MODERATOR_ACCESS = 4; //Can create posts, even if posts creation is restricted
const ADMIN_ACCESS = 5; //Can do everything const ADMIN_ACCESS = 5; //Can do everything
//Membership levels
const ADMINISTRATOR = 0;
const MODERATOR = 1;
const MEMBER = 2;
const INVITED = 3;
const PENDING = 4;
const VISITOR = 5;
//Private fields //Private fields
private $name; private $name;
private $number_members = -1; private $number_members = -1;

View File

@ -13,8 +13,9 @@ class GroupMember extends BaseUniqueObjectFromUser {
const ADMINISTRATOR = 0; const ADMINISTRATOR = 0;
const MODERATOR = 1; const MODERATOR = 1;
const MEMBER = 2; const MEMBER = 2;
const PENDING = 3; //When the group membership has not been approved yet const INVITED = 3;
const VISITOR = 4; //Simple visitor const PENDING = 4; //When the group membership has not been approved yet
const VISITOR = 5; //Simple visitor
//Private fields //Private fields
private $group_id = 1; private $group_id = 1;