Mod Name / Version - Email Post Replies 2.0
Description - This will allow a user to enable an option in their email preferences
and by default automatically receive all replies to their posts via email.
Version 2.0 updates to work with 6.4's new mail function.
Working Under - UBB.Threads 6.4
Pre-requisites - none
Author - JoshPet - www.joshuapettit.com
Credits - Commissioned by Smitdogg from www.mameworld.info
Files Altered - editemail.php, changeemail.php, editemail.tmpl, addpost.php
Database Altered - New field, U_EmailPostReply added to w3t_Users
New Files - none
Notes - will not email the user their own replies to their posts, only replies from
other users.
##
## Run this Query
##
ALTER TABLE w3t_Users
ADD U_EmailPostReply TINYINT( 1 ) DEFAULT '0' NOT NULL ;
##
## Open editemail.php
##
## Find this:
SELECT U_Username,U_EReplies,U_Notify,U_AdminEmails,U_EmailFormat
## Change to this:
SELECT U_Username,U_EReplies,U_Notify,U_AdminEmails,U_EmailFormat,U_EmailPostReply
## Find this:
list($CheckUser,$EReplies,$Notify,$adminemail,$emailformat) = $dbh -> fetch_array($sth);
## Change to this:
list($CheckUser,$EReplies,$Notify,$adminemail,$emailformat,$emailpostreply) = $dbh -> fetch_array($sth);
## Find this:
// ---------------------------------
// Set the default for Email replies
## Change to this:
// --------------------------------
// Set the default for Email post replies - by JoshPet
if ($emailpostreply) {
$emailpostreplyyes = "checked=\"checked\"";
$emailpostreplyno = "";
} else {
$emailpostreplyyes = "";
$emailpostreplyno = "checked=\"checked\"";
}
// ---------------------------------
// Set the default for Email replies
##
## Open changeemail.php
##
## Find this:
$emailformat = get_input("emailformat","post");
## Change to this:
$emailformat = get_input("emailformat","post");
$emailpostreply = get_input("emailpostreply","post");
## Find this:
$AdminEmails_q = addslashes($adminemails);
## Change to this:
$AdminEmails_q = addslashes($adminemails);
$emailpostreply_q = addslashes($emailpostreply);
## Find this:
U_EmailFormat = '$EmailFormat_q'
## Change to this:
U_EmailFormat = '$EmailFormat_q',
U_EmailPostReply = '$emailpostreply_q'
##
## Open editemail.tmpl
##
## Find this:
<br /><br />
{$ubbt_lang['PROF_REPLIES']}<br />
<input type="radio" name="EReplies" value="Off" $noereplies class="formboxes" />
{$ubbt_lang['TEXT_NO']}
<input type="radio" name="EReplies" value="On" $ereplies class="formboxes" />
{$ubbt_lang['TEXT_YES']}
## Change to this:
<br /><br />
Do you want replies to YOUR posts emailed to you?<br />
<input type="radio" name="emailpostreply" value="0" $emailpostreplyno class="formboxes" />
{$ubbt_lang['TEXT_NO']}
<input type="radio" name="emailpostreply" value="1" $emailpostreplyyes class="formboxes" />
{$ubbt_lang['TEXT_YES']}
<br /><br />
{$ubbt_lang['PROF_REPLIES']}<br />
<input type="radio" name="EReplies" value="Off" $noereplies class="formboxes" />
{$ubbt_lang['TEXT_NO']}
<input type="radio" name="EReplies" value="On" $ereplies class="formboxes" />
{$ubbt_lang['TEXT_YES']}
##
## Open addpost.php
##
## Find this:
// ---------------------------------------------
// Update the total post if the post is Approved
if ($Approved == "yes") {
## Change to this:
// ---------------------------------------------
// See if the original poster wanted replies to all of their posts - by JoshPet
if (($ParentUser != $user['U_Number']) && ($MainTopic != 1)) {
$query = "
SELECT U_Email,U_EmailFormat
FROM {$config['tbprefix']}Users
WHERE U_Number = $ParentUser
AND U_EmailPostReply = 1
";
$sth = $dbh -> do_query($query);
list($replyemail,$replyformat) = $dbh -> fetch_array($sth);
if ($replyemail) {
$EmailBody = $Body;
// If we are sending HTML email then we need the full path
// to images.
$newline = "\n";
if (stristr(PHP_OS,"win")) {
$newline = "\r\n";
}
if ($emailformat == "HTML") {
$EmailBody = str_replace("\"{$config['images']}","\"{$config['imageurl']}",$EmailBody);
$msg = "$postername replied to one of your posts:<br /><br /><a href=\"{$config['phpurl']}/showthreaded.php?Cat=$Cat&Number=$Mnumber\">{$config['phpurl']}/showthreaded.php?Cat=$Cat&Number=$Mnumber</a><br /><br />$EmailBody";
}
else {
$EmailBody = str_replace("<br />","\n",$EmailBody);
$msg = "$postername replied to one of your posts: $newline{$config['phpurl']}/showthreaded.php?Cat=$Cat&Number=$Mnumber$newline$newline $EmailBody";
}
$to = $replyemail;
$mailer = new mailer;
$subject = "Reply to Your Post: $Subject";
$mailer -> send_mail($emailformat,"",$to,$subject,$msg);
}
}
// ---------------------------------------------
// Update the total post if the post is Approved
if ($Approved == "yes") {