Added groups default icon

This commit is contained in:
Pierre HUBERT 2018-07-03 11:14:16 +02:00
parent 8367bd81ac
commit 1e229455fc
2 changed files with 22 additions and 1 deletions

View File

@ -93,6 +93,7 @@ class GroupsController {
$data["id"] = $info->get_id(); $data["id"] = $info->get_id();
$data["name"] = $info->get_name(); $data["name"] = $info->get_name();
$data["icon_url"] = $info->get_icon_url();
$data["number_members"] = $info->get_number_members(); $data["number_members"] = $info->get_number_members();
return $data; return $data;

View File

@ -7,10 +7,13 @@
class GroupInfo extends BaseUniqueObject { class GroupInfo extends BaseUniqueObject {
//Path to group icons in user data
const PATH_GROUPS_ICON = "groups_icon/";
//Private fields //Private fields
private $name; private $name;
private $number_members = -1; private $number_members = -1;
private $icon;
//Get and set the name of group //Get and set the name of group
@ -38,4 +41,21 @@ class GroupInfo extends BaseUniqueObject {
public function get_number_members() : int { public function get_number_members() : int {
return $this->number_members; return $this->number_members;
} }
//Get and set the URL of the icon of group
public function set_icon(string $icon){
$this->icon = $icon == "" ? null : $icon;
}
public function has_icon() : bool {
return $this->icon != null;
}
public function get_icon() : string {
return $this->icon != null ? $this->icon : self::PATH_GROUPS_ICON."default.png";
}
public function get_icon_url() : string {
return path_user_data($this->get_icon());
}
} }