forked from benjamw/battleship
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages.php
158 lines (134 loc) · 5.67 KB
/
messages.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
require_once 'includes/inc.global.php';
if (isset($_POST['action'])) {
test_token( );
try {
switch ($_POST['action']) {
case 'read' :
$Message->set_message_read($_POST['ids']);
break;
case 'unread' :
$Message->set_message_unread($_POST['ids']);
break;
case 'delete' :
$Message->delete_message($_POST['ids']);
break;
default :
break;
}
}
catch (MyException $e) {
Flash::store('Message Action FAILED !', true);
}
}
$meta['title'] = 'Message Center';
$meta['head_data'] = '
<script type="text/javascript" src="scripts/messages.js"></script>
';
$contents = '
<form method="post" action="'.$_SERVER['REQUEST_URI'].'"><div>
<input type="button" name="send" id="send" value="Send Message" />
</div></form>';
// INBOX
$messages = $Message->get_inbox_list( );
$table_format = array(
array('SPECIAL_CLASS', 'my_empty(\'[[[view_date]]]\')', 'highlight') ,
array('SPECIAL_HTML', 'true', 'id="msg[[[message_id]]]"') ,
array('Id', 'message_id') ,
array('Subject', '###@htmlentities(strmaxlen(html_entity_decode(\'[[[subject]]]\', ENT_QUOTES), 25), ENT_QUOTES, \'ISO-8859-1\', false)') ,
array('From', '###\'[[[sender]]]\'.(([[[global]]]) ? \' <span class="highlight">(<abbr title="GLOBAL">G</abbr>)</span>\' : \'\')') ,
array('Date Sent', '###@ifdateor(Settings::read(\'long_date\'), strtotime(\'[[[send_date]]]\'), strtotime(\'[[[create_date]]]\'))') ,
array('Date Read', '###@ifdateor(Settings::read(\'long_date\'), strtotime(\'[[[view_date]]]\'), \'Never\')') ,
array('Date Expires', '###@ifdateor(Settings::read(\'long_date\'), strtotime(\'[[[expire_date]]]\'), \'Never\')') ,
array('<input type="checkbox" id="in_all" />', '<input type="checkbox" name="ids[]" value="[[[message_id]]]" class="in_box" />', 'false', 'class="edit"') ,
);
$table_meta = array(
'sortable' => true ,
'no_data' => '<p>There are no messages in your inbox.</p><!-- NO_INBOX -->' ,
'caption' => 'Inbox' ,
);
$table = get_table($table_format, $messages, $table_meta);
// add the message edit form if we have messages shown
if (false === strpos($table, 'NO_INBOX')) {
$contents .= '
<form method="post" action="'.$_SERVER['REQUEST_URI'].'"><div class="action">
<input type="hidden" name="token" value="'.$_SESSION['token'].'" />
'.$table.'
<select name="action" id="in_action" style="float:right;">
<option value="">With Selected:</option>
<option value="read">Mark as Read</option>
<option value="unread">Mark as Unread</option>
<option value="delete">Delete</option>
</select>
</div></form>';
}
else {
$contents .= $table;
}
// OUTBOX
$result = $Message->get_outbox_list( );
$table_format = array(
array('SPECIAL_CLASS', ' ! [[[sent]]]', 'unsent') ,
array('SPECIAL_HTML', 'true', 'id="msg[[[message_id]]]"') ,
array('Id', 'message_id') ,
array('Subject', '###@htmlentities(strmaxlen(html_entity_decode(\'[[[subject]]]\'), 25), ENT_QUOTES, \'ISO-8859-1\', false)') ,
array('To', 'recipients') ,
array('Date Sent', '###@ifdateor(Settings::read(\'long_date\'), strtotime(\'[[[send_date]]]\'), strtotime(\'[[[create_date]]]\'))') ,
array('Date Expires', '###@ifdateor(Settings::read(\'long_date\'), strtotime(\'[[[expire_date]]]\'), \'Never\')') ,
array('<input type="checkbox" id="out_all" />', '<input type="checkbox" name="ids[]" value="[[[message_id]]]" class="out_box" />', 'false', 'class="edit"') ,
);
$table_meta = array(
'sortable' => true ,
'no_data' => '<p>There are no messages in your outbox.</p><!-- NO_OUTBOX -->' ,
'caption' => 'Outbox' ,
);
$table = get_table($table_format, $result, $table_meta);
// add the message edit form if we have messages shown
if (false === strpos($table, 'NO_OUTBOX')) {
$contents .= '
<form method="post" action="'.$_SERVER['REQUEST_URI'].'"><div class="action">
<input type="hidden" name="token" value="'.$_SESSION['token'].'" />
'.$table.'
<select name="action" id="out_action" style="float:right;">
<option value="">With Selected:</option>
<option value="delete">Delete</option>
</select>
</div></form>';
}
else {
$contents .= $table;
}
// ADMIN LIST
if (false && $GLOBALS['Player']->is_admin) {
$result = $Message->get_admin_list( );
$table_format = array(
array('SPECIAL_CLASS', ' ! [[[sent]]]', 'unsent') ,
array('SPECIAL_HTML', 'true', 'id="msg[[[message_id]]]"') ,
array('Id', 'message_id') ,
array('Subject', '###@htmlentities(strmaxlen(html_entity_decode(\'[[[subject]]]\'), 25), ENT_QUOTES, \'ISO-8859-1\', false)') ,
array('From', 'sender') ,
array('To', 'recipients') ,
array('Date Sent', '###@ifdateor(Settings::read(\'long_date\'), strtotime(\'[[[send_date]]]\'), strtotime(\'[[[create_date]]]\'))') ,
array('Date Expires', '###@ifdateor(Settings::read(\'long_date\'), strtotime(\'[[[expire_date]]]\'), \'Never\')') ,
);
$table_meta = array(
'sortable' => true ,
'no_data' => '<p>There are no messages in the admin list.</p><!-- NO_ADMIN -->' ,
'caption' => 'Admin List' ,
);
$table = get_table($table_format, $result, $table_meta);
// no form
$contents .= $table;
}
$hints = array(
'Click anywhere on a row to read your messages.' ,
'<span class="highlight">Colored inbox entries</span> indicate messages that have not been read.' ,
'<span class="highlight">(<abbr title="GLOBAL">G</abbr>)</span> indicates a GLOBAL message sent by an administrator.',
'<span class="highlight">Colored outbox entries</span> indicate messages that have not been sent.' ,
'Colored outbox <span class="highlight">recipient</span> entries indicate messages that have not been read.' ,
'Colored outbox <span class="highlight">sent dates</span> indicate messages that have not been sent.' ,
);
echo get_header($meta);
echo get_item($contents, $hints, $meta['title']);
call($GLOBALS);
echo get_footer( );