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
2014-04-18 22:54:28 +00:00
// Copyright (C) 2014 University of California
2008-08-05 22:43:14 +00:00
//
// 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
2014-04-18 22:54:28 +00:00
if ( DISABLE_FORUMS ) error_page ( " Forums are disabled " );
2011-02-09 22:11:34 +00:00
check_get_args ( array ( " action " , " thread " , " tnow " , " ttok " ));
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 )) {
2011-08-25 22:12:48 +00:00
page_head ( tra ( " 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 );
2011-08-25 22:12:48 +00:00
echo " <p> " . tra ( " You are now subscribed to %1. You will be notified whenever there is a new post. " , " <b> " . cleanup_title ( $thread -> title ) . " </b> " );
2006-06-16 23:53:56 +00:00
} else {
2011-08-25 22:12:48 +00:00
page_head ( tra ( " Subscription failed " ));
echo " <p> " . tra ( " We are currently unable to subscribe you to %1. Please try again later.. " , " <b> " . cleanup_title ( $thread -> title ) . " </b> " );
2006-06-16 23:53:56 +00:00
}
2011-08-25 22:12:48 +00:00
echo " </p><p><br /><a href= \" forum_thread.php?id= " . $thread -> id . " \" > " . tra ( " 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 )) {
2011-08-25 22:12:48 +00:00
page_head ( tra ( " 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 );
2011-08-25 22:12:48 +00:00
echo " <p> " . tra ( " You are no longer subscribed to %1. You will no longer receive notifications for this thread. " , " <b> " . cleanup_title ( $thread -> title ) . " </b> " );
2006-06-16 23:53:56 +00:00
} else {
2011-08-25 22:12:48 +00:00
page_head ( tra ( " Unsubscription failed " ));
echo " <p> " . tra ( " We are currently unable to unsubscribe you from %1. Please try again later.. " , " <b> " . cleanup_title ( $thread -> title ) . " </b> " );
2006-06-16 23:53:56 +00:00
}
2011-08-25 22:12:48 +00:00
echo " </p><p><br /><a href= \" forum_thread.php?id= " . $thread -> id . " \" > " . tra ( " 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 ) {
2011-08-25 22:12:48 +00:00
error_page ( tra ( " 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
?>