/** * Mark this item read/unread helper * * @param bool $unread Unread (True/False) (Default: False) * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) * @return string|null If $return is False, nothing will be returned, else the sql code to update this item */ protected function mark($unread = true, $return = false) { $this->notification_read = (bool) (!$unread); if ($return) { $where = array('notification_type_id = ' . (int) $this->notification_type_id, 'item_id = ' . (int) $this->item_id, 'user_id = ' . (int) $this->user_id); $where = implode(' AND ', $where); return $where; } else { $this->notification_manager->mark_notifications($this->get_type(), (int) $this->item_id, (int) $this->user_id, false, $this->notification_read); } }