Can get from the API the list of targets where user can create posts

This commit is contained in:
2019-05-19 15:35:43 +02:00
parent f8e6aa2d3c
commit 75940b53f3
3 changed files with 71 additions and 0 deletions

View File

@ -91,6 +91,32 @@ class GroupsComponent {
return $info;
}
/**
* Get the list of groups of a user where the users can create
* posts
*
* @param int $userID The ID of the target user
* @return array The list of the groups the user can participate to
*/
public function getListUserWhereCanCreatePosts(int $userID) : array {
$list = db()->select(self::GROUPS_MEMBERS_TABLE." m, ".self::GROUPS_LIST_TABLE." g",
"WHERE user_id = ?
AND m.groups_id = g.id
AND (
level = ".GroupMember::ADMINISTRATOR." OR
level = ".GroupMember::MODERATOR." OR
(level = ".GroupMember::MEMBER." AND posts_level = ".GroupInfo::POSTS_LEVEL_ALL_MEMBERS.")
)
",
array($userID),
array("g.id"));
foreach($list as $num => $info)
$list[$num] = (int)$info["id"];
return $list;
}
/**
* Get the visibility level of a group
*

View File

@ -76,6 +76,28 @@ class friends {
}
/**
* Get the list of friends of a given user that allows him to
* create posts on their page
*
* @param $userID The ID of the target user
* @return array The list of friends of a user that allows him
* to create posts
*/
public function getListThatAllowPostsFromUser(int $userID) : array {
$list = db()->select(
$this->friendsTable,
"WHERE autoriser_post_page = 1 AND ID_amis = ?",
array($userID),
array("ID_personne")
);
foreach($list as $num=>$info)
$list[$num] = (int)$info["ID_personne"];
return $list;
}
/**
* Respond to a friendship request
*