diff --git a/phpBB/db/mysql_schema.sql b/phpBB/db/mysql_schema.sql index f59e5200af..ec1cb6107b 100644 --- a/phpBB/db/mysql_schema.sql +++ b/phpBB/db/mysql_schema.sql @@ -423,6 +423,20 @@ CREATE TABLE phpbb_topics ( ); +# -------------------------------------------------------- +# +# Table structure for table 'phpbb_topics_watch' +# +DROP TABLE IF EXISTS phpbb_topics_watch; +CREATE TABLE phpbb_topics_watch ( + topic_id int(11), + user_id int(11), + notify_status tinyint(1) NOT NULL default '0', + PRIMARY KEY (topic_id), + KEY user_id (user_id) +); + + # -------------------------------------------------------- # # Table structure for table 'phpbb_users' diff --git a/phpBB/db/postgres_schema.sql b/phpBB/db/postgres_schema.sql index e9502a743a..486cc52ab0 100644 --- a/phpBB/db/postgres_schema.sql +++ b/phpBB/db/postgres_schema.sql @@ -418,6 +418,20 @@ CREATE INDEX _phpbb_topics_index ON phpbb_topics (forum_id, topic_id); CREATE INDEX forum_id_phpbb_topics_index ON phpbb_topics (forum_id); +/* -------------------------------------------------------- + Table structure for table phpbb_topics_watch +-------------------------------------------------------- */ +CREATE TABLE phpbb_topics_watch ( + topic_id int4, + user_id int4, + notify_status int2 NOT NULL default '0', + CONSTRAINT phpbb_topics_watch_pkey PRIMARY KEY (topic_id), + KEY user_id (user_id) +); +CREATE INDEX _phpbb_topics_watch_index ON phpbb_topics_watch (topic_id, user_id); +CREATE INDEX forum_id_phpbb_topics_index ON phpbb_topics (forum_id); + + /* -------------------------------------------------------- Table structure for table phpbb_user_group -------------------------------------------------------- */ diff --git a/phpBB/language/email/topic_notify_english.tpl b/phpBB/language/email/topic_notify_english.tpl new file mode 100644 index 0000000000..687a819565 --- /dev/null +++ b/phpBB/language/email/topic_notify_english.tpl @@ -0,0 +1,7 @@ +Hello {USERNAME}, + +You are receiving this email because you are watching the topic, "{TOPIC_TITLE}" at {SITENAME}. This topic has received a reply since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. + +{TOPIC_URL} + +{EMAIL_SIG} \ No newline at end of file diff --git a/phpBB/language/lang_english.php b/phpBB/language/lang_english.php index fd10c877a3..a5f2b813f8 100755 --- a/phpBB/language/lang_english.php +++ b/phpBB/language/lang_english.php @@ -233,6 +233,9 @@ $lang['Move_topic'] = "Move this topic"; $lang['Delete_topic'] = "Delete this topic"; $lang['Split_topic'] = "Split this topic"; +$lang['Stop_watching_topic'] = "Stop watching this topic"; +$lang['Start_watching_topic'] = "Watch this topic for replies"; + // // Posting/Replying (Not private messaging!) @@ -287,6 +290,8 @@ $lang['to_return_forum'] = "to return to the forum"; $lang['to_view_message'] = "to view your message"; $lang['to_return_topic'] = "to return to the topic"; +$lang['Topic_reply_notification'] = "Topic Reply Notification"; + // // Private Messaging // @@ -378,6 +383,9 @@ $lang['Always_smile'] = "Always enable Smilies"; $lang['Always_html'] = "Always allow HTML"; $lang['Always_bbcode'] = "Always allow BBCode"; $lang['Always_add_sig'] = "Always attach my signature"; +$lang['Always_notify'] = "Always notify me of replies"; +$lang['Always_notify_explain'] = "Sends an email when someone replies to a topic you have posted in. This can be changed whenever you post"; + $lang['Board_template'] = "Board Template"; $lang['Board_theme'] = "Board Theme"; $lang['Board_lang'] = "Board Language"; @@ -785,7 +793,6 @@ $lang['User_admin_explain'] = "Here you can change your user's information. Do n $lang['User_delete'] = "Delete this user"; $lang['User_delete_explain'] = "Click here to delete this user. This cannot be undone."; $lang['User_deleted'] = "User was successfully deleted."; - // // End // ------------------------------------------------- diff --git a/phpBB/posting.php b/phpBB/posting.php index 2eaa178f8f..1749196fb5 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -97,7 +97,7 @@ else $attach_sig = ( isset($HTTP_POST_VARS['submit']) || isset($HTTP_POST_VARS['preview']) ) ? ( ( !empty($HTTP_POST_VARS['attach_sig']) ) ? TRUE : 0 ) : $userdata['user_attachsig']; -$notify = ( isset($HTTP_POST_VARS['submit']) || isset($HTTP_POST_VARS['preview']) ) ? ( ( !empty($HTTP_POST_VARS['notify']) ) ? TRUE : 0 ) : $userdata['always_notify']; +$notify = ( isset($HTTP_POST_VARS['submit']) || isset($HTTP_POST_VARS['preview']) ) ? ( ( !empty($HTTP_POST_VARS['notify']) ) ? TRUE : 0 ) : $userdata['user_notify']; $preview = (isset($HTTP_POST_VARS['preview'])) ? TRUE : 0; @@ -518,6 +518,105 @@ if( ($mode == "newtopic" || $mode == "reply") && $topic_status == TOPIC_UNLOCKED if($db->sql_query($sql, END_TRANSACTION)) { setcookie('phpbb2_' . $forum_id . '_' . $new_topic_id, '', time() - 1, $cookiepath, $cookiedomain, $cookiesecure); + + // + // Email users who are watching this topic + // + if($mode == "reply") + { + $sql = "SELECT u.user_id, u.username, u.user_email, t.topic_title + FROM " . TOPICS_WATCH_TABLE . " tw, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u + WHERE tw.topic_id = $new_topic_id + AND tw.user_id <> " . $userdata['user_id'] . " + AND tw.user_id <> " . ANONYMOUS . " + AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . " + AND t.topic_id = tw.topic_id + AND u.user_id = tw.user_id"; + if( $result = $db->sql_query($sql) ) + { + $email_set = $db->sql_fetchrowset($result); + $update_watched_sql = ""; + + for($i = 0; $i < count($email_set); $i++) + { + if($email_set[$i]['user_email'] != "") + { + $email_headers = "From: " . $board_config['board_email_from'] . "\r\n"; + + $emailer->use_template("topic_notify"); + $emailer->email_address($email_set[$i]['user_email']); + $emailer->set_subject($lang['Topic_reply_notification']); + $emailer->extra_headers($email_headers); + + $emailer->assign_vars(array( + "USERNAME" => $email_set[$i]['username'], + "SITENAME" => $board_config['sitename'], + "TOPIC_TITLE" => $email_set[$i]['topic_title'], + "TOPIC_URL" => "http://" . $SERVER_NAME . "/viewtopic.$phpEx?" . POST_TOPIC_URL . "=$new_topic_id", + "EMAIL_SIG" => $board_config['board_email']) + ); + + $emailer->send(); + $emailer->reset(); + + if($update_watched_sql != "") + { + $update_watched_sql .= " OR "; + } + $update_watched_sql .= "user_id = " . $email_set[$i]['user_id']; + } + } + + if($update_watched_sql != "") + { + $sql = "UPDATE " . TOPICS_WATCH_TABLE . " + SET notify_status = " . TOPIC_WATCH_NOTIFIED . " + WHERE topic_id = $new_topic_id + AND $update_watched_sql"; + $db->sql_query($sql); + } + } + } + + // + // Handle notification request ... not complete + // only fully functional for new posts + // + if( !empty($notify) ) + { + if($mode == "reply") + { + $sql = "SELECT notify_status + FROM " . TOPICS_WATCH_TABLE . " + WHERE topic_id = $new_topic_id + AND user_id = " . $userdata['user_id']; + if( !$result = $db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, "Couldn't obtain topic watch information", "", __LINE__, __FILE__, $sql); + } + + if( $db->sql_numrows($result)) + { + if( !$notify ) + { + + } + } + else if( $notify ) + { + } + } + else if( $notify ) + { + $sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status) + VALUES (" . $userdata['user_id'] . ", $new_topic_id, 0)"; + if( !$result = $db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, "Couldn't insert topic watch information", "", __LINE__, __FILE__, $sql); + } + } + } + // // If we get here the post has been inserted successfully. // @@ -555,6 +654,12 @@ if( ($mode == "newtopic" || $mode == "reply") && $topic_status == TOPIC_UNLOCKED { if(SQL_LAYER == "mysql") { + $sql = "DELETE FROM " . POSTS_TABLE . " + WHERE post_id = $new_post_id"; + if( !$db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, "Error inserting data into posts text table and could not rollback", "", __LINE__, __FILE__, $sql); + } } // Rollback ? message_die(GENERAL_ERROR, "Error inserting data into posts text table", "", __LINE__, __FILE__, $sql); @@ -562,9 +667,6 @@ if( ($mode == "newtopic" || $mode == "reply") && $topic_status == TOPIC_UNLOCKED } else { - if(SQL_LAYER == "mysql") - { - } // Rollback ? message_die(GENERAL_ERROR, "Error inserting data into posts table", "", __LINE__, __FILE__, $sql); } @@ -1165,8 +1267,6 @@ if($preview && !$error) "preview" => "posting_preview.tpl") ); $template->assign_vars(array( - "ROW_COLOR" => "#" . $theme['td_color1'], - "ROW_CLASS" => $theme['td_class1'], "TOPIC_TITLE" => stripslashes($subject), "POST_SUBJECT" => stripslashes($subject), "POSTER_NAME" => stripslashes($username), @@ -1432,7 +1532,7 @@ $template->assign_vars(array( "S_BBCODE_CHECKED" => (!$bbcode_on) ? "checked=\"checked\"" : "", "S_SMILIES_CHECKED" => (!$smilies_on) ? "checked=\"checked\"" : "", "S_SIGNATURE_CHECKED" => ($attach_sig) ? "checked=\"checked\"" : "", - "S_NOTIFY_CHECKED" => ($attach_sig) ? "checked=\"checked\"" : "", + "S_NOTIFY_CHECKED" => ($notify) ? "checked=\"checked\"" : "", "S_TYPE_TOGGLE" => $topic_type_toggle, "S_TOPIC_ID" => $topic_id, diff --git a/phpBB/profile.php b/phpBB/profile.php index 3c778d7d91..e5b64a74a0 100644 --- a/phpBB/profile.php +++ b/phpBB/profile.php @@ -274,6 +274,7 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) $viewemail = (isset($HTTP_POST_VARS['viewemail'])) ? $HTTP_POST_VARS['viewemail'] : 0; $allowviewonline = (isset($HTTP_POST_VARS['hideonline'])) ? ( ($HTTP_POST_VARS['hideonline']) ? 0 : 1 ) : 1; + $notifyreply = (isset($HTTP_POST_VARS['notifyreply'])) ? $HTTP_POST_VARS['notifyreply'] : 0; $notifypm = (isset($HTTP_POST_VARS['notifypm'])) ? $HTTP_POST_VARS['notifypm'] : 1; $attachsig = (isset($HTTP_POST_VARS['attachsig'])) ? $HTTP_POST_VARS['attachsig'] : 0; @@ -668,7 +669,7 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) } $sql = "UPDATE " . USERS_TABLE . " - SET " . $username_sql . $passwd_sql . "user_email = '$email', user_icq = '$icq', user_website = '$website', user_occ = '$occupation', user_from = '$location', user_interests = '$interests', user_sig = '$signature', user_viewemail = $viewemail, user_aim = '$aim', user_yim = '$yim', user_msnm = '$msn', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify_pm = $notifypm, user_timezone = $user_timezone, user_dateformat = '$user_dateformat', user_lang = '$user_lang', user_template = '$user_template', user_active = $user_active, user_actkey = '$user_actkey', user_theme = $user_theme" . $avatar_sql . " + SET " . $username_sql . $passwd_sql . "user_email = '$email', user_icq = '$icq', user_website = '$website', user_occ = '$occupation', user_from = '$location', user_interests = '$interests', user_sig = '$signature', user_viewemail = $viewemail, user_aim = '$aim', user_yim = '$yim', user_msnm = '$msn', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_timezone = $user_timezone, user_dateformat = '$user_dateformat', user_lang = '$user_lang', user_template = '$user_template', user_active = $user_active, user_actkey = '$user_actkey', user_theme = $user_theme" . $avatar_sql . " WHERE user_id = $user_id"; if($result = $db->sql_query($sql)) @@ -716,8 +717,8 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) $user_id_value = ""; } - $sql = "INSERT INTO " . USERS_TABLE . " (" . $user_id_sql . "username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify_pm, user_timezone, user_dateformat, user_lang, user_template, user_theme, user_level, user_allow_pm, user_active, user_actkey) - VALUES (" . $user_id_value . "'$username', $regdate, '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', '$user_template', $user_theme, 0, 1, "; + $sql = "INSERT INTO " . USERS_TABLE . " (" . $user_id_sql . "username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_template, user_theme, user_level, user_allow_pm, user_active, user_actkey) + VALUES (" . $user_id_value . "'$username', $regdate, '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', '$user_template', $user_theme, 0, 1, "; if($board_config['require_activation'] || $coppa == 1) { @@ -766,11 +767,13 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) $emailer->set_subject($lang['Welcome_subject']); $emailer->extra_headers($email_headers); - $emailer->assign_vars(array("WELCOME_MSG" => $lang['Welcome_subject'], - "USERNAME" => $username, - "PASSWORD" => $password_confirm, - "ACTIVATE_URL" => "http://".$SERVER_NAME.$PHP_SELF."?mode=activate&act_key=$act_key", - "EMAIL_SIG" => $board_config['board_email'])); + $emailer->assign_vars(array( + "WELCOME_MSG" => $lang['Welcome_subject'], + "USERNAME" => $username, + "PASSWORD" => $password_confirm, + "ACTIVATE_URL" => "http://".$SERVER_NAME.$PHP_SELF."?mode=activate&act_key=$act_key", + "EMAIL_SIG" => $board_config['board_email']) + ); $emailer->send(); $emailer->reset(); } @@ -826,6 +829,7 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) $viewemail = $userdata['user_viewemail']; $notifypm = $userdata['user_notify_pm']; + $notifyreply = $userdata['user_notify']; $attachsig = $userdata['user_attachsig']; $allowhtml = $userdata['user_allowhtml']; $allowbbcode = $userdata['user_allowbbcode']; @@ -898,6 +902,8 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) "NOTIFY_PM_NO" => (!$notifypm) ? "checked=\"checked\"" : "", "ALWAYS_ADD_SIGNATURE_YES" => ($attachsig) ? "checked=\"checked\"" : "", "ALWAYS_ADD_SIGNATURE_NO" => (!$attachsig) ? "checked=\"checked\"" : "", + "NOTIFY_REPLY_YES" => ($notify_reply) ? "checked=\"checked\"" : "", + "NOTIFY_REPLY_NO" => (!$notify_reply) ? "checked=\"checked\"" : "", "ALWAYS_ALLOW_BBCODE_YES" => ($allowbbcode) ? "checked=\"checked\"" : "", "ALWAYS_ALLOW_BBCODE_NO" => (!$allowbbcode) ? "checked=\"checked\"" : "", "ALWAYS_ALLOW_HTML_YES" => ($allowhtml) ? "checked=\"checked\"" : "", @@ -956,6 +962,8 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) "L_SIGNATURE" => $lang['Signature'], "L_SIGNATURE_EXPLAIN" => $lang['Signature_explain'], + "L_NOTIFY_ON_REPLY" => $lang['Always_notify'], + "L_NOTIFY_ON_REPLY_EXPLAIN" => $lang['Always_notify_explain'], "L_NOTIFY_ON_PRIVMSG" => $lang['Notify_on_privmsg'], "L_PREFERENCES" => $lang['Preferences'], "L_PUBLIC_VIEW_EMAIL" => $lang['Public_view_email'], diff --git a/phpBB/templates/PSO/profile_add_body.tpl b/phpBB/templates/PSO/profile_add_body.tpl index 8dadf4fe3d..1c3c5e9118 100644 --- a/phpBB/templates/PSO/profile_add_body.tpl +++ b/phpBB/templates/PSO/profile_add_body.tpl @@ -77,6 +77,10 @@
{S_TIMEZONE} {S_TOPIC_ADMIN} |
- {JUMPBOX}{S_AUTH_LIST} | +{S_TIMEZONE} {S_WATCH_TOPIC} |
+ {JUMPBOX}{S_AUTH_LIST} {S_TOPIC_ADMIN} |