2004-02-02 23:34:39 +00:00
< ? php
2008-08-05 22:43:14 +00:00
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
2004-02-02 23:34:39 +00:00
2004-11-07 02:57:02 +00:00
require_once ( " ../inc/credit.inc " );
2004-11-19 07:33:59 +00:00
require_once ( " ../inc/email.inc " );
2005-09-15 18:30:17 +00:00
require_once ( " ../inc/util.inc " );
2007-11-07 17:23:29 +00:00
require_once ( " ../inc/team.inc " );
2007-12-30 22:02:16 +00:00
require_once ( " ../inc/friend.inc " );
2007-11-12 20:57:15 +00:00
require_once ( " ../inc/forum_db.inc " );
2008-01-04 22:59:21 +00:00
require_once ( " ../inc/notify.inc " );
2014-10-18 20:53:36 +00:00
require_once ( " ../inc/ldap.inc " );
2004-11-07 02:57:02 +00:00
2015-09-09 05:33:24 +00:00
if ( ! defined ( 'REMOTE_PROJECTS_TTL' )) {
define ( 'REMOTE_PROJECTS_TTL' , 86400 );
}
2016-12-24 22:50:01 +00:00
// add an element "projects" to user consisting of array of projects
// they've participated in
//
2015-08-07 22:22:10 +00:00
function get_other_projects ( $user ) {
$cpid = md5 ( $user -> cross_project_id . $user -> email_addr );
$url = " http://boinc.netsoft-online.com/get_user.php?cpid= " . $cpid ;
2006-12-29 19:01:03 +00:00
2015-08-07 22:22:10 +00:00
// Check the cache for that URL
//
$cacheddata = get_cached_data ( REMOTE_PROJECTS_TTL , $url );
if ( $cacheddata ){
$remote = unserialize ( $cacheddata );
} else {
2015-12-03 06:45:23 +00:00
// Fetch the XML, use curl if fopen() is disallowed
2015-08-07 22:22:10 +00:00
//
2015-12-03 06:45:23 +00:00
if ( ini_get ( 'allow_url_fopen' )) {
$timeout = 3 ;
$old_timeout = ini_set ( 'default_socket_timeout' , $timeout );
2015-12-29 20:42:46 +00:00
$xml_object = null ;
$f = @ file_get_contents ( $url );
if ( $f ) {
$xml_object = @ simplexml_load_string ( $f );
}
2015-12-03 06:45:23 +00:00
ini_set ( 'default_socket_timeout' , $old_timeout );
2015-12-29 20:42:46 +00:00
if ( ! $xml_object ) {
return $user ;
}
2015-12-03 06:45:23 +00:00
} else {
$ch = curl_init ( $url );
curl_setopt ( $ch , CURLOPT_HEADER , false );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FOLLOWLOCATION , true );
curl_setopt ( $ch , CURLOPT_MAXREDIRS , 3 );
curl_setopt ( $ch , CURLOPT_TIMEOUT , 3 );
2015-12-29 20:42:46 +00:00
$rawxml = @ curl_exec ( $ch );
$xml_object = null ;
if ( $rawxml ) {
$xml_object = @ simplexml_load_string ( $rawxml );
}
2015-12-03 06:45:23 +00:00
curl_close ( $ch );
2015-12-29 20:42:46 +00:00
if ( ! xml_object ) {
return $user ;
}
2015-12-03 06:45:23 +00:00
}
2015-12-29 20:42:46 +00:00
2015-12-03 06:45:23 +00:00
// auto-cast the project list to an array of stdClass projects
//
$remote = @ json_decode ( json_encode (( array ) $xml_object )) -> project ;
2016-12-24 22:50:01 +00:00
if ( count ( $remote ) == 1 ) {
$remote = array ( $remote );
}
2015-08-07 22:22:10 +00:00
if ( ! $remote ) {
return $user ;
} else {
// Cache the results
set_cached_data ( REMOTE_PROJECTS_TTL , serialize ( $remote ), $url );
2006-12-29 19:01:03 +00:00
}
}
2010-06-01 14:07:53 +00:00
2015-08-07 22:22:10 +00:00
$user -> projects = $remote ;
return $user ;
2006-12-29 19:01:03 +00:00
}
function show_project ( $project ) {
if ( $project -> url == " http://www.worldcommunitygrid.org/ " ) {
$x = $project -> name ;
} else {
2007-01-04 15:54:10 +00:00
$x = " <a href= \" $project->url " . " show_user.php?userid= $project->id\ " > $project -> name </ a > " ;
2006-12-29 19:01:03 +00:00
}
echo " <tr>
< td > $x </ td >
2008-05-13 21:46:50 +00:00
< td align = \ " right \" > " . number_format ( $project -> total_credit , 0 ) . " </td>
< td align = \ " right \" > " . number_format ( $project -> expavg_credit , 0 ) . " </td>
< td align = \ " right \" > " . date_str ( $project -> create_time ) . " </td>
2006-12-29 19:01:03 +00:00
</ tr >
" ;
}
function cmp ( $a , $b ) {
if ( $a -> expavg_credit == $b -> expavg_credit ) return 0 ;
return ( $a -> expavg_credit < $b -> expavg_credit ) ? 1 : - 1 ;
}
function show_other_projects ( $user , $personal ) {
2013-05-13 19:29:07 +00:00
if ( ! isset ( $user -> projects )) return ;
if ( count ( $user -> projects ) < 2 ) return ;
usort ( $user -> projects , " cmp " );
if ( $personal ) {
2016-11-11 20:36:27 +00:00
echo " <h3> " . tra ( " Projects in which you are participating " ) . " </h3> " ;
2013-05-13 19:29:07 +00:00
} else {
2016-11-11 20:36:27 +00:00
echo " <h3> " . tra ( " Projects in which %1 is participating " , $user -> name ) . " </h3> " ;
2013-05-13 19:29:07 +00:00
}
2016-11-11 20:36:27 +00:00
start_table ( 'table-striped' );
2016-12-05 05:04:23 +00:00
row_heading_array (
array (
tra ( " Project " ) . " <br/><small> " . tra ( " Click for user page " ) . " </small> " ,
tra ( " Total credit " ),
tra ( " Average credit " ),
tra ( " Since " )
),
array ( " " , ALIGN_RIGHT , ALIGN_RIGHT , ALIGN_RIGHT )
);
2013-05-13 19:29:07 +00:00
foreach ( $user -> projects as $project ) {
show_project ( $project );
2006-12-29 19:01:03 +00:00
}
2013-05-13 19:29:07 +00:00
end_table ();
2006-12-29 19:01:03 +00:00
}
2006-01-09 09:43:17 +00:00
function total_posts ( $user ) {
2007-10-28 15:03:14 +00:00
return BoincPost :: count ( " user= $user->id " );
2006-01-09 09:43:17 +00:00
}
2004-05-30 21:47:11 +00:00
function show_credit ( $user ) {
2007-11-02 14:43:02 +00:00
row2 ( tra ( " Total credit " ), format_credit_large ( $user -> total_credit ));
row2 ( tra ( " Recent average credit " ), format_credit ( $user -> expavg_credit ));
2014-08-15 23:20:40 +00:00
if ( function_exists ( " project_user_credit " )) {
project_user_credit ( $user );
}
2004-05-30 21:47:11 +00:00
}
2006-02-12 06:19:00 +00:00
require_once ( " ../inc/stats_sites.inc " );
2004-02-02 23:34:39 +00:00
// show dynamic user info (private)
//
function show_user_stats_private ( $user ) {
2006-02-12 06:19:00 +00:00
global $cpid_stats_sites ;
2007-11-26 00:51:00 +00:00
row1 ( tra ( " Computing and credit " ));
2004-05-30 21:47:11 +00:00
show_credit ( $user );
2006-02-01 04:00:11 +00:00
$config = get_config ();
2008-05-13 21:46:50 +00:00
row2 ( tra ( " Computers on this account " ), " <a href= \" hosts_user.php \" > " . tra ( " View " ) . " </a> " );
2007-10-30 19:36:27 +00:00
row2 ( tra ( " Tasks " ), " <a href= \" results.php?userid= $user->id\ " > " .tra( " View " ). " </ a > " );
2006-02-12 06:19:00 +00:00
$cpid = md5 ( $user -> cross_project_id . $user -> email_addr );
$x = " " ;
2006-02-14 22:30:42 +00:00
shuffle ( $cpid_stats_sites );
2006-02-12 06:19:00 +00:00
foreach ( $cpid_stats_sites as $site ) {
$name = $site [ 0 ];
$y = sprintf ( $site [ 1 ], $cpid );
2011-02-10 22:45:39 +00:00
$x .= " <a href= \" $y\ " > $name </ a >< br /> \n " ;
2005-09-15 18:18:53 +00:00
}
2014-10-02 19:15:54 +00:00
$x .= " <br/><small> " . tra ( " Cross-project ID " ) . " : $cpid </small> \n " ;
2007-10-30 19:36:27 +00:00
row2 ( tra ( " Cross-project statistics " ), $x );
2010-01-16 06:19:19 +00:00
$x = '<a href="cert1.php">' . tra ( " Account " ) . '</a>' ;
2008-05-28 21:08:26 +00:00
if ( $user -> teamid ) {
2012-12-19 00:38:40 +00:00
$x .= ' · <a href="cert_team.php">' . tra ( " Team " ) . '</a>' ;
2008-05-28 21:08:26 +00:00
}
2012-12-19 00:38:40 +00:00
$x .= ' · <a href="cert_all.php">' . tra ( " Cross-project " ) . '</a>' ;
2008-05-28 21:08:26 +00:00
row2 ( tra ( " Certificate " ), $x );
2015-11-30 08:36:29 +00:00
row2 ( tra ( " Stats on your cell phone " ), url_base () . " userw.php?id= $user->id " );
2004-02-02 23:34:39 +00:00
}
2007-12-18 20:28:08 +00:00
function notify_description ( $notify ) {
switch ( $notify -> type ) {
case NOTIFY_FRIEND_REQ :
2007-12-30 22:02:16 +00:00
return friend_notify_req_web_line ( $notify );
2007-12-18 20:28:08 +00:00
case NOTIFY_FRIEND_ACCEPT :
2007-12-30 22:02:16 +00:00
return friend_notify_accept_web_line ( $notify );
case NOTIFY_PM :
return pm_web_line ( $notify );
case NOTIFY_SUBSCRIBED_POST :
return subscribed_post_web_line ( $notify );
2007-12-18 20:28:08 +00:00
}
2014-07-12 21:32:59 +00:00
return null ;
2007-12-18 20:28:08 +00:00
}
2008-01-14 16:32:34 +00:00
function weak_auth ( $user ) {
$x = md5 ( $user -> authenticator . $user -> passwd_hash );
return " { $user -> id } _ $x " ;
}
2017-02-12 08:46:15 +00:00
// originally user URLs were assumed to be http://,
// and this prefix wasn't stored.
// Now the prefix can be http:// or https://.
// This function takes a user URL in any form and converts
// it to a canonical form, with the protocol prefix.
//
function normalize_user_url ( $url ) {
$x = strtolower ( $url );
if ( substr ( $x , 0 , 7 ) == 'http://' ) {
return 'http://' . substr ( $url , 7 );
}
if ( substr ( $x , 0 , 8 ) == 'https://' ) {
return 'https://' . substr ( $url , 8 );
}
return 'http://' . $url ;
}
2004-02-02 23:34:39 +00:00
// show static user info (private)
//
2004-05-30 21:47:11 +00:00
function show_user_info_private ( $user ) {
2007-10-30 19:36:27 +00:00
row2 ( tra ( " Name " ), $user -> name );
2014-10-18 20:53:36 +00:00
if ( LDAP_HOST && is_ldap_email ( $user -> email_addr )) {
row2 ( " LDAP ID " , ldap_email_to_uid ( $user -> email_addr ));
} else {
$email_text = $user -> email_addr ;
if ( defined ( " SHOW_NONVALIDATED_EMAIL_ADDR " ) && ! $user -> email_validated ) {
$email_text .= " (<a href=validate_email_addr.php>must be validated</a>) " ;
}
row2 ( tra ( " Email address " ), $email_text );
}
2004-05-14 22:57:59 +00:00
if ( strlen ( $user -> url )) {
2017-02-12 08:46:15 +00:00
$u = normalize_user_url ( $user -> url );
row2 ( tra ( " URL " ), sprintf ( '<a href="%s">%s</a>' , $u , $u ));
2004-05-14 22:57:59 +00:00
}
2007-10-30 19:36:27 +00:00
row2 ( tra ( " Country " ), $user -> country );
2017-06-05 21:26:42 +00:00
if ( POSTAL_CODE ) {
row2 ( tra ( " Postal code " ), $user -> postal_code );
}
2008-01-13 00:12:14 +00:00
row2 ( tra ( " %1 member since " , PROJECT ), date_str ( $user -> create_time ));
2008-10-16 04:02:59 +00:00
$url_tokens = url_tokens ( $user -> authenticator );
2014-10-18 20:53:36 +00:00
if ( LDAP_HOST && is_ldap_email ( $user -> email_addr )) {
// LDAP accounts can't change email or password
//
row2 ( tra ( " Change " ),
" <a href= \" edit_user_info_form.php? $url_tokens\ " > Account info </ a > "
);
} else {
row2 ( tra ( " Change " ),
" <a href= \" edit_email_form.php \" > " . tra ( " email address " ) . " </a>
& middot ; < a href = \ " " . secure_url_base () . " /edit_passwd_form.php \" > " . tra ( " password " ) . " </a>
& middot ; < a href = \ " edit_user_info_form.php? $url_tokens\ " > " .tra( " other account info " ). " </ a > "
);
}
2016-11-11 20:36:27 +00:00
row2 ( tra ( " User ID " ) . " <br/><p class= \" small \" > " . tra ( " Used in community functions " ) . " </p> " , $user -> id );
2017-06-17 05:44:24 +00:00
if ( ! NO_COMPUTING ) {
2012-04-19 07:36:47 +00:00
row2 (
tra ( " Account keys " ),
" <a href= \" weak_auth.php \" > " . tra ( " View " ) . " </a> "
);
2008-05-15 22:05:05 +00:00
}
2017-07-13 08:17:21 +00:00
}
2006-02-12 06:19:00 +00:00
2017-07-13 08:17:21 +00:00
function show_preference_links () {
2007-11-26 00:51:00 +00:00
row1 ( " <a name= \" prefs \" ></a> " . tra ( " Preferences " ));
2017-06-17 05:44:24 +00:00
if ( ! NO_COMPUTING ) {
2008-05-15 22:05:05 +00:00
row2 (
tra ( " When and how BOINC uses your computer " ),
" <a href= \" prefs.php?subset=global \" > " . tra ( " Computing preferences " ) . " </a> "
);
}
2007-11-26 00:51:00 +00:00
row2 ( tra ( " Message boards and private messages " ),
" <a href= \" edit_forum_preferences_form.php \" > " . tra ( " Community preferences " ) . " </a> "
);
2017-06-17 05:44:24 +00:00
if ( ! NO_COMPUTING ) {
2009-09-28 16:19:20 +00:00
row2 ( tra ( " Preferences for this project " ),
2008-05-15 22:05:05 +00:00
" <a href= \" prefs.php?subset=project \" > " . tra ( " %1 preferences " , PROJECT ) . " </a> "
);
}
2008-01-01 22:29:10 +00:00
}
2007-11-26 00:51:00 +00:00
2014-08-11 21:57:34 +00:00
function friend_links ( $user ) {
if ( is_banished ( $user )) {
return " " ;
}
$x = " <table height= \" 100 \" width= \" 150 \" border= \" 0 \" cellpadding= \" 4 \" ><tr><td class= \" friend \" > " ;
if ( $user -> has_profile ) {
$profile = BoincProfile :: lookup_fields ( " has_picture " , " userid= $user->id " );
if ( $profile && $profile -> has_picture ) {
$img_url = profile_thumb_url ( $user -> id );
} else {
2015-11-30 08:36:29 +00:00
$img_url = url_base () . " img/head_20.png " ;
2014-08-11 21:57:34 +00:00
}
$title = tra ( " View the profile of %1 " , $user -> name );
$alt = tra ( " Profile " );
2015-11-30 08:36:29 +00:00
$x .= ' <a href="' . url_base () . 'view_profile.php?userid=' . $user -> id . '"><img title="' . $title . '" src="' . $img_url . '" alt="' . $alt . '"></a><br>' ;
2014-08-11 21:57:34 +00:00
}
2015-11-30 08:36:29 +00:00
$x .= " <a href= \" " . url_base () . " show_user.php?userid= " . $user -> id . " \" > " . $user -> name . " </a> " ;
2014-08-11 21:57:34 +00:00
if ( $user -> donated == 1 ) {
require_once ( " ../project/donations.inc " );
$x .= DONATION_LINK ;
}
2016-06-16 09:23:01 +00:00
if ( $user -> donated == 2 ) {
require_once ( " ../project/donations.inc " );
$x .= DONATION_LINK_TWO ;
}
2014-08-11 21:57:34 +00:00
$x .= " </td></tr></table> \n " ;
return $x ;
}
2014-09-18 17:08:45 +00:00
// show user name, with links to profile if present.
// if $badge_height is > 0, show badges
//
function user_links ( $user , $badge_height = 0 ) {
2014-08-11 21:57:34 +00:00
BoincForumPrefs :: lookup ( $user );
if ( is_banished ( $user )) {
return " (banished: ID $user->id ) " ;
}
$x = " " ;
if ( $user -> has_profile ) {
2015-11-30 08:36:29 +00:00
$img_url = url_base () . " img/head_20.png " ;
$x .= ' <a href="' . url_base () . 'view_profile.php?userid=' . $user -> id . '"><img title="View the profile of ' . $user -> name . '" src="' . $img_url . '" alt="Profile"></a>' ;
2014-08-11 21:57:34 +00:00
}
2015-11-30 08:36:29 +00:00
$x .= " <a href= \" " . url_base () . " show_user.php?userid= " . $user -> id . " \" > " . $user -> name . " </a> " ;
2014-08-11 21:57:34 +00:00
if ( $user -> donated == 1 ) {
require_once ( " ../project/donations.inc " );
$x .= DONATION_LINK ;
}
2016-06-16 09:23:01 +00:00
if ( $user -> donated == 2 ) {
require_once ( " ../project/donations.inc " );
$x .= DONATION_LINK_TWO ;
}
2014-09-18 17:08:45 +00:00
if ( $badge_height ) {
$x .= badges_string ( true , $user , $badge_height );
}
2014-08-11 21:57:34 +00:00
if ( function_exists ( " project_user_links " )){
$x .= project_user_links ( $user );
}
return $x ;
}
2008-01-01 22:29:10 +00:00
function show_community_private ( $user ) {
2014-08-11 16:50:06 +00:00
show_badges_row ( true , $user );
2014-04-18 06:31:51 +00:00
if ( ! DISABLE_PROFILES ) {
if ( $user -> has_profile ) {
$x = " <a href= \" view_profile.php?userid= $user->id\ " > " .tra( " View " ). " </ a > & middot ; < a href = \ " delete_profile.php \" > " . tra ( " Delete " ) . " </a> " ;
} else {
$x = " <a href= \" create_profile.php \" > " . tra ( " Create " ) . " </a> " ;
}
row2 ( tra ( " Profile " ), $x );
2006-02-12 06:19:00 +00:00
}
2014-04-18 22:54:28 +00:00
if ( ! DISABLE_FORUMS ) {
$tot = total_posts ( $user );
if ( $tot ) {
2015-11-30 08:36:29 +00:00
row2 ( tra ( " Message boards " ), " <a href= \" " . url_base () . " forum_user_posts.php?userid= $user->id\ " > " .tra( " % 1 posts " , $tot ). " </ a > " );
2014-04-18 22:54:28 +00:00
}
2006-10-27 16:06:42 +00:00
}
2007-04-29 14:22:28 +00:00
2007-11-26 00:51:00 +00:00
row2 ( tra ( " Private messages " ), pm_notification ( $user ) . pm_email_remind ( $user ));
2006-02-12 06:19:00 +00:00
2007-12-18 20:28:08 +00:00
$notifies = BoincNotify :: enum ( " userid= $user->id " );
if ( count ( $notifies )) {
$x = " " ;
foreach ( $notifies as $notify ) {
2014-07-12 21:32:59 +00:00
$y = notify_description ( $notify );
if ( $y ) {
$x .= " • $y <br> " ;
} else {
$notify -> delete ();
}
2007-12-18 20:28:08 +00:00
}
2008-05-13 21:46:50 +00:00
$x .= " <a href= \" " . notify_rss_url ( $user ) . " \" ><img vspace= \" 4 \" border= \" 0 \" src= \" img/rss_icon.gif \" alt= \" RSS \" /></a> " ;
row2 ( tra ( " Notifications " ), $x );
2007-12-18 20:28:08 +00:00
}
2014-04-18 07:15:05 +00:00
if ( ! DISABLE_TEAMS ) {
2015-07-24 20:58:38 +00:00
if ( $user -> teamid && ( $team = BoincTeam :: lookup_id ( $user -> teamid ))) {
2009-07-22 18:41:02 +00:00
$x = " <a href= \" team_display.php?teamid= $team->id\ " > $team -> name </ a >
2012-12-19 00:38:40 +00:00
& middot ; < a href = \ " team_quit_form.php \" > " . tra ( " Quit team " ) . " </a> " ;
2009-07-22 18:41:02 +00:00
if ( is_team_admin ( $user , $team )) {
2012-12-19 00:38:40 +00:00
$x .= " · <a href= \" team_manage.php?teamid= $user->teamid\ " > " .tra( " Administer " ). " </ a > " ;
2009-07-22 18:41:02 +00:00
}
2007-11-07 23:59:08 +00:00
2009-07-22 18:41:02 +00:00
// if there's a foundership request, notify the founder
//
if ( $user -> id == $team -> userid && $team -> ping_user > 0 ) {
2014-10-02 19:15:54 +00:00
$x .= " <p class= \" text-danger \" > " . tra ( " (foundership change request pending) " ) . " </p> " ;
2007-11-07 23:59:08 +00:00
}
2009-07-22 18:41:02 +00:00
row2 ( tra ( " Member of team " ), $x );
} else {
2012-12-19 00:38:40 +00:00
row2 ( tra ( " Team " ), tra ( " None " ) . " · <a href= \" team_search.php \" > " . tra ( " find a team " ) . " </a> " );
2009-07-22 18:41:02 +00:00
}
$teams_founded = BoincTeam :: enum ( " userid= $user->id " );
foreach ( $teams_founded as $team ) {
if ( $team -> id != $user -> teamid ) {
$x = " <a href= \" team_display.php?teamid= $team->id\ " > $team -> name </ a > " ;
2016-11-11 20:36:27 +00:00
$x .= " | <a href= \" team_manage.php?teamid= " . $team -> id . " \" > " . tra ( " Administer " ) . " </a> " ;
2009-07-22 18:41:02 +00:00
if ( $team -> ping_user > 0 ) {
2014-10-02 19:15:54 +00:00
$x .= " <p class= \" text-danger \" > " . tra ( " (foundership change request pending) " ) . " </span> " ;
2009-07-22 18:41:02 +00:00
}
row2 ( tra ( " Founder but not member of " ), $x );
}
2006-12-29 23:36:24 +00:00
}
2004-02-02 23:34:39 +00:00
}
2008-01-01 22:29:10 +00:00
$friends = BoincFriend :: enum ( " user_src= $user->id and reciprocated=1 " );
2010-11-03 21:48:39 +00:00
$x = " <a href= \" user_search.php \" > " . tra ( " Find friends " ) . " </a><br/> \n " ;
2008-01-28 16:12:28 +00:00
$n = count ( $friends );
if ( $n ) {
2008-01-01 22:29:10 +00:00
foreach ( $friends as $friend ) {
$fuser = BoincUser :: lookup_id ( $friend -> user_dest );
2014-10-08 19:14:34 +00:00
if ( ! $fuser ) continue ;
2008-01-01 22:29:10 +00:00
$x .= friend_links ( $fuser );
}
2008-05-21 16:37:11 +00:00
row2 ( tra ( " Friends " ) . " ( $n ) " , $x );
2008-01-28 16:12:28 +00:00
} else {
2008-05-13 21:46:50 +00:00
row2 ( tra ( " Friends " ), $x );
2008-01-01 22:29:10 +00:00
}
2004-02-02 23:34:39 +00:00
}
// show summary of dynamic and static info (public)
2004-10-16 04:12:11 +00:00
//
2004-02-02 23:34:39 +00:00
function show_user_summary_public ( $user ) {
2007-12-18 20:28:08 +00:00
global $g_logged_in_user ;
2011-02-26 23:10:06 +00:00
row2 ( tra ( " User ID " ), $user -> id );
2008-05-15 11:17:40 +00:00
row2 ( tra ( " %1 member since " , PROJECT ), date_str ( $user -> create_time ));
2008-05-13 21:46:50 +00:00
row2 ( tra ( " Country " ), $user -> country );
2012-02-15 19:25:41 +00:00
// don't show URL if user has no recent credit (spam suppression)
//
2013-04-25 07:27:35 +00:00
if ( strlen ( $user -> url )) {
2017-06-17 05:44:24 +00:00
if ( ! NO_COMPUTING || $user -> expavg_credit > 1 ) {
2017-02-12 08:46:15 +00:00
$u = normalize_user_url ( $user -> url );
row2 ( tra ( " URL " ), sprintf ( '<a href="%s">%s</a>' , $u , $u ));
2013-04-25 07:27:35 +00:00
}
2004-02-02 23:34:39 +00:00
}
2017-06-17 05:44:24 +00:00
if ( ! NO_COMPUTING ) {
2008-05-15 22:05:05 +00:00
show_credit ( $user );
2004-02-02 23:34:39 +00:00
2008-05-15 22:05:05 +00:00
if ( $user -> show_hosts ) {
2015-11-30 08:36:29 +00:00
row2 ( tra ( " Computers " ), " <a href= \" " . url_base () . " hosts_user.php?userid= $user->id\ " > " .tra( " View " ). " </ a > " );
2008-05-15 22:05:05 +00:00
} else {
row2 ( tra ( " Computers " ), tra ( " hidden " ));
}
2004-02-02 23:34:39 +00:00
}
2006-02-17 22:01:22 +00:00
if ( $user -> donated == 1 ) {
2006-09-06 20:56:55 +00:00
if ( file_exists ( " ../project/donations.inc " )) {
require_once ( " ../project/donations.inc " );
2014-09-24 16:38:19 +00:00
row2 ( tra ( " Donor " ), DONATION_LINK );
2006-09-06 20:56:55 +00:00
}
2006-02-17 22:01:22 +00:00
}
2016-06-16 09:23:01 +00:00
if ( $user -> donated == 2 ) {
if ( file_exists ( " ../project/donations.inc " )) {
require_once ( " ../project/donations.inc " );
row2 ( tra ( " Donor " ), DONATION_LINK_TWO );
}
}
2008-01-01 22:29:10 +00:00
}
2010-02-04 16:55:16 +00:00
// Returns a cacheable community links data object
// @param user The user to produce a community links object for
2008-12-29 18:44:11 +00:00
function get_community_links_object ( $user ){
2013-05-07 07:53:06 +00:00
$cache_object = new StdClass ;
2008-12-29 18:44:11 +00:00
$cache_object -> post_count = total_posts ( $user );
$cache_object -> user = $user ;
2014-06-24 01:29:20 +00:00
$cache_object -> team = BoincTeam :: lookup_id ( $user -> teamid );
2013-05-07 07:53:06 +00:00
$cache_object -> friends = array ();
2008-12-29 18:44:11 +00:00
$friends = BoincFriend :: enum ( " user_src= $user->id and reciprocated=1 " );
2013-05-07 07:53:06 +00:00
foreach ( $friends as $friend ) {
$fuser = BoincUser :: lookup_id ( $friend -> user_dest );
2014-10-08 19:14:34 +00:00
if ( ! $fuser ) continue ;
2013-05-07 07:53:06 +00:00
$cache_object -> friends [] = $fuser ;
2008-12-29 18:44:11 +00:00
}
return $cache_object ;
}
function community_links ( $clo , $logged_in_user ){
$user = $clo -> user ;
$team = $clo -> team ;
$friends = $clo -> friends ;
$tot = $clo -> post_count ;
2014-04-18 07:15:05 +00:00
if ( ! DISABLE_TEAMS ) {
2009-07-22 18:41:02 +00:00
if ( $user -> teamid && $team ) {
2015-11-30 08:36:29 +00:00
row2 ( tra ( " Team " ), " <a href= \" " . url_base () . " team_display.php?teamid= $team->id\ " > $team -> name </ a > " );
2009-07-22 18:41:02 +00:00
} else {
row2 ( tra ( " Team " ), tra ( " None " ));
}
2008-01-01 22:29:10 +00:00
}
2014-04-18 22:54:28 +00:00
if ( ! DISABLE_FORUMS ) {
if ( $tot ) {
2015-11-30 08:36:29 +00:00
row2 ( tra ( " Message boards " ), " <a href= \" " . url_base () . " forum_user_posts.php?userid= $user->id\ " > " .tra( " % 1 posts " , $tot ). " </ a > " );
2014-04-18 22:54:28 +00:00
}
2007-12-18 20:28:08 +00:00
}
2008-12-29 18:44:11 +00:00
if ( $logged_in_user && $logged_in_user -> id != $user -> id ) {
2008-05-13 21:46:50 +00:00
row2 ( tra ( " Contact " ), " <a href= \" pm.php?action=new&userid= " . $user -> id . " \" > " . tra ( " Send private message " ) . " </a> " );
2009-02-06 03:40:54 +00:00
$friend = BoincFriend :: lookup ( $logged_in_user -> id , $user -> id );
2007-12-30 22:02:16 +00:00
if ( $friend && $friend -> reciprocated ) {
2008-05-13 21:46:50 +00:00
row2 ( tra ( " This person is a friend " ),
" <a href= \" friend.php?action=cancel_confirm&userid= $user->id\ " > " .tra( " Cancel friendship " ). " </ a > "
2007-12-30 22:02:16 +00:00
);
2008-01-02 17:52:21 +00:00
} else if ( $friend ) {
2008-05-13 21:46:50 +00:00
row2 ( tra ( " Friends " ), " <a href= \" friend.php?action=add&userid= $user->id\ " > " .tra( " Request pending " ). " </ a > " );
2007-12-30 22:02:16 +00:00
} else {
2008-05-13 21:46:50 +00:00
row2 ( tra ( " Friends " ), " <a href= \" friend.php?action=add&userid= $user->id\ " > " .tra( " Add as friend " ). " </ a > " );
2008-01-01 22:29:10 +00:00
}
}
2008-12-29 18:44:11 +00:00
if ( $friends ) {
2013-05-04 05:12:26 +00:00
$x = " " ;
2008-01-01 22:29:10 +00:00
foreach ( $friends as $friend ) {
2008-12-29 18:44:11 +00:00
$x .= friend_links ( $friend );
2007-12-18 20:28:08 +00:00
}
2008-12-29 18:44:11 +00:00
row2 ( tra ( " Friends " ) . " ( " . sizeof ( $friends ) . " ) " , $x );
2007-12-18 20:28:08 +00:00
}
2005-04-08 00:06:52 +00:00
}
function show_profile_link ( $user ) {
2004-02-02 23:34:39 +00:00
if ( $user -> has_profile ) {
2008-05-13 21:46:50 +00:00
row2 ( tra ( " Profile " ), " <a href= \" view_profile.php?userid= $user->id\ " > " .tra( " View " ). " </ a > " );
2004-02-02 23:34:39 +00:00
}
}
2010-02-04 16:55:16 +00:00
function show_account_private ( $user ) {
2016-11-11 20:36:27 +00:00
grid (
false ,
function () use ( $user ) {
start_table ();
2017-07-13 08:17:21 +00:00
row1 ( tra ( " Account information " ), 2 , 'heading' );
2016-11-11 20:36:27 +00:00
show_user_info_private ( $user );
2017-07-13 08:17:21 +00:00
show_preference_links ();
2017-06-17 05:44:24 +00:00
if ( ! NO_COMPUTING ) {
2016-11-11 20:36:27 +00:00
show_user_stats_private ( $user );
}
2010-02-04 16:55:16 +00:00
2016-11-11 20:36:27 +00:00
if ( file_exists ( " ../project/donations.inc " )) {
require_once ( " ../project/donations.inc " );
if ( function_exists ( 'show_user_donations_private' )) {
show_user_donations_private ( $user );
}
}
end_table ();
show_other_projects ( $user , true );
project_user_page_private ( $user );
//echo "<a href=delete_account.php>Delete account</a>\n";
},
function () use ( $user ) {
2017-07-13 08:17:21 +00:00
start_table ();
row1 ( tra ( " Community " ));
2016-11-11 20:36:27 +00:00
show_community_private ( $user );
2017-07-13 08:17:21 +00:00
end_table ();
2010-02-04 16:55:16 +00:00
}
2016-11-11 20:36:27 +00:00
);
2010-02-04 16:55:16 +00:00
}
2007-11-14 16:03:47 +00:00
$cvs_version_tracker [] = " \$ Id $ " ; //Generated automatically - do not edit
2004-02-02 23:34:39 +00:00
?>