From aeac868c119311888a531fb0040628ac2ec3d1bd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 1 Jul 2006 20:03:48 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=10559 --- checkin_notes | 22 +++ db/schema.sql | 27 ++- html/inc/email.inc | 195 +++------------------ html/inc/forum_email.inc | 141 +++++++++++++++ html/user/edit_forum_preferences_form.php | 1 + html/user/forum_moderate_post_action.php | 2 +- html/user/forum_moderate_thread_action.php | 2 +- html/user/forum_post.php | 2 +- html/user/forum_reply.php | 2 +- html/user/forum_report_post.php | 2 +- 10 files changed, 213 insertions(+), 183 deletions(-) create mode 100644 html/inc/forum_email.inc diff --git a/checkin_notes b/checkin_notes index 00bb4d6dca..f21ee9a593 100755 --- a/checkin_notes +++ b/checkin_notes @@ -7156,3 +7156,25 @@ Charlie 1 July 2006 (branch boinc_core_release_5_6) - Tag for 5.5.5 release, Macinitosh with sandbox only boinc_core_release_5_5_5 +David 1 July 2006 + - user web: moved forum-related email functions to a new file; + small bug fixes in forum moderation code + - changed db/schema.sql to match new forum code + - user web: html/project/project.inc must now have + define("FORUM_MODERATION_EMAIL_USER_ID", "N") + to specify who reports get sent to + (the ID of an existing account) + + db/ + schema.sql + html/ + inc/ + email.inc + forum_email.inc (new) + user/ + edit_forum_preferences_form.php + forum_moderate_post_action.php + forum_moderate_thread_action.php + forum_post.php + forum_reply.php + forum_report_post.php diff --git a/db/schema.sql b/db/schema.sql index e065f4b8f4..de89ce84ed 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -349,6 +349,7 @@ create table thread ( id integer not null auto_increment, forum integer not null, owner integer not null, + status integer not null, title varchar(254) not null, timestamp integer not null, -- time of last new or modified post @@ -361,6 +362,8 @@ create table thread ( -- (set periodically by update_forum_activity.php) sufferers integer not null, -- in help desk: # people who indicated they had same problem + score double not null, + votes integer not null, create_time integer not null, -- when this record was created hidden integer not null, @@ -395,7 +398,8 @@ create table post ( -- create table subscriptions ( userid integer not null, - threadid integer not null + threadid integer not null, + notified_time integer not null default 0 ) type=InnoDB; create table forum_preferences ( @@ -404,19 +408,21 @@ create table forum_preferences ( posts integer not null default 0, last_post integer not null, avatar varchar(254) not null default '', - avatar_type tinyint(4) not null default 0, hide_avatars tinyint(1) unsigned not null default 0, - sorting varchar(100) not null default '', - no_signature_by_default tinyint(1) unsigned not null default 0, + forum_sorting integer not null, + thread_sorting integer not null, + no_signature_by_default tinyint(1) unsigned not null default 1, images_as_links tinyint(1) unsigned not null default 0, link_popup tinyint(1) unsigned not null default 0, mark_as_read_timestamp integer not null default 0, special_user integer not null default 0, - jump_to_unread tinyint(1) unsigned not null default 0, + jump_to_unread tinyint(1) unsigned not null default 1, hide_signatures tinyint(1) unsigned not null default 0, rated_posts varchar(254) not null, - low_rating_threshold integer not null, - high_rating_threshold integer not null, + low_rating_threshold integer not null default -25, + high_rating_threshold integer not null default 5, + minimum_wrap_postcount INT DEFAULT 100 NOT NULL, + display_wrap_postcount INT DEFAULT 75 NOT NULL, ignorelist varchar(254) not null, ignore_sticky_posts tinyint(1) unsigned not null, primary key (userid) @@ -428,3 +434,10 @@ create table forum_logging ( timestamp integer not null default 0, primary key (userid,threadid) ) TYPE=MyISAM; + +create table post_ratings ( + post integer not null, + user integer not null, + rating tinyint not null, + primary key(post, user) +) TYPE=MyISAM; diff --git a/html/inc/email.inc b/html/inc/email.inc index 1b18947a13..ab18c86234 100644 --- a/html/inc/email.inc +++ b/html/inc/email.inc @@ -15,9 +15,8 @@ if (isset($USE_PHPMAILER)) { $USE_PHPMAILER = false; } -/** - * Function sends an email, either using PHPMailer or not. - **/ +// Function sends an email, either using PHPMailer or not. +// function send_email($user, $subject, $body) { global $USE_PHPMAILER; global $PHPMAILER_HOST; @@ -43,35 +42,6 @@ function send_email($user, $subject, $body) { } } -/** - * 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); - } -} - - function send_verify_email($old, $new, $user) { $x = md5($new.$user->authenticator); mail( @@ -84,35 +54,16 @@ To validate the new address, visit the URL: ); } -/** - * Send a link to a user that makes it possible for the user to validate the email address - * This function uses the new User object style - **/ -function send_verifier($user) { - $x = md5($user->getEmail().$user->getAuthenticator()); - re_send_email( - $user, - PROJECT." email verification", -"You have requested to validate the email address you have registered with " . PROJECT . -". -To validate the address, please visit the URL: -".URL_BASE."validate_email.php?u=".$user->getID()."&x=$x -" - ); -} - - -/** - * Send an email describing an account to the user. - * There are a few scenarios: - * - * 1) the account was created by user via web. - * In this case they're currently looking at the "validate account" page - * (account_created.php), although they might have strayed - * so we need to give them a link. - * 2) the account was created administratively - * 3) the user requested account key for existing account - **/ +// Send an email describing an account to the user. +// There are a few scenarios: +// +// 1) the account was created by user via web. +// In this case they're currently looking at the "validate account" page +// (account_created.php), although they might have strayed +// so we need to give them a link. +// 2) the account was created administratively +// 3) the user requested account key for existing account +// function send_auth_email($user, $is_new) { global $master_url; $body = ""; @@ -146,10 +97,9 @@ For further information and assistance with ".PROJECT." go to $master_url return send_email($user, $subject, $body); } -/** - * Function simply outputs some text letting the user know - * their authenticator was emailed to them. - **/ +// Function simply outputs some text letting the user know +// their authenticator was emailed to them. +// function email_sent_message($email_addr) { if (defined('EMAIL_FROM')) { $email_from = EMAIL_FROM; @@ -167,12 +117,12 @@ function email_sent_message($email_addr) { "; } -/** a valid email address is of the form A@B.C - * where A, B, C are nonempty, - * A and B don't contain @ or ., - * and C doesn't contain @ (but can contain .) - **/ - // TODO: Replace this with some regex. Please. +// a valid email address is of the form A@B.C +// where A, B, C are nonempty, +// A and B don't contain @ or ., +// and C doesn't contain @ (but can contain .) +// TODO: Replace this with some regex. Please. +// function is_valid_email_addr($addr) { $x = strstr($addr, "@"); if (!$x) return false; @@ -187,74 +137,9 @@ function is_valid_email_addr($addr) { } -/** - * If a post is hidden, this function emails the author - * to let them know what happened. - **/ -function send_moderation_email($post, $message) { - global $master_url; - $body = ""; - $thread = $post->getThread(); - $subject = PROJECT." forum moderation notice for $user->name"; - $body = PROJECT." notification: - -This email is sent to inform you that one of your posts in the forum has been affected by moderation in ".PROJECT.": - Thread: ".$thread->getTitle()." - Link: ".$master_url."/forum_thread.php?id=".$thread->getID()." - -The moderator gave this explanation to why your post was moderated: -".$message; -$body .= " - -This was the contents of your post: -".$post->getContent()." - -For further information and assistance with ".PROJECT." go to ".$master_url; - return send_email($post->getOwner(), $subject, $body); - -} - -/** - * If an entire thread is hidden, this function emails the owner - * to let them know what happened. - */ -function send_thread_moderation_email($thread, $message) { - global $master_url; - $user = $thread->getOwner(); - $body = ""; - - $subject = PROJECT." forum moderation notice for $user->name"; - $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()." - Link: ".$master_url."/forum_thread.php?id=".$thread->getID()." - -The moderator gave this explanation to why your thread was moderated: -".$message; -$body .= " - -For further information and assistance with ".PROJECT." go to ".$master_url; - return 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); -} - -/** - * If a user's host is identified as causing problems, this email is sent - * to the owner to let them know. - **/ +// If a user's host is identified as causing problems, this email is sent +// to the owner to let them know. +// function send_problem_email($user, $host) { global $master_url; $body = ""; @@ -330,36 +215,4 @@ For further information and assistance with ".PROJECT." go to $master_url"; } -/** - * 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) { - global $master_url; - global $forum_post_reporting_admin; - - $body = ""; - - $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()." - Post: ".$post->getID()." - Link: $master_url/forum_thread.php?id=".$thread->getID()."#".$post->getID()." - -The reporting user gave this explanation to why the post was reported: -".$message." - -This was the contents of the post: -".$post->getContent()." - -For further information and assistance with ".PROJECT." go to $master_url"; - //Security check, do we have an admin? - if (!$forum_post_reporting_admin) 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"); - return send_email($forum_post_reporting_admin, $subject, $body); -} - - ?> diff --git a/html/inc/forum_email.inc b/html/inc/forum_email.inc new file mode 100644 index 0000000000..0daa3f37bf --- /dev/null +++ b/html/inc/forum_email.inc @@ -0,0 +1,141 @@ +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. + **/ +function send_moderation_email($post, $message) { + global $master_url; + $body = ""; + $thread = $post->getThread(); + $subject = PROJECT." forum moderation notice for $user->name"; + $body = PROJECT." notification: + +This email is sent to inform you that one of your posts in the forum has been affected by moderation in ".PROJECT.": + Thread: ".$thread->getTitle()." + Link: ".$master_url."/forum_thread.php?id=".$thread->getID()." + +The moderator gave this explanation to why your post was moderated: +".$message; +$body .= " + +This was the contents of your post: +".$post->getContent()." + +For further information and assistance with ".PROJECT." go to ".$master_url; + return re_send_email($post->getOwner(), $subject, $body); + +} + +/** + * If an entire thread is hidden, this function emails the owner + * to let them know what happened. + */ +function send_thread_moderation_email($thread, $message) { + global $master_url; + $user = $thread->getOwner(); + $body = ""; + + $subject = PROJECT." forum moderation notice for $user->name"; + $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()." + Link: ".$master_url."/forum_thread.php?id=".$thread->getID()." + +The moderator gave this explanation to why your thread was moderated: +".$message; +$body .= " + +For further information and assistance with ".PROJECT." go to ".$master_url; + 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) { + global $master_url; + $forum_post_reporting_admin = newUser(FORUM_MODERATION_EMAIL_USER_ID); + + $body = ""; + + $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()." + Post: ".$post->getID()." + Link: $master_url/forum_thread.php?id=".$thread->getID()."#".$post->getID()." + +The reporting user gave this explanation to why the post was reported: +".$message." + +This was the contents of the post: +".$post->getContent()." + +For further information and assistance with ".PROJECT." go to $master_url"; + //Security check, do we have an admin? + if (!$forum_post_reporting_admin) 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"); + return re_send_email($forum_post_reporting_admin, $subject, $body); +} + +?> diff --git a/html/user/edit_forum_preferences_form.php b/html/user/edit_forum_preferences_form.php index d87b693f04..9d4fcaea45 100644 --- a/html/user/edit_forum_preferences_form.php +++ b/html/user/edit_forum_preferences_form.php @@ -2,6 +2,7 @@ require_once("../inc/db.inc"); require_once("../inc/forum.inc"); +require_once("../inc/forum_std.inc"); require_once("../inc/util.inc"); db_init(); diff --git a/html/user/forum_moderate_post_action.php b/html/user/forum_moderate_post_action.php index 401cf6d49b..73156bb9a9 100644 --- a/html/user/forum_moderate_post_action.php +++ b/html/user/forum_moderate_post_action.php @@ -5,7 +5,7 @@ **/ require_once("../inc/forum.inc"); -require_once("../inc/email.inc"); +require_once("../inc/forum_email.inc"); require_once("../inc/forum_std.inc"); db_init(); diff --git a/html/user/forum_moderate_thread_action.php b/html/user/forum_moderate_thread_action.php index d9514731ca..8d2581e940 100644 --- a/html/user/forum_moderate_thread_action.php +++ b/html/user/forum_moderate_thread_action.php @@ -5,7 +5,7 @@ **/ require_once("../inc/forum.inc"); -require_once("../inc/email.inc"); +require_once("../inc/forum_email.inc"); require_once("../inc/forum_std.inc"); diff --git a/html/user/forum_post.php b/html/user/forum_post.php index 215a40201b..e7e6c25325 100644 --- a/html/user/forum_post.php +++ b/html/user/forum_post.php @@ -5,7 +5,7 @@ * it will apply the changes by calling methods on the forum **/ -require_once('../inc/email.inc'); +require_once('../inc/forum_email.inc'); require_once('../inc/forum.inc'); require_once('../inc/forum_std.inc'); diff --git a/html/user/forum_reply.php b/html/user/forum_reply.php index bb7a55cd1e..5d82f3974b 100644 --- a/html/user/forum_reply.php +++ b/html/user/forum_reply.php @@ -4,7 +4,7 @@ * action take place here. **/ -require_once('../inc/email.inc'); +require_once('../inc/forum_email.inc'); require_once('../inc/forum.inc'); require_once('../inc/forum_std.inc'); diff --git a/html/user/forum_report_post.php b/html/user/forum_report_post.php index 038a2a4e90..cb987a68c0 100644 --- a/html/user/forum_report_post.php +++ b/html/user/forum_report_post.php @@ -7,7 +7,7 @@ **/ require_once('../inc/forum.inc'); -require_once('../inc/email.inc'); +require_once('../inc/forum_email.inc'); require_once('../inc/forum_std.inc'); db_init();