2003-07-25 20:28:35 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-11-15 22:51:05 +00:00
|
|
|
|
|
|
|
// This file allows people to subscribe to threads.
|
|
|
|
// Whenever someone posts to the thread
|
2007-11-12 20:57:15 +00:00
|
|
|
// 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);
|
2006-06-16 23:53:56 +00:00
|
|
|
|
2007-11-15 22:51:05 +00:00
|
|
|
function show_title($forum, $thread) {
|
2007-11-16 21:48:28 +00:00
|
|
|
switch ($forum->parent_type) {
|
|
|
|
case 0:
|
2007-11-15 22:51:05 +00:00
|
|
|
$category = BoincCategory::lookup_id($forum->category);
|
|
|
|
show_forum_title($category, $forum, $thread);
|
2007-11-16 21:48:28 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2007-11-26 04:12:15 +00:00
|
|
|
show_team_forum_title($forum, $thread);
|
2007-11-16 21:48:28 +00:00
|
|
|
break;
|
2007-11-15 22:51:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function subscribe($forum, $thread, $user) {
|
2007-11-12 20:57:15 +00:00
|
|
|
if (BoincSubscription::replace($user->id, $thread->id)) {
|
2007-11-15 22:51:05 +00:00
|
|
|
page_head("Subscription successful");
|
2007-11-15 00:27:02 +00:00
|
|
|
show_forum_header($user);
|
2007-11-15 22:51:05 +00:00
|
|
|
show_title($forum, $thread);
|
2007-11-12 20:57:15 +00:00
|
|
|
echo "<p>You are now subscribed to <b>", cleanup_title($thread->title), "</b>.
|
2007-12-30 22:02:16 +00:00
|
|
|
You will be notified whenever there is a new post.";
|
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-15 22:51:05 +00:00
|
|
|
function unsubscribe($forum, $thread, $user) {
|
2007-11-12 20:57:15 +00:00
|
|
|
BoincSubscription::delete($user->id, $thread->id);
|
|
|
|
if (!BoincSubscription::lookup($user->id, $thread->id)) {
|
2007-11-15 22:51:05 +00:00
|
|
|
page_head("Unsubscription successful");
|
2007-11-15 00:27:02 +00:00
|
|
|
show_forum_header($user);
|
2007-11-15 22:51:05 +00:00
|
|
|
show_title($forum, $thread);
|
2007-11-12 20:57:15 +00:00
|
|
|
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
|
|
|
|
2007-11-15 22:51:05 +00:00
|
|
|
if (!$thread || !$action) {
|
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
|
|
|
|
2007-11-15 22:51:05 +00:00
|
|
|
$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();
|
|
|
|
}
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
?>
|
|
|
|
|