forked from Moc/mailbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.php
More file actions
116 lines (103 loc) · 2.95 KB
/
Copy pathcompose.php
File metadata and controls
116 lines (103 loc) · 2.95 KB
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
<?php
/*
* Mailbox - an e107 plugin by Tijn Kuyper
*
* Copyright (C) 2016-2017 Tijn Kuyper (http://www.tijnkuyper.nl)
* 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', false, true);
// Load the header and the mailbox class
require_once(HEADERF);
require_once(e_PLUGIN."mailbox/mailbox_class.php");
// Load template and shortcodes
$sc = e107::getScBatch('mailbox', TRUE);
$template = e107::getTemplate('mailbox');
$template = array_change_key_case($template);
// Define variables
$sql = e107::getDb();
$tp = e107::getParser();
$frm = e107::getForm();
$text = '';
$mailbox_class = new Mailbox;
// Open container
$text .= '<div class="row">';
// Open left sidebar
$text .= '<div class="col-md-3">';
// Load left sidebar
$text .= $tp->parseTemplate($template['box_navigation'], true, $sc);
// Close left sidebar
$text .= '</div>';
// Open right content
$text .= '<div class="col-md-9">';
// Check if the user has just submitted a message
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
// Get message id when updating existing draft
if($tp->filter($_GET['cid']))
{
$_POST['id'] = $tp->filter($_GET['cid']);
}
// Determine whether we are sending, saving as a draft or discarding the message
switch($_POST['compose'])
{
// Message should be send to the receiver
case 'send':
default:
$text .= $mailbox_class->process_compose("send", $_POST);
break;
// Message should be saved as a draft
case 'draft':
$text .= $mailbox_class->process_compose("draft", $_POST);
break;
case 'discard':
print_a("The message should be discarded");
break;
}
}
// Check if we are continuing a draft - in which case we need to retrieve the data from db
if($tp->filter($_GET['cid']))
{
$cid = $tp->filter($_GET['cid']);
$draftvalues = $sql->retrieve('mailbox_messages', 'message_id, message_from, message_to, message_subject, message_text, message_draft, message_sent', 'message_id='.$cid);
/* Confirm that:
- user is indeed the original sender of the message
- message is a draft
- message has not been sent yet
*/
if(
$draftvalues['message_from'] == USERID &&
$draftvalues['message_draft'] == 1 &&
$draftvalues['message_sent'] == 0
)
{
$sc->setVars($draftvalues);
$text .= $tp->parseTemplate($template['compose_message'], true, $sc);
}
else
{
$text .= '<div class="mailbox-infomessage">'.LAN_MAILBOX_MESSAGENOTYOURS.'</div>';
}
}
else
{
$text .= $tp->parseTemplate($template['compose_message'], true, $sc);
}
// Close right content
$text .= '</div>';
// Close container
$text .= '</div>';
$ns->tablerender(LAN_MAILBOX_NAME, e107::getMessage()->render().$text);
require_once(FOOTERF);
exit;