2003-07-25 20:28:35 +00:00
|
|
|
<?php
|
2007-11-12 20:57:15 +00:00
|
|
|
// This file allows people to subscribe to threads
|
|
|
|
// Whenever someone posts a new post to the thread
|
|
|
|
// the subscribers will receive a notification email
|
2004-12-27 03:42:11 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
require_once('../inc/forum.inc');
|
2004-12-27 03:42:11 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
$action = get_str('action');
|
|
|
|
$threadid = get_int('thread');
|
2007-11-12 20:57:15 +00:00
|
|
|
$thread = BoincThread::lookup_id($threadid);
|
|
|
|
$forum = BoincForum::lookup_id($thread->forum);
|
|
|
|
$category = BoincCategory::lookup_id($forum->category);
|
2006-06-16 23:53:56 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
function subscribe($category, $forum, $thread, $user) {
|
|
|
|
if (BoincSubscription::replace($user->id, $thread->id)) {
|
|
|
|
page_head("Subscription Successful");
|
|
|
|
show_forum_title($user, $category, $forum, $thread, true);
|
|
|
|
echo "<p>You are now subscribed to <b>", cleanup_title($thread->title), "</b>.
|
|
|
|
You will receive an email whenever someone posts to the thread.";
|
2006-06-16 23:53:56 +00:00
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
page_head("Subscription failed");
|
|
|
|
echo "<p>We are currently unable to subscribe you to this thread (<b>", cleanup_title($thread->title), "</b>).
|
|
|
|
Please try again later..";
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
echo "</p><p><br /><a href=\"forum_thread.php?id=".$thread->id."\">Return to thread</a></p>";
|
2006-06-16 23:53:56 +00:00
|
|
|
page_tail();
|
|
|
|
}
|
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
function unsubscribe($category, $forum, $thread, $user) {
|
|
|
|
BoincSubscription::delete($user->id, $thread->id);
|
|
|
|
if (!BoincSubscription::lookup($user->id, $thread->id)) {
|
|
|
|
page_head("Unsubscription Successful");
|
|
|
|
show_forum_title($user, $category, $forum, $thread, true);
|
|
|
|
echo "<p>You are no longer subscribed to <b>", cleanup_title($thread->title), "</b>.
|
|
|
|
You will no longer receive notifications for this thread.";
|
2006-06-16 23:53:56 +00:00
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
page_head("Unsubscription failed");
|
|
|
|
echo "<p>We are currently unable to unsubscribe you to this thread (<b>", cleanup_title($thread->title), "</b>).
|
|
|
|
Please try again later..";
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
echo "</p><p><br /><a href=\"forum_thread.php?id=".$thread->id."\">Return to thread</a></p>";
|
2006-06-16 23:53:56 +00:00
|
|
|
page_tail();
|
|
|
|
}
|
2003-07-25 20:28:35 +00:00
|
|
|
|
2003-07-26 00:20:44 +00:00
|
|
|
if ($thread && $action) {
|
2007-11-12 20:57:15 +00:00
|
|
|
$user = get_logged_in_user();
|
|
|
|
check_tokens($user->authenticator);
|
2003-07-26 00:20:44 +00:00
|
|
|
|
|
|
|
if ($action == "subscribe") {
|
2007-11-12 20:57:15 +00:00
|
|
|
subscribe($category, $forum, $thread, $user);
|
2003-07-26 00:20:44 +00:00
|
|
|
exit();
|
|
|
|
} else if ($action == "unsubscribe") {
|
2007-11-12 20:57:15 +00:00
|
|
|
unsubscribe($category, $forum, $thread, $user);
|
2003-07-26 00:20:44 +00:00
|
|
|
exit();
|
|
|
|
} else {
|
|
|
|
show_result_page(null, false, $thread);
|
2003-08-14 00:57:03 +00:00
|
|
|
exit();
|
2003-07-26 00:20:44 +00:00
|
|
|
}
|
2003-07-25 20:28:35 +00:00
|
|
|
} else {
|
2006-06-16 23:53:56 +00:00
|
|
|
error_page("Unknown subscription action");
|
2003-07-25 20:28:35 +00:00
|
|
|
}
|
2003-07-26 00:20:44 +00:00
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
?>
|
|
|
|
|