$newMessage = new InboxMessage(); $newMessage->comment = $row['message']; $newMessage->date = $row['date']; $newMessage->is_comment = 0; $newMessage->user_id = $row['from_user']; $newMessage->id = $row['id']; //get the username from ID $userLookup = $connection->query("SELECT username FROM users WHERE id={$newMessage->user_id}"); while ($user = $userLookup->fetch_assoc()) { $newMessage->username = $user['username']; } //if the message has been viewed add it to the 'unread' set if ($row['viewed'] == 0) { $unreadMessages->addMessage($newMessage); } else { $readMessages->addMessage($newMessage); } } //The InboxMessage class contains all the parameters for each inbox message //and the function for actually rendering the html class InboxMessage { public function renderComment() { $html = "<div class='comment' data-comment-id='" . $this->id . "'>"; $html .= "<div class='comment-head'>"; $html .= "<span>{$this->username}</span> posted at {$this->date} </div>"; $html .= "<p>" . $this->comment . "</p>"; $html .= "<div class='comment-actions'><a class='reply-btn'>Reply</a> : <a class='message-user-btn'>Direct Message</a> : <a href='story" . $this->article_path . "#comment{$this->id}'>View Context</a> : <a href='functions/read-inbox-item.php?id={$this->id}&context=comment'>Mark as Read</a></div>"; $html .= "</div>"; echo $html;
$commentResponse->id = $reply['id']; $commentResponse->comment = $reply['comment']; $commentResponse->user_id = $reply['user_id']; $commentResponse->date = $reply['date']; $commentResponse->article_path = $reply['article_path']; $commentResponse->is_comment = 1; //get the username from ID $userLookup = $connection->query("SELECT username FROM users WHERE id={$commentResponse->user_id}"); while ($user = $userLookup->fetch_assoc()) { $commentResponse->username = $user['username']; } //if the response has been viewed add it to the unread MessageSet if ($reply['response_viewed'] == 0) { $unreadComments->addMessage($commentResponse); } else { $readComments->addMessage($commentResponse); } } //replies that have already been read } //The InboxMessage class contains all the parameters for each inbox message //and the function for actually rendering the html class InboxMessage { public function renderComment() { $html = "<div class='comment' data-comment-id='" . $this->id . "'>"; $html .= "<div class='comment-head'>"; $html .= "<span>{$this->username}</span> posted at {$this->date} </div>"; #$html .= "<a class='reply-btn'>Reply</a> : <a class='message-user-btn'>Message User</a></div>"; $html .= "<p>" . $this->comment . "</p>";