------------------------------------------------
This MOD originaly was created by Cr@zy Sash, but after I tryed to troubleshooting it, I got an idea how to make it more advanced and using only one entry in the database for each message instead of doublicating for each folder.
Still
51% of credit goes to
Cr@zy Sash ------------------------------------------------
-----------|
Overview |-----------------------
With this MOD
members will be able send private messages to other members.
Each member has 3 folders:
-
Inbox-
Sentbox-
OutboxQ: Whats the difference betwen
Sentbox and
Outbox?
A: In
Sentbox stores messages that have been received (the recipient read them). In
Outbox stores messages that have not been received (the recipient has not read them yet).
Advantage of having
Outbox is that u can edit messages from that folder (only).
---- Updated 5-03-2003 2pm (EST) ----
Now also, members can set to receive email notify or open popup window when received new message.
-----------|
Changed Files |--------------------
/member.php
/details.php
/includes/constants.php
/includes/page_header.php
/lang/<yourlanguage>/main.php
<templates of your chose>---- Updated 5-03-2003 2pm (EST) ----/includes/db_field_definitions.php
/templates/<yourtemplate>/member_editprofile.html
/templates/<yourtemplate>/header.html-----------|
New file |---------------------------
pms.php-----------|
New templates |--------------------
pms.html
pms_folder.html
pms_view.html
pms_new.html
pms_delete.html
pms_perpage_dropdown_form.html---- new added 5-03-2003 2pm (EST) ----pms_notify.html-----------|
New images |----------------------
asc_order.png
desc_order.png-----------|
Installation |-----------------------
Step 1. Updated 5-03-2003 2pm (EST)Download "
PMS" package.
Extract files acording this:
/pms.php
/pms_install.php
/templates/<yourtemplate>/pms.html
/templates/<yourtemplate>/pms_delete.html
/templates/<yourtemplate>/pms_folder.html
/templates/<yourtemplate>/pms_new.html
/templates/<yourtemplate>/pms_view.html
/templates/<yourtemplate>/pms_perpage_dropdown_form.html
/templates/<yourtemplate>/images/asc_order.png
/templates/<yourtemplate>/images/desc_order.png---- new added 5-03-2003 2pm (EST) ----/lang/<yourlanguage>/email/notify.htmlStep 2.Open
/includes/constants.phpAt the end of the file, just before closing
?> add this:
//PMS
define('PMS_TABLE', $table_prefix.'pms');
define('PMS_RDLT', 0); //Recipient deleted message (message only in: Sender's Setbox)
define('PMS_SDLT', 1); //Sender deleted message (message only in: Recipient's Inbox)
define('PMS_SENT', 2); //Recipient read message (message in: Sender's Sentbox and Recipient's Inbox)
define('PMS_UNREAD', 3); //Recipient not read message (message in: Sender's Outbox and Recipient's Inbox - New Message)
Step 3. Updated 5-03-2003 2pm (EST)Open
/lang/<yourlanguage>/main.phpAt the end of the file, just before closing
?> add this:
//--- PMS ----
$lang['pms_inbox'] = "Inbox";
$lang['pms_outbox'] = "Outbox";
$lang['pms_sentbox'] = "Sentbox";
$lang['pms_link'] = " You have<br />» <b>{msg_new_count}</b> new message(s)<br /> in your <b>{inbox}</b>.";
$lang['pms'] = "Private Messaging";
$lang['pms_short'] = "PMS";
$lang['pms_error'] = "Error";
$lang['pms_error_to'] = "You must select a recipient.";
$lang['pms_error_subject'] = "You must enter a subject.";
$lang['pms_error_message'] = "You must enter a message.";
$lang['pms_error_folder'] = "No folder selected.";
$lang['pms_error_id'] = "Nothing to show.";
$lang['pms_error_delete'] = "Nothing to delete.";
$lang['pms_compose'] = "Compose";
$lang['pms_delete'] = "Delete";
$lang['pms_delete_selected'] = "Delete selected";
$lang['pms_delete_all'] = "Delete all";
$lang['pms_delete_success'] = "The messages where deleted successfuly";
$lang['pms_delete_confirm'] = "Are you sure you want to delete that message from <b>".$lang['pms_'.$mode]."</b>?";
$lang['pms_delete_confirm_select'] = "Are you sure you want to delete selected messages from <b>".$lang['pms_'.$mode]."</b>?";
$lang['pms_delete_confirm_all'] = "Are you sure you want to delete ALL messages from <b>".$lang['pms_'.$mode]."</b>?";
$lang['pms_new'] = "New message";
$lang['pms_select_user'] = "Select a user";
$lang['pms_sent_success'] = "The message was send successfully";
$lang['pms_redirect'] = "Please wait a moment";
$lang['pms_empty'] = "No messages in this folder";
$lang['pms_reply'] = "Reply";
$lang['pms_view'] = "View message";
$lang['pms_mark'] = "Mark";
$lang['pms_edit'] = "Edit";
$lang['pms_subject'] = "Subject";
$lang['pms_message'] = "Message";
$lang['pms_to'] = "Recipient";
$lang['pms_date'] = "Date";
$lang['pms_send'] = "Send";
$lang['pms_preview'] = "Preview";
$lang['pms_status'] = "Status";
$lang['pms_from'] = "Sender";
$lang['pms_html'] = "Anable HTML in this message";
$lang['pms_bbcode'] = "Anable BBCode in this message";
$lang['pms_perpage'] = "Messages per page";
$lang['pms_user_pm'] = "PM";
$lang['pms_user_pm_alt'] = "PM to this user";
$lang['pms_total'] = "Total messages";
$lang['pms_received'] = "Received";
$lang['pms_quote'] = "Quote";
$lang['pms_error_save'] = "Error saving message. (the message could has been received)";
$lang['pms_error_notfound'] = "Can't find message.";
$lang['pms_paging_stats'] = "You have {total_cat_images} message(s) {new} on {total_pages} page(s) in your {box}.<br />Displayed: massage {first_page} to {last_page}.";
$lang['pms_email'] = "Notify by email on new Private Message";
$lang['pms_popup'] = "Pop up window on new Private Message";
$lang['pms_popup_confirm'] = "You have a new private message. Click OK to view it, or cancel to hide this prompt.";
$lang['pms_popup_newwindow'] = "Open in new window?\\n\\n(Press cancel to open your Inbox in the current window.)";
$lang['pms_email_new'] = "New private message";
Step 4.In your browser start
pms_install.php* in address bar type something like this:
http://YOURSITE/4images/pms_install.phpFinish the installation.
After this step the
main installation is complete.
U can check it by going to:
http://YOURSITE/4images/pms.phpStep 5. Updated 5-03-2003 2pm (EST)Open
/includes/page_header.phpFind:
$site_template->register_vars(array(
"media_url" => MEDIA_PATH,
Replace with:
//-----------------------------------------------------
//--- PMS ---------------------------------------------
//-----------------------------------------------------
$sql = "SELECT COUNT(pms_id) AS total
FROM ".PMS_TABLE."
WHERE pms_to = ".$user_info['user_id']." AND (pms_type = ".PMS_SENT." OR pms_type = ".PMS_SDLT." OR pms_type = ".PMS_UNREAD.")";
$result = $site_db->query_firstrow($sql);
$pms_inbox = $result['total'];
$sql = "SELECT COUNT(pms_id) AS total
FROM ".PMS_TABLE."
WHERE pms_from = ".$user_info['user_id']." AND pms_type = ".PMS_UNREAD;
$result = $site_db->query_firstrow($sql);
$pms_outbox = $result['total'];
$sql = "SELECT COUNT(pms_id) AS total
FROM ".PMS_TABLE."
WHERE pms_from = ".$user_info['user_id']." AND (pms_type = ".PMS_SENT." OR pms_type = ".PMS_RDLT.")";
$result = $site_db->query_firstrow($sql);
$pms_sentbox = $result['total'];
$sql = "SELECT COUNT(pms_id) AS new
FROM ".PMS_TABLE."
WHERE pms_to = ".$user_info['user_id']." AND pms_type = ".PMS_UNREAD;
$result = $site_db->query_firstrow($sql);
$pms_new = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php")."\">".(($result['new']) ? "<blink>".$result['new']."</blink>" : 0)."</a>";
$pms = preg_replace("/".$site_template->start."msg_new_count".$site_template->end."/siU", $pms_new, $lang['pms_link']);
$pms = preg_replace("/".$site_template->start."inbox".$site_template->end."/siU", "<a href=\"".$site_sess->url(ROOT_PATH."pms.php")."\">".$lang['pms_inbox']."</a>", $pms);
// PMS Boxes
$blink = "<script language=\"JavaScript\">\n<!--\nvar flg=0;\nfunction blink(){\nvar myElement=document.getElementById('blnk');\nflg^=1;\nif(flg==1){\nmyElement.style.visibility='hidden';\n}\nelse{\nmyElement.style.visibility='visible';\n}\ntimerID = setTimeout( 'blink()' , 500 );\n}\n//-->\n</script>\n";
$show_inbox = ($result['new']) ? $blink."<span id=\"blnk\">".$lang['pms_inbox']."</span><script language=\"JavaScript\">blink();</script>" : $lang['pms_inbox'];
$inbox = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=inbox")."\" title=\"".$lang['pms_total']." (".$pms_inbox.")\">".$show_inbox."</a>";
$sentbox = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=sentbox")."\" title=\"".$lang['pms_total']." (".$pms_sentbox.")\">".$lang['pms_sentbox']."</a>";
$outbox = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=outbox")."\" title=\"".$lang['pms_total']." (".$pms_outbox.")\">".$lang['pms_outbox']."</a>";
$newpms = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=new")."\">".$lang['pms_new']."</a>";
$sql = "SELECT pms_date
FROM ".PMS_TABLE."
WHERE pms_to = ".$user_info['user_id']." AND pms_type = ".PMS_UNREAD."
ORDER BY pms_date DESC";
$result = $site_db->query_firstrow($sql);
$pms_popup_script = "";
$pms_popup_header = "";
if ($result && $user_info['user_pms_popup'] && !ereg("pms.php", $self_url)) {
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
$cookie_pmsnewpopup = isset($HTTP_COOKIE_VARS[$cookie_name.'pmsnewpopup']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'pmsnewpopup'])) : 0;
$pmsnewpopup = (isset($session_info['pmsnewpopup'])) ? $session_info['pmsnewpopup'] : $cookie_pmsnewpopup;
if ($pmsnewpopup < $result['pms_date']) {
$cookie_expire = time() + 60 * 60 * 24 * 90;
setcookie($cookie_name.'pmsnewpopup', serialize($result['pms_date']), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
$site_sess->set_session_var("pmsnewpopup", $result['pms_date']);
$pms_popup_script = "<script language=\"JavaScript\">
<!--
function confirm_newpm() {
input_box=confirm('".$lang['pms_popup_confirm']."');
if (input_box==true) { // Output when OK is clicked
second_box=confirm('".$lang['pms_popup_newwindow']."');
if (second_box==true) {
window.open('".$site_sess->url(ROOT_PATH."pms.php")."','pmnew','width=600,height=500,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,top=50,left=50');
} else {
window.location='".$site_sess->url(ROOT_PATH."pms.php")."';
}
} else {
// Output when Cancel is clicked
}
}
// -->
</script>";
$pms_popup_header = "onload=\"Javascript:confirm_newpm()\"";
}
}
$site_template->register_vars(array(
"pms_boxes" => ($user_info['user_level'] < USER) ? "" : $inbox." | ".$sentbox." | ".$outbox." | ".$newpms,
"pms_popup_script" => $pms_popup_script,
"pms_popup_header" => $pms_popup_header,
"media_url" => MEDIA_PATH,
Step 6.Edit templates where u want to show folders links.
Use those tags:
{pms_boxes} - this will show folders
{pms} - this will show "You have
2 new images in Inbox"
Step 7.Open
/member.phpFind:
$site_template->register_vars(array(
"user_id" => $user_row['user_id'],
"user_name" => (isset($user_row['user_name'])) ? htmlspecialchars($user_row['user_name']) : REPLACE_EMPTY,
Add after:
"lang_pm" => ($user_info['user_id'] != $user_row['user_id']) ? "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=reply&user_id=".$user_row['user_id'])."\" alt=\"".$lang['pms_user_pm_alt']."\">".$lang['pms_user_pm']."</a>" : "",
Step 8. Updated 05-21-03Open
/details.phpFind:
"comment_id" => $comment_row[$i]['comment_id'],
Add after:
"lang_pm" => ($user_info['user_id'] != $comment_row[$i]['user_id'] && $user_info['user_level'] >= USER && $comment_row[$i]['user_id'] >= USER) ? "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=reply&user_id=".$comment_row[$i]['user_id'])."\" alt=\"".$lang['pms_user_pm_alt']."\">".$lang['pms_user_pm']."</a>" : "",
Step 9.Open:
/templates/<yourtemplate>/member_profile.html/templates/<yourtemplate>/comment_bit.htmlUse this tag to show link to PM the user:
{lang_pm}Step 10. new added 05-03-2003 2pm (EST)Open
/includes/db_field_definitions.phpAt the end of the file, just before closing
?> add this:
$additional_user_fields['user_pms_email'] = array($lang['pms_email'], "radio", 0);
$additional_user_fields['user_pms_popup'] = array($lang['pms_popup'], "radio", 0);
Step 11. new added 05-03-2003 2pm (EST)Open
/templates/<yourtemplate>/member_editprofile.htmlAdd this:
<tr>
<td class="row2"><b>{lang_user_pms_email}</b></td>
<td class="row2">
<input type="radio" name="user_pms_email" value="1"{user_pms_email_yes} />
{lang_yes}
<input type="radio" name="user_pms_email" value="0"{user_pms_email_no} />
{lang_no}
</td>
</tr>
<tr>
<td class="row1"><b>{lang_user_pms_popup}</b></td>
<td class="row1">
<input type="radio" name="user_pms_popup" value="1"{user_pms_popup_yes} />
{lang_yes}
<input type="radio" name="user_pms_popup" value="0"{user_pms_popup_no} />
{lang_no}
</td>
</tr>
Step 12. new added 05-03-2003 2pm (EST)Open
/templates/<yourtemplate>/header.html1. in between
<head> and
</head> add this:
{pms_popup_script}2. inside
<body> tag add
{pms_popup_header}Should looks like this:
<body {pms_popup_header}-----------|
Note |-----------------------------
All templates where created for my site design, and just little bit adopted for default teplate. Because of that some colors ar missing - that's your work now
.
Also, I didnt remove one, might be useful, feature - different color for "success" messages and "warning/error".
If u wish use it, here what u need to do:
create two new classes in
style.css for examle:
.msg0 {
background-color: #FFCECE;
color: #2F6B9D;
}
.msg1 {
background-color: #CEFFDD;
color: #2F6B9D;
}
then use something like this in the
pms.html template:
class="msg{msg_color}"