diff --git a/html/forum/subscribe.inc b/html/forum/subscribe.inc new file mode 100644 index 0000000000..52705488e0 --- /dev/null +++ b/html/forum/subscribe.inc @@ -0,0 +1,61 @@ +id . ", threadid = " . $thread->id; + show_result_page(sql_query($sql), $thread); +} + +function show_result_page($success, $thread) { + if ($success) { + doHeader("Subscription Successful"); + echo "Subscription successful"; + echo "
You are now subscribed to ", $thread->title, ". You will receive an email whenver another user posts to this thread.
"; + } else { + // Chances are that an error of this kind will be caught at the DB level, but we'll add a case anyway. + doHeader("Subscription Failed"); + echo "Subscription failed"; + if ($thread) { + echo "There was a problem subscribing you to ", $thread->title, ". Please try again later.
"; + } else { + echo "The thread you tried to subscribe to does not exist.
"; + } + } + + doFooter(); + +} + +function notify_subscribers($thread) { + $sql = "SELECT * FROM subscriptions WHERE threadid = " . $thread->id; + $result = sql_query($sql); + + while ($row = mysql_fetch_assoc($result)) { + send_notice_email($row['userid'], $thread); + } + +} + +function send_notice_email($userId, $thread) { + $result = sql_query("SELECT * FROM user WHERE id = $userId"); + $row = mysql_fetch_assoc($result); + + $title = PROJECT . ": A user has posted to your subscribed thread."; + $body = "Another " . PROJECT . " user has posted to the thread \"" . $thread->title . "\"."; + // Include a link to the thread here. + + mail($row['email_addr'], $title, $body); +} + +?> \ No newline at end of file diff --git a/html/forum/subscribe.php b/html/forum/subscribe.php new file mode 100644 index 0000000000..0f126a125e --- /dev/null +++ b/html/forum/subscribe.php @@ -0,0 +1,15 @@ + \ No newline at end of file