|
1
|
|
|
<?php |
|
2
|
|
|
// This file is part of BOINC. |
|
3
|
|
|
// http://boinc.berkeley.edu |
|
4
|
|
|
// Copyright (C) 2008 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
|
|
|
require_once("../inc/credit.inc"); |
|
20
|
|
|
require_once("../inc/email.inc"); |
|
21
|
|
|
require_once("../inc/util.inc"); |
|
22
|
|
|
require_once("../inc/team.inc"); |
|
23
|
|
|
require_once("../inc/friend.inc"); |
|
24
|
|
|
require_once("../inc/forum_db.inc"); |
|
25
|
|
|
require_once("../inc/notify.inc"); |
|
26
|
|
|
require_once("../inc/ldap.inc"); |
|
27
|
|
|
|
|
28
|
|
|
if (!defined('REMOTE_PROJECTS_TTL')) { |
|
29
|
|
|
define('REMOTE_PROJECTS_TTL', 86400); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
// add an element "projects" to user consisting of array of projects |
|
33
|
|
|
// they've participated in |
|
34
|
|
|
// |
|
35
|
|
|
function get_other_projects($user) { |
|
36
|
|
|
$cpid = md5($user->cross_project_id . $user->email_addr); |
|
37
|
|
|
$url = "http://boinc.netsoft-online.com/get_user.php?cpid=".$cpid; |
|
38
|
|
|
|
|
39
|
|
|
// Check the cache for that URL |
|
40
|
|
|
// |
|
41
|
|
|
$cacheddata = get_cached_data(REMOTE_PROJECTS_TTL, $url); |
|
42
|
|
|
if ($cacheddata) { |
|
43
|
|
|
$remote = unserialize($cacheddata); |
|
44
|
|
|
if (!$remote) $remote = []; |
|
45
|
|
|
} else { |
|
46
|
|
|
// Fetch the XML, use curl if fopen() is disallowed |
|
47
|
|
|
// |
|
48
|
|
|
if (ini_get('allow_url_fopen')) { |
|
49
|
|
|
$timeout = 3; |
|
50
|
|
|
$old_timeout = ini_set('default_socket_timeout', $timeout); |
|
51
|
|
|
$xml_object = null; |
|
52
|
|
|
$f = @file_get_contents($url); |
|
53
|
|
|
if ($f) { |
|
54
|
|
|
$xml_object = @simplexml_load_string($f); |
|
55
|
|
|
} |
|
56
|
|
|
ini_set('default_socket_timeout', $old_timeout); |
|
57
|
|
|
if (!$xml_object) { |
|
58
|
|
|
return $user; |
|
59
|
|
|
} |
|
60
|
|
|
} else { |
|
61
|
|
|
$ch = curl_init($url); |
|
62
|
|
|
curl_setopt($ch, CURLOPT_HEADER, false); |
|
63
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
64
|
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
65
|
|
|
curl_setopt($ch, CURLOPT_MAXREDIRS, 3); |
|
66
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 3); |
|
67
|
|
|
$rawxml = @curl_exec($ch); |
|
68
|
|
|
$xml_object = null; |
|
69
|
|
|
if ($rawxml) { |
|
70
|
|
|
$xml_object = @simplexml_load_string($rawxml); |
|
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
curl_close($ch); |
|
73
|
|
|
if (!$xml_object) { |
|
74
|
|
|
return $user; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
// auto-cast the project list to an array of stdClass projects |
|
79
|
|
|
// |
|
80
|
|
|
$remote = @json_decode(json_encode((array)$xml_object))->project; |
|
81
|
|
|
if (!$remote) $remote = []; |
|
82
|
|
|
if (!is_array($remote)) { |
|
83
|
|
|
$remote = [$remote]; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
// Cache the results |
|
87
|
|
|
set_cached_data(REMOTE_PROJECTS_TTL, serialize($remote), $url); |
|
88
|
|
|
} |
|
89
|
|
|
$user->projects = $remote; |
|
90
|
|
|
return $user; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
function show_project($project) { |
|
94
|
|
|
if ($project->url == "http://www.worldcommunitygrid.org/") { |
|
95
|
|
|
$x = $project->name; |
|
96
|
|
|
} else { |
|
97
|
|
|
$x = sprintf( |
|
98
|
|
|
'<a href="%sshow_user.php?userid=%d">%s</a>', |
|
99
|
|
|
$project->url, |
|
100
|
|
|
$project->id, |
|
101
|
|
|
$project->name |
|
102
|
|
|
); |
|
103
|
|
|
} |
|
104
|
|
|
echo "<tr> |
|
105
|
|
|
<td>$x</td> |
|
106
|
|
|
<td align=\"right\">".number_format($project->total_credit, 0)."</td> |
|
107
|
|
|
<td align=\"right\">".number_format($project->expavg_credit, 0)."</td> |
|
108
|
|
|
<td align=\"right\">".date_str($project->create_time)."</td> |
|
109
|
|
|
</tr> |
|
110
|
|
|
"; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
function cmp($a, $b) { |
|
114
|
|
|
if ($a->expavg_credit == $b->expavg_credit) return 0; |
|
115
|
|
|
return ($a->expavg_credit < $b->expavg_credit) ? 1 : -1; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
function show_other_projects($user, $personal) { |
|
119
|
|
|
if (!isset($user->projects)) return; |
|
120
|
|
|
if (count($user->projects) < 2) return; |
|
121
|
|
|
|
|
122
|
|
|
usort($user->projects, "cmp"); |
|
123
|
|
|
if ($personal) { |
|
124
|
|
|
$t = tra("Projects in which you are participating"); |
|
125
|
|
|
} else { |
|
126
|
|
|
$t = tra("Projects in which %1 is participating", $user->name); |
|
127
|
|
|
} |
|
128
|
|
|
panel( |
|
129
|
|
|
$t, |
|
130
|
|
|
function() use ($user) { |
|
131
|
|
|
show_other_projects_aux($user); |
|
132
|
|
|
} |
|
133
|
|
|
); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
function show_other_projects_aux($user) { |
|
137
|
|
|
start_table('table-striped'); |
|
138
|
|
|
row_heading_array( |
|
139
|
|
|
array( |
|
140
|
|
|
tra("Project")."<br/><small>".tra("Click for user page")."</small>", |
|
141
|
|
|
tra("Total credit"), |
|
142
|
|
|
tra("Average credit"), |
|
143
|
|
|
tra("Since") |
|
|
|
|
|
|
144
|
|
|
), |
|
145
|
|
|
array("", ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT) |
|
146
|
|
|
); |
|
147
|
|
|
foreach ($user->projects as $project) { |
|
148
|
|
|
show_project($project); |
|
149
|
|
|
} |
|
150
|
|
|
end_table(); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
function total_posts($user) { |
|
154
|
|
|
return BoincPost::count("user=$user->id"); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
function show_credit($user) { |
|
158
|
|
|
row2(tra("Total credit"), format_credit_large($user->total_credit)); |
|
159
|
|
|
row2(tra("Recent average credit"), format_credit($user->expavg_credit)); |
|
160
|
|
|
if (function_exists("project_user_credit")) { |
|
161
|
|
|
project_user_credit($user); |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
require_once("../inc/stats_sites.inc"); |
|
166
|
|
|
// show dynamic user info (private) |
|
167
|
|
|
// |
|
168
|
|
|
function show_user_stats_private($user) { |
|
169
|
|
|
global $cpid_stats_sites; |
|
170
|
|
|
|
|
171
|
|
|
if (!NO_STATS) { |
|
172
|
|
|
show_credit($user); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
if (!NO_HOSTS) { |
|
176
|
|
|
row2(tra("Computers on this account"), "<a href=\"hosts_user.php\">".tra("View")."</a>"); |
|
177
|
|
|
} |
|
178
|
|
|
if (!NO_COMPUTING) { |
|
179
|
|
|
row2(tra("Tasks"), "<a href=\"results.php?userid=$user->id\">".tra("View")."</a>"); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
if (!NO_STATS) { |
|
183
|
|
|
$cpid = md5($user->cross_project_id . $user->email_addr); |
|
184
|
|
|
$x = ""; |
|
185
|
|
|
shuffle($cpid_stats_sites); |
|
186
|
|
|
foreach ($cpid_stats_sites as $site) { |
|
187
|
|
|
$name = $site[0]; |
|
188
|
|
|
$y = sprintf($site[1], $cpid); |
|
189
|
|
|
$x .= "<a href=\"$y\">$name</a><br/>\n"; |
|
190
|
|
|
} |
|
191
|
|
|
$x .= "<br/><small>".tra("Cross-project ID").": $cpid</small>\n"; |
|
192
|
|
|
row2(tra("Cross-project statistics"), $x); |
|
193
|
|
|
$x = sprintf('<a href="%s">%s</a>', cert_filename(), tra("Account")); |
|
194
|
|
|
if ($user->teamid) { |
|
195
|
|
|
$x .= ' · <a href="cert_team.php">'.tra("Team").'</a>'; |
|
196
|
|
|
} |
|
197
|
|
|
$x .= ' · <a href="cert_all.php">'.tra("Cross-project").'</a>'; |
|
198
|
|
|
row2(tra("Certificate"), $x); |
|
199
|
|
|
} |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
function notify_description($notify) { |
|
203
|
|
|
switch ($notify->type) { |
|
204
|
|
|
case NOTIFY_FRIEND_REQ: |
|
205
|
|
|
return friend_notify_req_web_line($notify); |
|
206
|
|
|
case NOTIFY_FRIEND_ACCEPT: |
|
207
|
|
|
return friend_notify_accept_web_line($notify); |
|
208
|
|
|
case NOTIFY_PM: |
|
209
|
|
|
return pm_web_line($notify); |
|
210
|
|
|
case NOTIFY_SUBSCRIBED_THREAD: |
|
211
|
|
|
return subscribed_thread_web_line($notify); |
|
212
|
|
|
case NOTIFY_SUBSCRIBED_FORUM: |
|
213
|
|
|
return subscribed_forum_web_line($notify); |
|
214
|
|
|
} |
|
215
|
|
|
return null; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
// a string that can be used to authenticate some operations, |
|
219
|
|
|
// but can't be used to log in to the account |
|
220
|
|
|
// (e.g. can't be used to change email addr or passwd) |
|
221
|
|
|
// |
|
222
|
|
|
// this is a function of |
|
223
|
|
|
// - authenticator (never changes) |
|
224
|
|
|
// - user ID (never changes) |
|
225
|
|
|
// - password |
|
226
|
|
|
// - email addr |
|
227
|
|
|
// |
|
228
|
|
|
function weak_auth($user) { |
|
229
|
|
|
$x = md5($user->authenticator.$user->passwd_hash); |
|
230
|
|
|
return "{$user->id}_$x"; |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
// originally user URLs were assumed to be http://, |
|
234
|
|
|
// and this prefix wasn't stored. |
|
235
|
|
|
// Now the prefix can be http:// or https://. |
|
236
|
|
|
// This function takes a user URL in any form and converts |
|
237
|
|
|
// it to a canonical form, with the protocol prefix. |
|
238
|
|
|
// |
|
239
|
|
|
function normalize_user_url($url) { |
|
240
|
|
|
$url = sanitize_user_url($url); |
|
241
|
|
|
if (!$url) return ''; |
|
242
|
|
|
$x = strtolower($url); |
|
243
|
|
|
if (substr($x, 0, 7) == 'http://') { |
|
244
|
|
|
return 'http://'.substr($url, 7); |
|
245
|
|
|
} |
|
246
|
|
|
if (substr($x, 0, 8) == 'https://') { |
|
247
|
|
|
return 'https://'.substr($url, 8); |
|
248
|
|
|
} |
|
249
|
|
|
return 'http://'.$url; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
// show static user info (private) |
|
253
|
|
|
// |
|
254
|
|
|
function show_user_info_private($user) { |
|
255
|
|
|
row2(tra("Name"), $user->name); |
|
256
|
|
|
if (LDAP_HOST && is_ldap_email($user->email_addr)) { |
|
257
|
|
|
row2("LDAP ID", ldap_email_to_uid($user->email_addr)); |
|
258
|
|
|
} else { |
|
259
|
|
|
$email_text = $user->email_addr; |
|
260
|
|
|
if (defined("SHOW_NONVALIDATED_EMAIL_ADDR") && !$user->email_validated) { |
|
261
|
|
|
$email_text .= " (<a href=validate_email_addr.php>must be validated</a>)"; |
|
262
|
|
|
} |
|
263
|
|
|
row2(tra("Email address"), $email_text); |
|
264
|
|
|
} |
|
265
|
|
|
if (USER_URL && $user->url) { |
|
266
|
|
|
$u = normalize_user_url($user->url); |
|
267
|
|
|
row2( |
|
268
|
|
|
tra("URL"), |
|
269
|
|
|
$u?sprintf('<a href="%s">%s</a>', $u, $u):tra('Invalid URL') |
|
270
|
|
|
); |
|
271
|
|
|
} |
|
272
|
|
|
if (USER_COUNTRY) { |
|
273
|
|
|
row2(tra("Country"), $user->country); |
|
274
|
|
|
} |
|
275
|
|
|
if (POSTAL_CODE) { |
|
276
|
|
|
row2(tra("Postal code"), $user->postal_code); |
|
277
|
|
|
} |
|
278
|
|
|
row2(tra("%1 member since", PROJECT), date_str($user->create_time)); |
|
279
|
|
|
$url_tokens = url_tokens($user->authenticator); |
|
280
|
|
|
if (LDAP_HOST && is_ldap_email($user->email_addr)) { |
|
281
|
|
|
// LDAP accounts can't change email or password |
|
282
|
|
|
// |
|
283
|
|
|
row2(tra("Change"), |
|
284
|
|
|
"<a href=\"edit_user_info_form.php?$url_tokens\">Account info</a>" |
|
285
|
|
|
); |
|
286
|
|
|
} else { |
|
287
|
|
|
$delete_account_str = ""; |
|
288
|
|
|
$config = get_config(); |
|
289
|
|
|
if (parse_bool($config, "enable_delete_account")) { |
|
290
|
|
|
$delete_account_str = " · <a href=\"delete_account_request.php\">".tra("delete account")."</a>"; |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
row2(tra("Change"), |
|
294
|
|
|
"<a href=\"edit_email_form.php\">".tra("email address")."</a> |
|
295
|
|
|
· <a href=\"".secure_url_base()."/edit_passwd_form.php\">".tra("password")."</a> |
|
296
|
|
|
· <a href=\"edit_user_info_form.php?$url_tokens\">".tra("other account info")."</a>" |
|
297
|
|
|
.$delete_account_str |
|
298
|
|
|
); |
|
299
|
|
|
} |
|
300
|
|
|
if (!UNIQUE_USER_NAME) { |
|
301
|
|
|
row2(tra("User ID")."<br/><p class=\"small\">".tra("Used in community functions")."</p>", $user->id); |
|
302
|
|
|
} |
|
303
|
|
|
if (!NO_COMPUTING) { |
|
304
|
|
|
row2( |
|
305
|
|
|
tra("Account keys"), |
|
306
|
|
|
"<a href=\"weak_auth.php\">".tra("View")."</a>" |
|
307
|
|
|
); |
|
308
|
|
|
|
|
309
|
|
|
require_once("../inc/account_ownership.inc"); |
|
310
|
|
|
if (file_exists($account_ownership_private_key_file_path)) { |
|
|
|
|
|
|
311
|
|
|
// If the server has keys configured show the account ownership form |
|
312
|
|
|
row2( |
|
313
|
|
|
tra("Account Ownership"), |
|
314
|
|
|
"<a href=\"account_ownership.php?$url_tokens\">Generate ownership proof</a>" |
|
315
|
|
|
); |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
} |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
function show_preference_links() { |
|
322
|
|
|
if (!NO_GLOBAL_PREFS) { |
|
323
|
|
|
row2( |
|
324
|
|
|
tra("When and how BOINC uses your computer"), |
|
325
|
|
|
"<a href=\"prefs.php?subset=global\">".tra("Computing preferences")."</a>" |
|
326
|
|
|
); |
|
327
|
|
|
} |
|
328
|
|
|
row2(tra("Message boards and private messages"), |
|
329
|
|
|
"<a href=\"edit_forum_preferences_form.php\">".tra("Community preferences")."</a>" |
|
330
|
|
|
); |
|
331
|
|
|
if (!NO_COMPUTING) { |
|
332
|
|
|
row2(tra("Preferences for this project"), |
|
333
|
|
|
"<a href=\"prefs.php?subset=project\">".tra("%1 preferences", PROJECT)."</a>" |
|
334
|
|
|
); |
|
335
|
|
|
} |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
// return string describing a friend: |
|
339
|
|
|
// their name, and profile picture if it exists |
|
340
|
|
|
// |
|
341
|
|
|
function friend_links($user) { |
|
342
|
|
|
$x = sprintf( |
|
343
|
|
|
'<a href="%s%s?userid=%d" style="%s">%s</a>', |
|
344
|
|
|
url_base(), |
|
345
|
|
|
SHOW_USER_PAGE, |
|
346
|
|
|
$user->id, |
|
347
|
|
|
'vertical-align:top', |
|
348
|
|
|
$user->name |
|
349
|
|
|
); |
|
350
|
|
|
if ($user->has_profile) { |
|
351
|
|
|
$profile = BoincProfile::lookup_fields("has_picture", "userid=$user->id"); |
|
352
|
|
|
if ($profile && $profile->has_picture) { |
|
353
|
|
|
$img_url = profile_thumb_url($user->id); |
|
354
|
|
|
} else { |
|
355
|
|
|
$img_url = url_base()."img/head_20.png"; |
|
356
|
|
|
} |
|
357
|
|
|
$alt = tra("Profile"); |
|
358
|
|
|
$x .= sprintf( |
|
359
|
|
|
'<a href="%sview_profile.php?userid=%d"><img title="%s" src="%s" alt="%s"></a><br>', |
|
360
|
|
|
url_base(), |
|
361
|
|
|
$user->id, |
|
362
|
|
|
tra("View the profile of %1", $user->name), |
|
363
|
|
|
$img_url, |
|
364
|
|
|
tra("Profile") |
|
365
|
|
|
); |
|
366
|
|
|
} |
|
367
|
|
|
if (function_exists("project_user_links")) { |
|
368
|
|
|
$x .= project_user_links($user); |
|
369
|
|
|
} |
|
370
|
|
|
return $x; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
// show user name, with links to profile if present. |
|
374
|
|
|
// if $badge_height is > 0, show badges |
|
375
|
|
|
// if $name_limit, limit name to N chars |
|
376
|
|
|
// |
|
377
|
|
|
function user_links($user, $badge_height=0, $name_limit=0) { |
|
378
|
|
|
if (!$user) { |
|
379
|
|
|
error_log("user_links(): null arg\n"); |
|
|
|
|
|
|
380
|
|
|
return; |
|
381
|
|
|
} |
|
382
|
|
|
BoincForumPrefs::lookup($user); |
|
383
|
|
|
$x = ""; |
|
384
|
|
|
if ($user->has_profile) { |
|
385
|
|
|
$img_url = url_base()."img/head_20.png"; |
|
386
|
|
|
$x .= sprintf( |
|
387
|
|
|
' <a href="%s%s?userid=%d"><img title="View the profile of %s" src="%s" alt="Profile"></a>', |
|
388
|
|
|
url_base(), |
|
389
|
|
|
'view_profile.php', |
|
390
|
|
|
$user->id, |
|
391
|
|
|
$user->name, |
|
392
|
|
|
$img_url |
|
393
|
|
|
); |
|
394
|
|
|
} |
|
395
|
|
|
$name = $user->name; |
|
396
|
|
|
if ($name_limit && strlen($name) > $name_limit) { |
|
397
|
|
|
$name = substr($name, 0, $name_limit)."..."; |
|
398
|
|
|
} |
|
399
|
|
|
$x .= sprintf( |
|
400
|
|
|
'<a href="%s%s?userid=%d">%s</a>', |
|
401
|
|
|
url_base(), |
|
402
|
|
|
SHOW_USER_PAGE, |
|
403
|
|
|
$user->id, |
|
404
|
|
|
$name |
|
405
|
|
|
); |
|
406
|
|
|
if (function_exists("project_user_links")){ |
|
407
|
|
|
$x .= project_user_links($user); |
|
408
|
|
|
} |
|
409
|
|
|
if ($badge_height) { |
|
410
|
|
|
$x .= badges_string(true, $user, $badge_height); |
|
411
|
|
|
} |
|
412
|
|
|
return $name_limit?"<nobr>$x</nobr>":$x; |
|
413
|
|
|
} |
|
414
|
|
|
|
|
415
|
|
|
// show community links for the logged in user |
|
416
|
|
|
// |
|
417
|
|
|
function show_community_private($user) { |
|
418
|
|
|
show_badges_row(true, $user); |
|
419
|
|
|
if (!DISABLE_PROFILES) { |
|
420
|
|
|
if ($user->has_profile) { |
|
421
|
|
|
$x = "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a> · <a href=\"delete_profile.php\">".tra("Delete")."</a>"; |
|
422
|
|
|
} else { |
|
423
|
|
|
$x = "<a href=\"create_profile.php\">".tra("Create")."</a>"; |
|
424
|
|
|
} |
|
425
|
|
|
row2(tra("Profile"), $x); |
|
426
|
|
|
} |
|
427
|
|
|
if (!DISABLE_FORUMS) { |
|
428
|
|
|
$tot = total_posts($user); |
|
429
|
|
|
if ($tot) { |
|
430
|
|
|
if (is_banished($user)) { |
|
431
|
|
|
row2(tra("Message boards"), tra('(banished)')); |
|
432
|
|
|
} else { |
|
433
|
|
|
row2( |
|
434
|
|
|
tra("Message boards"), |
|
435
|
|
|
sprintf( |
|
436
|
|
|
'<a href="%s/forum_user_posts.php?userid=%d">%s</a>', |
|
437
|
|
|
url_base(), $user->id, tra('%1 posts', $tot) |
|
438
|
|
|
) |
|
439
|
|
|
); |
|
440
|
|
|
} |
|
441
|
|
|
} |
|
442
|
|
|
} |
|
443
|
|
|
|
|
444
|
|
|
row2(tra("Private messages"), pm_notification($user).pm_email_remind($user)); |
|
445
|
|
|
|
|
446
|
|
|
$notifies = BoincNotify::enum("userid=$user->id"); |
|
447
|
|
|
if (count($notifies)) { |
|
448
|
|
|
$x = ""; |
|
449
|
|
|
foreach ($notifies as $notify) { |
|
450
|
|
|
$y = notify_description($notify); |
|
451
|
|
|
if ($y) { |
|
452
|
|
|
$x .= "• $y<br>"; |
|
453
|
|
|
} else { |
|
454
|
|
|
$notify->delete(); |
|
455
|
|
|
} |
|
456
|
|
|
} |
|
457
|
|
|
$x .= "<a href=\"".notify_rss_url($user)."\"><img vspace=\"4\" border=\"0\" src=\"img/rss_icon.gif\" alt=\"RSS\" /></a>"; |
|
458
|
|
|
row2(tra("Notifications"), $x); |
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
if (!DISABLE_TEAMS) { |
|
462
|
|
|
if ($user->teamid && ($team = BoincTeam::lookup_id($user->teamid))) { |
|
463
|
|
|
$x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a> |
|
464
|
|
|
· <a href=\"team_quit_form.php\">".tra("Quit team")."</a>"; |
|
465
|
|
|
if (is_team_admin($user, $team)) { |
|
466
|
|
|
$x .= " · <a href=\"team_manage.php?teamid=$user->teamid\">".tra("Administer")."</a>"; |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
// if there's a foundership request, notify the founder |
|
470
|
|
|
// |
|
471
|
|
|
if ($user->id==$team->userid && $team->ping_user >0) { |
|
472
|
|
|
$x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>"; |
|
473
|
|
|
} |
|
474
|
|
|
row2(tra("Member of team"), $x); |
|
475
|
|
|
} else { |
|
476
|
|
|
row2(tra("Team"), tra("None")." · <a href=\"team_search.php\">".tra("find a team")."</a>"); |
|
477
|
|
|
} |
|
478
|
|
|
|
|
479
|
|
|
$teams_founded = BoincTeam::enum("userid=$user->id"); |
|
480
|
|
|
foreach ($teams_founded as $team) { |
|
481
|
|
|
if ($team->id != $user->teamid) { |
|
482
|
|
|
$x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>"; |
|
483
|
|
|
$x .= " | <a href=\"team_manage.php?teamid=".$team->id."\">".tra("Administer")."</a>"; |
|
484
|
|
|
if ($team->ping_user > 0) { |
|
485
|
|
|
$x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</span>"; |
|
486
|
|
|
} |
|
487
|
|
|
row2(tra("Founder but not member of"), $x); |
|
488
|
|
|
} |
|
489
|
|
|
} |
|
490
|
|
|
} |
|
491
|
|
|
|
|
492
|
|
|
$friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
|
493
|
|
|
$x = []; |
|
494
|
|
|
if ($friends) { |
|
495
|
|
|
foreach($friends as $friend) { |
|
496
|
|
|
$fuser = BoincUser::lookup_id($friend->user_dest); |
|
497
|
|
|
if (!$fuser) continue; |
|
498
|
|
|
$x[] = friend_links($fuser); |
|
499
|
|
|
} |
|
500
|
|
|
row2(tra("Friends"), implode('<br>', $x)); |
|
501
|
|
|
} else { |
|
502
|
|
|
row2(tra("Friends"), '---'); |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
if (is_admin($user)) { |
|
506
|
|
|
row2('Special users', '<a href=user_permissions.php>Manage</a>'); |
|
507
|
|
|
} |
|
508
|
|
|
} |
|
509
|
|
|
|
|
510
|
|
|
// show summary of dynamic and static info (public) |
|
511
|
|
|
// |
|
512
|
|
|
function show_user_summary_public($user) { |
|
513
|
|
|
global $g_logged_in_user; |
|
514
|
|
|
if (!UNIQUE_USER_NAME) { |
|
515
|
|
|
row2(tra("User ID"), $user->id); |
|
516
|
|
|
} |
|
517
|
|
|
row2(tra("%1 member since", PROJECT), date_str($user->create_time)); |
|
518
|
|
|
if (USER_COUNTRY) { |
|
519
|
|
|
row2(tra("Country"), $user->country); |
|
520
|
|
|
} |
|
521
|
|
|
if (USER_URL && $user->url) { |
|
522
|
|
|
// don't show URL if user has no recent credit (spam suppression) |
|
523
|
|
|
// |
|
524
|
|
|
if (!NO_COMPUTING || $user->expavg_credit > 1) { |
|
525
|
|
|
$u = normalize_user_url($user->url); |
|
526
|
|
|
row2(tra("URL"), sprintf('<a href="%s">%s</a>', $u, $u)); |
|
527
|
|
|
} |
|
528
|
|
|
} |
|
529
|
|
|
if (!NO_COMPUTING) { |
|
530
|
|
|
show_credit($user); |
|
531
|
|
|
|
|
532
|
|
|
if ($user->show_hosts) { |
|
533
|
|
|
row2(tra("Computers"), "<a href=\"".url_base()."hosts_user.php?userid=$user->id\">".tra("View")."</a>"); |
|
534
|
|
|
} else { |
|
535
|
|
|
row2(tra("Computers"), tra("hidden")); |
|
536
|
|
|
} |
|
537
|
|
|
} |
|
538
|
|
|
if (function_exists("project_user_summary_public")) { |
|
539
|
|
|
project_user_summary_public($user); |
|
540
|
|
|
} |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
// return an object with data to show the user's community links |
|
544
|
|
|
// |
|
545
|
|
|
function get_community_links_object($user){ |
|
546
|
|
|
$cache_object = new StdClass; |
|
547
|
|
|
$cache_object->post_count = total_posts($user); |
|
548
|
|
|
$cache_object->user = $user; |
|
549
|
|
|
$cache_object->team = BoincTeam::lookup_id($user->teamid); |
|
550
|
|
|
$cache_object->friends = array(); |
|
551
|
|
|
|
|
552
|
|
|
$friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
|
553
|
|
|
foreach($friends as $friend) { |
|
554
|
|
|
$fuser = BoincUser::lookup_id($friend->user_dest); |
|
555
|
|
|
if (!$fuser) continue; |
|
556
|
|
|
$cache_object->friends[] = $fuser; |
|
557
|
|
|
} |
|
558
|
|
|
return $cache_object; |
|
559
|
|
|
} |
|
560
|
|
|
|
|
561
|
|
|
// show community links of another user (described by $clo) |
|
562
|
|
|
// |
|
563
|
|
|
function community_links($clo, $logged_in_user){ |
|
564
|
|
|
$user = $clo->user; |
|
565
|
|
|
if (!$user) { |
|
566
|
|
|
error_log("community_links(): null user\n"); |
|
|
|
|
|
|
567
|
|
|
return; |
|
568
|
|
|
} |
|
569
|
|
|
$team = $clo->team; |
|
570
|
|
|
$friends = $clo->friends; |
|
571
|
|
|
$tot = $clo->post_count; |
|
572
|
|
|
|
|
573
|
|
|
if (!DISABLE_TEAMS) { |
|
574
|
|
|
if ($user->teamid && $team) { |
|
575
|
|
|
row2(tra("Team"), "<a href=\"".url_base()."team_display.php?teamid=$team->id\">$team->name</a>"); |
|
576
|
|
|
} else { |
|
577
|
|
|
row2(tra("Team"), '—'); |
|
578
|
|
|
} |
|
579
|
|
|
} |
|
580
|
|
|
if (!DISABLE_FORUMS) { |
|
581
|
|
|
if ($tot) { |
|
582
|
|
|
$link = sprintf( |
|
583
|
|
|
'<a href="%s/forum_user_posts.php?userid=%d">%s</a>', |
|
584
|
|
|
url_base(), $user->id, tra("%1 posts", $tot) |
|
585
|
|
|
); |
|
586
|
|
|
if (is_banished($user)) { |
|
587
|
|
|
if (is_moderator($logged_in_user)) { |
|
588
|
|
|
row2(tra("Message boards"), $link.' (banished)'); |
|
589
|
|
|
} else { |
|
590
|
|
|
row2(tra("Message boards"), tra('(banished)')); |
|
591
|
|
|
} |
|
592
|
|
|
} else { |
|
593
|
|
|
row2(tra("Message boards"), $link); |
|
594
|
|
|
} |
|
595
|
|
|
} |
|
596
|
|
|
} |
|
597
|
|
|
if ($logged_in_user && $logged_in_user->id != $user->id) { |
|
598
|
|
|
row2(tra("Contact"), "<a href=\"pm.php?action=new&userid=".$user->id."\">".tra("Send private message")."</a>"); |
|
599
|
|
|
$friend = BoincFriend::lookup($logged_in_user->id, $user->id); |
|
600
|
|
|
if ($friend && $friend->reciprocated) { |
|
601
|
|
|
row2(tra("This person is a friend"), |
|
602
|
|
|
"<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>" |
|
603
|
|
|
); |
|
604
|
|
|
} else if ($friend) { |
|
605
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>"); |
|
606
|
|
|
} else { |
|
607
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>"); |
|
608
|
|
|
} |
|
609
|
|
|
} |
|
610
|
|
|
|
|
611
|
|
|
if ($friends) { |
|
612
|
|
|
$x = []; |
|
613
|
|
|
foreach($friends as $friend) { |
|
614
|
|
|
$x[] = friend_links($friend); |
|
615
|
|
|
} |
|
616
|
|
|
row2(tra('Friends'), implode('<br>', $x)); |
|
617
|
|
|
} |
|
618
|
|
|
} |
|
619
|
|
|
|
|
620
|
|
|
function show_profile_link($user) { |
|
621
|
|
|
if ($user->has_profile) { |
|
622
|
|
|
row2(tra("Profile"), "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a>"); |
|
623
|
|
|
} |
|
624
|
|
|
} |
|
625
|
|
|
|
|
626
|
|
|
function show_account_private($user) { |
|
627
|
|
|
grid( |
|
628
|
|
|
false, |
|
629
|
|
|
function() use ($user) { |
|
630
|
|
|
panel( |
|
631
|
|
|
tra("Account information"), |
|
632
|
|
|
function() use ($user) { |
|
633
|
|
|
start_table(); |
|
634
|
|
|
show_user_info_private($user); |
|
635
|
|
|
end_table(); |
|
636
|
|
|
} |
|
637
|
|
|
); |
|
638
|
|
|
if (!NO_COMPUTING || !NO_STATS || !NO_HOSTS) { |
|
639
|
|
|
panel( |
|
640
|
|
|
tra("Computing"), |
|
641
|
|
|
function() use($user) { |
|
|
|
|
|
|
642
|
|
|
start_table(); |
|
643
|
|
|
show_user_stats_private($user); |
|
644
|
|
|
end_table(); |
|
645
|
|
|
} |
|
646
|
|
|
); |
|
647
|
|
|
} |
|
648
|
|
|
if (function_exists('show_user_donations_private')) { |
|
649
|
|
|
show_user_donations_private($user); |
|
650
|
|
|
} |
|
651
|
|
|
if (!NO_COMPUTING) { |
|
652
|
|
|
show_other_projects($user, true); |
|
653
|
|
|
} |
|
654
|
|
|
if (function_exists("project_user_page_private")) { |
|
655
|
|
|
project_user_page_private($user); |
|
656
|
|
|
} |
|
657
|
|
|
}, |
|
658
|
|
|
function() use ($user) { |
|
659
|
|
|
panel( |
|
660
|
|
|
tra("Community"), |
|
661
|
|
|
function() use ($user) { |
|
662
|
|
|
start_table(); |
|
663
|
|
|
show_community_private($user); |
|
664
|
|
|
end_table(); |
|
665
|
|
|
} |
|
666
|
|
|
); |
|
667
|
|
|
panel( |
|
668
|
|
|
tra("Preferences"), |
|
669
|
|
|
function() use($user) { |
|
|
|
|
|
|
670
|
|
|
start_table(); |
|
671
|
|
|
show_preference_links(); |
|
672
|
|
|
end_table(); |
|
673
|
|
|
} |
|
674
|
|
|
); |
|
675
|
|
|
} |
|
676
|
|
|
); |
|
677
|
|
|
} |
|
678
|
|
|
|
|
679
|
|
|
|
|
680
|
|
|
|
|
681
|
|
|
?> |
|
682
|
|
|
|