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_POST: |
211
|
|
|
return subscribed_post_web_line($notify); |
212
|
|
|
} |
213
|
|
|
return null; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
// a string that can be used to authenticate some operations, |
217
|
|
|
// but can't be used to log in to the account |
218
|
|
|
// (e.g. can't be used to change email addr or passwd) |
219
|
|
|
// |
220
|
|
|
// this is a function of |
221
|
|
|
// - authenticator (never changes) |
222
|
|
|
// - user ID (never changes) |
223
|
|
|
// - password |
224
|
|
|
// - email addr |
225
|
|
|
// |
226
|
|
|
function weak_auth($user) { |
227
|
|
|
$x = md5($user->authenticator.$user->passwd_hash); |
228
|
|
|
return "{$user->id}_$x"; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
// originally user URLs were assumed to be http://, |
232
|
|
|
// and this prefix wasn't stored. |
233
|
|
|
// Now the prefix can be http:// or https://. |
234
|
|
|
// This function takes a user URL in any form and converts |
235
|
|
|
// it to a canonical form, with the protocol prefix. |
236
|
|
|
// |
237
|
|
|
function normalize_user_url($url) { |
238
|
|
|
$url = sanitize_user_url($url); |
239
|
|
|
if (!$url) return ''; |
240
|
|
|
$x = strtolower($url); |
241
|
|
|
if (substr($x, 0, 7) == 'http://') { |
242
|
|
|
return 'http://'.substr($url, 7); |
243
|
|
|
} |
244
|
|
|
if (substr($x, 0, 8) == 'https://') { |
245
|
|
|
return 'https://'.substr($url, 8); |
246
|
|
|
} |
247
|
|
|
return 'http://'.$url; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
// show static user info (private) |
251
|
|
|
// |
252
|
|
|
function show_user_info_private($user) { |
253
|
|
|
row2(tra("Name"), $user->name); |
254
|
|
|
if (LDAP_HOST && is_ldap_email($user->email_addr)) { |
255
|
|
|
row2("LDAP ID", ldap_email_to_uid($user->email_addr)); |
256
|
|
|
} else { |
257
|
|
|
$email_text = $user->email_addr; |
258
|
|
|
if (defined("SHOW_NONVALIDATED_EMAIL_ADDR") && !$user->email_validated) { |
259
|
|
|
$email_text .= " (<a href=validate_email_addr.php>must be validated</a>)"; |
260
|
|
|
} |
261
|
|
|
row2(tra("Email address"), $email_text); |
262
|
|
|
} |
263
|
|
|
if (USER_URL && $user->url) { |
264
|
|
|
$u = normalize_user_url($user->url); |
265
|
|
|
row2( |
266
|
|
|
tra("URL"), |
267
|
|
|
$u?sprintf('<a href="%s">%s</a>', $u, $u):tra('Invalid URL') |
268
|
|
|
); |
269
|
|
|
} |
270
|
|
|
if (USER_COUNTRY) { |
271
|
|
|
row2(tra("Country"), $user->country); |
272
|
|
|
} |
273
|
|
|
if (POSTAL_CODE) { |
274
|
|
|
row2(tra("Postal code"), $user->postal_code); |
275
|
|
|
} |
276
|
|
|
row2(tra("%1 member since", PROJECT), date_str($user->create_time)); |
277
|
|
|
$url_tokens = url_tokens($user->authenticator); |
278
|
|
|
if (LDAP_HOST && is_ldap_email($user->email_addr)) { |
279
|
|
|
// LDAP accounts can't change email or password |
280
|
|
|
// |
281
|
|
|
row2(tra("Change"), |
282
|
|
|
"<a href=\"edit_user_info_form.php?$url_tokens\">Account info</a>" |
283
|
|
|
); |
284
|
|
|
} else { |
285
|
|
|
$delete_account_str = ""; |
286
|
|
|
$config = get_config(); |
287
|
|
|
if (parse_bool($config, "enable_delete_account")) { |
288
|
|
|
$delete_account_str = " · <a href=\"delete_account_request.php\">".tra("delete account")."</a>"; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
row2(tra("Change"), |
292
|
|
|
"<a href=\"edit_email_form.php\">".tra("email address")."</a> |
293
|
|
|
· <a href=\"".secure_url_base()."/edit_passwd_form.php\">".tra("password")."</a> |
294
|
|
|
· <a href=\"edit_user_info_form.php?$url_tokens\">".tra("other account info")."</a>" |
295
|
|
|
.$delete_account_str |
296
|
|
|
); |
297
|
|
|
} |
298
|
|
|
if (!UNIQUE_USER_NAME) { |
299
|
|
|
row2(tra("User ID")."<br/><p class=\"small\">".tra("Used in community functions")."</p>", $user->id); |
300
|
|
|
} |
301
|
|
|
if (!NO_COMPUTING) { |
302
|
|
|
row2( |
303
|
|
|
tra("Account keys"), |
304
|
|
|
"<a href=\"weak_auth.php\">".tra("View")."</a>" |
305
|
|
|
); |
306
|
|
|
|
307
|
|
|
require_once("../inc/account_ownership.inc"); |
308
|
|
|
if (file_exists($account_ownership_private_key_file_path)) { |
|
|
|
|
309
|
|
|
// If the server has keys configured show the account ownership form |
310
|
|
|
row2( |
311
|
|
|
tra("Account Ownership"), |
312
|
|
|
"<a href=\"account_ownership.php?$url_tokens\">Generate ownership proof</a>" |
313
|
|
|
); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
} |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
function show_preference_links() { |
320
|
|
|
if (!NO_GLOBAL_PREFS) { |
321
|
|
|
row2( |
322
|
|
|
tra("When and how BOINC uses your computer"), |
323
|
|
|
"<a href=\"prefs.php?subset=global\">".tra("Computing preferences")."</a>" |
324
|
|
|
); |
325
|
|
|
} |
326
|
|
|
row2(tra("Message boards and private messages"), |
327
|
|
|
"<a href=\"edit_forum_preferences_form.php\">".tra("Community preferences")."</a>" |
328
|
|
|
); |
329
|
|
|
if (!NO_COMPUTING) { |
330
|
|
|
row2(tra("Preferences for this project"), |
331
|
|
|
"<a href=\"prefs.php?subset=project\">".tra("%1 preferences", PROJECT)."</a>" |
332
|
|
|
); |
333
|
|
|
} |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
// return string describing a friend: |
337
|
|
|
// their name, and profile picture if it exists |
338
|
|
|
// |
339
|
|
|
function friend_links($user) { |
340
|
|
|
if (is_banished($user)) { |
341
|
|
|
return ""; |
342
|
|
|
} |
343
|
|
|
$x = sprintf( |
344
|
|
|
'<a href="%s%s?userid=%d" style="%s">%s</a>', |
345
|
|
|
url_base(), |
346
|
|
|
SHOW_USER_PAGE, |
347
|
|
|
$user->id, |
348
|
|
|
'vertical-align:top', |
349
|
|
|
$user->name |
350
|
|
|
); |
351
|
|
|
if ($user->has_profile) { |
352
|
|
|
$profile = BoincProfile::lookup_fields("has_picture", "userid=$user->id"); |
353
|
|
|
if ($profile && $profile->has_picture) { |
354
|
|
|
$img_url = profile_thumb_url($user->id); |
355
|
|
|
} else { |
356
|
|
|
$img_url = url_base()."img/head_20.png"; |
357
|
|
|
} |
358
|
|
|
$alt = tra("Profile"); |
359
|
|
|
$x .= sprintf( |
360
|
|
|
'<a href="%sview_profile.php?userid=%d"><img title="%s" src="%s" alt="%s"></a><br>', |
361
|
|
|
url_base(), |
362
|
|
|
$user->id, |
363
|
|
|
tra("View the profile of %1", $user->name), |
364
|
|
|
$img_url, |
365
|
|
|
tra("Profile") |
366
|
|
|
); |
367
|
|
|
} |
368
|
|
|
if (function_exists("project_user_links")) { |
369
|
|
|
$x .= project_user_links($user); |
370
|
|
|
} |
371
|
|
|
return $x; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
// show user name, with links to profile if present. |
375
|
|
|
// if $badge_height is > 0, show badges |
376
|
|
|
// if $name_limit, limit name to N chars |
377
|
|
|
// |
378
|
|
|
function user_links($user, $badge_height=0, $name_limit=0) { |
379
|
|
|
if (!$user) { |
380
|
|
|
error_log("user_links(): null arg\n"); |
|
|
|
|
381
|
|
|
return; |
382
|
|
|
} |
383
|
|
|
BoincForumPrefs::lookup($user); |
384
|
|
|
if (is_banished($user)) { |
385
|
|
|
return "(banished: ID $user->id)"; |
386
|
|
|
} |
387
|
|
|
$x = ""; |
388
|
|
|
if ($user->has_profile) { |
389
|
|
|
$img_url = url_base()."img/head_20.png"; |
390
|
|
|
$x .= sprintf( |
391
|
|
|
' <a href="%s%s?userid=%d"><img title="View the profile of %s" src="%s" alt="Profile"></a>', |
392
|
|
|
url_base(), |
393
|
|
|
'view_profile.php', |
394
|
|
|
$user->id, |
395
|
|
|
$user->name, |
396
|
|
|
$img_url |
397
|
|
|
); |
398
|
|
|
} |
399
|
|
|
$name = $user->name; |
400
|
|
|
if ($name_limit && strlen($name) > $name_limit) { |
401
|
|
|
$name = substr($name, 0, $name_limit)."..."; |
402
|
|
|
} |
403
|
|
|
$x .= sprintf( |
404
|
|
|
'<a href="%s%s?userid=%d">%s</a>', |
405
|
|
|
url_base(), |
406
|
|
|
SHOW_USER_PAGE, |
407
|
|
|
$user->id, |
408
|
|
|
$name |
409
|
|
|
); |
410
|
|
|
if (function_exists("project_user_links")){ |
411
|
|
|
$x .= project_user_links($user); |
412
|
|
|
} |
413
|
|
|
if ($badge_height) { |
414
|
|
|
$x .= badges_string(true, $user, $badge_height); |
415
|
|
|
} |
416
|
|
|
return $name_limit?"<nobr>$x</nobr>":$x; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
function show_community_private($user) { |
420
|
|
|
show_badges_row(true, $user); |
421
|
|
|
if (!DISABLE_PROFILES) { |
422
|
|
|
if ($user->has_profile) { |
423
|
|
|
$x = "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a> · <a href=\"delete_profile.php\">".tra("Delete")."</a>"; |
424
|
|
|
} else { |
425
|
|
|
$x = "<a href=\"create_profile.php\">".tra("Create")."</a>"; |
426
|
|
|
} |
427
|
|
|
row2(tra("Profile"), $x); |
428
|
|
|
} |
429
|
|
|
if (!DISABLE_FORUMS) { |
430
|
|
|
$tot = total_posts($user); |
431
|
|
|
if ($tot) { |
432
|
|
|
row2(tra("Message boards"), "<a href=\"".url_base()."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>"); |
433
|
|
|
} |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
row2(tra("Private messages"), pm_notification($user).pm_email_remind($user)); |
437
|
|
|
|
438
|
|
|
$notifies = BoincNotify::enum("userid=$user->id"); |
439
|
|
|
if (count($notifies)) { |
440
|
|
|
$x = ""; |
441
|
|
|
foreach ($notifies as $notify) { |
442
|
|
|
$y = notify_description($notify); |
443
|
|
|
if ($y) { |
444
|
|
|
$x .= "• $y<br>"; |
445
|
|
|
} else { |
446
|
|
|
$notify->delete(); |
447
|
|
|
} |
448
|
|
|
} |
449
|
|
|
$x .= "<a href=\"".notify_rss_url($user)."\"><img vspace=\"4\" border=\"0\" src=\"img/rss_icon.gif\" alt=\"RSS\" /></a>"; |
450
|
|
|
row2(tra("Notifications"), $x); |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
if (!DISABLE_TEAMS) { |
454
|
|
|
if ($user->teamid && ($team = BoincTeam::lookup_id($user->teamid))) { |
455
|
|
|
$x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a> |
456
|
|
|
· <a href=\"team_quit_form.php\">".tra("Quit team")."</a>"; |
457
|
|
|
if (is_team_admin($user, $team)) { |
458
|
|
|
$x .= " · <a href=\"team_manage.php?teamid=$user->teamid\">".tra("Administer")."</a>"; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
// if there's a foundership request, notify the founder |
462
|
|
|
// |
463
|
|
|
if ($user->id==$team->userid && $team->ping_user >0) { |
464
|
|
|
$x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>"; |
465
|
|
|
} |
466
|
|
|
row2(tra("Member of team"), $x); |
467
|
|
|
} else { |
468
|
|
|
row2(tra("Team"), tra("None")." · <a href=\"team_search.php\">".tra("find a team")."</a>"); |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
$teams_founded = BoincTeam::enum("userid=$user->id"); |
472
|
|
|
foreach ($teams_founded as $team) { |
473
|
|
|
if ($team->id != $user->teamid) { |
474
|
|
|
$x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>"; |
475
|
|
|
$x .= " | <a href=\"team_manage.php?teamid=".$team->id."\">".tra("Administer")."</a>"; |
476
|
|
|
if ($team->ping_user > 0) { |
477
|
|
|
$x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</span>"; |
478
|
|
|
} |
479
|
|
|
row2(tra("Founder but not member of"), $x); |
480
|
|
|
} |
481
|
|
|
} |
482
|
|
|
} |
483
|
|
|
|
484
|
|
|
$friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
485
|
|
|
$x = []; |
486
|
|
|
if ($friends) { |
487
|
|
|
foreach($friends as $friend) { |
488
|
|
|
$fuser = BoincUser::lookup_id($friend->user_dest); |
489
|
|
|
if (!$fuser) continue; |
490
|
|
|
$x[] = friend_links($fuser); |
491
|
|
|
} |
492
|
|
|
row2(tra("Friends"), implode('<br>', $x)); |
493
|
|
|
} else { |
494
|
|
|
row2(tra("Friends"), '---'); |
495
|
|
|
} |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
// show summary of dynamic and static info (public) |
499
|
|
|
// |
500
|
|
|
function show_user_summary_public($user) { |
501
|
|
|
global $g_logged_in_user; |
502
|
|
|
if (!UNIQUE_USER_NAME) { |
503
|
|
|
row2(tra("User ID"), $user->id); |
504
|
|
|
} |
505
|
|
|
row2(tra("%1 member since", PROJECT), date_str($user->create_time)); |
506
|
|
|
if (USER_COUNTRY) { |
507
|
|
|
row2(tra("Country"), $user->country); |
508
|
|
|
} |
509
|
|
|
if (USER_URL && $user->url) { |
510
|
|
|
// don't show URL if user has no recent credit (spam suppression) |
511
|
|
|
// |
512
|
|
|
if (!NO_COMPUTING || $user->expavg_credit > 1) { |
513
|
|
|
$u = normalize_user_url($user->url); |
514
|
|
|
row2(tra("URL"), sprintf('<a href="%s">%s</a>', $u, $u)); |
515
|
|
|
} |
516
|
|
|
} |
517
|
|
|
if (!NO_COMPUTING) { |
518
|
|
|
show_credit($user); |
519
|
|
|
|
520
|
|
|
if ($user->show_hosts) { |
521
|
|
|
row2(tra("Computers"), "<a href=\"".url_base()."hosts_user.php?userid=$user->id\">".tra("View")."</a>"); |
522
|
|
|
} else { |
523
|
|
|
row2(tra("Computers"), tra("hidden")); |
524
|
|
|
} |
525
|
|
|
} |
526
|
|
|
if (function_exists("project_user_summary_public")) { |
527
|
|
|
project_user_summary_public($user); |
528
|
|
|
} |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
// return an object with data to show the user's community links |
532
|
|
|
// |
533
|
|
|
function get_community_links_object($user){ |
534
|
|
|
$cache_object = new StdClass; |
535
|
|
|
$cache_object->post_count = total_posts($user); |
536
|
|
|
$cache_object->user = $user; |
537
|
|
|
$cache_object->team = BoincTeam::lookup_id($user->teamid); |
538
|
|
|
$cache_object->friends = array(); |
539
|
|
|
|
540
|
|
|
$friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
541
|
|
|
foreach($friends as $friend) { |
542
|
|
|
$fuser = BoincUser::lookup_id($friend->user_dest); |
543
|
|
|
if (!$fuser) continue; |
544
|
|
|
$cache_object->friends[] = $fuser; |
545
|
|
|
} |
546
|
|
|
return $cache_object; |
547
|
|
|
} |
548
|
|
|
|
549
|
|
|
// show community links of another user (described by $clo) |
550
|
|
|
// |
551
|
|
|
function community_links($clo, $logged_in_user){ |
552
|
|
|
$user = $clo->user; |
553
|
|
|
if (!$user) { |
554
|
|
|
error_log("community_links(): null user\n"); |
|
|
|
|
555
|
|
|
return; |
556
|
|
|
} |
557
|
|
|
$team = $clo->team; |
558
|
|
|
$friends = $clo->friends; |
559
|
|
|
$tot = $clo->post_count; |
560
|
|
|
|
561
|
|
|
if (!DISABLE_TEAMS) { |
562
|
|
|
if ($user->teamid && $team) { |
563
|
|
|
row2(tra("Team"), "<a href=\"".url_base()."team_display.php?teamid=$team->id\">$team->name</a>"); |
564
|
|
|
} else { |
565
|
|
|
row2(tra("Team"), '—'); |
566
|
|
|
} |
567
|
|
|
} |
568
|
|
|
if (!DISABLE_FORUMS) { |
569
|
|
|
if ($tot) { |
570
|
|
|
row2(tra("Message boards"), "<a href=\"".url_base()."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>"); |
571
|
|
|
} |
572
|
|
|
} |
573
|
|
|
if ($logged_in_user && $logged_in_user->id != $user->id) { |
574
|
|
|
row2(tra("Contact"), "<a href=\"pm.php?action=new&userid=".$user->id."\">".tra("Send private message")."</a>"); |
575
|
|
|
$friend = BoincFriend::lookup($logged_in_user->id, $user->id); |
576
|
|
|
if ($friend && $friend->reciprocated) { |
577
|
|
|
row2(tra("This person is a friend"), |
578
|
|
|
"<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>" |
579
|
|
|
); |
580
|
|
|
} else if ($friend) { |
581
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>"); |
582
|
|
|
} else { |
583
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>"); |
584
|
|
|
} |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
if ($friends) { |
588
|
|
|
$x = []; |
589
|
|
|
foreach($friends as $friend) { |
590
|
|
|
$x[] = friend_links($friend); |
591
|
|
|
} |
592
|
|
|
row2(tra('Friends'), implode('<br>', $x)); |
593
|
|
|
} |
594
|
|
|
} |
595
|
|
|
|
596
|
|
|
function show_profile_link($user) { |
597
|
|
|
if ($user->has_profile) { |
598
|
|
|
row2(tra("Profile"), "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a>"); |
599
|
|
|
} |
600
|
|
|
} |
601
|
|
|
|
602
|
|
|
function show_account_private($user) { |
603
|
|
|
grid( |
604
|
|
|
false, |
605
|
|
|
function() use ($user) { |
606
|
|
|
panel( |
607
|
|
|
tra("Account information"), |
608
|
|
|
function() use ($user) { |
609
|
|
|
start_table(); |
610
|
|
|
show_user_info_private($user); |
611
|
|
|
end_table(); |
612
|
|
|
} |
613
|
|
|
); |
614
|
|
|
if (!NO_COMPUTING || !NO_STATS || !NO_HOSTS) { |
615
|
|
|
panel( |
616
|
|
|
tra("Computing"), |
617
|
|
|
function() use($user) { |
|
|
|
|
618
|
|
|
start_table(); |
619
|
|
|
show_user_stats_private($user); |
620
|
|
|
end_table(); |
621
|
|
|
} |
622
|
|
|
); |
623
|
|
|
} |
624
|
|
|
if (function_exists('show_user_donations_private')) { |
625
|
|
|
show_user_donations_private($user); |
626
|
|
|
} |
627
|
|
|
if (!NO_COMPUTING) { |
628
|
|
|
show_other_projects($user, true); |
629
|
|
|
} |
630
|
|
|
if (function_exists("project_user_page_private")) { |
631
|
|
|
project_user_page_private($user); |
632
|
|
|
} |
633
|
|
|
}, |
634
|
|
|
function() use ($user) { |
635
|
|
|
panel( |
636
|
|
|
tra("Community"), |
637
|
|
|
function() use ($user) { |
638
|
|
|
start_table(); |
639
|
|
|
show_community_private($user); |
640
|
|
|
end_table(); |
641
|
|
|
} |
642
|
|
|
); |
643
|
|
|
panel( |
644
|
|
|
tra("Preferences"), |
645
|
|
|
function() use($user) { |
|
|
|
|
646
|
|
|
start_table(); |
647
|
|
|
show_preference_links(); |
648
|
|
|
end_table(); |
649
|
|
|
} |
650
|
|
|
); |
651
|
|
|
} |
652
|
|
|
); |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
|
656
|
|
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
657
|
|
|
|
658
|
|
|
?> |
659
|
|
|
|