mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 13:59:29 +00:00
Centralized membership levels in GroupMember class
This commit is contained in:
parent
a1d078a461
commit
d55cca75b2
@ -20,12 +20,12 @@ class GroupsController {
|
||||
* API groups membership levels
|
||||
*/
|
||||
const GROUPS_MEMBERSHIP_LEVELS = array(
|
||||
GroupInfo::ADMINISTRATOR => "administrator",
|
||||
GroupInfo::MODERATOR => "moderator",
|
||||
GroupInfo::MEMBER => "member",
|
||||
GroupInfo::INVITED => "invited",
|
||||
GroupInfo::PENDING => "pending",
|
||||
GroupInfo::VISITOR => "visitor"
|
||||
GroupMember::ADMINISTRATOR => "administrator",
|
||||
GroupMember::MODERATOR => "moderator",
|
||||
GroupMember::MEMBER => "member",
|
||||
GroupMember::INVITED => "invited",
|
||||
GroupMember::PENDING => "pending",
|
||||
GroupMember::VISITOR => "visitor"
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -290,14 +290,14 @@ class GroupsComponent {
|
||||
$membership_level = $this->getMembershipLevel($userID, $groupID);
|
||||
|
||||
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
|
||||
if($membership_level == GroupInfo::ADMINISTRATOR)
|
||||
if($membership_level == GroupMember::ADMINISTRATOR)
|
||||
return GroupInfo::ADMIN_ACCESS;
|
||||
if($membership_level == GroupInfo::MODERATOR)
|
||||
if($membership_level == GroupMember::MODERATOR)
|
||||
return GroupInfo::MODERATOR_ACCESS;
|
||||
if($membership_level == GroupInfo::MEMBER)
|
||||
if($membership_level == GroupMember::MEMBER)
|
||||
return GroupInfo::MEMBER_ACCESS;
|
||||
|
||||
//Get the visibility level of the group
|
||||
@ -308,8 +308,8 @@ class GroupsComponent {
|
||||
return GroupInfo::VIEW_ACCESS;
|
||||
|
||||
//Else, all pending and invited membership get limited access
|
||||
if($membership_level == GroupInfo::PENDING ||
|
||||
$membership_level == GroupInfo::INVITED)
|
||||
if($membership_level == GroupMember::PENDING ||
|
||||
$membership_level == GroupMember::INVITED)
|
||||
return GroupInfo::LIMITED_ACCESS;
|
||||
|
||||
//Private groups gives limited access
|
||||
|
@ -27,14 +27,6 @@ class GroupInfo extends BaseUniqueObject {
|
||||
const MEMBER_ACCESS = 3; //Member access (same as view access but as member)
|
||||
const MODERATOR_ACCESS = 4; //Can create posts, even if posts creation is restricted
|
||||
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 $name;
|
||||
|
@ -13,8 +13,9 @@ class GroupMember extends BaseUniqueObjectFromUser {
|
||||
const ADMINISTRATOR = 0;
|
||||
const MODERATOR = 1;
|
||||
const MEMBER = 2;
|
||||
const PENDING = 3; //When the group membership has not been approved yet
|
||||
const VISITOR = 4; //Simple visitor
|
||||
const INVITED = 3;
|
||||
const PENDING = 4; //When the group membership has not been approved yet
|
||||
const VISITOR = 5; //Simple visitor
|
||||
|
||||
//Private fields
|
||||
private $group_id = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user