Can check if a user is the owner of a comment or not.

This commit is contained in:
Pierre 2018-01-24 06:58:06 +01:00
parent 249c85c1db
commit 37b3893849

View File

@ -102,6 +102,21 @@ class Comments {
return isset($commentInfos["postID"]) ? $commentInfos["postID"] : 0;
}
/**
* Check if a user is the owner of a comment or not
*
* @param int $userID The ID of the user to check
* @param int $commentID The ID of the comment to check
* @return bool TRUE if the user is the owner of the post / FALSE else
*/
public function is_owner(int $userID, int $commentID) : bool {
return CS::get()->db->count(
$this::COMMENTS_TABLE,
"WHERE ID = ? AND ID_personne = ?",
array($commentID, $userID)
) > 0;
}
/**
* Parse a comment informations
*