From efa6f4e3d6810a9862f32ee53502cac0bc9d06cd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 18 Sep 2014 10:08:45 -0700 Subject: [PATCH] web: make badge display configurable See http://boinc.berkeley.edu/trac/wiki/BadgeDoc --- html/inc/forum.inc | 3 +-- html/inc/host.inc | 4 ++-- html/inc/team.inc | 10 +++++----- html/inc/uotd.inc | 4 ++-- html/inc/user.inc | 9 +++++++-- html/inc/util.inc | 12 +++++++++++- html/user/forum_forum.php | 2 +- html/user/friend.php | 2 +- html/user/pm.php | 4 ++-- html/user/profile_menu.php | 2 +- html/user/profile_search_action.php | 2 +- html/user/team_admins.php | 2 +- html/user/team_delta.php | 2 +- html/user/team_email_list.php | 2 +- html/user/team_remove_inactive_form.php | 2 +- html/user/top_users.php | 2 +- html/user/user_search.php | 2 +- 17 files changed, 40 insertions(+), 26 deletions(-) diff --git a/html/inc/forum.inc b/html/inc/forum.inc index 4efcb7235e..053605fdc6 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -539,7 +539,6 @@ function show_post( } } - // Print the special user lines, if any // global $special_user_bitfield; @@ -567,7 +566,7 @@ function show_post(
"; - echo user_links($user); + echo user_links($user, BADGE_HEIGHT_SMALL); echo "
"; if ($user->create_time > time()-ST_NEW_TIME) $fstatus.=ST_NEW."
"; if ($fstatus) echo "$fstatus"; diff --git a/html/inc/host.inc b/html/inc/host.inc index faef97c4aa..77433c2194 100644 --- a/html/inc/host.inc +++ b/html/inc/host.inc @@ -102,7 +102,7 @@ function show_host($host, $user, $ipprivate) { } else { $owner = BoincUser::lookup_id($host->userid); if ($owner && $owner->show_hosts) { - row2(tra("Owner"), user_links($owner)); + row2(tra("Owner"), user_links($owner, BADGE_HEIGHT_MEDIUM)); } else { row2(tra("Owner"), tra("Anonymous")); $anonymous = true; @@ -359,7 +359,7 @@ function show_host_row($host, $i, $private, $show_owner, $any_product_name) { if ($anonymous) { echo "".tra("Anonymous")."\n"; } else { - echo "", user_links($user), "\n"; + echo "", user_links($user, BADGE_HEIGHT_MEDIUM), "\n"; } } } diff --git a/html/inc/team.inc b/html/inc/team.inc index d916d68bc6..ce45b1c01f 100644 --- a/html/inc/team.inc +++ b/html/inc/team.inc @@ -161,7 +161,7 @@ function display_team_page($team, $user) { } } row1(tra('Members')); - row2(tra('Founder'), user_links($team->founder)); + row2(tra('Founder'), user_links($team->founder, BADGE_HEIGHT_MEDIUM)); if (count($team->admins)) { $first = true; $x = ""; @@ -171,7 +171,7 @@ function display_team_page($team, $user) { } else { $x .= " · "; } - $x .= user_links($a); + $x .= user_links($a, BADGE_HEIGHT_MEDIUM); } row2(tra('Admins'), $x); } @@ -185,7 +185,7 @@ function display_team_page($team, $user) { } else { $x .= " · "; } - $x .= user_links($a); + $x .= user_links($a, BADGE_HEIGHT_MEDIUM); } } row2(tra('New members in last day'), $x); @@ -256,7 +256,7 @@ function display_team_members($team, $offset, $sort_by) { foreach ($users as $user) { $user_total_credit = format_credit_large($user->total_credit); $user_expavg_credit = format_credit($user->expavg_credit); - $x = user_links($user); + $x = user_links($user, BADGE_HEIGHT_MEDIUM); if ($user->id == $team->userid) { $x .= ' ['.tra('Founder').']'; } else if (is_team_admin_aux($user, $admins)) { @@ -387,7 +387,7 @@ function show_team_row($team, $i) { $team_expavg_credit = format_credit_large($team->expavg_credit); $team_total_credit = format_credit_large($team->total_credit); $j = $i % 2; - $b = badges_string(false, $team, 24); + $b = badges_string(false, $team, BADGE_HEIGHT_MEDIUM); echo" $i id>$team->name $b diff --git a/html/inc/uotd.inc b/html/inc/uotd.inc index 2aed5ea99e..93ad0046f6 100644 --- a/html/inc/uotd.inc +++ b/html/inc/uotd.inc @@ -38,7 +38,7 @@ function uotd_thumbnail($profile, $user) { function show_uotd($profile) { $user = BoincUser::lookup_id($profile->userid); echo uotd_thumbnail($profile, $user); - echo user_links($user, true)."
"; + echo user_links($user, BADGE_HEIGHT_MEDIUM)."
"; $x = output_transform($profile->response1); $x = sanitize_tags($x); echo sub_sentence($x, ' ', 150, true); @@ -178,7 +178,7 @@ function generate_uotd_gadget($profile, $user) { echo "age: $age"; if($age <= 86400+3600) { // allow for slop $x .= uotd_thumbnail($profile, $user); - $x .= user_links($user); + $x .= user_links($user, BADGE_HEIGHT_MEDIUM); $resp = sanitize_tags(output_transform($profile->response1)); $x .= "  ". sub_sentence($resp, ' ', 250, true); } diff --git a/html/inc/user.inc b/html/inc/user.inc index 654ff427f1..daad097fa4 100644 --- a/html/inc/user.inc +++ b/html/inc/user.inc @@ -262,7 +262,10 @@ function friend_links($user) { return $x; } -function user_links($user) { +// show user name, with links to profile if present. +// if $badge_height is > 0, show badges +// +function user_links($user, $badge_height=0) { BoincForumPrefs::lookup($user); if (is_banished($user)) { return "(banished: ID $user->id)"; @@ -277,7 +280,9 @@ function user_links($user) { require_once("../project/donations.inc"); $x .= DONATION_LINK; } - $x .= badges_string(true, $user, 24); + if ($badge_height) { + $x .= badges_string(true, $user, $badge_height); + } if (function_exists("project_user_links")){ $x .= project_user_links($user); } diff --git a/html/inc/util.inc b/html/inc/util.inc index e6994d0f3c..2ce0466733 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -56,6 +56,15 @@ if (!defined('DISABLE_TEAMS')) { if (!defined('DISABLE_BADGES')) { define('DISABLE_BADGES', false); } +if (!defined('BADGE_HEIGHT_SMALL')) { + define('BADGE_HEIGHT_SMALL', 20); +} +if (!defined('BADGE_HEIGHT_MEDIUM')) { + define('BADGE_HEIGHT_MEDIUM', 24); +} +if (!defined('BADGE_HEIGHT_LARGE')) { + define('BADGE_HEIGHT_LARGE', 56); +} $caching = false; // if set, we're writing to a file rather than to client @@ -909,7 +918,8 @@ function badges_string($is_user, $item, $height) { } function show_badges_row($is_user, $item) { - $x = badges_string($is_user, $item, 48); + if (BADGE_HEIGHT_LARGE == 0) return; + $x = badges_string($is_user, $item, BADGE_HEIGHT_LARGE); if ($x) { row2("Badges", $x); } diff --git a/html/user/forum_forum.php b/html/user/forum_forum.php index 02674b89e9..a1ec537122 100644 --- a/html/user/forum_forum.php +++ b/html/user/forum_forum.php @@ -217,7 +217,7 @@ function show_forum($forum, $start, $sort_style, $user) { echo ' '.($thread->replies+1).' - '.user_links($owner).' + '.user_links($owner, BADGE_HEIGHT_SMALL).' '.$thread->views.' '.time_diff_str($thread->timestamp, time()).' diff --git a/html/user/friend.php b/html/user/friend.php index a82199892a..eba443015f 100644 --- a/html/user/friend.php +++ b/html/user/friend.php @@ -139,7 +139,7 @@ function handle_query($user) { if (!$friend) error_page("Request not found"); page_head(tra("Friend request")); echo time_str($friend->create_time)."

\n"; - $x = user_links($srcuser, true); + $x = user_links($srcuser, BADGE_HEIGHT_MEDIUM); echo tra("%1 has requested friendship with you.", $x); if (strlen($friend->message)) { echo "

".tra("%1 says: %2", $srcuser->name, $friend->message)."

"; diff --git a/html/user/pm.php b/html/user/pm.php index 5134155828..2070ffb675 100644 --- a/html/user/pm.php +++ b/html/user/pm.php @@ -103,7 +103,7 @@ function do_inbox($logged_in_user) { $msg->update("opened=1"); } echo " $checkbox $msg->subject \n"; - echo "".user_links($sender); + echo "".user_links($sender, BADGE_HEIGHT_SMALL); show_block_link($msg->senderid); echo "
".time_str($msg->date)."\n"; echo "".output_transform($msg->content, $options)."

"; @@ -142,7 +142,7 @@ function do_read($logged_in_user) { start_table(); echo "".tra("Subject")."".$message->subject.""; - echo "".tra("Sender")."".user_links($sender); + echo "".tra("Sender")."".user_links($sender, BADGE_HEIGHT_SMALL); show_block_link($message->senderid); echo ""; echo "".tra("Date")."".time_str($message->date).""; diff --git a/html/user/profile_menu.php b/html/user/profile_menu.php index 48c930ad4d..b8acc0f0f4 100644 --- a/html/user/profile_menu.php +++ b/html/user/profile_menu.php @@ -48,7 +48,7 @@ echo ""; if ($profile) { $user = BoincUser::lookup_id($profile->userid); echo uotd_thumbnail($profile, $user); - echo user_links($user)."
"; + echo user_links($user, BADGE_HEIGHT_MEDIUM)."
"; $resp = output_transform($profile->response1); $resp = sanitize_tags($resp); echo sub_sentence($resp, ' ', 150, true); diff --git a/html/user/profile_search_action.php b/html/user/profile_search_action.php index 76c446da8b..47f449bbcb 100644 --- a/html/user/profile_search_action.php +++ b/html/user/profile_search_action.php @@ -25,7 +25,7 @@ check_get_args(array("search_string", "offset")); function show_profile_link2($profile, $n) { $user = BoincUser::lookup_id($profile->userid); - echo "".user_links($user)."".date_str($user->create_time)."$user->country".(int)$user->total_credit."".(int)$user->expavg_credit."\n"; + echo "".user_links($user, BADGE_HEIGHT_SMALL)."".date_str($user->create_time)."$user->country".(int)$user->total_credit."".(int)$user->expavg_credit."\n"; } $search_string = get_str('search_string'); diff --git a/html/user/team_admins.php b/html/user/team_admins.php index fbc2d6af62..af25e051f0 100644 --- a/html/user/team_admins.php +++ b/html/user/team_admins.php @@ -29,7 +29,7 @@ function show_admin($user, $admin) { $tokens = url_tokens($user->authenticator); $date = date_str($admin->create_time); echo " - ".user_links($admin_user)." + ".user_links($admin_user, BADGE_HEIGHT_MEDIUM)." $date "; diff --git a/html/user/team_delta.php b/html/user/team_delta.php index 9d28836b03..551901b2d2 100644 --- a/html/user/team_delta.php +++ b/html/user/team_delta.php @@ -43,7 +43,7 @@ function show_delta($delta) { } else { echo " $when - ",user_links($user)," (ID $user->id) + ",user_links($user, BADGE_HEIGHT_MEDIUM)," (ID $user->id) $what $delta->total_credit diff --git a/html/user/team_email_list.php b/html/user/team_email_list.php index ef5be1e9ee..5963cf4c35 100644 --- a/html/user/team_email_list.php +++ b/html/user/team_email_list.php @@ -79,7 +79,7 @@ foreach($users as $user) { echo "$user->name $e\n"; } else { $e = $user->send_email?"$user->email_addr":""; - table_row(user_links($user), $e, format_credit($user->total_credit), format_credit($user->expavg_credit), $user->country); + table_row(user_links($user, BADGE_HEIGHT_MEDIUM), $e, format_credit($user->total_credit), format_credit($user->expavg_credit), $user->country); } } if (!$plain) { diff --git a/html/user/team_remove_inactive_form.php b/html/user/team_remove_inactive_form.php index a590592425..aa6d8977d1 100644 --- a/html/user/team_remove_inactive_form.php +++ b/html/user/team_remove_inactive_form.php @@ -55,7 +55,7 @@ foreach($users as $user) { echo " id> - ".user_links($user)." ($user->id) + ".user_links($user, BADGE_HEIGHT_MEDIUM)." ($user->id) $user_total_credit $user_expavg_credit diff --git a/html/user/top_users.php b/html/user/top_users.php index 849821bb5a..1383aaa669 100644 --- a/html/user/top_users.php +++ b/html/user/top_users.php @@ -71,7 +71,7 @@ function show_user_row($user, $i) { echo " $i - ", user_links($user), " + ", user_links($user, BADGE_HEIGHT_MEDIUM), " ", format_credit_large($user->expavg_credit), " ", format_credit_large($user->total_credit), " ", $user->country, " diff --git a/html/user/user_search.php b/html/user/user_search.php index a8d1ca4d9c..f318a8ca6d 100644 --- a/html/user/user_search.php +++ b/html/user/user_search.php @@ -23,7 +23,7 @@ require_once("../inc/user.inc"); function show_user($user) { echo " - ", user_links($user), " (ID $user->id) + ", user_links($user, BADGE_HEIGHT_MEDIUM), " (ID $user->id) "; if ($user->teamid) { $team = BoincTeam::lookup_id($user->teamid);