From e8d8fffbd18534e557c0b805c946981e36d1330f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 4 Jul 2018 16:49:28 +0200 Subject: [PATCH] Can change group visibility. --- RestControllers/GroupsController.php | 7 +++++++ classes/components/GroupsComponent.php | 3 +++ classes/models/GroupInfo.php | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/RestControllers/GroupsController.php b/RestControllers/GroupsController.php index a2ecf4a..5590f2b 100644 --- a/RestControllers/GroupsController.php +++ b/RestControllers/GroupsController.php @@ -138,6 +138,13 @@ class GroupsController { $settings->set_id($groupID); $settings->set_name(postString("name", 3)); + //Get group visibility + $visiblity = postString("visibility", 3); + $levels = array_flip(self::GROUPS_VISIBILITY_LEVELS); + if(!isset($levels[$visiblity])) + Rest_fatal_error(400, "Unrecognized group visibility level!"); + $settings->set_visibility($levels[$visiblity]); + //Try to save the new settings of the group if(!components()->groups->set_settings($settings)) Rest_fatal_error(500, "An error occured while trying to update group settings!"); diff --git a/classes/components/GroupsComponent.php b/classes/components/GroupsComponent.php index c97952c..b19bcad 100644 --- a/classes/components/GroupsComponent.php +++ b/classes/components/GroupsComponent.php @@ -336,6 +336,9 @@ class GroupsComponent { if($settings->has_logo()) $data["path_logo"] = $settings->get_logo(); + if($settings->has_visibility()) + $data["visibility"] = $settings->get_visibility(); + return $data; } } diff --git a/classes/models/GroupInfo.php b/classes/models/GroupInfo.php index 081ee57..9df7cf8 100644 --- a/classes/models/GroupInfo.php +++ b/classes/models/GroupInfo.php @@ -20,7 +20,7 @@ class GroupInfo extends BaseUniqueObject { private $number_members = -1; private $logo; private $membership_level = -1; - private $visiblity; + private $visiblity = -1; //Get and set the name of group