New version of visibility detection in createPost method

This commit is contained in:
Pierre 2018-01-10 07:03:21 +01:00
parent 9e82720491
commit 4338d7043d

View File

@ -120,23 +120,17 @@ class postsController {
//Get the visibility of the post //Get the visibility of the post
if(!isset($_POST['visibility'])) if(!isset($_POST['visibility']))
Rest_fatal_error(400, "Please specify the visibility of the post !"); Rest_fatal_error(400, "Please specify the visibility of the post !");
switch($_POST['visibility']){ $api_visibility = $_POST['visibility'];
case "private":
$visibility = Posts::VISIBILITY_USER; //Get the visibility levels of the API
break; $post_visibility = array_flip($this::VISIBILITY_LEVELS_API);
case "friends": //Check for the existence of the visibility level
$visibility = Posts::VISIBILITY_FRIENDS; if(!isset($post_visibility[$api_visibility]))
break; Rest_fatal_error(400, "Specified visibility level not recognized !");
case "public": //Save it
$visibility = Posts::VISIBILITY_PUBLIC; $visibility = $post_visibility[$api_visibility];
break;
default:
Rest_fatal_error(500, "Unrecognized visibility level for the post !");
break;
}
//Act differently depending of the post content //Act differently depending of the post content
//For text post //For text post