diff --git a/checkin_notes b/checkin_notes index 7b9a51a745..fd12b088c5 100755 --- a/checkin_notes +++ b/checkin_notes @@ -20905,3 +20905,15 @@ David 8 Dec 2004 Makefile.am lib/ Makefile.am + +David 8 Dec 2004 + - web site: added Team leaderboards broken down by type (see team.php) + + html/ + inc/ + team.inc + util.inc + user/ + sample_index.php + team.php + top_teams.php diff --git a/html/inc/team.inc b/html/inc/team.inc index ac1f54e2de..4bf2ef4dc6 100644 --- a/html/inc/team.inc +++ b/html/inc/team.inc @@ -11,6 +11,19 @@ function show_team_create_account_url($team) { row2("Create team account URL
Accounts created via this URL will belong to this team and will have the project preferences of its founder", "$url"); } +function team_type_name($type) { + switch ($type) { + case 1: return "Unclassified"; + case 2: return "Company"; + case 3: return "Primary school"; + case 4: return "Secondary school"; + case 5: return "Junior college"; + case 6: return "University or department"; + case 7: return "Government agency"; + } + return "Unknown"; +} + function display_team_page($team, $offset, $sort_by) { $n = 20; @@ -37,7 +50,12 @@ function display_team_page($team, $offset, $sort_by) { row2("Description", sanitize_html($team->description)); } if (strlen($team->url)) {; - row2("Web site", "url>http://$team->url"); + if (strstr($team->url, "http://")) { + $x = $team->url; + } else { + $x = "http://$team->url"; + } + row2("Web site", "$x"); } row2("Members", $team->nusers); @@ -46,6 +64,7 @@ function display_team_page($team, $offset, $sort_by) { $user = lookup_user_id($team->userid); row2("Founder", user_links($user)); row2("Country", $team->country); + row2("Type", team_type_name($team->type)); row2("Join this team", "id>Join"); show_team_create_account_url($team); echo ""; diff --git a/html/inc/util.inc b/html/inc/util.inc index d95674c762..4c10e85c63 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -433,7 +433,7 @@ function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { } function format_credit($cobblestones) { - return sprintf("%.2f", $cobblestones); + return number_format($cobblestones, 2); } function project_is_stopped() { diff --git a/html/user/sample_index.php b/html/user/sample_index.php index 3c49409de8..40b6702b4c 100644 --- a/html/user/sample_index.php +++ b/html/user/sample_index.php @@ -38,7 +38,7 @@ function show_nav() { "; diff --git a/html/user/team.php b/html/user/team.php index d0831c32df..c01c338637 100644 --- a/html/user/team.php +++ b/html/user/team.php @@ -34,9 +34,20 @@ echo "

".PROJECT." participants may form teams. -

  • Show top teams
  • Create a team + Show top teams: + "; page_tail(); diff --git a/html/user/top_teams.php b/html/user/top_teams.php index ecd1a0d9d5..d12beebe2f 100644 --- a/html/user/top_teams.php +++ b/html/user/top_teams.php @@ -1,69 +1,80 @@ - 7) { + $type = null; +} +if ($type) { + $type_url = "&type=$type"; + $type_sql = "where type=$type"; + $type_name = team_type_name($type); +} - if ($offset < 1000) { - $cache_args = "sort_by=$sort_by&offset=$offset"; - start_cache(TOP_PAGES_TTL, $cache_args); - } else { - page_head("Limit exceeded"); - echo "Sorry - first 1000 only."; - page_tail(); - exit(); - } +if ($offset % $n) $offset = 0; - require_once("../inc/db.inc"); - require_once("../inc/user.inc"); - require_once("../inc/team.inc"); +if ($offset < 1000) { + $cache_args = "sort_by=$sort_by&offset=$offset".$type_url; + start_cache(TOP_PAGES_TTL, $cache_args); +} else { + page_head("Limit exceeded"); + echo "Sorry - first 1000 only."; + page_tail(); + exit(); +} - db_init(); +require_once("../inc/db.inc"); +require_once("../inc/user.inc"); - page_head("Top teams"); +db_init(); + +page_head("Top $type_name teams"); +if ($sort_by == "total_credit") { + $sort_clause = "total_credit desc"; +} else { + $sort_clause = "expavg_credit desc"; +} +$result = mysql_query("select * from team $type_sql order by $sort_clause limit $offset,$n"); +start_table(); +row1("Teams", 6); +team_table_start($sort_by); +$i = $offset + 1; +while ($team = mysql_fetch_object($result)) { if ($sort_by == "total_credit") { - $sort_clause = "total_credit desc"; + show_team_row($team, $i); + $i++; } else { - $sort_clause = "expavg_credit desc"; - } - $result = mysql_query("select * from team order by $sort_clause limit $offset,$n"); - start_table(); - row1("Teams", 6); - team_table_start($sort_by); - $i = $offset + 1; - while ($team = mysql_fetch_object($result)) { - if ($sort_by == "total_credit") { + if (!team_inactive_ndays($team, 7)) { show_team_row($team, $i); $i++; - } else { - if (!team_inactive_ndays($team, 7)) { - show_team_row($team, $i); - $i++; - } } } - mysql_free_result($result); - echo "\n

    \n"; - if ($offset > 0) { - $new_offset = $offset - $n; - echo "Last $n | "; +} +mysql_free_result($result); +echo "\n

    \n"; +if ($offset > 0) { + $new_offset = $offset - $n; + echo "Last $n | "; - } - $new_offset = $offset + $n; - echo "Next $n"; +} +$new_offset = $offset + $n; +echo "Next $n"; - if ($offset < 1000) { - page_tail(true); - end_cache(TOP_PAGES_TTL, $cache_args); - } else { - page_tail(); - } +if ($offset < 1000) { + page_tail(true); + end_cache(TOP_PAGES_TTL, $cache_args); +} else { + page_tail(); +} -} ?> +?>