2006-07-01 20:03:48 +00:00
< ? php
require_once ( " ../inc/util.inc " );
2006-11-04 19:21:05 +00:00
require_once ( " ../inc/email.inc " );
2006-07-01 20:03:48 +00:00
require_once ( " ../project/project.inc " );
// Determine if phpmailer is installed and to be used (defined in project.inc)
if ( isset ( $USE_PHPMAILER )) {
if ( $USE_PHPMAILER ) {
require_once ( " ../inc/phpmailer/class.phpmailer.php " );
}
} else {
$USE_PHPMAILER = false ;
}
if ( FORUM_MODERATION_EMAIL ) {
}
/**
* Send mail using the new User object style
**/
function re_send_email ( $user , $subject , $body ) {
global $USE_PHPMAILER ;
global $PHPMAILER_HOST ;
global $PHPMAILER_MAILER ;
if ( $USE_PHPMAILER ) {
$mail = new PHPMailer ();
$mail -> AddAddress ( $user -> getEmail (), $user -> getName ());
$mail -> Subject = $subject ;
$mail -> Body = $body ;
$mail -> From = EMAIL_FROM ;
$mail -> FromName = EMAIL_FROM ;
$mail -> Host = $PHPMAILER_HOST ;
$mail -> Mailer = $PHPMAILER_MAILER ;
return $mail -> Send ();
} else {
if ( defined ( 'EMAIL_FROM' )) {
$headers = " From: " . EMAIL_FROM ;
} else {
$headers = " " ;
}
return mail ( $user -> getEmail (), $subject , $body , $headers );
}
}
/**
* If a post is hidden , this function emails the author
* to let them know what happened .
**/
2007-01-01 21:18:49 +00:00
function send_moderation_email ( $post , $message , $action ) {
$moderator = re_get_logged_in_user ();
2006-07-01 20:03:48 +00:00
$body = " " ;
$thread = $post -> getThread ();
2006-08-09 19:12:54 +00:00
$user = $post -> getOwner ();
2007-01-01 21:18:49 +00:00
$subject = PROJECT . " forum " . $action . " notice " ;
2006-07-01 20:03:48 +00:00
$body = PROJECT . " notification:
2007-02-07 21:24:34 +00:00
$ownerid = $user -> getID ();
2006-07-01 20:03:48 +00:00
2006-08-09 19:12:54 +00:00
This email is to inform you that one of your posts in the forum has been affected by moderation in " .PROJECT. " :
2007-01-01 21:18:49 +00:00
Thread : " . $thread->getTitle (). "
2007-02-07 21:24:34 +00:00
Post : " . $post->getID (). " by " . $user->getID (). " ( " . $user->getName (). " )
2007-01-23 20:48:05 +00:00
Link : " .URL_BASE. " forum_thread . php ? id = " . $thread->getID (). "
2007-01-01 21:18:49 +00:00
Moderator : " . $moderator->getName (). " ( " . $moderator->getID (). " )
Action : " . $action . "
2006-07-01 20:03:48 +00:00
The moderator gave this explanation to why your post was moderated :
" . $message ;
$body .= "
2006-08-09 19:12:54 +00:00
This was the content of your post :
2006-07-01 20:03:48 +00:00
" . $post->getContent (). "
2006-08-09 19:12:54 +00:00
For further information and assistance with " .PROJECT. " go to " .MASTER_URL;
2007-01-01 21:18:49 +00:00
$emails = explode ( " | " , POST_REPORT_EMAILS );
$success = true ;
foreach ( $emails as $email ) {
$admin -> email_addr = $email ;
if ( ! send_email ( $admin , " POST " . $action . " REPORT: " . $thread -> getTitle (), $body )) {
$success = false ;
}
}
2006-08-09 19:12:54 +00:00
return re_send_email ( $user , $subject , $body );
2006-07-01 20:03:48 +00:00
}
/**
* If an entire thread is hidden , this function emails the owner
* to let them know what happened .
*/
2007-01-01 21:18:49 +00:00
function send_thread_moderation_email ( $thread , $message , $action ) {
$moderator = re_get_logged_in_user ();
2006-07-01 20:03:48 +00:00
$user = $thread -> getOwner ();
$body = " " ;
2006-08-09 19:12:54 +00:00
$subject = PROJECT . " forum moderation notice " ;
2006-07-01 20:03:48 +00:00
$body = PROJECT . " notification:
This email is sent to inform you that one of your threads in the forum has been affected by moderation in " .PROJECT. " :
Thread : " . $thread->getTitle (). "
2007-01-23 20:48:05 +00:00
Link : " .MASTER_URL. " forum_thread . php ? id = " . $thread->getID (). "
2007-01-01 21:18:49 +00:00
Moderator : " . $moderator->getName (). " ( " . $moderator->getID (). " )
Action : " . $action . "
2006-07-01 20:03:48 +00:00
The moderator gave this explanation to why your thread was moderated :
" . $message ;
$body .= "
2006-08-09 19:12:54 +00:00
For further information and assistance with " .PROJECT. " go to " .MASTER_URL;
2007-01-01 21:18:49 +00:00
$emails = explode ( " | " , POST_REPORT_EMAILS );
foreach ( $emails as $email ) {
$admin -> email_addr = $email ;
if ( ! send_email ( $admin , " THREAD " . $action . " REPORT: " . $thread -> getTitle (), $body )) {
$success = false ;
}
}
2006-07-01 20:03:48 +00:00
return re_send_email ( $user , $subject , $body );
}
/**
* If a user is subscribed to a thread that is replied to , this
* function sends them an email notifying them of the reply .
**/
function send_reply_notification_email ( $thread , $user ){
$title = PROJECT . " : A user has posted to ' " . stripslashes ( $thread -> getTitle ()) . " ' " ;
$link = URL_BASE . " forum_thread.php?id= " . $thread -> getID ();
$body = " Another " . PROJECT . " user has posted to the thread \" " . stripslashes ( $thread -> getTitle ()) . " \" . \n "
. " To view the updated thread, visit the following URL: \n \n $link " ;
return re_send_email ( $user , $title , $body );
}
/**
* When a user clicks the red " x " to notify moderators about a post ,
* this function generates the email to let the moderators know about
* it .
**/
function send_report_post_email ( $user , $thread , $post , $message ) {
$body = " " ;
2007-02-07 21:24:34 +00:00
$owner = $post -> getOwner ();
2006-07-01 20:03:48 +00:00
$subject = PROJECT . " post in ' " . $thread -> getTitle () . " ' reported as offensive " ;
$body = PROJECT . " notification:
This email is sent to inform you that one of the posts in the forum was reported as offensive in " .PROJECT. " :
Thread : " . $thread->getTitle (). "
2007-02-07 21:24:34 +00:00
Post : " . $post->getID (). " by " . $owner->getID (). " ( " . $owner->getName (). " )
2007-01-01 21:18:49 +00:00
Reporting User : " . $user->getID (). " ( " . $user->getName (). " )
2007-01-23 20:48:05 +00:00
Link : " .URL_BASE. " forum_thread . php ? id = " . $thread->getID (). " #".$post->getID()."
2006-07-01 20:03:48 +00:00
The reporting user gave this explanation to why the post was reported :
" . $message . "
This was the contents of the post :
" . $post->getContent (). "
2006-08-09 19:12:54 +00:00
For further information and assistance with " .PROJECT. " go to " .MASTER_URL;
2006-11-04 19:21:05 +00:00
2006-07-01 20:03:48 +00:00
//Security check, do we have an admin?
2006-11-04 19:21:05 +00:00
if ( ! defined ( " POST_REPORT_EMAILS " )) error_page ( " This project has not yet defined an administrator to handle this kind of forum reports. Please contact the project and tell them to add this information in their html/project/project.inc file " );
$emails = explode ( " | " , POST_REPORT_EMAILS );
$success = true ;
foreach ( $emails as $email ) {
$admin -> email_addr = $email ;
if ( ! send_email ( $admin , $subject , $body )) {
$success = false ;
}
}
return success ;
2006-07-01 20:03:48 +00:00
}
2007-03-24 14:57:30 +00:00
function send_banish_email ( $user , $duration , $reason ) {
2006-08-08 20:32:37 +00:00
$subject = PROJECT . " posting privileges suspended " ;
$body = "
This email is to inform you that you will not be able to
2007-03-24 14:57:30 +00:00
post to the " .PROJECT. " message boards until " .date('M j, Y G:i', $duration ). " ,
2006-08-08 20:32:37 +00:00
because your postings have not followed our guidelines .
" ;
2007-03-24 14:57:30 +00:00
if ( $reason ) {
$body .= " \n \n The moderator gave the following explanation about your suspension: \n " ;
$body .= $reason ;
}
2007-01-01 21:18:49 +00:00
$emails = explode ( " | " , POST_REPORT_EMAILS );
$success = true ;
foreach ( $emails as $email ) {
$admin -> email_addr = $email ;
if ( ! send_email ( $admin , $user -> getName () . " has been banished. " , $body )) {
$success = false ;
}
}
2006-08-08 21:29:59 +00:00
return re_send_email ( $user , $subject , $body );
2006-08-08 20:32:37 +00:00
}
2006-07-01 20:03:48 +00:00
?>