-
Notifications
You must be signed in to change notification settings - Fork 4
/
mailbox.php
128 lines (112 loc) · 3.47 KB
/
mailbox.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
<?php
/*
* Mailbox
*
* Copyright (C) 2021 - Tijn Kuyper (Moc)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
if(!defined('e107_INIT'))
{
require_once("../../class2.php");
}
if(!e107::isInstalled('mailbox'))
{
e107::redirect();
exit;
}
// Load the LAN files
e107::lan('mailbox');
// Define variables
$sql = e107::getDb();
$tp = e107::getParser();
$text = '';
$page = $tp->filter($_GET['page']);
// Load mailbox class and initiate
require_once(e_PLUGIN."mailbox/mailbox_class.php");
$mailbox_class = new Mailbox;
// Check if AJAX calls were made
if(e_AJAX_REQUEST)
{
// Check if 'mark as read/unread' button was pressed
if(varset($_POST['action']) == 'readunread')
{
$mailbox_class->ajaxReadUnread();
}
// Check if 'mark as star' button was pressed, or individual star
if(varset($_POST['action']) == 'star')
{
$mailbox_class->ajaxStar();
}
// Check if trash button was pressed
if(varset($_POST['action']) == 'trash')
{
$mailbox_class->ajaxTrash();
}
}
// Get some basic info
$current_mailbox = $mailbox_class->get_current_mailbox($page);
$queryargs = $mailbox_class->get_database_queryargs($current_mailbox);
// Set pagetitles
define('PAGE_NAME', LAN_MAILBOX_NAME);
$pagetitle = $mailbox_class->get_pagetitle($page);
define('e_PAGETITLE', $pagetitle);
// Load the header and mailbox class
require_once(HEADERF);
// Load template and shortcodes
$sc = e107::getScBatch('mailbox', TRUE);
$template = e107::getTemplate('mailbox');
$template = array_change_key_case($template);
if(!USERID)
{
e107::getMessage()->addError(LAN_MAILBOX_NOTLOGGEDIN);
}
else
{
// Notify user that messages in trashbox are permanently deleted after 14 days in the trashbox
if($current_mailbox == 'trashbox')
{
e107::getMessage()->addInfo(LAN_MAILBOX_TRASHDELETED);
}
// Open container
$text .= $tp->parseTemplate($template['container']['start'], true, $sc);
// Open sidemenu
$text .= $tp->parseTemplate($template['box_navigation']['start'], true, $sc);
// Load sidemenu content
$text .= $tp->parseTemplate($template['box_navigation']['content'], true, $sc);
// Close sidemenu
$text .= $tp->parseTemplate($template['box_navigation']['end'], true, $sc);
// Open tablelist
$text .= $tp->parseTemplate($template['tablelist']['start'], true, $sc);
// Load tablelist table (contents)
// Header
$text .= $tp->parseTemplate($template['tablelist']['header'], true, $sc);
// Body (= messages)
// Construct query
$query_getmessages = $sql->retrieve('mailbox_messages', '*', $queryargs, true);
// Check if there messages to display
if($query_getmessages)
{
// Messages found, loop through
foreach($query_getmessages as $message)
{
$sc->setVars($message); // pass query values on so they can be used in the shortcodes
$text .= $tp->parseTemplate($template['tablelist']['messages'], true, $sc);
}
}
else
{
$nomessages = e107::getParser()->lanVars(LAN_MAILBOX_NOMESSAGESTODISPLAY, $current_mailbox, true);
$text .= e107::getMessage()->addInfo($nomessages);
}
// Footer
$text .= $tp->parseTemplate($template['tablelist']['footer'], true, $sc);
// Close tabellist
$text .= $tp->parseTemplate($template['tablelist']['end'], true, $sc);
// Close container
$text .= $tp->parseTemplate($template['container']['end'], true, $sc);
}
$ns->tablerender(LAN_MAILBOX_NAME, e107::getMessage()->render().$text, 'mailbox');
require_once(FOOTERF);
exit;