Improved noticationToDB

This commit is contained in:
Pierre 2018-02-20 14:25:28 +01:00
parent ecbccd1b9d
commit 6d1c5c3d2c
2 changed files with 27 additions and 3 deletions

View File

@ -262,6 +262,8 @@ class notificationComponent {
$data = array(); $data = array();
if($notification->has_id())
$data['id'] = $notification->get_id();
if($notification->has_seen_state()) if($notification->has_seen_state())
$data['seen'] = $notification->is_seen() ? 1 : 0; $data['seen'] = $notification->is_seen() ? 1 : 0;
if($notification->has_from_user_id()) if($notification->has_from_user_id())
@ -270,8 +272,10 @@ class notificationComponent {
$data['dest_user_id'] = $notification->get_dest_user_id(); $data['dest_user_id'] = $notification->get_dest_user_id();
if($notification->has_type()) if($notification->has_type())
$data['type'] = $notification->get_type(); $data['type'] = $notification->get_type();
$data['on_elem_id'] = $notification->get_on_elem_id(); if($notification->has_on_elem_id())
$data['on_elem_type'] = $notification->get_on_elem_type(); $data['on_elem_id'] = $notification->get_on_elem_id();
if($notification->has_on_elem_type())
$data['on_elem_type'] = $notification->get_on_elem_type();
//Specify complementary fields only if required //Specify complementary fields only if required
if($full_entry){ if($full_entry){

View File

@ -89,7 +89,7 @@ class Notification {
* @return bool TRUE if the notification as an ID / FALSE else * @return bool TRUE if the notification as an ID / FALSE else
*/ */
public function has_id() : bool { public function has_id() : bool {
return $this->id != null; return ($this->id != null) && ($this->id != 0);
} }
/** /**
@ -219,6 +219,16 @@ class Notification {
return $this->on_elem_id; return $this->on_elem_id;
} }
/**
* Check if the id of element targeted by the notification has been
* specified or not
*
* @return bool TRUE if the ID of the target element has been specified
*/
public function has_on_elem_id() : bool {
return $this->on_elem_id != null;
}
/** /**
* Set notification target element type * Set notification target element type
* *
@ -237,6 +247,16 @@ class Notification {
return $this->on_elem_type; return $this->on_elem_type;
} }
/**
* Check if the type of element targeted by the notification has been
* specified or not
*
* @return bool TRUE if the ID of the target element has been specified
*/
public function has_on_elem_type() : bool {
return $this->on_elem_type != null;
}
/** /**
* Set notification event type * Set notification event type
* *