- Timestamp:
- 03/21/10 15:45:34 (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
common/db/score.php (modified) (2 diffs)
-
www/macros/macro_rankings.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/score.php
r1110 r1116 78 78 } 79 79 if ($round != null) { 80 if (is_string($round)) 80 if (is_string($round)) { 81 81 $round = array($round); 82 83 if (is_array($round) && count($round) > 0) { 84 $rounds_where = "(`id` IN (" . db_escape_array($round) . "))"; 85 $query = "SELECT `id`, `state`, `public_eval` FROM `ia_round` WHERE " . $rounds_where; 86 $round_objects = db_fetch_all($query); 87 $allowed_round_ids = array(); 88 89 foreach ($round_objects as $round) { 90 if (identity_can('round-view-scores', $round)) { 91 $allowed_round_ids[] = $round["id"]; 92 } 93 } 94 95 if (count($allowed_round_ids) == 0) { 82 } 83 84 if (is_array($round)) { 85 if (count($round) > 0) { 86 $where[] = "(`round_id` IN (" . db_escape_array($round) . "))"; 87 } else { 96 88 $where[] = "(TRUE = FALSE)"; 97 } else {98 $where[] = "(`round_id` IN (" . db_escape_array($allowed_round_ids) . "))";99 89 } 100 90 } … … 370 360 // if detail_task == true, extra columns for each task will be created 371 361 // if detail_round == true, extra columns for each round will be created 372 function score_get_rankings($rounds, $tasks, $start = 0, $count = 999999, $detail_task = false, $detail_round = false) 373 { 362 function score_get_rankings($rounds, $tasks, $start = 0, $count = 999999, 363 $detail_task = false, $detail_round = false) { 364 if (count($rounds) == 0) { 365 return array(); 366 } 374 367 $where = score_build_where_clauses(null, null, $rounds); 375 368 376 369 // Get the total score for all rounds 377 $query = "SELECT SUM(score) AS score, user_id, ia_user.username AS user_name, ia_user.full_name AS user_full, 378 ia_user.rating_cache AS user_rating 379 FROM ia_score_user_round 380 LEFT JOIN ia_user ON ia_user.id = ia_score_user_round.user_id 381 WHERE ".implode('AND', $where)." 382 GROUP BY `user_id` 383 ORDER BY score DESC 384 LIMIT ".db_escape($start).", ".db_escape($count); 370 $query = " 371 SELECT ".(count($rounds) > 1 ? "SUM(score) AS score" : "score").", 372 user_id, ia_user.username AS user_name, 373 ia_user.full_name AS user_full, 374 ia_user.rating_cache AS user_rating 375 FROM ia_score_user_round 376 LEFT JOIN ia_user ON ia_user.id = ia_score_user_round.user_id 377 WHERE".implode('AND', $where)." 378 ".(count($rounds) > 1 ? "GROUP BY `user_id`" : "")." 379 ORDER BY score DESC 380 LIMIT ".db_escape($start).", ".db_escape($count); 385 381 386 382 $rankings = db_fetch_all($query); -
trunk/www/macros/macro_rankings.php
r1110 r1116 52 52 foreach ($round_param as $param) { 53 53 $round = preg_split('/\s*\:\s*/', $param); 54 if (!identity_can('round-view-scores', round_get($round[0]))) { 55 continue; 56 } 54 57 array_push($rounds, array( 55 58 'round_id' => $round[0], 56 59 'round_name' => getattr($round, 1, ' ') 57 ) 58 ); 60 )); 59 61 } 60 62 … … 72 74 'key' => 'user_full', 73 75 'rowform' => create_function_cached('$row', 74 'return format_user_normal($row["user_name"], $row["user_full"], $row["user_rating"]);'),76 'return format_user_normal($row["user_name"], $row["user_full"], $row["user_rating"]);'), 75 77 ), 76 78 ); … … 83 85 84 86 if ($detail_task == true) { 85 $new_tasks = round_get_tasks($round_id, null, null, null, null, null);86 foreach ($new_tasks as $task) {87 array_push($columns, array(88 'name' => $task['id'],89 'type' => 'task',90 'title' => $task['title']91 ));92 array_push($tasks, $task);87 $new_tasks = round_get_tasks($round_id); 88 foreach ($new_tasks as $task) { 89 array_push($columns, array( 90 'name' => $task['id'], 91 'type' => 'task', 92 'title' => $task['title'] 93 )); 94 array_push($tasks, $task); 93 95 } 94 96 } … … 110 112 'rowform' => create_function_cached('$row', 'return round($row[\''.$column['name'].'\']);'), 111 113 'css_class' => 'number score' 112 ));114 )); 113 115 } 114 116 … … 118 120 } 119 121 array_push($column_infos, array( 120 'title' => $total, 121 'key' => 'score', 122 'rowform' => create_function_cached('$row', 'return round($row[\'score\']);'), 123 'css_class' => 'number score' 124 ) 125 ); 122 'title' => $total, 123 'key' => 'score', 124 'rowform' => create_function_cached('$row', 'return round($row[\'score\']);'), 125 'css_class' => 'number score' 126 )); 126 127 127 128 $round_ids = array();
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)