. // This file allows people to subscribe to threads. // Whenever someone posts to the thread // the subscribers will receive a notification email require_once('../inc/forum.inc'); check_get_args(array("action", "thread", "tnow", "ttok")); $action = get_str('action'); $threadid = get_int('thread'); $thread = BoincThread::lookup_id($threadid); $forum = BoincForum::lookup_id($thread->forum); function show_title($forum, $thread) { switch ($forum->parent_type) { case 0: $category = BoincCategory::lookup_id($forum->category); show_forum_title($category, $forum, $thread); break; case 1: show_team_forum_title($forum, $thread); break; } } function subscribe($forum, $thread, $user) { if (BoincSubscription::replace($user->id, $thread->id)) { page_head(tra("Subscription successful")); show_forum_header($user); show_title($forum, $thread); echo "

".tra("You are now subscribed to %1. You will be notified whenever there is a new post.", "".cleanup_title($thread->title).""); } else { page_head(tra("Subscription failed")); echo "

".tra("We are currently unable to subscribe you to %1. Please try again later..", "".cleanup_title($thread->title).""); } echo "


id."\">".tra("Return to thread")."

"; page_tail(); } function unsubscribe($forum, $thread, $user) { BoincSubscription::delete($user->id, $thread->id); if (!BoincSubscription::lookup($user->id, $thread->id)) { page_head(tra("Unsubscription successful")); show_forum_header($user); show_title($forum, $thread); echo "

".tra("You are no longer subscribed to %1. You will no longer receive notifications for this thread.", "".cleanup_title($thread->title).""); } else { page_head(tra("Unsubscription failed")); echo "

".tra("We are currently unable to unsubscribe you from %1. Please try again later..", "".cleanup_title($thread->title).""); } echo "


id."\">".tra("Return to thread")."

"; page_tail(); } if (!$thread || !$action) { error_page(tra("Unknown subscription action")); } $user = get_logged_in_user(); check_tokens($user->authenticator); if ($action == "subscribe") { subscribe($forum, $thread, $user); exit(); } else if ($action == "unsubscribe") { unsubscribe($forum, $thread, $user); exit(); } ?>