diff --git a/RestControllers/GroupsController.php b/RestControllers/GroupsController.php index 1b502e1..0c9e18b 100644 --- a/RestControllers/GroupsController.php +++ b/RestControllers/GroupsController.php @@ -37,6 +37,14 @@ class GroupsController { GroupInfo::SECRET_GROUP => "secrete" ); + /** + * API posts creation levels + */ + const GROUPS_POSTS_LEVELS = array( + GroupInfo::POSTS_LEVEL_MODERATORS => "moderators", + GroupInfo::POSTS_LEVEL_ALL_MEMBERS => "members" + ); + /** * Create a group * @@ -616,6 +624,7 @@ class GroupsController { $data["membership"] = self::GROUPS_MEMBERSHIP_LEVELS[$info->get_membership_level()]; $data["visibility"] = self::GROUPS_VISIBILITY_LEVELS[$info->get_visibility()]; $data["registration_level"] = self::GROUPS_REGISTRATION_LEVELS[$info->get_registration_level()]; + $data["posts_level"] = self::GROUPS_POSTS_LEVELS[$info->get_posts_level()]; $data["virtual_directory"] = $info->get_virtual_directory(); return $data; diff --git a/classes/components/GroupsComponent.php b/classes/components/GroupsComponent.php index ec95496..695ca01 100644 --- a/classes/components/GroupsComponent.php +++ b/classes/components/GroupsComponent.php @@ -591,6 +591,7 @@ class GroupsComponent { $info->set_membership_level($this->getMembershipLevel(userID, $info->get_id())); $info->set_visibility($data["visibility"]); $info->set_registration_level($data["registration_level"]); + $info->set_posts_level($data["posts_level"]); if($data["path_logo"] != null && $data["path_logo"] != "" && $data["path_logo"] != "null") $info->set_logo($data["path_logo"]); diff --git a/classes/models/GroupInfo.php b/classes/models/GroupInfo.php index 060bef3..090594a 100644 --- a/classes/models/GroupInfo.php +++ b/classes/models/GroupInfo.php @@ -28,6 +28,10 @@ class GroupInfo extends BaseUniqueObject { const MODERATOR_ACCESS = 4; //Can create posts, even if posts creation is restricted const ADMIN_ACCESS = 5; //Can do everything + //Post levels + const POSTS_LEVEL_MODERATORS = 0; //Only the moderators and the administrator can create posts + const POSTS_LEVEL_ALL_MEMBERS = 1; //All the members of the group can create posts + //Private fields private $name; private $number_members = -1; @@ -35,6 +39,7 @@ class GroupInfo extends BaseUniqueObject { private $membership_level = -1; private $visiblity = -1; private $registration_level = -1; + private $posts_level = -1; private $virtual_directory; //Get and set the name of group @@ -130,6 +135,19 @@ class GroupInfo extends BaseUniqueObject { return $this->registration_level; } + //Get and set posts level + public function set_posts_level(int $posts_level){ + $this->posts_level = $posts_level; + } + + public function has_posts_level() : bool { + return $this->posts_level > -1; + } + + public function get_posts_level() : int { + return $this->posts_level; + } + //Get and set virtual directory public function set_virtual_directory(string $virtual_directory){ $this->virtual_directory = $virtual_directory == "" ? null : $virtual_directory;