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
|
|
|
if (parse_bool(get_config(), 'keyword_sched')) { |
337
|
|
|
row2( |
338
|
|
|
tra('What types of jobs to run'), |
339
|
|
|
sprintf('<a href=kw_prefs.php>%s</a>', |
340
|
|
|
tra('Science and location preferences') |
341
|
|
|
) |
342
|
|
|
); |
343
|
|
|
} |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
// return string describing a friend: |
347
|
|
|
// their name, and profile picture if it exists |
348
|
|
|
// |
349
|
|
|
function friend_links($user) { |
350
|
|
|
$x = sprintf( |
351
|
|
|
'<a href="%s%s?userid=%d" style="%s">%s</a>', |
352
|
|
|
url_base(), |
353
|
|
|
SHOW_USER_PAGE, |
354
|
|
|
$user->id, |
355
|
|
|
'vertical-align:top', |
356
|
|
|
$user->name |
357
|
|
|
); |
358
|
|
|
if ($user->has_profile) { |
359
|
|
|
$profile = BoincProfile::lookup_fields("has_picture", "userid=$user->id"); |
360
|
|
|
if ($profile && $profile->has_picture) { |
361
|
|
|
$img_url = profile_thumb_url($user->id); |
362
|
|
|
} else { |
363
|
|
|
$img_url = url_base()."img/head_20.png"; |
364
|
|
|
} |
365
|
|
|
$alt = tra("Profile"); |
366
|
|
|
$x .= sprintf( |
367
|
|
|
'<a href="%sview_profile.php?userid=%d"><img title="%s" src="%s" alt="%s"></a><br>', |
368
|
|
|
url_base(), |
369
|
|
|
$user->id, |
370
|
|
|
tra("View the profile of %1", $user->name), |
371
|
|
|
$img_url, |
372
|
|
|
tra("Profile") |
373
|
|
|
); |
374
|
|
|
} |
375
|
|
|
if (function_exists("project_user_links")) { |
376
|
|
|
$x .= project_user_links($user); |
377
|
|
|
} |
378
|
|
|
return $x; |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
// show user name, with links to profile if present. |
382
|
|
|
// if $badge_height is > 0, show badges |
383
|
|
|
// if $name_limit, limit name to N chars |
384
|
|
|
// |
385
|
|
|
function user_links($user, $badge_height=0, $name_limit=0) { |
386
|
|
|
if (!$user) { |
387
|
|
|
error_log("user_links(): null arg\n"); |
|
|
|
|
388
|
|
|
return; |
389
|
|
|
} |
390
|
|
|
BoincForumPrefs::lookup($user); |
391
|
|
|
$x = ""; |
392
|
|
|
if ($user->has_profile) { |
393
|
|
|
$img_url = url_base()."img/head_20.png"; |
394
|
|
|
$x .= sprintf( |
395
|
|
|
' <a href="%s%s?userid=%d"><img title="View the profile of %s" src="%s" alt="Profile"></a>', |
396
|
|
|
url_base(), |
397
|
|
|
'view_profile.php', |
398
|
|
|
$user->id, |
399
|
|
|
$user->name, |
400
|
|
|
$img_url |
401
|
|
|
); |
402
|
|
|
} |
403
|
|
|
$name = $user->name; |
404
|
|
|
if ($name_limit && strlen($name) > $name_limit) { |
405
|
|
|
$name = substr($name, 0, $name_limit)."..."; |
406
|
|
|
} |
407
|
|
|
$x .= sprintf( |
408
|
|
|
'<a href="%s%s?userid=%d">%s</a>', |
409
|
|
|
url_base(), |
410
|
|
|
SHOW_USER_PAGE, |
411
|
|
|
$user->id, |
412
|
|
|
$name |
413
|
|
|
); |
414
|
|
|
if (function_exists("project_user_links")){ |
415
|
|
|
$x .= project_user_links($user); |
416
|
|
|
} |
417
|
|
|
if ($badge_height) { |
418
|
|
|
$x .= badges_string(true, $user, $badge_height); |
419
|
|
|
} |
420
|
|
|
return $name_limit?"<nobr>$x</nobr>":$x; |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
// show community links for the logged in user |
424
|
|
|
// |
425
|
|
|
function show_community_private($user) { |
426
|
|
|
show_badges_row(true, $user); |
427
|
|
|
if (!DISABLE_PROFILES) { |
428
|
|
|
if ($user->has_profile) { |
429
|
|
|
$x = "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a> · <a href=\"delete_profile.php\">".tra("Delete")."</a>"; |
430
|
|
|
} else { |
431
|
|
|
$x = "<a href=\"create_profile.php\">".tra("Create")."</a>"; |
432
|
|
|
} |
433
|
|
|
row2(tra("Profile"), $x); |
434
|
|
|
} |
435
|
|
|
if (!DISABLE_FORUMS) { |
436
|
|
|
$tot = total_posts($user); |
437
|
|
|
if ($tot) { |
438
|
|
|
if (is_banished($user)) { |
439
|
|
|
row2(tra("Message boards"), tra('(banished)')); |
440
|
|
|
} else { |
441
|
|
|
row2( |
442
|
|
|
tra("Message boards"), |
443
|
|
|
sprintf( |
444
|
|
|
'<a href="%s/forum_user_posts.php?userid=%d">%s</a>', |
445
|
|
|
url_base(), $user->id, tra('%1 posts', $tot) |
446
|
|
|
) |
447
|
|
|
); |
448
|
|
|
} |
449
|
|
|
} |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
row2(tra("Private messages"), pm_notification($user).pm_email_remind($user)); |
453
|
|
|
|
454
|
|
|
$notifies = BoincNotify::enum("userid=$user->id"); |
455
|
|
|
if (count($notifies)) { |
456
|
|
|
$x = ""; |
457
|
|
|
foreach ($notifies as $notify) { |
458
|
|
|
$y = notify_description($notify); |
459
|
|
|
if ($y) { |
460
|
|
|
$x .= "• $y<br>"; |
461
|
|
|
} else { |
462
|
|
|
$notify->delete(); |
463
|
|
|
} |
464
|
|
|
} |
465
|
|
|
$x .= "<a href=\"".notify_rss_url($user)."\"><img vspace=\"4\" border=\"0\" src=\"img/rss_icon.gif\" alt=\"RSS\" /></a>"; |
466
|
|
|
row2(tra("Notifications"), $x); |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
if (!DISABLE_TEAMS) { |
470
|
|
|
if ($user->teamid && ($team = BoincTeam::lookup_id($user->teamid))) { |
471
|
|
|
$x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a> |
472
|
|
|
· <a href=\"team_quit_form.php\">".tra("Quit team")."</a>"; |
473
|
|
|
if (is_team_admin($user, $team)) { |
474
|
|
|
$x .= " · <a href=\"team_manage.php?teamid=$user->teamid\">".tra("Administer")."</a>"; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
// if there's a foundership request, notify the founder |
478
|
|
|
// |
479
|
|
|
if ($user->id==$team->userid && $team->ping_user >0) { |
480
|
|
|
$x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>"; |
481
|
|
|
} |
482
|
|
|
row2(tra("Member of team"), $x); |
483
|
|
|
} else { |
484
|
|
|
row2(tra("Team"), tra("None")." · <a href=\"team_search.php\">".tra("find a team")."</a>"); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
$teams_founded = BoincTeam::enum("userid=$user->id"); |
488
|
|
|
foreach ($teams_founded as $team) { |
489
|
|
|
if ($team->id != $user->teamid) { |
490
|
|
|
$x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>"; |
491
|
|
|
$x .= " | <a href=\"team_manage.php?teamid=".$team->id."\">".tra("Administer")."</a>"; |
492
|
|
|
if ($team->ping_user > 0) { |
493
|
|
|
$x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</span>"; |
494
|
|
|
} |
495
|
|
|
row2(tra("Founder but not member of"), $x); |
496
|
|
|
} |
497
|
|
|
} |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
$friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
501
|
|
|
$x = []; |
502
|
|
|
if ($friends) { |
503
|
|
|
foreach($friends as $friend) { |
504
|
|
|
$fuser = BoincUser::lookup_id($friend->user_dest); |
505
|
|
|
if (!$fuser) continue; |
506
|
|
|
$x[] = friend_links($fuser); |
507
|
|
|
} |
508
|
|
|
row2(tra("Friends"), implode('<br>', $x)); |
509
|
|
|
} else { |
510
|
|
|
row2(tra("Friends"), '---'); |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
if (is_admin($user)) { |
514
|
|
|
row2('Special users', '<a href=user_permissions.php>Manage</a>'); |
515
|
|
|
} |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
// show summary of dynamic and static info (public) |
519
|
|
|
// |
520
|
|
|
function show_user_summary_public($user) { |
521
|
|
|
global $g_logged_in_user; |
522
|
|
|
if (!UNIQUE_USER_NAME) { |
523
|
|
|
row2(tra("User ID"), $user->id); |
524
|
|
|
} |
525
|
|
|
row2(tra("%1 member since", PROJECT), date_str($user->create_time)); |
526
|
|
|
if (USER_COUNTRY) { |
527
|
|
|
row2(tra("Country"), $user->country); |
528
|
|
|
} |
529
|
|
|
if (USER_URL && $user->url) { |
530
|
|
|
// don't show URL if user has no recent credit (spam suppression) |
531
|
|
|
// |
532
|
|
|
if (!NO_COMPUTING || $user->expavg_credit > 1) { |
533
|
|
|
$u = normalize_user_url($user->url); |
534
|
|
|
row2(tra("URL"), sprintf('<a href="%s">%s</a>', $u, $u)); |
535
|
|
|
} |
536
|
|
|
} |
537
|
|
|
if (!NO_COMPUTING) { |
538
|
|
|
show_credit($user); |
539
|
|
|
|
540
|
|
|
if ($user->show_hosts) { |
541
|
|
|
row2(tra("Computers"), "<a href=\"".url_base()."hosts_user.php?userid=$user->id\">".tra("View")."</a>"); |
542
|
|
|
} else { |
543
|
|
|
row2(tra("Computers"), tra("hidden")); |
544
|
|
|
} |
545
|
|
|
} |
546
|
|
|
if (function_exists("project_user_summary_public")) { |
547
|
|
|
project_user_summary_public($user); |
548
|
|
|
} |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
// return an object with data to show the user's community links |
552
|
|
|
// |
553
|
|
|
function get_community_links_object($user){ |
554
|
|
|
$cache_object = new StdClass; |
555
|
|
|
$cache_object->post_count = total_posts($user); |
556
|
|
|
$cache_object->user = $user; |
557
|
|
|
$cache_object->team = BoincTeam::lookup_id($user->teamid); |
558
|
|
|
$cache_object->friends = array(); |
559
|
|
|
|
560
|
|
|
$friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
561
|
|
|
foreach($friends as $friend) { |
562
|
|
|
$fuser = BoincUser::lookup_id($friend->user_dest); |
563
|
|
|
if (!$fuser) continue; |
564
|
|
|
$cache_object->friends[] = $fuser; |
565
|
|
|
} |
566
|
|
|
return $cache_object; |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
// show community links of another user (described by $clo) |
570
|
|
|
// |
571
|
|
|
function community_links($clo, $logged_in_user){ |
572
|
|
|
$user = $clo->user; |
573
|
|
|
if (!$user) { |
574
|
|
|
error_log("community_links(): null user\n"); |
|
|
|
|
575
|
|
|
return; |
576
|
|
|
} |
577
|
|
|
$team = $clo->team; |
578
|
|
|
$friends = $clo->friends; |
579
|
|
|
$tot = $clo->post_count; |
580
|
|
|
|
581
|
|
|
if (!DISABLE_TEAMS) { |
582
|
|
|
if ($user->teamid && $team) { |
583
|
|
|
row2(tra("Team"), "<a href=\"".url_base()."team_display.php?teamid=$team->id\">$team->name</a>"); |
584
|
|
|
} else { |
585
|
|
|
row2(tra("Team"), '—'); |
586
|
|
|
} |
587
|
|
|
} |
588
|
|
|
if (!DISABLE_FORUMS) { |
589
|
|
|
if ($tot) { |
590
|
|
|
$link = sprintf( |
591
|
|
|
'<a href="%s/forum_user_posts.php?userid=%d">%s</a>', |
592
|
|
|
url_base(), $user->id, tra("%1 posts", $tot) |
593
|
|
|
); |
594
|
|
|
if (is_banished($user)) { |
595
|
|
|
if (is_moderator($logged_in_user)) { |
596
|
|
|
row2(tra("Message boards"), $link.' (banished)'); |
597
|
|
|
} else { |
598
|
|
|
row2(tra("Message boards"), tra('(banished)')); |
599
|
|
|
} |
600
|
|
|
} else { |
601
|
|
|
row2(tra("Message boards"), $link); |
602
|
|
|
} |
603
|
|
|
} |
604
|
|
|
} |
605
|
|
|
if ($logged_in_user && $logged_in_user->id != $user->id) { |
606
|
|
|
row2(tra("Contact"), "<a href=\"pm.php?action=new&userid=".$user->id."\">".tra("Send private message")."</a>"); |
607
|
|
|
$friend = BoincFriend::lookup($logged_in_user->id, $user->id); |
608
|
|
|
if ($friend && $friend->reciprocated) { |
609
|
|
|
row2(tra("This person is a friend"), |
610
|
|
|
"<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>" |
611
|
|
|
); |
612
|
|
|
} else if ($friend) { |
613
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>"); |
614
|
|
|
} else { |
615
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>"); |
616
|
|
|
} |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
if ($friends) { |
620
|
|
|
$x = []; |
621
|
|
|
foreach($friends as $friend) { |
622
|
|
|
$x[] = friend_links($friend); |
623
|
|
|
} |
624
|
|
|
row2(tra('Friends'), implode('<br>', $x)); |
625
|
|
|
} |
626
|
|
|
} |
627
|
|
|
|
628
|
|
|
function show_profile_link($user) { |
629
|
|
|
if ($user->has_profile) { |
630
|
|
|
row2(tra("Profile"), "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a>"); |
631
|
|
|
} |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
function show_account_private($user) { |
635
|
|
|
grid( |
636
|
|
|
false, |
637
|
|
|
function() use ($user) { |
638
|
|
|
panel( |
639
|
|
|
tra("Account information"), |
640
|
|
|
function() use ($user) { |
641
|
|
|
start_table(); |
642
|
|
|
show_user_info_private($user); |
643
|
|
|
end_table(); |
644
|
|
|
} |
645
|
|
|
); |
646
|
|
|
if (!NO_COMPUTING || !NO_STATS || !NO_HOSTS) { |
647
|
|
|
panel( |
648
|
|
|
tra("Computing"), |
649
|
|
|
function() use($user) { |
|
|
|
|
650
|
|
|
start_table(); |
651
|
|
|
show_user_stats_private($user); |
652
|
|
|
end_table(); |
653
|
|
|
} |
654
|
|
|
); |
655
|
|
|
} |
656
|
|
|
if (function_exists('show_user_donations_private')) { |
657
|
|
|
show_user_donations_private($user); |
658
|
|
|
} |
659
|
|
|
if (!NO_COMPUTING) { |
660
|
|
|
show_other_projects($user, true); |
661
|
|
|
} |
662
|
|
|
if (function_exists("project_user_page_private")) { |
663
|
|
|
project_user_page_private($user); |
664
|
|
|
} |
665
|
|
|
}, |
666
|
|
|
function() use ($user) { |
667
|
|
|
panel( |
668
|
|
|
tra("Community"), |
669
|
|
|
function() use ($user) { |
670
|
|
|
start_table(); |
671
|
|
|
show_community_private($user); |
672
|
|
|
end_table(); |
673
|
|
|
} |
674
|
|
|
); |
675
|
|
|
panel( |
676
|
|
|
tra("Preferences"), |
677
|
|
|
function() use($user) { |
|
|
|
|
678
|
|
|
start_table(); |
679
|
|
|
show_preference_links(); |
680
|
|
|
end_table(); |
681
|
|
|
} |
682
|
|
|
); |
683
|
|
|
} |
684
|
|
|
); |
685
|
|
|
} |
686
|
|
|
|
687
|
|
|
|
688
|
|
|
|
689
|
|
|
?> |
690
|
|
|
|