Skip to content
Permalink
Newer
Older
100644 105 lines (98 sloc) 4.36 KB
1
<?php
2
defined('APP_DIR') or define('APP_DIR', __DIR__ . '/../app/');
3
include_once(APP_DIR . 'model/User.php');
4
include_once(APP_DIR . 'model/SecureMessage.php');
5
include_once(APP_DIR . 'include/http.php');
6
7
$data = User::authenticated();
8
if (!$data) {
9
Http::redirect('index.php');
10
}
11
12
$user = User::get($data->username);
13
$inbox = SecureMessage::all_to($user->id);
14
$outbox = SecureMessage::all_from($user->id);
15
16
include 'template/header.html';
17
include 'template/user_menu_button.php';
18
?>
19
20
<div class="row messages-container">
21
<div class="col l8 m10 s12 offset-l2 offset-m1">
22
<div class="row">
23
<div class="col s12">
24
<h1> Messages </h1>
25
</div>
26
<div class="col s12 card-panel">
27
<ul class="tabs">
28
<li class="tab col s3"><a href="#inbox">Inbox</a></li>
29
<li class="tab col s3"><a href="#sent">Sent</a></li>
30
</ul>
31
</div>
32
<div id="inbox" class="col s12">
33
<ul id="messages-list" class="collapsible popout" data-collapsible="accordion">
34
<?php foreach($inbox as $message) { ?>
35
<li value="<?php echo $message->id ?>">
36
<div class="collapsible-header">
37
<?php if ($message->is_read) { ?>
38
<i id="inbox-icon-<?php echo $message->id ?>"
39
class="material-icons">check
40
</i>
41
<?php } else { ?>
42
<i id="inbox-icon-<?php echo $message->id ?>"
43
class="material-icons red-text">fiber_new
44
</i>
45
<?php } ?>
46
<?php echo htmlspecialchars($message->sender()->username) ?>
47
</div>
48
<div class="collapsible-body">
49
<span>
50
<?php echo htmlspecialchars($message->message) ?>
51
</span>
52
</div>
53
</li>
54
<?php } ?>
55
</ul>
56
</div>
57
<div id="sent" class="col s12" style="display:none">
58
<ul id="sent-list" class="collapsible popout" data-collapsible="accordion">
59
<?php foreach($outbox as $message) { ?>
60
<li>
61
<div class="collapsible-header">
62
<?php if ($message->is_read) { ?>
63
<i class="material-icons green-text">check_circle</i>
64
<?php } else { ?>
65
<i class="material-icons">arrow_forward</i>
66
<?php } ?>
67
<?php echo htmlspecialchars($message->receiver()->username) ?>
68
</div>
69
<div class="collapsible-body">
70
<span>
71
<?php echo htmlspecialchars($message->message) ?>
72
</span>
73
</div>
74
</li>
75
<?php } ?>
76
</ul>
77
</div>
78
</div>
79
</div>
80
</div>
81
82
<div class="row send-message-container">
83
<div class="col l8 m10 s12 offset-l2 offset-m1 z-depth-3 message-compose-box">
84
<input type="hidden" id="user-id" value="<?php echo $user->id ?>">
85
<div class="input-field col s6">
86
<input placeholder="Enter their username" id="recipient" type="text" class="validate">
87
<label id="recipient-label" for="recipient">Recipient</label>
88
</div>
89
<div clas="col s12"></div>
90
<div class="input-field col s12">
91
<textarea placeholder="Craft a message..." id="message-compose" class="materialize-textarea"></textarea>
92
</div>
93
</div>
94
</div>
95
96
<div class="fixed-action-btn">
97
<button data-position="top" data-delay="50" data-tooltip="Send message"
98
id="send-button" class="modal-trigger btn-floating btn-large blue tooltipped">
99
<i class="large material-icons waves-effect waves-light">send</i>
100
</button>
101
</div>
102
103
<?php
104
include 'template/footer.html';
105
?>
You can’t perform that action at this time.