Can delete groups.

This commit is contained in:
Pierre HUBERT
2018-08-31 09:56:46 +02:00
parent 9df1c93a24
commit 827fec68c7
5 changed files with 145 additions and 9 deletions

View File

@ -93,7 +93,7 @@ class notificationComponent {
//Determine the visibility level of the notification
if($notification->get_on_elem_type() == Notification::POST){
//Fetch post informations
//Fetch post information
$info_post = components()->posts->get_single($notification->get_on_elem_id());
//Check for error
@ -402,6 +402,21 @@ class notificationComponent {
}
/**
* Delete all the notifications related with a post
*
* @param int $postID The ID of the target post
* @return bool TRUE for a success / FALSE else
*/
public function deleteAllRelatedWithPost(int $postID) : bool {
$notification = new Notification();
$notification->set_on_elem_type(Notification::POST);
$notification->set_on_elem_id($postID);
return $this->delete($notification);
}
/**
* Delete all the notifications related with a user
*
@ -421,6 +436,26 @@ class notificationComponent {
}
/**
* Delete all the notifications related with a group
*
* @param int $groupID The ID of the target group
* @return bool TRUE for a success / FALSE else
*/
public function deleteAllRelatedWithGroup(int $groupID) : bool {
//Groups membership notifications
$notification = new Notification();
$notification->set_on_elem_type(Notification::GROUP_MEMBERSHIP);
$notification->set_on_elem_id($groupID);
if(!$this->delete($notification)) return FALSE;
$notification->set_on_elem_type(Notification::GROUP_PAGE);
if(!$this->delete($notification)) return FALSE;
return TRUE;
}
/**
* Convert a notification object into database array
*