mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 15:59:29 +00:00
Created delete method on the API.
This commit is contained in:
parent
a67c62fd95
commit
336fa60314
@ -354,6 +354,33 @@ class postsController {
|
||||
return array("success" => "The visibility level has been updated !");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete post
|
||||
*
|
||||
* @url POST /posts/delete
|
||||
*/
|
||||
public function delete_post(){
|
||||
|
||||
user_login_required();
|
||||
|
||||
//Get the post ID
|
||||
$postID = getPostPostID("postID");
|
||||
|
||||
//Get the user access over the post
|
||||
$user_access = CS::get()->components->posts->access_level($postID, userID);
|
||||
|
||||
//Check if the user is allowed to delete the post or not
|
||||
if($user_access != Posts::FULL_ACCESS && $user_access != Posts::INTERMEDIATE_ACCESS)
|
||||
Rest_fatal_error(401, "You are not allowed to delete this post !");
|
||||
|
||||
//Delete the post
|
||||
if(!CS::get()->components->posts->delete($postID))
|
||||
Rest_fatal_error(500, "Couldn't delete post!");
|
||||
|
||||
//Success
|
||||
return array("success" => "The post has been deleted!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the visibility level specified in a POST request
|
||||
|
Loading…
Reference in New Issue
Block a user