The Messages Plugin Class. Allow your users to write messages to each other.
More...
The Messages Plugin Class. Allow your users to write messages to each other.
Messages Plugin
Basic Messaging functions. This class serve functions fetch and draw messages, inbox and so on
Basic Features:
-
fetch all messages
-
fetch a single message
-
get Inbox Data
-
draw Inbox
-
mark messages as spam, read, unread
-
trash messages and many more
This plugin is definitly still in development.
- Author
- Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
- Copyright
- 2009-2016 Daniel Retzl
- Version
- 1.0.0/
Definition at line 21 of file messages.php.
◆ __construct()
YAWK\PLUGINS\MESSAGES\messages::__construct |
( |
|
$db, |
|
|
|
$location |
|
) |
| |
messages constructor - check if class is called from frontend or backend
- Parameters
-
object | $db | database |
string | $location | frontend or backend |
Definition at line 27 of file messages.php.
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; }
static getSetting($db, $property)
Get and return value for property from settings database.
static getHost($db)
get hostname (url where yawk is installed) from database
References $db, $host, $prefix, YAWK\sys\getHost(), and YAWK\settings\getSetting().
◆ drawInbox()
YAWK\PLUGINS\MESSAGES\messages::drawInbox |
( |
|
$type, |
|
|
|
$messages, |
|
|
|
$lang |
|
) |
| |
draw the complete Inbox
- Parameters
-
string | $type | spam, trash or all |
array | $messages | messages array |
- Returns
- string
Definition at line 433 of file messages.php.
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>
References $email, $messages, and $type.
Referenced by YAWK\PLUGINS\MESSAGES\messages\drawMenu().
◆ drawMenu()
YAWK\PLUGINS\MESSAGES\messages::drawMenu |
( |
|
$db, |
|
|
|
$lang |
|
) |
| |
draw html (output) messages menu
- Parameters
-
- Returns
- string
Definition at line 515 of file messages.php.
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>";
print $lang['FILEMAN_UPLOAD']
drawNewMessage($to, $lang)
draw a new message
drawInbox($type, $messages, $lang)
draw the complete Inbox
References $_GET, $db, $lang, YAWK\PLUGINS\MESSAGES\messages\drawInbox(), and YAWK\PLUGINS\MESSAGES\messages\drawNewMessage().
Referenced by YAWK\PLUGINS\MESSAGES\messages\getInbox().
◆ drawNewMessage()
YAWK\PLUGINS\MESSAGES\messages::drawNewMessage |
( |
|
$to, |
|
|
|
$lang |
|
) |
| |
draw a new message
- Parameters
-
string | $to | username to send |
- Returns
- string message fieldset
Definition at line 597 of file messages.php.
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\">
References $_GET, and $msg_to.
Referenced by YAWK\PLUGINS\MESSAGES\messages\drawMenu(), and YAWK\PLUGINS\MESSAGES\messages\MessageView().
◆ getInbox()
YAWK\PLUGINS\MESSAGES\messages::getInbox |
( |
|
$db, |
|
|
|
$lang |
|
) |
| |
◆ MessageView()
YAWK\PLUGINS\MESSAGES\messages::MessageView |
( |
|
$db, |
|
|
|
$msg_id, |
|
|
|
$lang |
|
) |
| |
view messages
- Parameters
-
object | $db | database |
int | $msg_id | message ID |
- Returns
- string
Definition at line 393 of file messages.php.
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>
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 getUserImage($location, $user, $cssClass, $w, $h)
return and output user image
References $db, $lang, $msg_id, YAWK\PLUGINS\MESSAGES\messages\drawNewMessage(), YAWK\user\getUserImage(), YAWK\sys\splitDateShort(), and YAWK\sys\time_ago().
The documentation for this class was generated from the following file:
- /var/www/htdocs/yawk.io/system/plugins/messages/classes/messages.php