From 91943a49ab53339926dea23e58f0382996af2cba Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 15 Jul 2018 18:55:00 +0200 Subject: [PATCH] Can return the URL and the description of a group to the API. --- RestControllers/GroupsController.php | 2 ++ classes/components/GroupsComponent.php | 4 +++ classes/models/AdvancedGroupInfo.php | 37 ++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/RestControllers/GroupsController.php b/RestControllers/GroupsController.php index 26095a3..fd4e3ec 100644 --- a/RestControllers/GroupsController.php +++ b/RestControllers/GroupsController.php @@ -621,6 +621,8 @@ class GroupsController { $data = self::GroupInfoToAPI($info); $data["time_create"] = $info->get_time_create(); + $data["description"] = $info->get_description(); + $data["url"] = $info->get_url(); return $data; } diff --git a/classes/components/GroupsComponent.php b/classes/components/GroupsComponent.php index 3bb4457..ef7a143 100644 --- a/classes/components/GroupsComponent.php +++ b/classes/components/GroupsComponent.php @@ -620,6 +620,10 @@ class GroupsComponent { //Parse advanced information $info->set_time_create($data["time_create"]); + if($data["description"] != null && $data["description"] != "" && $data["description"] != "null") + $info->set_description($data["description"]); + if($data["url"] != null && $data["url"] != "" && $data["url"] != "null") + $info->set_url($data["url"]); return $info; diff --git a/classes/models/AdvancedGroupInfo.php b/classes/models/AdvancedGroupInfo.php index 0d10f7d..4a96a4a 100644 --- a/classes/models/AdvancedGroupInfo.php +++ b/classes/models/AdvancedGroupInfo.php @@ -10,11 +10,13 @@ require_once __DIR__."/GroupInfo.php"; class AdvancedGroupInfo extends GroupInfo { - //Private fields - private $time_create = -1; + //Private fields + private $time_create = -1; + private $url; + private $description; - //Get and set the creation time of the group - public function set_time_create(int $time_create){ + //Get and set the creation time of the group + public function set_time_create(int $time_create){ $this->time_create = $time_create; } @@ -24,6 +26,31 @@ class AdvancedGroupInfo extends GroupInfo { public function get_time_create() : int { return $this->time_create; - } + } + //Set and get url + public function set_url(string $url){ + $this->url = $url == "" ? null : $url; + } + + public function has_url() : bool { + return $this->url != null; + } + + public function get_url() : string { + return $this->url != null ? $this->url : "null"; + } + + //Set and get description + public function set_description(string $description){ + $this->description = $description == "" ? null : $description; + } + + public function has_description() : bool { + return $this->description != null; + } + + public function get_description() : string { + return $this->description != null ? $this->description : "null"; + } } \ No newline at end of file