-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_user_messages_answer_message.php
278 lines (176 loc) · 8.5 KB
/
admin_user_messages_answer_message.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?php
function admin_user_answer_message($content) {
global $wpdb;
// global $current_user;
// get_currentuserinfo();
// Read user ID from the Front End User plugin Level 10 is Administrator
global $ewd_feup_user_table_name, $ewd_feup_levels_table_name, $ewd_feup_user_fields_table_name;
$UserCookie = CheckLoginCookie();
$User = $wpdb->get_row($wpdb->prepare("SELECT * FROM $ewd_feup_user_table_name WHERE Username='%s'", $UserCookie['Username']));
$current_user->ID = $User->User_ID;
include('admin_user_messages_settings.php');
$table_name = $wpdb->prefix . 'admin_user_message';
//$table_users = $wpdb->prefix . 'users';
// Read from FEU instead of blog users
$table_users = $ewd_feup_user_table_name;
if(isset($_POST['submitted'])) {
$messageIdAnswer = $_POST['messageIdAnswer'];
$query = "SELECT * FROM $table_name WHERE auto = '$messageIdAnswer'";
$result = mysql_query($query);
}
if(isset($_POST['submittedAnswer'])) {
$sender = $_POST['sender'];
$receiver = $_POST['receiver'];
$subject = $_POST['subject'];
$answer = $_POST['answerTextarea'];
$subjectOldAndNew = $_POST['subjectOldAndNew'];
$todayDate = date('Y-m-d');
$timestamp = time() + 28800; // +8GMT
$timeSend = date("H:i:s",$timestamp);
$query = "INSERT INTO $table_name (auto, sender, receiver, time, date, message, status, subject)
VALUES ('','{$sender}','{$receiver}', '{$timeSend}', '{$todayDate}', '{$answer}', '0', '{$subjectOldAndNew}')";
$wpdb->query($query);
echo "<span>" . $aum_term_msg_successfull_sent . "</span>";
echo "<p> </p>";
?>
<script>
function gotoInbox() {
document.location.href = "<?php echo 'http://' . $aum_btn_back_to_inbox; ?>";
}
</script>
<?php
echo "<input type='button' class='aum_button' value='" . $aum_btn_back_to_inbox_text . "' onclick='gotoInbox();'>";
echo "<p> </p>";
// Change to Username & UserID as per FEU wpdb
$queryReceiverMail = "SELECT Username FROM $table_users WHERE User_ID = '$receiver'";
$resultReceiverMail = mysql_query($queryReceiverMail);
while($rowReceiverMail = mysql_fetch_row($resultReceiverMail)) {
$siteurl = site_url();
$utext = utf8_decode($aum_mail_message);
$mailtext = '
<head>
<title></title>
</head>
<style>
font-family:calibri, verdana, arial, helvetica;
font-size:14px;
</style>
<body>
' . nl2br($utext) .'
<br><br>
<a href="' . $siteurl . '">' . $siteurl . '</a>
</body>
</html>
';
$empfaenger = $rowReceiverMail[0]; //Mailadresse
$absender = $aum_mail_sender_mail;
$betreff = "Neue Nachricht auf " . $siteurl;
$antwortan = $aum_mail_sender_mail;
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "From: $absender\r\n";
$header .= "Reply-To: $antwortan\r\n";
// $header .= "Cc: $cc\r\n"; // falls an CC gesendet werden soll
$header .= "X-Mailer: PHP ". phpversion();
/*
// disable send email notification
// mail( $empfaenger,
$betreff,
$mailtext,
$header);
*/
}
}
?>
<script>
function sendAnswerIntoDb() {
//alert (document.getElementById("subjectOldAndNew").value);
if (document.getElementById("subjectOldAndNew").value == '') {
<?php
echo 'alert("' . $aum_msg_missing_subject . '");';
?>
document.getElementById("subjectOldAndNew").focus();
return;
} else {
document.getElementById("sender").value = '<?php echo $current_user->ID; ?>';
//document.getElementById("receiver").value = '<?php echo $receiverNew; ?>';
document.getElementById("subject").value = '<?php echo $subjectName ?>';
document.sendAnswerIntoDbForm.submit();
}
}
</script>
<form name="sendAnswerIntoDbForm" action="<?php the_permalink(); ?>" method="post">
<input type="hidden" name="sender" id="sender" value="">
<input type="hidden" name="receiver" id="receiver" value="">
<input type="hidden" name="subject" id="subject" value="">
<input type="hidden" name="submittedAnswer" id="submittedAnswer" value="true">
<?php
if(isset($_POST['submitted'])) {
?>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><a href="<?php echo 'http://' . $aum_btn_back_to_inbox; ?>"><?php echo $aum_term_link_inbox; ?></a> | <a href="<?php echo 'http://' . $aum_btn_post_message; ?>"><?php echo $aum_term_link_post_a_message; ?></a> | <a href="<?php echo 'http://' . $aum_btn_back_to_send_msg; ?>"><?php echo $aum_term_link_sent_messages; ?></a> | <a href="<?php echo 'http://' . $aum_btn_search; ?>"><?php echo $aum_term_search_button; ?></a></td>
</tr>
<tr valign="top">
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td>
<?php
while($row = mysql_fetch_row($result)) {
$querySender = "SELECT Username FROM $table_users WHERE User_ID = '$row[1]'";
$resultSender = mysql_query($querySender);
$subjectName = $row[7];
$receiverNew = $row[1];
//echo "test: " . $receiverNew;
?>
<script>
document.getElementById("receiver").value = '<?php echo $receiverNew; ?>';
</script>
<?php
while($rowSender = mysql_fetch_row($resultSender)) {
echo $aum_term_msg_from . ": ";
echo $rowSender[0];
$senderName = $rowSender[0];
}
echo "<br>";
echo $aum_term_sent_date . ": ";
$d = explode("-",$row[4]);
echo $d[2] . "." . $d[1] . "." . $d[0];
echo " - " . $row[3];
echo "<br><br>";
$row7input = htmlspecialchars($row[7]);
//$row7input2 = htmlentities($row7input);
//echo $row7input;
//echo "Betreff: <input type=text name=subjectOldAndNew id=subjectOldAndNew value=" . $row[7] . ">";
echo $aum_term_subject . ": <input type=text name=subjectOldAndNew id=subjectOldAndNew value='' class=aum_text>";
echo "<br>";
echo $aum_term_msg . ":<br>";
echo "<textarea class=aum_text cols=80 rows=10 style=width:100% name=answerTextarea id=answerTextarea>";
echo "--- " . $aum_term_msg . " ---\n";
echo $aum_term_subject . ": " . $row[7] . "\n";
echo $aum_term_sent_date . ": ";
$d = explode("-",$row[4]);
echo $d[2] . "." . $d[1] . "." . $d[0];
echo " um " . $row[3] . "\n";
echo "Gesendet von: " . $senderName . "\n\n";
$utext = str_replace("<br />", "<br />\n", $row[5]);
echo $utext;
echo "</textarea><br>";
echo "<input type=button class='aum_button' value='" . $aum_btn_send_answer_text . "' onclick='sendAnswerIntoDb();'>";
echo "</form>";
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
?>
<?php
}
add_shortcode( 'admin_user_answer_message', 'admin_user_answer_message' );
?>