Skip to content
Permalink
Newer
Older
100644 131 lines (124 sloc) 6.08 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 = array_reverse(SecureMessage::all_to($user->id));
14
$outbox = array_reverse(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 id="in-message-<?php echo $message->id ?>" value="<?php echo $message->id ?>"
36
class="message"
37
>
38
<div class="collapsible-header">
39
<?php if ($message->is_read) { ?>
40
<i id="inbox-icon-<?php echo $message->id ?>"
41
class="material-icons">check
42
</i>
43
<?php } else { ?>
44
<i id="inbox-icon-<?php echo $message->id ?>"
45
class="material-icons red-text">fiber_new
46
</i>
47
<?php } ?>
48
<?php echo htmlspecialchars($message->sender()->username) ?>
49
<a class="right waves-circle message-opt-button center-align dropdown-button"
50
data-activates="message-dropdown-<?php echo $message->id ?>"
51
>
52
<i class="material-icons">more_vert</i>
53
</a>
54
<ul id="message-dropdown-<?php echo $message->id ?>" class='dropdown-content'>
55
<li>
56
<a onclick="deleteInboxMessage(<?php echo $message->id ?>)">
57
Delete
58
</a>
59
</li>
60
</ul>
61
</div>
62
<div class="collapsible-body">
63
<span>
64
<?php echo htmlspecialchars($message->message) ?>
65
</span>
66
</div>
67
</li>
68
<?php } ?>
69
</ul>
70
</div>
71
<div id="sent" class="col s12" style="display:none">
72
<ul id="sent-list" class="collapsible popout" data-collapsible="accordion">
73
<?php foreach($outbox as $message) { ?>
74
<li id="out-message-<?php echo $message->id ?>" class="message">
75
<div class="collapsible-header">
76
<?php if ($message->is_read) { ?>
77
<i class="material-icons green-text">check_circle</i>
78
<?php } else { ?>
79
<i class="material-icons">arrow_forward</i>
80
<?php } ?>
81
<?php echo htmlspecialchars($message->receiver()->username) ?>
82
<a class="right waves-circle message-opt-button center-align dropdown-button"
83
data-activates="sent-dropdown-<?php echo $message->id ?>"
84
>
85
<i class="material-icons">more_vert</i>
86
</a>
87
<ul id="sent-dropdown-<?php echo $message->id ?>" class='dropdown-content'>
88
<li>
89
<a onclick="deleteSentMessage(<?php echo $message->id ?>)">
90
Delete
91
</a>
92
</li>
93
</ul>
94
</div>
95
<div class="collapsible-body">
96
<span>
97
<?php echo htmlspecialchars($message->message) ?>
98
</span>
99
</div>
100
</li>
101
<?php } ?>
102
</ul>
103
</div>
104
</div>
105
</div>
106
</div>
107
108
<div class="row send-message-container">
109
<div class="col l8 m10 s12 offset-l2 offset-m1 z-depth-3 message-compose-box">
110
<input type="hidden" id="user-id" value="<?php echo $user->id ?>">
111
<div class="input-field col s6">
112
<input placeholder="Enter their username" id="recipient" type="text" class="validate">
113
<label id="recipient-label" for="recipient">Recipient</label>
114
</div>
115
<div clas="col s12"></div>
116
<div class="input-field col s12">
117
<textarea placeholder="Craft a message..." id="message-compose" class="materialize-textarea"></textarea>
118
</div>
119
</div>
120
</div>
121
122
<div class="fixed-action-btn">
123
<button data-position="left" data-delay="50" data-tooltip="Send message"
124
id="send-button" class="modal-trigger btn-floating btn-large blue tooltipped">
125
<i class="large material-icons waves-effect waves-light">send</i>
126
</button>
127
</div>
128
129
<?php
130
include 'template/footer.html';
131
?>
You can’t perform that action at this time.