Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
131 lines (124 sloc) 6.08 KB
<?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 id="in-message-<?php echo $message->id ?>" value="<?php echo $message->id ?>"
class="message"
>
<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) ?>
<a class="right waves-circle message-opt-button center-align dropdown-button"
data-activates="message-dropdown-<?php echo $message->id ?>"
>
<i class="material-icons">more_vert</i>
</a>
<ul id="message-dropdown-<?php echo $message->id ?>" class='dropdown-content'>
<li>
<a onclick="deleteInboxMessage(<?php echo $message->id ?>)">
Delete
</a>
</li>
</ul>
</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 id="out-message-<?php echo $message->id ?>" class="message">
<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) ?>
<a class="right waves-circle message-opt-button center-align dropdown-button"
data-activates="sent-dropdown-<?php echo $message->id ?>"
>
<i class="material-icons">more_vert</i>
</a>
<ul id="sent-dropdown-<?php echo $message->id ?>" class='dropdown-content'>
<li>
<a onclick="deleteSentMessage(<?php echo $message->id ?>)">
Delete
</a>
</li>
</ul>
</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="left" 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';
?>
You can’t perform that action at this time.