| @@ 628-649 (lines=22) @@ | ||
| 625 | return $trainers; |
|
| 626 | } |
|
| 627 | ||
| 628 | public function getTrainerLevelRanking() |
|
| 629 | { |
|
| 630 | $exclue = ''; |
|
| 631 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
| 632 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
| 633 | } |
|
| 634 | $req = 'SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL '.$exclue.' GROUP BY owner_level, owner_name) x GROUP BY level'; |
|
| 635 | $result = $this->mysqli->query($req); |
|
| 636 | $levelData = array(); |
|
| 637 | while ($data = $result->fetch_object()) { |
|
| 638 | $levelData[$data->level] = $data->count; |
|
| 639 | } |
|
| 640 | for ($i = 5; $i <= 40; ++$i) { |
|
| 641 | if (!isset($levelData[$i])) { |
|
| 642 | $levelData[$i] = 0; |
|
| 643 | } |
|
| 644 | } |
|
| 645 | // sort array again |
|
| 646 | ksort($levelData); |
|
| 647 | ||
| 648 | return $levelData; |
|
| 649 | } |
|
| 650 | ||
| 651 | public function getActivePokemon($trainer_name) |
|
| 652 | { |
|
| @@ 681-702 (lines=22) @@ | ||
| 678 | return $pokemon; |
|
| 679 | } |
|
| 680 | ||
| 681 | public function getTrainerLevelCount($team_id) |
|
| 682 | { |
|
| 683 | $exclue = ''; |
|
| 684 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
| 685 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
| 686 | } |
|
| 687 | $req = "SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL AND team = '".$team_id."' ".$exclue.' GROUP BY owner_level, owner_name) x GROUP BY level'; |
|
| 688 | $result = $this->mysqli->query($req); |
|
| 689 | $levelData = array(); |
|
| 690 | while ($data = $result->fetch_object()) { |
|
| 691 | $levelData[$data->level] = $data->count; |
|
| 692 | } |
|
| 693 | for ($i = 5; $i <= 40; ++$i) { |
|
| 694 | if (!isset($levelData[$i])) { |
|
| 695 | $levelData[$i] = 0; |
|
| 696 | } |
|
| 697 | } |
|
| 698 | // sort array again |
|
| 699 | ksort($levelData); |
|
| 700 | ||
| 701 | return $levelData; |
|
| 702 | } |
|
| 703 | ||
| 704 | ///////// |
|
| 705 | // Cron |
|
| @@ 614-635 (lines=22) @@ | ||
| 611 | return $trainers; |
|
| 612 | } |
|
| 613 | ||
| 614 | public function getTrainerLevelCount($team_id) |
|
| 615 | { |
|
| 616 | $req = "SELECT level, count(level) AS count FROM trainer WHERE team = '".$team_id."'"; |
|
| 617 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
| 618 | $req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
| 619 | } |
|
| 620 | $req .= ' GROUP BY level'; |
|
| 621 | $result = $this->mysqli->query($req); |
|
| 622 | $levelData = array(); |
|
| 623 | while ($data = $result->fetch_object()) { |
|
| 624 | $levelData[$data->level] = $data->count; |
|
| 625 | } |
|
| 626 | for ($i = 5; $i <= 40; ++$i) { |
|
| 627 | if (!isset($levelData[$i])) { |
|
| 628 | $levelData[$i] = 0; |
|
| 629 | } |
|
| 630 | } |
|
| 631 | // sort array again |
|
| 632 | ksort($levelData); |
|
| 633 | ||
| 634 | return $levelData; |
|
| 635 | } |
|
| 636 | ||
| 637 | private function getTrainerData($trainer_name, $team, $page, $ranking) |
|
| 638 | { |
|