diff --git a/src/xgp3.0.0/CHANGELOG.txt b/src/xgp3.0.0/CHANGELOG.txt index 7b21848b6..152981a33 100644 --- a/src/xgp3.0.0/CHANGELOG.txt +++ b/src/xgp3.0.0/CHANGELOG.txt @@ -12,6 +12,7 @@ - [#120] Fixed empty alliance tag for alliances administration on the admin cp, other issues were fixed too (Thanks JonaMiX).- - [#122] Fixed notice in the fleet shortcuts page (Thanks JonaMiX).- - [#123] Fixed notice on the fleet 2 page when there are shortcuts available (Thanks JonaMiX).- +- [#124] Fixed issue where the rank was being shown in the search and galaxy when it was disable for some levels.- - [#000] Added missing language line on the home page title.- - [#000] Fixed misplaced language line on the home page for login and register.- - [#000] Minor improvement over registration page. Redirection from index.php?page=reg to index.php?page=register removed, default is now "register".- diff --git a/src/xgp3.0.0/upload/application/controllers/game/galaxy.php b/src/xgp3.0.0/upload/application/controllers/game/galaxy.php index dfc33ad76..766c32402 100755 --- a/src/xgp3.0.0/upload/application/controllers/game/galaxy.php +++ b/src/xgp3.0.0/upload/application/controllers/game/galaxy.php @@ -130,54 +130,57 @@ private function build_page() } // END FIX BY alivan - $this->_galaxy_data = parent::$db->query("SELECT - (SELECT CONCAT ( GROUP_CONCAT(buddy_receiver) , ',' , GROUP_CONCAT(buddy_sender) ) AS buddys FROM " . BUDDY . " AS b WHERE (b.buddy_receiver = u.user_id OR b.buddy_sender = u.user_id ) ) AS buddys, - p.planet_debris_metal AS metal, - p.planet_debris_crystal AS crystal, - p.`planet_id` AS id_planet, - p.planet_galaxy, - p.planet_system, - p.planet_planet, - p.planet_type, - p.planet_destroyed, - p.planet_name, - p.planet_image, - p.planet_last_update, - p.planet_user_id, - u.user_id, - u.user_ally_id, - u.user_banned, - se.setting_vacations_status, - u.user_onlinetime, - u.user_name, - s.user_statistic_total_rank, - s.user_statistic_total_points, - m.planet_id AS id_luna, - m.planet_diameter, - m.planet_temp_min, - m.planet_destroyed AS destroyed_moon, - m.planet_name AS name_moon, - a.alliance_name, - a.alliance_tag, - a.alliance_web, - (SELECT COUNT(user_id) AS `ally_members` FROM `" . USERS . "` WHERE `user_ally_id` = a.`alliance_id`) AS `ally_members` - FROM " . PLANETS . " AS p - INNER JOIN " . USERS . " AS u ON p.planet_user_id = u.user_id - INNER JOIN " . SETTINGS . " AS se ON se.setting_user_id = u.user_id - INNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id - LEFT JOIN " . ALLIANCE . " AS a ON a.alliance_id = u.user_ally_id - LEFT JOIN " . PLANETS . " AS m ON m.planet_id = (SELECT mp.`planet_id` - FROM " . PLANETS . " AS mp - WHERE (mp.planet_galaxy=p.planet_galaxy AND - mp.planet_system=p.planet_system AND - mp.planet_planet=p.planet_planet AND - mp.planet_type=3)) - WHERE (p.planet_galaxy='" . $this->_galaxy . "' AND - p.planet_system='" . $this->_system . "' AND - p.planet_type='1' AND - (p.planet_planet>'0' AND - p.planet_planet<='" . MAX_PLANET_IN_SYSTEM . "')) - ORDER BY p.planet_planet;"); + $this->_galaxy_data = parent::$db->query( + "SELECT + (SELECT CONCAT ( GROUP_CONCAT(buddy_receiver) , ',' , GROUP_CONCAT(buddy_sender) ) AS buddys FROM " . BUDDY . " AS b WHERE (b.buddy_receiver = u.user_id OR b.buddy_sender = u.user_id ) ) AS buddys, + p.planet_debris_metal AS metal, + p.planet_debris_crystal AS crystal, + p.`planet_id` AS id_planet, + p.planet_galaxy, + p.planet_system, + p.planet_planet, + p.planet_type, + p.planet_destroyed, + p.planet_name, + p.planet_image, + p.planet_last_update, + p.planet_user_id, + u.user_id, + u.user_ally_id, + u.user_banned, + se.setting_vacations_status, + u.user_onlinetime, + u.user_name, + u.user_authlevel, + s.user_statistic_total_rank, + s.user_statistic_total_points, + m.planet_id AS id_luna, + m.planet_diameter, + m.planet_temp_min, + m.planet_destroyed AS destroyed_moon, + m.planet_name AS name_moon, + a.alliance_name, + a.alliance_tag, + a.alliance_web, + (SELECT COUNT(user_id) AS `ally_members` FROM `" . USERS . "` WHERE `user_ally_id` = a.`alliance_id`) AS `ally_members` + FROM " . PLANETS . " AS p + INNER JOIN " . USERS . " AS u ON p.planet_user_id = u.user_id + INNER JOIN " . SETTINGS . " AS se ON se.setting_user_id = u.user_id + INNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id + LEFT JOIN " . ALLIANCE . " AS a ON a.alliance_id = u.user_ally_id + LEFT JOIN " . PLANETS . " AS m ON m.planet_id = (SELECT mp.`planet_id` + FROM " . PLANETS . " AS mp + WHERE (mp.planet_galaxy=p.planet_galaxy AND + mp.planet_system=p.planet_system AND + mp.planet_planet=p.planet_planet AND + mp.planet_type=3)) + WHERE (p.planet_galaxy='" . $this->_galaxy . "' AND + p.planet_system='" . $this->_system . "' AND + p.planet_type='1' AND + (p.planet_planet>'0' AND + p.planet_planet<='" . MAX_PLANET_IN_SYSTEM . "')) + ORDER BY p.planet_planet;" + ); $parse = $this->_lang; $parse['js_path'] = XGP_ROOT . JS_PATH; diff --git a/src/xgp3.0.0/upload/application/controllers/game/overview.php b/src/xgp3.0.0/upload/application/controllers/game/overview.php index b1773217b..b65185fb5 100755 --- a/src/xgp3.0.0/upload/application/controllers/game/overview.php +++ b/src/xgp3.0.0/upload/application/controllers/game/overview.php @@ -38,6 +38,7 @@ class Overview extends XGPCore private $_lang; private $_current_user; private $_current_planet; + private $_noob; /** * __construct() @@ -55,6 +56,7 @@ public function __construct() $this->_lang = parent::$lang; $this->_current_user = parent::$users->getUserData(); $this->_current_planet = parent::$users->getPlanetData(); + $this->_noob = FunctionsLib::loadLibrary('NoobsProtectionLib'); $this->build_page(); } @@ -421,7 +423,7 @@ private function get_user_rank() $user_rank = '-'; $total_rank = $this->_current_user['user_statistic_total_rank'] == '' ? $this->_current_planet['stats_users'] : $this->_current_user['user_statistic_total_rank']; - if ($this->_current_user['user_authlevel'] <= FunctionsLib::readConfig('stat_admin_level')) { + if ($this->_noob->isRankVisible($this->_current_user['user_authlevel'])) { $user_rank = FormatLib::prettyNumber($this->_current_user['user_statistic_total_points']) . " (" . $this->_lang['ov_place'] . ' ' . FunctionsLib::setUrl('game.php?page=statistics&range=' . $total_rank, $total_rank, $total_rank) . ' ' . $this->_lang['ov_of'] . ' ' . $this->_current_planet['stats_users'] . ")"; } diff --git a/src/xgp3.0.0/upload/application/controllers/game/search.php b/src/xgp3.0.0/upload/application/controllers/game/search.php index b391f3b9e..3912a2efd 100755 --- a/src/xgp3.0.0/upload/application/controllers/game/search.php +++ b/src/xgp3.0.0/upload/application/controllers/game/search.php @@ -34,6 +34,7 @@ class Search extends XGPCore private $_current_user; private $_lang; + private $_noob; /** * __construct() @@ -50,6 +51,7 @@ public function __construct() $this->_lang = parent::$lang; $this->_current_user = parent::$users->getUserData(); + $this->_noob = FunctionsLib::loadLibrary('NoobsProtectionLib'); $this->build_page(); } @@ -71,18 +73,18 @@ public function __destruct() */ private function build_page() { - $parse = $this->_lang; - $type = isset($_POST['type']) ? $_POST['type'] : ''; - $searchtext = parent::$db->escapeValue(isset($_POST['searchtext']) ? $_POST['searchtext'] : '' ); - $search_results = ''; - + $parse = $this->_lang; + $type = isset($_POST['type']) ? $_POST['type'] : ''; + $searchtext = parent::$db->escapeValue(isset($_POST['searchtext']) ? $_POST['searchtext'] : '' ); + $search_results = ''; + if ($_POST) { switch ($type) { case 'playername': default: $table = parent::$page->getTemplate('search/search_user_table'); $row = parent::$page->getTemplate('search/search_user_row'); - $search = parent::$db->query("SELECT u.user_id AS user_id, u.user_name, p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, s.user_statistic_total_rank AS rank, a.alliance_id, a.alliance_name + $search = parent::$db->query("SELECT u.user_id AS user_id, u.user_name, u.user_authlevel, p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, s.user_statistic_total_rank AS rank, a.alliance_id, a.alliance_name FROM " . USERS . " AS u INNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id INNER JOIN " . PLANETS . " AS p ON p.`planet_id` = u.user_home_planet_id @@ -92,7 +94,7 @@ private function build_page() case 'planetname': $table = parent::$page->getTemplate('search/search_user_table'); $row = parent::$page->getTemplate('search/search_user_row'); - $search = parent::$db->query("SELECT u.user_id AS user_id, u.user_name, p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, s.user_statistic_total_rank AS rank, a.alliance_id, a.alliance_name + $search = parent::$db->query("SELECT u.user_id AS user_id, u.user_name, u.user_authlevel, p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, s.user_statistic_total_rank AS rank, a.alliance_id, a.alliance_name FROM " . USERS . " AS u INNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id INNER JOIN " . PLANETS . " AS p ON p.`planet_id` = u.user_home_planet_id @@ -141,7 +143,7 @@ private function build_page() $s['planet_name'] = $s['planet_name']; $s['username'] = $s['user_name']; $s['alliance_name'] = ($s['alliance_name'] != '') ? "{$s['alliance_name']}" : ''; - $s['position'] = "" . $s['rank'] . ""; + $s['position'] = $this->setPosition($s['rank'], $s['user_authlevel']); $s['coordinated'] = "{$s['planet_galaxy']}:{$s['planet_system']}:{$s['planet_planet']}"; $result_list .= parent::$page->parseTemplate($row, $s); } elseif ($type == 'allytag' or $type == 'allyname') { @@ -166,6 +168,25 @@ private function build_page() parent::$page->display(parent::$page->parseTemplate(parent::$page->getTemplate('search/search_body'), $parse)); } + + /** + * Set the user position or not based on its level + * + * @param int $user_rank User rank + * @param int $user_level User level + * + * @return string + */ + private function setPosition($user_rank, $user_level) + { + if ($this->_noob->isRankVisible($user_level)) { + + return '' . $user_rank . ''; + } else { + + return '-'; + } + } } /* end of search.php */ \ No newline at end of file diff --git a/src/xgp3.0.0/upload/application/libraries/GalaxyLib.php b/src/xgp3.0.0/upload/application/libraries/GalaxyLib.php index b369f825b..15e9f23b7 100755 --- a/src/xgp3.0.0/upload/application/libraries/GalaxyLib.php +++ b/src/xgp3.0.0/upload/application/libraries/GalaxyLib.php @@ -403,6 +403,11 @@ private function usernameBlock() $parse['username'] = $this->row_data['user_name']; $parse['current_rank'] = $this->row_data['user_statistic_total_rank']; $parse['start'] = (floor($this->row_data['user_statistic_total_rank'] / 100) * 100) + 1; + + if (!$this->noob->isRankVisible($this->row_data['user_authlevel'])) { + $parse['current_rank'] = '-'; + $parse['start'] = 0; + } if ($this->row_data['user_id'] != $this->current_user['user_id']) { diff --git a/src/xgp3.0.0/upload/application/libraries/NoobsProtectionLib.php b/src/xgp3.0.0/upload/application/libraries/NoobsProtectionLib.php index 1ee927bda..567fc409a 100755 --- a/src/xgp3.0.0/upload/application/libraries/NoobsProtectionLib.php +++ b/src/xgp3.0.0/upload/application/libraries/NoobsProtectionLib.php @@ -31,15 +31,19 @@ class NoobsProtectionLib extends XGPCore private $protection; private $protectiontime; private $protectionmulti; + private $allowed_level; /** * __construct() */ public function __construct() { - $this->protection = FunctionsLib::readConfig('noobprotection'); - $this->protectiontime = FunctionsLib::readConfig('noobprotectiontime'); - $this->protectionmulti = FunctionsLib::readConfig('noobprotectionmulti'); + $configs = FunctionsLib::readConfig('', true); + + $this->protection = $configs['noobprotection']; + $this->protectiontime = $configs['noobprotectiontime']; + $this->protectionmulti = $configs['noobprotectionmulti']; + $this->allowed_level = $configs['stat_admin_level']; } /** @@ -125,6 +129,22 @@ public function returnPoints($current_user_id, $other_user_id) ); return $user_points; } + + /** + * Determines if the rank can be shown or not + * + * @param int $user_auth_level User authorization level (0-3) + * + * @return boolean + */ + public function isRankVisible($user_auth_level) + { + if ($user_auth_level <= $this->allowed_level) { + return true; + } + + return false; + } } /* end of NoobsProtectionLib.php */