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 = "<a href=\"$project->url"."show_user.php?userid=$project->id\">$project->name</a>"; |
98
|
|
|
} |
99
|
|
|
echo "<tr> |
100
|
|
|
<td>$x</td> |
101
|
|
|
<td align=\"right\">".number_format($project->total_credit, 0)."</td> |
102
|
|
|
<td align=\"right\">".number_format($project->expavg_credit, 0)."</td> |
103
|
|
|
<td align=\"right\">".date_str($project->create_time)."</td> |
104
|
|
|
</tr> |
105
|
|
|
"; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
function cmp($a, $b) { |
109
|
|
|
if ($a->expavg_credit == $b->expavg_credit) return 0; |
110
|
|
|
return ($a->expavg_credit < $b->expavg_credit) ? 1 : -1; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
function show_other_projects($user, $personal) { |
114
|
|
|
if (!isset($user->projects)) return; |
115
|
|
|
if (count($user->projects) < 2) return; |
116
|
|
|
|
117
|
|
|
usort($user->projects, "cmp"); |
118
|
|
|
if ($personal) { |
119
|
|
|
echo "<h3>".tra("Projects in which you are participating")."</h3>"; |
120
|
|
|
} else { |
121
|
|
|
echo "<h3>".tra("Projects in which %1 is participating", $user->name)."</h3>"; |
122
|
|
|
} |
123
|
|
|
start_table('table-striped'); |
124
|
|
|
row_heading_array( |
125
|
|
|
array( |
126
|
|
|
tra("Project")."<br/><small>".tra("Click for user page")."</small>", |
127
|
|
|
tra("Total credit"), |
128
|
|
|
tra("Average credit"), |
129
|
|
|
tra("Since") |
130
|
|
|
), |
131
|
|
|
array("", ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT) |
132
|
|
|
); |
133
|
|
|
foreach ($user->projects as $project) { |
134
|
|
|
show_project($project); |
135
|
|
|
} |
136
|
|
|
end_table(); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
function total_posts($user) { |
140
|
|
|
return BoincPost::count("user=$user->id"); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
function show_credit($user) { |
144
|
|
|
row2(tra("Total credit"), format_credit_large($user->total_credit)); |
145
|
|
|
row2(tra("Recent average credit"), format_credit($user->expavg_credit)); |
146
|
|
|
if (function_exists("project_user_credit")) { |
147
|
|
|
project_user_credit($user); |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
require_once("../inc/stats_sites.inc"); |
152
|
|
|
// show dynamic user info (private) |
153
|
|
|
// |
154
|
|
|
function show_user_stats_private($user) { |
155
|
|
|
global $cpid_stats_sites; |
156
|
|
|
|
157
|
|
|
if (NO_COMPUTING && NO_STATS && NO_HOSTS) { |
158
|
|
|
return; |
159
|
|
|
} |
160
|
|
|
row1(tra("Computing")); |
161
|
|
|
|
162
|
|
|
if (!NO_STATS) { |
163
|
|
|
show_credit($user); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
if (!NO_HOSTS) { |
167
|
|
|
row2(tra("Computers on this account"), "<a href=\"hosts_user.php\">".tra("View")."</a>"); |
168
|
|
|
} |
169
|
|
|
if (!NO_COMPUTING) { |
170
|
|
|
row2(tra("Tasks"), "<a href=\"results.php?userid=$user->id\">".tra("View")."</a>"); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
if (!NO_STATS) { |
174
|
|
|
$cpid = md5($user->cross_project_id . $user->email_addr); |
175
|
|
|
$x = ""; |
176
|
|
|
shuffle($cpid_stats_sites); |
177
|
|
|
foreach ($cpid_stats_sites as $site) { |
178
|
|
|
$name = $site[0]; |
179
|
|
|
$y = sprintf($site[1], $cpid); |
180
|
|
|
$x .= "<a href=\"$y\">$name</a><br/>\n"; |
181
|
|
|
} |
182
|
|
|
$x .= "<br/><small>".tra("Cross-project ID").": $cpid</small>\n"; |
183
|
|
|
row2(tra("Cross-project statistics"), $x); |
184
|
|
|
$x = sprintf('<a href="%s">%s</a>', cert_filename(), tra("Account")); |
185
|
|
|
if ($user->teamid) { |
186
|
|
|
$x .= ' · <a href="cert_team.php">'.tra("Team").'</a>'; |
187
|
|
|
} |
188
|
|
|
$x .= ' · <a href="cert_all.php">'.tra("Cross-project").'</a>'; |
189
|
|
|
row2(tra("Certificate"), $x); |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
function notify_description($notify) { |
194
|
|
|
switch ($notify->type) { |
195
|
|
|
case NOTIFY_FRIEND_REQ: |
196
|
|
|
return friend_notify_req_web_line($notify); |
197
|
|
|
case NOTIFY_FRIEND_ACCEPT: |
198
|
|
|
return friend_notify_accept_web_line($notify); |
199
|
|
|
case NOTIFY_PM: |
200
|
|
|
return pm_web_line($notify); |
201
|
|
|
case NOTIFY_SUBSCRIBED_POST: |
202
|
|
|
return subscribed_post_web_line($notify); |
203
|
|
|
} |
204
|
|
|
return null; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
// a string that can be used to authenticate some operations, |
208
|
|
|
// but can't be used to log in to the account |
209
|
|
|
// (e.g. can't be used to change email addr or passwd) |
210
|
|
|
// |
211
|
|
|
// this is a function of |
212
|
|
|
// - authenticator (never changes) |
213
|
|
|
// - user ID (never changes) |
214
|
|
|
// - password |
215
|
|
|
// - email addr |
216
|
|
|
// |
217
|
|
|
function weak_auth($user) { |
218
|
|
|
$x = md5($user->authenticator.$user->passwd_hash); |
219
|
|
|
return "{$user->id}_$x"; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
// originally user URLs were assumed to be http://, |
223
|
|
|
// and this prefix wasn't stored. |
224
|
|
|
// Now the prefix can be http:// or https://. |
225
|
|
|
// This function takes a user URL in any form and converts |
226
|
|
|
// it to a canonical form, with the protocol prefix. |
227
|
|
|
// |
228
|
|
|
function normalize_user_url($url) { |
229
|
|
|
$url = sanitize_user_url($url); |
230
|
|
|
if (!$url) return ''; |
231
|
|
|
$x = strtolower($url); |
232
|
|
|
if (substr($x, 0, 7) == 'http://') { |
233
|
|
|
return 'http://'.substr($url, 7); |
234
|
|
|
} |
235
|
|
|
if (substr($x, 0, 8) == 'https://') { |
236
|
|
|
return 'https://'.substr($url, 8); |
237
|
|
|
} |
238
|
|
|
return 'http://'.$url; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
// show static user info (private) |
242
|
|
|
// |
243
|
|
|
function show_user_info_private($user) { |
244
|
|
|
row2(tra("Name"), $user->name); |
245
|
|
|
if (LDAP_HOST && is_ldap_email($user->email_addr)) { |
246
|
|
|
row2("LDAP ID", ldap_email_to_uid($user->email_addr)); |
247
|
|
|
} else { |
248
|
|
|
$email_text = $user->email_addr; |
249
|
|
|
if (defined("SHOW_NONVALIDATED_EMAIL_ADDR") && !$user->email_validated) { |
250
|
|
|
$email_text .= " (<a href=validate_email_addr.php>must be validated</a>)"; |
251
|
|
|
} |
252
|
|
|
row2(tra("Email address"), $email_text); |
253
|
|
|
} |
254
|
|
|
if (USER_URL && $user->url) { |
255
|
|
|
$u = normalize_user_url($user->url); |
256
|
|
|
row2( |
257
|
|
|
tra("URL"), |
258
|
|
|
$u?sprintf('<a href="%s">%s</a>', $u, $u):tra('Invalid URL') |
259
|
|
|
); |
260
|
|
|
} |
261
|
|
|
if (USER_COUNTRY) { |
262
|
|
|
row2(tra("Country"), $user->country); |
263
|
|
|
} |
264
|
|
|
if (POSTAL_CODE) { |
265
|
|
|
row2(tra("Postal code"), $user->postal_code); |
266
|
|
|
} |
267
|
|
|
row2(tra("%1 member since", PROJECT), date_str($user->create_time)); |
268
|
|
|
$url_tokens = url_tokens($user->authenticator); |
269
|
|
|
if (LDAP_HOST && is_ldap_email($user->email_addr)) { |
270
|
|
|
// LDAP accounts can't change email or password |
271
|
|
|
// |
272
|
|
|
row2(tra("Change"), |
273
|
|
|
"<a href=\"edit_user_info_form.php?$url_tokens\">Account info</a>" |
274
|
|
|
); |
275
|
|
|
} else { |
276
|
|
|
$delete_account_str = ""; |
277
|
|
|
$config = get_config(); |
278
|
|
|
if (parse_bool($config, "enable_delete_account")) { |
279
|
|
|
$delete_account_str = " · <a href=\"delete_account_request.php\">".tra("delete account")."</a>"; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
row2(tra("Change"), |
283
|
|
|
"<a href=\"edit_email_form.php\">".tra("email address")."</a> |
284
|
|
|
· <a href=\"".secure_url_base()."/edit_passwd_form.php\">".tra("password")."</a> |
285
|
|
|
· <a href=\"edit_user_info_form.php?$url_tokens\">".tra("other account info")."</a>" |
286
|
|
|
.$delete_account_str |
287
|
|
|
); |
288
|
|
|
} |
289
|
|
|
if (!UNIQUE_USER_NAME) { |
290
|
|
|
row2(tra("User ID")."<br/><p class=\"small\">".tra("Used in community functions")."</p>", $user->id); |
291
|
|
|
} |
292
|
|
|
if (!NO_COMPUTING) { |
293
|
|
|
row2( |
294
|
|
|
tra("Account keys"), |
295
|
|
|
"<a href=\"weak_auth.php\">".tra("View")."</a>" |
296
|
|
|
); |
297
|
|
|
|
298
|
|
|
require_once("../inc/account_ownership.inc"); |
299
|
|
|
if (file_exists($account_ownership_private_key_file_path)) { |
|
|
|
|
300
|
|
|
// If the server has keys configured show the account ownership form |
301
|
|
|
row2( |
302
|
|
|
tra("Account Ownership"), |
303
|
|
|
"<a href=\"account_ownership.php?$url_tokens\">Generate ownership proof</a>" |
304
|
|
|
); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
} |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
function show_preference_links() { |
311
|
|
|
row1("<a name=\"prefs\"></a>".tra("Preferences")); |
312
|
|
|
if (!NO_GLOBAL_PREFS) { |
313
|
|
|
row2( |
314
|
|
|
tra("When and how BOINC uses your computer"), |
315
|
|
|
"<a href=\"prefs.php?subset=global\">".tra("Computing preferences")."</a>" |
316
|
|
|
); |
317
|
|
|
} |
318
|
|
|
row2(tra("Message boards and private messages"), |
319
|
|
|
"<a href=\"edit_forum_preferences_form.php\">".tra("Community preferences")."</a>" |
320
|
|
|
); |
321
|
|
|
if (!NO_COMPUTING) { |
322
|
|
|
row2(tra("Preferences for this project"), |
323
|
|
|
"<a href=\"prefs.php?subset=project\">".tra("%1 preferences", PROJECT)."</a>" |
324
|
|
|
); |
325
|
|
|
} |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
// return describing a friend: their name, and profile picture if it exists |
329
|
|
|
// |
330
|
|
|
function friend_links($user) { |
331
|
|
|
if (is_banished($user)) { |
332
|
|
|
return ""; |
333
|
|
|
} |
334
|
|
|
$x = sprintf( |
335
|
|
|
'<a href="%s%s?userid=%d" style="%s">%s</a>', |
336
|
|
|
url_base(), |
337
|
|
|
SHOW_USER_PAGE, |
338
|
|
|
$user->id, |
339
|
|
|
'vertical-align:top', |
340
|
|
|
$user->name |
341
|
|
|
); |
342
|
|
|
if ($user->has_profile) { |
343
|
|
|
$profile = BoincProfile::lookup_fields("has_picture", "userid=$user->id"); |
344
|
|
|
if ($profile && $profile->has_picture) { |
345
|
|
|
$img_url = profile_thumb_url($user->id); |
346
|
|
|
} else { |
347
|
|
|
$img_url = url_base()."img/head_20.png"; |
348
|
|
|
} |
349
|
|
|
$alt = tra("Profile"); |
350
|
|
|
$x .= sprintf( |
351
|
|
|
'<a href="%sview_profile.php?userid=%d"><img title="%s" src="%s" alt="%s"></a><br>', |
352
|
|
|
url_base(), |
353
|
|
|
$user->id, |
354
|
|
|
tra("View the profile of %1", $user->name), |
355
|
|
|
$img_url, |
356
|
|
|
tra("Profile") |
357
|
|
|
); |
358
|
|
|
} |
359
|
|
|
if (function_exists("project_user_links")) { |
360
|
|
|
$x .= project_user_links($user); |
361
|
|
|
} |
362
|
|
|
$x .= '</div>'; |
363
|
|
|
return $x; |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
// show user name, with links to profile if present. |
367
|
|
|
// if $badge_height is > 0, show badges |
368
|
|
|
// if $name_limit, limit name to N chars |
369
|
|
|
// |
370
|
|
|
function user_links($user, $badge_height=0, $name_limit=0) { |
371
|
|
|
BoincForumPrefs::lookup($user); |
372
|
|
|
if (is_banished($user)) { |
373
|
|
|
return "(banished: ID $user->id)"; |
374
|
|
|
} |
375
|
|
|
$x = ""; |
376
|
|
|
if ($user->has_profile) { |
377
|
|
|
$img_url = url_base()."img/head_20.png"; |
378
|
|
|
$x .= sprintf( |
379
|
|
|
' <a href="%s%s?userid=%d"><img title="View the profile of %s" src="%s" alt="Profile"></a>', |
380
|
|
|
url_base(), |
381
|
|
|
'view_profile.php', |
382
|
|
|
$user->id, |
383
|
|
|
$user->name, |
384
|
|
|
$img_url |
385
|
|
|
); |
386
|
|
|
} |
387
|
|
|
$name = $user->name; |
388
|
|
|
if ($name_limit && strlen($name) > $name_limit) { |
389
|
|
|
$name = substr($name, 0, $name_limit)."..."; |
390
|
|
|
} |
391
|
|
|
$x .= sprintf( |
392
|
|
|
'<a href="%s%s?userid=%d">%s</a>', |
393
|
|
|
url_base(), |
394
|
|
|
SHOW_USER_PAGE, |
395
|
|
|
$user->id, |
396
|
|
|
$name |
397
|
|
|
); |
398
|
|
|
if (function_exists("project_user_links")){ |
399
|
|
|
$x .= project_user_links($user); |
400
|
|
|
} |
401
|
|
|
if ($badge_height) { |
402
|
|
|
$x .= badges_string(true, $user, $badge_height); |
403
|
|
|
} |
404
|
|
|
return $name_limit?"<nobr>$x</nobr>":$x; |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
function show_community_private($user) { |
408
|
|
|
show_badges_row(true, $user); |
409
|
|
|
if (!DISABLE_PROFILES) { |
410
|
|
|
if ($user->has_profile) { |
411
|
|
|
$x = "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a> · <a href=\"delete_profile.php\">".tra("Delete")."</a>"; |
412
|
|
|
} else { |
413
|
|
|
$x = "<a href=\"create_profile.php\">".tra("Create")."</a>"; |
414
|
|
|
} |
415
|
|
|
row2(tra("Profile"), $x); |
416
|
|
|
} |
417
|
|
|
if (!DISABLE_FORUMS) { |
418
|
|
|
$tot = total_posts($user); |
419
|
|
|
if ($tot) { |
420
|
|
|
row2(tra("Message boards"), "<a href=\"".url_base()."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>"); |
421
|
|
|
} |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
row2(tra("Private messages"), pm_notification($user).pm_email_remind($user)); |
425
|
|
|
|
426
|
|
|
$notifies = BoincNotify::enum("userid=$user->id"); |
427
|
|
|
if (count($notifies)) { |
428
|
|
|
$x = ""; |
429
|
|
|
foreach ($notifies as $notify) { |
430
|
|
|
$y = notify_description($notify); |
431
|
|
|
if ($y) { |
432
|
|
|
$x .= "• $y<br>"; |
433
|
|
|
} else { |
434
|
|
|
$notify->delete(); |
435
|
|
|
} |
436
|
|
|
} |
437
|
|
|
$x .= "<a href=\"".notify_rss_url($user)."\"><img vspace=\"4\" border=\"0\" src=\"img/rss_icon.gif\" alt=\"RSS\" /></a>"; |
438
|
|
|
row2(tra("Notifications"), $x); |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
if (!DISABLE_TEAMS) { |
442
|
|
|
if ($user->teamid && ($team = BoincTeam::lookup_id($user->teamid))) { |
443
|
|
|
$x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a> |
444
|
|
|
· <a href=\"team_quit_form.php\">".tra("Quit team")."</a>"; |
445
|
|
|
if (is_team_admin($user, $team)) { |
446
|
|
|
$x .= " · <a href=\"team_manage.php?teamid=$user->teamid\">".tra("Administer")."</a>"; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
// if there's a foundership request, notify the founder |
450
|
|
|
// |
451
|
|
|
if ($user->id==$team->userid && $team->ping_user >0) { |
452
|
|
|
$x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>"; |
453
|
|
|
} |
454
|
|
|
row2(tra("Member of team"), $x); |
455
|
|
|
} else { |
456
|
|
|
row2(tra("Team"), tra("None")." · <a href=\"team_search.php\">".tra("find a team")."</a>"); |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
$teams_founded = BoincTeam::enum("userid=$user->id"); |
460
|
|
|
foreach ($teams_founded as $team) { |
461
|
|
|
if ($team->id != $user->teamid) { |
462
|
|
|
$x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>"; |
463
|
|
|
$x .= " | <a href=\"team_manage.php?teamid=".$team->id."\">".tra("Administer")."</a>"; |
464
|
|
|
if ($team->ping_user > 0) { |
465
|
|
|
$x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</span>"; |
466
|
|
|
} |
467
|
|
|
row2(tra("Founder but not member of"), $x); |
468
|
|
|
} |
469
|
|
|
} |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
$friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
473
|
|
|
$x = ''; |
474
|
|
|
if ($friends) { |
475
|
|
|
foreach($friends as $friend) { |
476
|
|
|
$fuser = BoincUser::lookup_id($friend->user_dest); |
477
|
|
|
if (!$fuser) continue; |
478
|
|
|
$x .= friend_links($fuser); |
479
|
|
|
} |
480
|
|
|
row2(tra("Friends"), $x); |
481
|
|
|
} else { |
482
|
|
|
row2(tra("Friends"), '---'); |
483
|
|
|
} |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
// show summary of dynamic and static info (public) |
487
|
|
|
// |
488
|
|
|
function show_user_summary_public($user) { |
489
|
|
|
global $g_logged_in_user; |
490
|
|
|
if (!UNIQUE_USER_NAME) { |
491
|
|
|
row2(tra("User ID"), $user->id); |
492
|
|
|
} |
493
|
|
|
row2(tra("%1 member since", PROJECT), date_str($user->create_time)); |
494
|
|
|
if (USER_COUNTRY) { |
495
|
|
|
row2(tra("Country"), $user->country); |
496
|
|
|
} |
497
|
|
|
if (USER_URL && $user->url) { |
498
|
|
|
// don't show URL if user has no recent credit (spam suppression) |
499
|
|
|
// |
500
|
|
|
if (!NO_COMPUTING || $user->expavg_credit > 1) { |
501
|
|
|
$u = normalize_user_url($user->url); |
502
|
|
|
row2(tra("URL"), sprintf('<a href="%s">%s</a>', $u, $u)); |
503
|
|
|
} |
504
|
|
|
} |
505
|
|
|
if (!NO_COMPUTING) { |
506
|
|
|
show_credit($user); |
507
|
|
|
|
508
|
|
|
if ($user->show_hosts) { |
509
|
|
|
row2(tra("Computers"), "<a href=\"".url_base()."hosts_user.php?userid=$user->id\">".tra("View")."</a>"); |
510
|
|
|
} else { |
511
|
|
|
row2(tra("Computers"), tra("hidden")); |
512
|
|
|
} |
513
|
|
|
} |
514
|
|
|
if (function_exists("project_user_summary_public")) { |
515
|
|
|
project_user_summary_public($user); |
516
|
|
|
} |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
// Returns a cacheable community links data object |
520
|
|
|
// @param user The user to produce a community links object for |
521
|
|
|
|
522
|
|
|
function get_community_links_object($user){ |
523
|
|
|
$cache_object = new StdClass; |
524
|
|
|
$cache_object->post_count = total_posts($user); |
525
|
|
|
$cache_object->user = $user; |
526
|
|
|
$cache_object->team = BoincTeam::lookup_id($user->teamid); |
527
|
|
|
$cache_object->friends = array(); |
528
|
|
|
|
529
|
|
|
$friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
530
|
|
|
foreach($friends as $friend) { |
531
|
|
|
$fuser = BoincUser::lookup_id($friend->user_dest); |
532
|
|
|
if (!$fuser) continue; |
533
|
|
|
$cache_object->friends[] = $fuser; |
534
|
|
|
} |
535
|
|
|
return $cache_object; |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
// show community links of another user (described by $clo) |
539
|
|
|
// |
540
|
|
|
function community_links($clo, $logged_in_user){ |
541
|
|
|
$user = $clo->user; |
542
|
|
|
$team = $clo->team; |
543
|
|
|
$friends = $clo->friends; |
544
|
|
|
$tot = $clo->post_count; |
545
|
|
|
|
546
|
|
|
if (!DISABLE_TEAMS) { |
547
|
|
|
if ($user->teamid && $team) { |
548
|
|
|
row2(tra("Team"), "<a href=\"".url_base()."team_display.php?teamid=$team->id\">$team->name</a>"); |
549
|
|
|
} else { |
550
|
|
|
row2(tra("Team"), tra("None")); |
551
|
|
|
} |
552
|
|
|
} |
553
|
|
|
if (!DISABLE_FORUMS) { |
554
|
|
|
if ($tot) { |
555
|
|
|
row2(tra("Message boards"), "<a href=\"".url_base()."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>"); |
556
|
|
|
} |
557
|
|
|
} |
558
|
|
|
if ($logged_in_user && $logged_in_user->id != $user->id) { |
559
|
|
|
row2(tra("Contact"), "<a href=\"pm.php?action=new&userid=".$user->id."\">".tra("Send private message")."</a>"); |
560
|
|
|
$friend = BoincFriend::lookup($logged_in_user->id, $user->id); |
561
|
|
|
if ($friend && $friend->reciprocated) { |
562
|
|
|
row2(tra("This person is a friend"), |
563
|
|
|
"<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>" |
564
|
|
|
); |
565
|
|
|
} else if ($friend) { |
566
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>"); |
567
|
|
|
} else { |
568
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>"); |
569
|
|
|
} |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
if ($friends) { |
573
|
|
|
$x = ''; |
574
|
|
|
foreach($friends as $friend) { |
575
|
|
|
$x .= friend_links($friend); |
576
|
|
|
} |
577
|
|
|
row2(tra('Friends'), $x); |
578
|
|
|
} |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
function show_profile_link($user) { |
582
|
|
|
if ($user->has_profile) { |
583
|
|
|
row2(tra("Profile"), "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a>"); |
584
|
|
|
} |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
function show_account_private($user) { |
588
|
|
|
grid( |
589
|
|
|
false, |
590
|
|
|
function() use ($user) { |
591
|
|
|
start_table(); |
592
|
|
|
row1(tra("Account information"), 2, 'heading'); |
593
|
|
|
show_user_info_private($user); |
594
|
|
|
show_preference_links(); |
595
|
|
|
show_user_stats_private($user); |
596
|
|
|
|
597
|
|
|
if (function_exists('show_user_donations_private')) { |
598
|
|
|
show_user_donations_private($user); |
599
|
|
|
} |
600
|
|
|
end_table(); |
601
|
|
|
if (!NO_COMPUTING) { |
602
|
|
|
show_other_projects($user, true); |
603
|
|
|
} |
604
|
|
|
if (function_exists("project_user_page_private")) { |
605
|
|
|
project_user_page_private($user); |
606
|
|
|
} |
607
|
|
|
}, |
608
|
|
|
function() use ($user) { |
609
|
|
|
start_table(); |
610
|
|
|
row1(tra("Community")); |
611
|
|
|
show_community_private($user); |
612
|
|
|
end_table(); |
613
|
|
|
} |
614
|
|
|
); |
615
|
|
|
} |
616
|
|
|
|
617
|
|
|
|
618
|
|
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
619
|
|
|
|
620
|
|
|
?> |
621
|
|
|
|