id and (validate_state=0 or validate_state=4)");
$foobar = mysql_fetch_object($result);
if (!$foobar) return 0;
mysql_free_result($result);
return $foobar->total;
}
function total_posts($user) {
$result = mysql_query(
"select count(id) as total from post where user=$user->id"
);
$foobar = mysql_fetch_object($result);
if (!$foobar) return 0;
mysql_free_result($result);
return $foobar->total;
}
function show_credit($user) {
row2(tr(TOTAL_CREDIT), format_credit($user->total_credit));
row2(tr(EXPAVG_CREDIT), format_credit($user->expavg_credit));
project_user_credit($user);
}
require_once("../inc/stats_sites.inc");
// show dynamic user info (private)
//
function show_user_stats_private($user) {
global $cpid_stats_sites;
row1("Work done");
row2(PROJECT." member since", date_str($user->create_time));
show_credit($user);
$config = get_config();
if (parse_bool($config, "show_results")) {
row2("Pending credit", "View");
}
row2("Computers on this account",
"View"
);
row2("Results", "id>View");
$cpid = md5($user->cross_project_id . $user->email_addr);
$x = "";
shuffle($cpid_stats_sites);
foreach ($cpid_stats_sites as $site) {
$name = $site[0];
$y = sprintf($site[1], $cpid);
$x .= "$name
";
}
$x .= "
Cross-project ID: $cpid\n";
row2("Cross-project statistics", $x);
row2("Stats on your cell phone", URL_BASE."userw.php?id=$user->id");
row2("Account number
Used in URLs", $user->id);
}
// show static user info (private)
//
function show_user_info_private($user) {
if (is_valid_email_addr($user->email_addr)) {
$email_text = $user->email_addr;
} else {
$email_text = "Verification pending";
}
row1("Account information");
row2("Email address
", $email_text);
row2("Name", $user->name);
if (strlen($user->url)) {
$x = "http://$user->url";
} else {
$x = "none";
}
row2("URL", $x);
row2("Country", $user->country);
row2("Postal code", $user->postal_code);
row2("Change", "email address | password | other account info");
row2("", "Log out");
row1("Community");
$sql = "SELECT * FROM profile WHERE userid = ".$user->id;
$result = mysql_query($sql);
if (mysql_num_rows($result) != 0) {
$x = "id>View or edit | Delete";
} else {
$x = "Create";
}
row2("Profile", $x);
if ($user->teamid) {
$team = lookup_team($user->teamid);
$x = "id>$team->name
| Quit team";
if ($team->userid == $user->id) {
$x .= " | management functions";
}
row2("Team", $x);
} else {
row2("Team", "None (find a team)");
}
$tot = total_posts($user);
if ($tot) {
row2("Message boards", "id>$tot posts");
}
row1("Preferences");
row2(
"General preferences
specify when and how BOINC uses your computer",
"View or edit"
);
row2(PROJECT." preferences
control resource share and customize graphics",
"View or edit"
);
row2("Message board preferences
configure features and appearance of message boards",
"View or edit"
);
}
// show summary of dynamic and static info (public)
//
function show_user_summary_public($user) {
row2(PROJECT." member since", date_str($user->create_time));
row2("Country", $user->country);
if (strlen($user->url)) {
row2("URL", "url>http://$user->url");
}
show_credit($user);
if ($user->teamid && ($team = lookup_team($user->teamid))) {
row2("Team", "id>$team->name");
} else {
row2("Team", "None");
}
if ($user->show_hosts) {
row2("Computers", "id>View");
} else {
row2("Computers", "hidden");
}
$tot = total_posts($user);
if ($tot) {
row2("Message boards", "id>$tot posts");
}
if ($user->donated == 1) {
if (file_exists("../project/donations.inc")) {
require_once("../project/donations.inc");
$x .= DONATION_LINK;
row2("Donor",$x);
}
}
}
function show_profile_link($user) {
if ($user->has_profile) {
row2("Profile", "id>View");
}
}
// show a summary of the user.
// NOTE: This is intended to be shown only to that user.
// it has info that other users aren't supposed to see
function show_user_page_private($user) {
$config = get_config();
start_table("width=100%");
show_user_info_private($user);
show_user_stats_private($user);
// Does this project accept donations? Then put in a project specific
// function to show user donation information in ../project/donations.inc
//
if (parse_bool($config, "donations_accepted")) {
if (file_exists("../project/donations.inc")) {
require_once("../project/donations.inc");
show_user_donations_private($user);
}
}
end_table();
}
function user_table_start($sort_by) {
start_table();
echo "