forked from Phorum/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
follow.php
108 lines (89 loc) · 4.76 KB
/
follow.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2011 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program 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. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
// //
////////////////////////////////////////////////////////////////////////////////
define('phorum_page','subscribe');
require_once './common.php';
require_once PHORUM_PATH.'/include/api/format/messages.php';
phorum_api_request_require_login();
// checking read-permissions
if(!phorum_check_read_common()) {
return;
}
// somehow we got to a folder
if($PHORUM["folder_flag"] || empty($PHORUM["forum_id"])){
phorum_api_redirect(PHORUM_INDEX_URL, $PHORUM["forum_id"]);
}
if(isset($PHORUM["args"][1])){
$thread=(int)$PHORUM["args"][1];
} elseif(isset($_POST["thread"])){
$thread=(int)$_POST["thread"];
}
if(empty($thread)) {
phorum_api_redirect(PHORUM_LIST_URL);
exit();
}
$message=$PHORUM['DB']->get_message($thread);
# We stepped away from using "remove" as the URL parameter to stop
# following a certain thread, because it got blacklisted by several
# spam filtering programs. We'll still handle the remove parameter
# though, to keep supporting the URLs that are in the messages
# that were sent out before this change.
if(isset($PHORUM["args"]["remove"]) || isset($PHORUM["args"]["stop"])){
// we are removing a message from the follow list
phorum_api_user_unsubscribe( $PHORUM['user']['user_id'], $thread );
$PHORUM["DATA"]["OKMSG"]=$PHORUM["DATA"]["LANG"]["RemoveFollowed"];
$PHORUM["DATA"]["URL"]["REDIRECT"]=phorum_api_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $thread);
$PHORUM["DATA"]["BACKMSG"]=$PHORUM["DATA"]["LANG"]["BackToThread"];
$template="message";
} elseif(isset($PHORUM["args"]["noemail"])){
// we are stopping emails for this thread
phorum_api_user_unsubscribe( $PHORUM['user']['user_id'], $thread );
phorum_api_user_subscribe( $PHORUM['user']['user_id'], $thread, $message["forum_id"], PHORUM_SUBSCRIPTION_BOOKMARK );
$PHORUM["DATA"]["OKMSG"]=$PHORUM["DATA"]["LANG"]["NoMoreEmails"];
$PHORUM["DATA"]["URL"]["REDIRECT"]=phorum_api_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $thread);
$PHORUM["DATA"]["BACKMSG"]=$PHORUM["DATA"]["LANG"]["BackToThread"];
$template="message";
} elseif(!empty($_POST)) {
// the user has submitted the form
$type = (!empty($PHORUM["allow_email_notify"]) && isset($_POST["send_email"])) ? PHORUM_SUBSCRIPTION_MESSAGE : PHORUM_SUBSCRIPTION_BOOKMARK;
phorum_api_user_subscribe( $PHORUM['user']['user_id'], $thread, $message["forum_id"], $type );
$PHORUM["DATA"]["URL"]["REDIRECT"] = phorum_api_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $thread);
$PHORUM["DATA"]["BACKMSG"]=$PHORUM["DATA"]["LANG"]["BackToThread"];
$PHORUM["DATA"]["OKMSG"]=$PHORUM["DATA"]["LANG"]["BookmarkedThread"];
$template="message";
} else {
// we are following a new thread
list($messages) = phorum_api_format_messages(array($message));
$PHORUM["DATA"]["URL"]["ACTION"] = phorum_api_url(PHORUM_FOLLOW_ACTION_URL);
$PHORUM["DATA"]["SUBJECT"] = $message["subject"];
$PHORUM["DATA"]["AUTHOR"] = $message["author"];
$PHORUM["DATA"]["THREAD"] = $thread;
$PHORUM["DATA"]["FORUM_ID"] = $PHORUM["forum_id"];
$PHORUM["DATA"]["ALLOW_EMAIL_NOTIFY"] = !empty($PHORUM["allow_email_notify"]);
$PHORUM["DATA"]['POST_VARS'].="<input type=\"hidden\" name=\"thread\" value=\"{$PHORUM["DATA"]["THREAD"]}\" />\n";
$template = "follow";
}
$PHORUM['DATA']['BREADCRUMBS'][] = array(
'URL' => '',
'TEXT' => $PHORUM['DATA']['LANG']['FollowThread'],
'TYPE' => 'follow'
);
// set all our common URL's
phorum_build_common_urls();
phorum_api_output($template);
?>