2003-07-25 20:28:35 +00:00
|
|
|
<?php
|
2006-06-16 23:53:56 +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');
|
|
|
|
require_once('../inc/forum_std.inc');
|
2003-07-25 20:28:35 +00:00
|
|
|
|
2004-12-27 03:42:11 +00:00
|
|
|
db_init();
|
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
$action = get_str('action');
|
|
|
|
$threadid = get_int('thread');
|
|
|
|
$thread = new Thread($threadid);
|
|
|
|
|
|
|
|
function subscribe($thread, $user) {
|
|
|
|
$thread->subscribe($user);
|
|
|
|
if ($thread->isSubscribed($user)){
|
|
|
|
page_head("Subscription Successful");
|
|
|
|
show_forum_title($thread->getForum(), $thread);
|
|
|
|
echo "<p>You are now subscribed to <b>", cleanup_title($thread->getTitle()), "</b>.
|
|
|
|
You will receive an email whenever someone posts to the thread.";
|
|
|
|
} else {
|
|
|
|
page_head("Subscription failed");
|
|
|
|
echo "<p>We are currently unable to subscribe you to this thread (<b>", cleanup_title($thread->getTitle()), "</b>).
|
|
|
|
Please try again later..";
|
|
|
|
}
|
|
|
|
echo "</p><p><br /><a href=\"forum_thread.php?id=".$thread->getID()."\">Return to thread</a></p>";
|
|
|
|
page_tail();
|
|
|
|
}
|
|
|
|
|
|
|
|
function unsubscribe($thread, $user=null) {
|
|
|
|
$thread->unsubscribe($user);
|
|
|
|
if (!$thread->isSubscribed($user)){
|
|
|
|
page_head("Unsubscription Successful");
|
|
|
|
show_forum_title($thread->getForum(), $thread);
|
|
|
|
echo "<p>You are no longer subscribed to <b>", cleanup_title($thread->getTitle()), "</b>.
|
|
|
|
You will no longer receive notifications for this thread.";
|
|
|
|
} else {
|
|
|
|
page_head("Unsubscription failed");
|
|
|
|
echo "<p>We are currently unable to unsubscribe you to this thread (<b>", cleanup_title($thread->getTitle()), "</b>).
|
|
|
|
Please try again later..";
|
|
|
|
}
|
|
|
|
echo "</p><p><br /><a href=\"forum_thread.php?id=".$thread->getID()."\">Return to thread</a></p>";
|
|
|
|
page_tail();
|
|
|
|
}
|
2003-07-25 20:28:35 +00:00
|
|
|
|
2003-07-26 00:20:44 +00:00
|
|
|
if ($thread && $action) {
|
2006-06-16 23:53:56 +00:00
|
|
|
$user = re_get_logged_in_user(true);
|
2007-02-08 19:54:05 +00:00
|
|
|
check_tokens($user->getAuthenticator());
|
2003-07-26 00:20:44 +00:00
|
|
|
|
|
|
|
if ($action == "subscribe") {
|
|
|
|
subscribe($thread, $user);
|
|
|
|
exit();
|
|
|
|
} else if ($action == "unsubscribe") {
|
|
|
|
unsubscribe($thread, $user);
|
|
|
|
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
|
|
|
?>
|
|
|
|
|