From 1e229455fcd18f5abf2c34ae7f0193fd4e701fae Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 3 Jul 2018 11:14:16 +0200 Subject: [PATCH] Added groups default icon --- RestControllers/GroupsController.php | 1 + classes/models/GroupInfo.php | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/RestControllers/GroupsController.php b/RestControllers/GroupsController.php index 585c63c..7876cae 100644 --- a/RestControllers/GroupsController.php +++ b/RestControllers/GroupsController.php @@ -93,6 +93,7 @@ class GroupsController { $data["id"] = $info->get_id(); $data["name"] = $info->get_name(); + $data["icon_url"] = $info->get_icon_url(); $data["number_members"] = $info->get_number_members(); return $data; diff --git a/classes/models/GroupInfo.php b/classes/models/GroupInfo.php index b244ced..1527bb1 100644 --- a/classes/models/GroupInfo.php +++ b/classes/models/GroupInfo.php @@ -7,10 +7,13 @@ class GroupInfo extends BaseUniqueObject { + //Path to group icons in user data + const PATH_GROUPS_ICON = "groups_icon/"; + //Private fields private $name; private $number_members = -1; - + private $icon; //Get and set the name of group @@ -37,5 +40,22 @@ class GroupInfo extends BaseUniqueObject { public function get_number_members() : int { 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()); } } \ No newline at end of file