mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 13:59:29 +00:00
Created User->canCreatePosts method
This commit is contained in:
parent
e4343b0ef4
commit
5a4918db39
@ -151,7 +151,7 @@ class userController
|
||||
//If it is his page, yes by default
|
||||
userID == $userID ? TRUE :
|
||||
//Else check friendship status
|
||||
CS::get()->components->friends->can_post_text(userID, $userID);
|
||||
CS::get()->components->user->canCreatePosts(userID, $userID);
|
||||
}
|
||||
|
||||
//Return user informations
|
||||
|
@ -436,6 +436,36 @@ class User{
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user can create a post on another user page
|
||||
*
|
||||
* @param int $userID The ID of the user who could create post
|
||||
* @param int $targetID The ID of the user who could receive new posts
|
||||
* @return bool True if the user is allowed to create post / false else
|
||||
*/
|
||||
public function canCreatePosts(int $userID, int $targetID){
|
||||
|
||||
//If the user is signed out, the response is NO by default
|
||||
if($userID == 0)
|
||||
return FALSE;
|
||||
|
||||
//If the two user are friends, the response is yes by default
|
||||
if($userID === $targetID)
|
||||
return TRUE;
|
||||
|
||||
//Check if the user is allowed to access user page
|
||||
if(!$this->userAllowed($userID, $targetID))
|
||||
return FALSE;
|
||||
|
||||
//Check if the friendship of the users allow them to create posts
|
||||
if(!CS::get()->components->friends->can_post_text($userID, $targetID))
|
||||
return FALSE;
|
||||
|
||||
//Else the user is allowed
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a user allow comments on his page or not
|
||||
|
Loading…
Reference in New Issue
Block a user