Issues (1963)

html/inc/friend.inc (2 issues)

1
<?php
2
// This file is part of BOINC.
3
// http://boinc.berkeley.edu
4
// Copyright (C) 2024 University of California
5
//
6
// BOINC is free software; you can redistribute it and/or modify it
7
// under the terms of the GNU Lesser General Public License
8
// as published by the Free Software Foundation,
9
// either version 3 of the License, or (at your option) any later version.
10
//
11
// BOINC is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
// See the GNU Lesser General Public License for more details.
15
//
16
// You should have received a copy of the GNU Lesser General Public License
17
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
18
19
// code related to 'friend' features
20
21
// The following two are what gets put into notification email digests
22
//
23
function friend_notify_req_email_line($notify) {
24
    $src_user = BoincUser::lookup_id($notify->opaque);
25
    if (!$src_user) return null;
26
    return "$src_user->name has requested friendship with you. Please accept or decline.";
27
}
28
29
function friend_notify_accept_email_line($notify) {
30
    $src_user = BoincUser::lookup_id($notify->opaque);
31
    if (!$src_user) return null;
32
    return "$src_user->name has confirmed you as a friend";
33
}
34
35
// The following two are what gets put in the Notification
36
// area of user's Account page
37
//
38
function friend_notify_req_web_line($notify) {
39
    $user = BoincUser::lookup_id($notify->opaque);
40
    if (!$user) return null;
41
    return sprintf(
42
        '<a href=friend.php?action=query&userid=%d>Friendship request</a> from <a href=%s?userid=%d>%s</a>',
43
        $notify->opaque,
44
        SHOW_USER_PAGE,
45
        $user->id,
46
        $user->name
47
    );
48
}
49
50
function friend_notify_accept_web_line($notify) {
51
    $user = BoincUser::lookup_id($notify->opaque);
52
    if (!$user) return null;
53
    return "
54
        <a href=friend.php?action=accepted&userid=$notify->opaque>Friendship confirmation</a> from $user->name
55
    ";
56
}
57
58
function send_friend_request_email($src_user, $dest_user, $msg) {
59
    $message  = "
60
$src_user->name has added you as a friend at ".PROJECT.".
61
";
62
    if (strlen($msg)) {
63
        $message .= "
64
$src_user->name says: $msg
65
";
66
    }
67
68
    $message .= "
69
Please accept or decline by visiting
70
".secure_url_base().HOME_PAGE."
71
72
--------------------------
73
To change email preferences, visit:
74
".secure_url_base()."edit_forum_preferences_form.php
75
Do not reply to this message.
76
" ;
0 ignored issues
show
Space found before semicolon; expected "";" but found "" ;"
Loading history...
77
    send_email($dest_user, "[".PROJECT."] friend request", $message);
78
}
79
80
function send_friend_accept_email($dest_user, $src_user, $msg) {
81
    $message  = "
82
$dest_user->name has confirmed you as a friend at ".PROJECT.".
83
";
84
    if (strlen($msg)) {
85
        $message .= "
86
$dest_user->name says: $msg
87
";
88
    }
89
90
    $message .= "
91
Visit your Account page at
92
".secure_url_base().HOME_PAGE."
93
94
--------------------------
95
To change email preferences, visit:
96
".secure_url_base()."edit_forum_preferences_form.php
97
Do not reply to this message.
98
" ;
0 ignored issues
show
Space found before semicolon; expected "";" but found "" ;"
Loading history...
99
    send_email($src_user, "[".PROJECT."] friend confirmed", $message);
100
}
101
102
function friend_req_rss($notify, &$title, &$msg, &$url) {
103
    $src_user = BoincUser::lookup_id($notify->opaque);
104
    if (!$src_user) {
105
        $msg = null;
106
        return;
107
    }
108
    $title = "Friend request";
109
    $msg = "$src_user->name has requested friendship with you. Please accept or decline.";
110
    $url = secure_url_base()."friend.php?action=query&target_userid=$notify->userid&userid=$notify->opaque";
111
}
112
113
function friend_accept_rss($notify, &$title, &$msg, &$url) {
114
    $src_user = BoincUser::lookup_id($notify->opaque);
115
    if (!$src_user) {
116
        $msg = null;
117
        return;
118
    }
119
    $title = "Friendship confirmation";
120
    $msg = "$src_user->name has confirmed you as a friend";
121
    $url = secure_url_base().HOME_PAGE;
122
}
123
124
// delete friendship connections
125
//
126
function delete_friends($user) {
127
    BoincFriend::delete_aux("user_src=$user->id or user_dest=$user->id");
128
}
129
130
?>
131