mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 22:09: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
|
* 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"
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
||||||
|
@ -27,14 +27,6 @@ class GroupInfo extends BaseUniqueObject {
|
|||||||
const MEMBER_ACCESS = 3; //Member access (same as view access but as member)
|
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 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;
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user