29 if (isset($location) && (!empty($location)))
33 if ($location ===
"backend")
37 else if ($location ===
"frontend")
52 echo
"<script type=\"text/javascript\" src=\"$prefix".
"system/plugins/messages/js/message-send.js\"></script>";
53 echo
"<script type='text/javascript'>
54 function markAsSpam(msg_id)
57 url:'$prefix".
"system/plugins/messages/js/message-spam.php',
59 data:'msg_id='+msg_id,
60 success:function(data){
62 alert('Something went wrong!');
67 $('#row-'+msg_id).css('color', '#610B0B').fadeToggle(400);
73 function markAsTrash(msg_id)
76 url:'$prefix".
"system/plugins/messages/js/message-trash.php',
78 data:'msg_id='+msg_id,
79 success:function(data){
81 alert('Something went wrong!');
86 $('#row-'+msg_id).fadeToggle(400);
92 function closeMessage(msg_id)
95 url:'$prefix".
"system/plugins/messages/js/message-read.php',
97 data:'msg_id='+msg_id,
98 success:function(data){
100 alert('Something went wrong!');
105 $('#messagebox').fadeToggle(400);
106 window.location.href = 'index.php?plugin=messages&pluginpage=mailbox';
113 function restoreFromTrash(msg_id)
116 url:'$prefix".
"system/plugins/messages/js/message-restore-trash.php',
118 data:'msg_id='+msg_id,
119 success:function(data){
121 alert('Something went wrong!');
126 $('#row-'+msg_id).css('color', '#088A29').fadeToggle(400);
132 function markAsDeleted(msg_id)
135 url:'$prefix".
"system/plugins/messages/js/message-delete.php',
137 data:'msg_id='+msg_id,
138 success:function(data){
140 alert('Something went wrong!');
145 $('#row-'+msg_id).css('color', '#FF0000').fadeToggle(400);
151 function markAsRead(msg_id)
154 url:'$prefix".
"system/plugins/messages/js/message-read.php',
156 data:'msg_id='+msg_id,
157 success:function(data){
159 alert('Something went wrong!');
164 // $('#row-'+msg_id).toggleClass('bold', 'normal').fadeTo('fast', 0.8);
165 // $('#row-'+msg_id).toggleClass('normal', 'bold').fadeTo('fast', 1);
166 // $('#read-icon-'+msg_id).toggleClass('fa fa-envelope-o fa fa-envelope');
172 function messageToggle(msg_id)
175 url:'$prefix".
"system/plugins/messages/js/message-toggle.php',
177 data:'msg_id='+msg_id,
178 success:function(data){
180 alert('Something went wrong!');
185 $('#row-'+msg_id).toggleClass('bold', 'normal').fadeTo('fast', 0.8);
186 $('#row-'+msg_id).toggleClass('normal', 'bold').fadeTo('fast', 1);
187 $('#read-icon-'+msg_id).toggleClass('fa fa-envelope-o fa fa-envelope');
192 function refreshInbox(type)
195 url:'$prefix".
"system/plugins/messages/js/message-fetch.php',
198 success:function(data){
200 alert('Something went wrong!');
205 // alert('REFRESH! '+type);
206 // $('#row-'+id).fadeOut(420);
213 <style type='text/css'>
214 .bold { font-weight: bold; }
215 .normal { font-weight: normal; opacity: 0.6; }
228 if (!empty(@$_SESSION[
'username'] && (!empty(@$_SESSION[
'uid']))))
230 if (\
YAWK\user::isLoggedIn(
$db, $_SESSION[
'username']))
237 echo
"<h2>$lang[REGISTERED_ONLY]</h2>";
238 return \YAWK\user::drawLoginBox(
'',
'');
243 echo
"<h2>$lang[REGISTERED_ONLY]</h2>";
244 return \YAWK\user::drawLoginBox(
'',
'');
265 public function fetchMessages(
$db,
$type){
268 if (isset($_SESSION[
'username']) && isset($_SESSION[
'uid'])) {
270 $uid = $_SESSION[
'uid'];
274 $sql =
$db->query(
"SELECT * FROM {plugin_msg} AS msg
275 LEFT JOIN {users} AS u ON msg.fromUID=u.id
276 WHERE toUID = '".
$uid.
"' AND trash ='0' AND spam ='0'
277 ORDER BY msg_read,msg_date DESC");
279 elseif (
$type ===
"trash")
281 $sql =
$db->query(
"SELECT * FROM {plugin_msg} AS msg
282 LEFT JOIN {users} AS u ON msg.fromUID=u.id
283 WHERE toUID = '".
$uid.
"' AND trash ='1' AND spam ='0'
284 ORDER BY msg_read,msg_date DESC");
286 elseif (
$type ===
"spam")
288 $sql =
$db->query(
"SELECT * FROM {plugin_msg} AS msg
289 LEFT JOIN {users} AS u ON msg.fromUID=u.id
290 WHERE toUID = '".
$uid.
"' AND trash ='0' AND spam ='1'
291 ORDER BY msg_read,msg_date DESC");
295 while ($row = mysqli_fetch_assoc(
$sql)){
301 return "Something strange has happened. Are you logged in? Please re-login.";
311 public function fetchSingleMessage(
$db,
$msg_id)
313 $sql =
$db->query(
"SELECT * FROM {plugin_msg} WHERE msg_id = '".
$msg_id.
"'");
314 $row = mysqli_fetch_assoc(
$sql);
330 if (
$sql =
$db->query(
"SELECT * FROM {plugin_msg} AS msg
331 LEFT JOIN {users} AS u ON msg.fromUID=u.id
332 WHERE fromUID = '".$fromUID.
"' AND msg_id NOT LIKE '".
$msg_id.
"' AND toUID ='".
$toUID.
"' AND trash ='0' AND spam ='0'
333 ORDER BY msg_read,msg_date DESC"))
335 $relatedMessages = array();
336 while ($row = mysqli_fetch_assoc(
$sql))
338 $relatedMessages[] = $row;
341 return $relatedMessages;
345 return "Could not fetch more related messages from this user.";
355 public function drawRelatedMessages(
$db, $relatedMessages,
$lang)
359 if (isset($relatedMessages) && is_array($relatedMessages))
361 foreach ($relatedMessages as $relatedMessage)
365 $from = \YAWK\user::getUserNameFromID(
$db, $relatedMessage[
'fromUID']);
370 <div class=\"box box-primary\">
371 <div class=\"box-header with-border\">
372 <h3 class=\"box-title\">$picture $lang[MESSAGE] $lang[FROM] <b>$from</b> $timeAgo <small>($splitDate[month], $splitDate[day] $splitDate[year], $splitDate[time])</small> </h3>
373 <div class=\"box-tools pull-right\">
374 <span class=\"label label-primary\">$relatedMessage[msg_date]</span>
375 <button class=\"btn btn-box-tool\" data-widget=\"remove\" onclick=\"closeMessage('$relatedMessage[msg_id]')\" data-toggle=\"tooltip\" title=\"$lang[CLOSE]\"><i class=\"fa fa-times\"></i></button>
377 <div class=\"box-body\">
378 <h3>$relatedMessage[msg_body]</h3><hr>
395 $message = self::fetchSingleMessage(
$db,
$msg_id);
396 $from = \YAWK\user::getUserNameFromID(
$db, $message[
'fromUID']);
402 $html =
"<br><br><br>
404 <div class=\"col-md-8\"><div class=\"box box-primary\">
405 <div class=\"box-header with-border\">
406 <h3 class=\"box-title\">$picture $lang[MESSAGE] $lang[FROM] <b><a href=\"index.php?page=user-edit&user=$from\">$from</a></b> $timeAgo <small>($splitDate[month], $splitDate[day] $splitDate[year], $splitDate[time])</small> </h3>
407 <div class=\"box-tools pull-right\">
408 <span class=\"label label-primary\">$message[msg_date]</span>
409 <button class=\"btn btn-box-tool\" data-widget=\"remove\" onclick=\"closeMessage('$message[msg_id]')\" data-toggle=\"tooltip\" title=\"$lang[CLOSE]\"><i class=\"fa fa-times\"></i></button>
411 <div class=\"box-body\"><h3>$message[msg_body]</h3><hr></div></div></div></div>
412 <div class=\"col-md-4\" id=\"messagebox\">";
418 <div class=\"col-md-8\">";
419 $html .= self::drawRelatedMessages(
$db, self::fetchRelatedMessages(
$db, $message[
'fromUID'], $message[
'toUID'], $message[
'msg_id']),
$lang);
422 <div class=\"col-md-4\"> </div>
434 $html =
"<table class='table table-striped' id=\"table-sort\">
435 <tr style='font-weight:bold;' class='small'>
436 <td width='15%'>$lang[DATE]</td>
437 <td width='25%'>$lang[FROM] $lang[USER]</td>
438 <td width='50%'>$lang[MESSAGE] <small>($lang[PREVIEW])</small></td>
439 <td width='20%' style=\"text-align: center;\">$lang[ACTIONS]</td>
442 if (
$email[
'msg_read'] ===
'0') { $style =
"bold"; $envelope =
"fa fa-envelope"; }
443 if (
$email[
'msg_read'] ===
'1') { $style =
"normal"; $envelope =
"fa fa-envelope-o"; }
447 if (
$type ===
"spam")
449 $style =
"text-danger";
455 if (
$type ===
"trash")
466 $revert_icon =
"fa fa-undo";
467 $revert_action =
"restoreFromTrash('$email[msg_id]')";
468 $revert_title =
"$lang[RESTORE_MSG]";
470 $trash_icon =
"fa fa-trash";
471 $trash_action =
"markAsDeleted('$email[msg_id]')";
472 $trash_title =
"$lang[DEL_MSG]";
476 $revert_icon = $envelope;
477 $revert_action =
"messageToggle('$email[msg_id]')";
478 $revert_title =
"$lang[MARK_AS_READ]";
480 $trash_icon =
"fa fa-trash-o";
481 $trash_action =
"markAsTrash('$email[msg_id]')";
482 $trash_title =
"$lang[MOVE_TO_TRASH]";
490 $spam_icon =
"fa fa-user-secret";
491 $spam_action =
"markAsSpam('$email[msg_id]')";
492 $spam_title =
"$lang[MARK_AS_SPAM]";
494 $msg_preview = substr(
$email[
'msg_body'],0 -64);
496 <tr id=\"row-$email[msg_id]\" class=\"$style\">
497 <td>$email[msg_date]</td>
498 <td><a href=\"index.php?plugin=messages&pluginpage=mailbox&msg_id=$email[msg_id]\"><div style=\"width:100%\">$email[username]</div></a></td>
499 <td><a href=\"index.php?plugin=messages&pluginpage=mailbox&msg_id=$email[msg_id]\"><div style=\"width:100%\">$msg_preview <small>[...]</small></div></a></td>
500 <td style=\"text-align:center\">
501 <i id=\"read-icon-$email[msg_id]\" class=\"$revert_icon\" onclick=\"$revert_action\" title=\"$revert_title\"></i>
502 <i class=\"$trash_icon\" onclick=\"$trash_action\" title=\"$trash_title\"></i>
503 <i class=\"$spam_icon\" onclick=\"$spam_action\" title=\"$spam_title\"></i> </td>
517 if (isset(
$_GET[
'active']) && (!empty(
$_GET[
'active'])))
519 switch (
$_GET[
'active'])
522 $active_inbox =
"class=\"active\"";
523 $active_inbox_tab_pane =
'class="tab-pane active"';
524 $active_compose =
'';
525 $active_compose_tab_pane =
'tab-pane';
530 $active_inbox_tab_pane =
'class="tab-pane"';
531 $active_compose =
"class=\"active\"";
532 $active_compose_tab_pane =
"class='tab-pane active'";
537 $active_inbox =
"class=\"active\"";
538 $active_inbox_tab_pane =
'class="tab-pane active"';
539 $active_compose =
'';
540 $active_compose_tab_pane =
"class='tab-pane'";
544 <ul class=\"nav nav-tabs\" role=\"tablist\">
545 <li role=\"presentation\" $active_inbox onclick=\"refreshInbox('all')\"><a href=\"#inbox\" aria-controls=\"home\" role=\"tab\" data-toggle=\"tab\">
546 <i class=\"fa fa-envelope-o\"></i> $lang[INBOX]</a></li>
548 <li role=\"presentation\" $active_compose><a href=\"#newmessage\" aria-controls=\"newmessage\" role=\"tab\" data-toggle=\"tab\">
549 <i class=\"fa fa-plus-square-o\"></i> $lang[MESSAGE]</a></li>
551 <li role=\"presentation\"><a href=\"#trash\" aria-controls=\"messages\" role=\"tab\" data-toggle=\"tab\">
552 <i class=\"fa fa-trash-o\"></i> $lang[RECYCLE_BIN]</a></li>
554 <li role=\"presentation\"><a href=\"#spam\" aria-controls=\"messages\" role=\"tab\" data-toggle=\"tab\">
555 <i class=\"fa fa-user-secret\"></i> $lang[SPAM]</a></li>
559 <div class=\"tab-content\">
562 <div role=\"tabpanel\" $active_inbox_tab_pane id=\"inbox\">
563 <h4><i class=\"fa fa-envelope-o fa-2x\"></i> $lang[INBOX]</h4>";
570 <div role=\"tabpanel\" $active_compose_tab_pane id=\"newmessage\">
571 <h4><i class=\"fa fa-envelope fa-2x\"></i> $lang[MSG_COMPOSE]</h4>";
576 <div role=\"tabpanel\" class=\"tab-pane\" id=\"trash\">
577 <h4><i class=\"fa fa-trash fa-2x\"></i> $lang[RECYCLE_BIN_HEADING]</h4>";
582 <div role=\"tabpanel\" class=\"tab-pane\" id=\"spam\">
583 <h4><i class=\"fa fa-user-secret fa-2x\"></i> $lang[SPAM_HEADING]</h4>";
598 $key =
"U3E44ERG0H0M3";
599 if (isset(
$_GET[
'to']) && (!empty(
$_GET[
'to'])))
603 if (isset($to) && (!empty($to)))
605 $replyLabel =
"$lang[REPLY_TO]";
610 $replyLabel =
"$lang[RECIPIENT_USERNAME]";
614 <fieldset id=\"comment_thread\" class=\"animated zoomInDown\">
615 <label for=\"msg_to\">$replyLabel</label> <input id=\"msg_to\" type=\"text\" $msg_to class=\"form-control\" name=\"msg_to\" size=\"16\" placeholder=\"to:\" maxlength=\"64\">
616 <label for=\"msg_body\">$lang[YOUR_MSG]</label> <textarea id=\"msg_body\" name=\"msg_body\" class=\"form-control\" cols=\"68\" rows=\"12\"></textarea><br>
617 <input type=\"button\" class=\"btn btn-success\" id=\"submit_post\" name=\"save_comment\" title=\"$lang[SEND]\" value=\"$lang[MSG_SEND_BTN]\">
618 <input type=\"hidden\" name=\"msg_from\" value=\"$_SESSION[username]\" id=\"msg_from\">
619 <input type=\"hidden\" name=\"fromUID\" value=\"$_SESSION[uid]\" id=\"fromUID\">
620 <input type=\"hidden\" name=\"token\" value=\"".$key.
"\" id=\"token\">
633 if (
$db->query(
"UPDATE {plugin_msg} SET msg_read = '1' WHERE msg_id = '".$msg_id.
"'"))
print $lang['FILEMAN_UPLOAD']
The Messages Plugin Class. Allow your users to write messages to each other.
drawMenu($db, $lang)
draw html (output) messages menu
MessageView($db, $msg_id, $lang)
view messages
__construct($db, $location)
messages constructor - check if class is called from frontend or backend
drawNewMessage($to, $lang)
draw a new message
getInbox($db, $lang)
get inbox and draw menu
drawInbox($type, $messages, $lang)
draw the complete Inbox
static getSetting($db, $property)
Get and return value for property from settings database.
static time_ago($userdate, $lang)
how many time is been gone since given date
static splitDateShort($date)
split a date to month, day, year and time this is the same as splitDate() but keep the months short
static getHost($db)
get hostname (url where yawk is installed) from database
static getUserImage($location, $user, $cssClass, $w, $h)
return and output user image
This class serves methods to create backup from files.