diff --git a/RestControllers/SettingsController.php b/RestControllers/SettingsController.php index f271377..3cb43c1 100644 --- a/RestControllers/SettingsController.php +++ b/RestControllers/SettingsController.php @@ -23,8 +23,35 @@ class SettingsController { if(!$user_settings->isValid()) Rest_fatal_error(500, "Could not get user settings !"); - print_r($user_settings); + //Parse and return settings entry + return $this->GeneralSettingsToAPI($user_settings); } + /** + * Turn a GeneralSettings object into a valid API object + * + * @param GeneralSettings $settings The object to convert + * @return array Generated API object + */ + private function GeneralSettingsToAPI(GeneralSettings $settings) : array { + + $data = array(); + + $data["id"] = $settings->get_id(); + $data["email"] = $settings->get_email(); + $data["firstName"] = $settings->get_firstName(); + $data["lastName"] = $settings->get_lastName(); + $data["is_public"] = $settings->is_publicPage(); + $data["is_open"] = $settings->is_openPage(); + $data["allow_comments"] = $settings->is_allowComments(); + $data["allow_posts_from_friends"] = $settings->is_allowPostsFriends(); + $data["allow_comunic_mails"] = $settings->is_allowComunicMails(); + $data["public_friends_list"] = $settings->is_friendsListPublic(); + $data["virtual_directory"] = $settings->get_virtualDirectory(); + $data["personnal_website"] = $settings->get_personnalWebsite(); + + return $data; + } + } \ No newline at end of file