Made notification system more clear.

This commit is contained in:
Pierre HUBERT 2018-08-02 09:06:21 +02:00
parent 814ee8949b
commit c152593c88

View File

@ -161,23 +161,8 @@ class notificationComponent {
//For the posts on groups //For the posts on groups
else if($notification->get_from_container_type() == Notification::GROUP_PAGE){ else if($notification->get_from_container_type() == Notification::GROUP_PAGE){
//Get the list of the members of the group that follows it //Push to all the members of a group who follows it
$list = components()->groups->getListFollowers($notification->get_from_container_id()); return $this->push_members_group($notification, $notification->get_from_container_id());
//Process the list of followers
$target_users = array();
foreach($list as $userID){
//If the current follower is the user creating the notification
if($userID == $notification->get_from_user_id())
continue;
$target_users[] = $userID;
}
//Push the notification
return $this->push_public($notification, $target_users);
} }
//Unimplemented scenario //Unimplemented scenario
@ -228,6 +213,34 @@ class notificationComponent {
} }
/**
* Push a notification to all the members of a group following it
*
* @param Notification $notification The notification to push
* @param int $groupID Target group ID
* @return bool TRUE success / FALSE else
*/
private function push_members_group(Notification $notification, int $groupID) : bool {
//Get the list of the members of the group that follows it
$list = components()->groups->getListFollowers($groupID);
//Process the list of followers
$target_users = array();
foreach($list as $userID){
//If the current follower is the user creating the notification
if($userID == $notification->get_from_user_id())
continue;
$target_users[] = $userID;
}
//Push the notification
return $this->push_public($notification, $target_users);
}
/** /**
* Push a notification to all the moderators of a group * Push a notification to all the moderators of a group
* *