mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 15:59:29 +00:00
Can delete a notification.
This commit is contained in:
parent
19516e3a5e
commit
87a19b02f9
@ -174,6 +174,37 @@ class notificationComponent {
|
||||
return CS::get()->db->addLine(self::NOTIFICATIONS_TABLE, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete notifications
|
||||
*
|
||||
* @param Notification $notification The notification to delete
|
||||
* @return bool TRUE for a success / FALSE else
|
||||
*/
|
||||
public function delete(Notification $notification) : bool {
|
||||
|
||||
//If the notification has an ID we delete a notification by its ID
|
||||
if($notification->has_id()){
|
||||
//Delete a notification by its ID
|
||||
$conditions = "id = ?";
|
||||
$values = array($notification->get_id());
|
||||
}
|
||||
|
||||
//Delete the notification
|
||||
else{
|
||||
|
||||
//Delete a specific notification
|
||||
$data = $this->noticationToDB($notification, FALSE);
|
||||
$array = CS::get()->db->splitConditionsArray($data);
|
||||
$conditions = $array[0];
|
||||
$values = $array[2];
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Delete the notification
|
||||
return CS::get()->db->deleteEntry(self::NOTIFICATIONS_TABLE, $conditions, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a notification object into database array
|
||||
*
|
||||
@ -188,7 +219,8 @@ class notificationComponent {
|
||||
|
||||
$data['seen'] = $notification->is_seen() ? 1 : 0;
|
||||
$data['from_user_id'] = $notification->get_from_user_id();
|
||||
$data['dest_user_id'] = $notification->get_dest_user_id();
|
||||
if($notification->has_dest_user_id())
|
||||
$data['dest_user_id'] = $notification->get_dest_user_id();
|
||||
$data['type'] = $notification->get_type();
|
||||
$data['on_elem_id'] = $notification->get_on_elem_id();
|
||||
$data['on_elem_type'] = $notification->get_on_elem_type();
|
||||
|
@ -75,7 +75,7 @@ class Notification {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notification iD
|
||||
* Get notification ID
|
||||
*
|
||||
* @return int The ID of the notification
|
||||
*/
|
||||
@ -83,6 +83,15 @@ class Notification {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the notification object has an ID or not
|
||||
*
|
||||
* @return bool TRUE if the notification as an ID / FALSE else
|
||||
*/
|
||||
public function has_id() : bool {
|
||||
return $this->id != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set notification creation time
|
||||
*
|
||||
@ -156,6 +165,15 @@ class Notification {
|
||||
return $this->dest_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the notification has a destination user ID
|
||||
*
|
||||
* @return bool TRUE if the destination user ID was specified
|
||||
*/
|
||||
public function has_dest_user_id() : bool {
|
||||
return $this->dest_user_id != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set notification target element id
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user