2018-07-03 07:10:04 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Group information model
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
|
|
|
class GroupInfo extends BaseUniqueObject {
|
|
|
|
|
2018-07-04 11:52:39 +00:00
|
|
|
//Path to group logo in user data
|
|
|
|
const PATH_GROUPS_LOGO = "groups_logo";
|
2018-07-03 09:14:16 +00:00
|
|
|
|
2018-07-04 14:11:29 +00:00
|
|
|
//Groups visibility
|
|
|
|
const OPEN_GROUP = 0;
|
|
|
|
const PRIVATE_GROUP = 1;
|
|
|
|
const SECRET_GROUP = 2;
|
|
|
|
|
2018-07-05 05:48:51 +00:00
|
|
|
//Registration levels
|
|
|
|
const OPEN_REGISTRATION = 0;
|
|
|
|
const MODERATED_REGISTRATION = 1;
|
|
|
|
const CLOSED_REGISTRATION = 2;
|
2018-07-04 15:28:29 +00:00
|
|
|
|
|
|
|
//User access to a group
|
|
|
|
const NO_ACCESS = 0; //Can not even know if the group exists or not
|
|
|
|
const LIMITED_ACCESS = 1; //Access to the name of the group only
|
|
|
|
const VIEW_ACCESS = 2; //Can see the posts of the group, but not a member of the group
|
|
|
|
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
|
2018-07-05 05:48:51 +00:00
|
|
|
|
2018-07-16 06:38:54 +00:00
|
|
|
//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
|
|
|
|
|
2018-07-05 05:48:51 +00:00
|
|
|
//Private fields
|
|
|
|
private $name;
|
|
|
|
private $number_members = -1;
|
|
|
|
private $logo;
|
|
|
|
private $membership_level = -1;
|
|
|
|
private $visiblity = -1;
|
|
|
|
private $registration_level = -1;
|
2018-07-16 06:38:54 +00:00
|
|
|
private $posts_level = -1;
|
2018-07-14 09:01:40 +00:00
|
|
|
private $virtual_directory;
|
2018-07-17 08:56:12 +00:00
|
|
|
private $following = FALSE;
|
2018-07-03 07:10:04 +00:00
|
|
|
|
|
|
|
//Get and set the name of group
|
|
|
|
public function set_name(string $name){
|
|
|
|
$this->name = $name == "" ? null : $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function has_name() : bool {
|
|
|
|
return $this->name != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_name() : string {
|
|
|
|
return $this->name != null ? $this->name : "null";
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get and set the number of members of the group
|
|
|
|
public function set_number_members(int $number_members){
|
|
|
|
$this->number_members = $number_members;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function has_number_members() : bool {
|
|
|
|
return $this->number_members > -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_number_members() : int {
|
|
|
|
return $this->number_members;
|
2018-07-03 09:14:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-04 11:52:39 +00:00
|
|
|
//Get and set the URL of the logo of group
|
|
|
|
public function set_logo(string $logo){
|
|
|
|
$this->logo = $logo == "" ? null : $logo;
|
2018-07-03 09:14:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-04 11:52:39 +00:00
|
|
|
public function has_logo() : bool {
|
|
|
|
return $this->logo != null;
|
2018-07-03 09:14:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-04 11:52:39 +00:00
|
|
|
public function get_logo() : string {
|
|
|
|
return $this->logo != null ? $this->logo : self::PATH_GROUPS_LOGO."/default.png";
|
2018-07-03 09:14:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-04 11:52:39 +00:00
|
|
|
public function get_logo_url() : string {
|
|
|
|
return path_user_data($this->get_logo());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_logo_sys_path() : string {
|
|
|
|
|
|
|
|
//For security reasons, this method is available
|
|
|
|
//only if the user has really a logo (avoid unattended
|
|
|
|
//operation on default logo)
|
|
|
|
if(!$this->has_logo())
|
|
|
|
throw new Exception("This GroupInfo object has not any logo set!");
|
|
|
|
|
|
|
|
return path_user_data($this->get_logo(), true);
|
2018-07-03 12:33:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Get and set the membership level of the current user
|
|
|
|
public function set_membership_level(int $membership_level){
|
|
|
|
$this->membership_level = $membership_level;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function has_membership_level() : bool {
|
|
|
|
return $this->membership_level > -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_membership_level() : int {
|
|
|
|
return $this->membership_level;
|
|
|
|
}
|
2018-07-04 14:11:29 +00:00
|
|
|
|
|
|
|
//Get and set group visibility
|
|
|
|
public function set_visibility(int $visibility){
|
|
|
|
$this->visibility = $visibility;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function has_visibility() : bool {
|
|
|
|
return $this->visibility > -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_visibility() : int {
|
|
|
|
return $this->visibility;
|
|
|
|
}
|
2018-07-05 05:48:51 +00:00
|
|
|
|
|
|
|
//Get and set registration levels
|
|
|
|
public function set_registration_level(int $registration_level){
|
|
|
|
$this->registration_level = $registration_level;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function has_registration_level() : bool {
|
|
|
|
return $this->registration_level > -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_registration_level() : int {
|
|
|
|
return $this->registration_level;
|
|
|
|
}
|
2018-07-14 09:01:40 +00:00
|
|
|
|
2018-07-16 06:38:54 +00:00
|
|
|
//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;
|
|
|
|
}
|
|
|
|
|
2018-07-14 09:01:40 +00:00
|
|
|
//Get and set virtual directory
|
2018-07-14 09:37:06 +00:00
|
|
|
public function set_virtual_directory(string $virtual_directory){
|
|
|
|
$this->virtual_directory = $virtual_directory == "" ? null : $virtual_directory;
|
2018-07-14 09:01:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function has_virtual_directory() : bool {
|
2018-07-14 09:37:06 +00:00
|
|
|
return $this->virtual_directory != null;
|
2018-07-14 09:01:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-14 09:37:06 +00:00
|
|
|
public function get_virtual_directory() : string {
|
|
|
|
return $this->virtual_directory != null ? $this->virtual_directory : "null";
|
2018-07-14 09:01:40 +00:00
|
|
|
}
|
2018-07-17 08:56:12 +00:00
|
|
|
|
|
|
|
//Set and get following status
|
|
|
|
public function set_following(bool $following){
|
|
|
|
$this->following = $following;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isFollowing() : bool {
|
|
|
|
return $this->following;
|
|
|
|
}
|
2018-07-03 07:10:04 +00:00
|
|
|
}
|