Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
cse4707-secure-messaging/public/messages.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
105 lines (98 sloc)
4.39 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('APP_DIR') or define('APP_DIR', __DIR__ . '/../app/'); | |
include_once(APP_DIR . 'model/User.php'); | |
include_once(APP_DIR . 'model/SecureMessage.php'); | |
include_once(APP_DIR . 'include/http.php'); | |
$data = User::authenticated(); | |
if (!$data) { | |
Http::redirect('index.php'); | |
} | |
$user = User::get($data->username); | |
$inbox = array_reverse(SecureMessage::all_to($user->id)); | |
$outbox = array_reverse(SecureMessage::all_from($user->id)); | |
include 'template/header.html'; | |
include 'template/user_menu_button.php'; | |
?> | |
<div class="row messages-container"> | |
<div class="col l8 m10 s12 offset-l2 offset-m1"> | |
<div class="row"> | |
<div class="col s12"> | |
<h1> Messages </h1> | |
</div> | |
<div class="col s12 card-panel"> | |
<ul class="tabs"> | |
<li class="tab col s3"><a href="#inbox">Inbox</a></li> | |
<li class="tab col s3"><a href="#sent">Sent</a></li> | |
</ul> | |
</div> | |
<div id="inbox" class="col s12"> | |
<ul id="messages-list" class="collapsible popout" data-collapsible="accordion"> | |
<?php foreach($inbox as $message) { ?> | |
<li value="<?php echo $message->id ?>"> | |
<div class="collapsible-header"> | |
<?php if ($message->is_read) { ?> | |
<i id="inbox-icon-<?php echo $message->id ?>" | |
class="material-icons">check | |
</i> | |
<?php } else { ?> | |
<i id="inbox-icon-<?php echo $message->id ?>" | |
class="material-icons red-text">fiber_new | |
</i> | |
<?php } ?> | |
<?php echo htmlspecialchars($message->sender()->username) ?> | |
</div> | |
<div class="collapsible-body"> | |
<span> | |
<?php echo htmlspecialchars($message->message) ?> | |
</span> | |
</div> | |
</li> | |
<?php } ?> | |
</ul> | |
</div> | |
<div id="sent" class="col s12" style="display:none"> | |
<ul id="sent-list" class="collapsible popout" data-collapsible="accordion"> | |
<?php foreach($outbox as $message) { ?> | |
<li> | |
<div class="collapsible-header"> | |
<?php if ($message->is_read) { ?> | |
<i class="material-icons green-text">check_circle</i> | |
<?php } else { ?> | |
<i class="material-icons">arrow_forward</i> | |
<?php } ?> | |
<?php echo htmlspecialchars($message->receiver()->username) ?> | |
</div> | |
<div class="collapsible-body"> | |
<span> | |
<?php echo htmlspecialchars($message->message) ?> | |
</span> | |
</div> | |
</li> | |
<?php } ?> | |
</ul> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="row send-message-container"> | |
<div class="col l8 m10 s12 offset-l2 offset-m1 z-depth-3 message-compose-box"> | |
<input type="hidden" id="user-id" value="<?php echo $user->id ?>"> | |
<div class="input-field col s6"> | |
<input placeholder="Enter their username" id="recipient" type="text" class="validate"> | |
<label id="recipient-label" for="recipient">Recipient</label> | |
</div> | |
<div clas="col s12"></div> | |
<div class="input-field col s12"> | |
<textarea placeholder="Craft a message..." id="message-compose" class="materialize-textarea"></textarea> | |
</div> | |
</div> | |
</div> | |
<div class="fixed-action-btn"> | |
<button data-position="top" data-delay="50" data-tooltip="Send message" | |
id="send-button" class="modal-trigger btn-floating btn-large blue tooltipped"> | |
<i class="large material-icons waves-effect waves-light">send</i> | |
</button> | |
</div> | |
<?php | |
include 'template/footer.html'; | |
?> |