Changeset 1116 for trunk/common
- Timestamp:
- 03/21/10 15:45:34 (2 years ago)
- File:
-
- 1 edited
-
trunk/common/db/score.php (modified) (2 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);
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)