Skip to content

Commit 42cbd1c

Browse files
committed
Fixed Issue #124
Also created new method isRankVisible to handle better if the rank can be show or not.
1 parent 93f69ac commit 42cbd1c

File tree

6 files changed

+112
-60
lines changed

6 files changed

+112
-60
lines changed

src/xgp3.0.0/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [#120] Fixed empty alliance tag for alliances administration on the admin cp, other issues were fixed too (Thanks JonaMiX).-
1313
- [#122] Fixed notice in the fleet shortcuts page (Thanks JonaMiX).-
1414
- [#123] Fixed notice on the fleet 2 page when there are shortcuts available (Thanks JonaMiX).-
15+
- [#124] Fixed issue where the rank was being shown in the search and galaxy when it was disable for some levels.-
1516
- [#000] Added missing language line on the home page title.-
1617
- [#000] Fixed misplaced language line on the home page for login and register.-
1718
- [#000] Minor improvement over registration page. Redirection from index.php?page=reg to index.php?page=register removed, default is now "register".-

src/xgp3.0.0/upload/application/controllers/game/galaxy.php

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -130,54 +130,57 @@ private function build_page()
130130
}
131131
// END FIX BY alivan
132132

133-
$this->_galaxy_data = parent::$db->query("SELECT
134-
(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,
135-
p.planet_debris_metal AS metal,
136-
p.planet_debris_crystal AS crystal,
137-
p.`planet_id` AS id_planet,
138-
p.planet_galaxy,
139-
p.planet_system,
140-
p.planet_planet,
141-
p.planet_type,
142-
p.planet_destroyed,
143-
p.planet_name,
144-
p.planet_image,
145-
p.planet_last_update,
146-
p.planet_user_id,
147-
u.user_id,
148-
u.user_ally_id,
149-
u.user_banned,
150-
se.setting_vacations_status,
151-
u.user_onlinetime,
152-
u.user_name,
153-
s.user_statistic_total_rank,
154-
s.user_statistic_total_points,
155-
m.planet_id AS id_luna,
156-
m.planet_diameter,
157-
m.planet_temp_min,
158-
m.planet_destroyed AS destroyed_moon,
159-
m.planet_name AS name_moon,
160-
a.alliance_name,
161-
a.alliance_tag,
162-
a.alliance_web,
163-
(SELECT COUNT(user_id) AS `ally_members` FROM `" . USERS . "` WHERE `user_ally_id` = a.`alliance_id`) AS `ally_members`
164-
FROM " . PLANETS . " AS p
165-
INNER JOIN " . USERS . " AS u ON p.planet_user_id = u.user_id
166-
INNER JOIN " . SETTINGS . " AS se ON se.setting_user_id = u.user_id
167-
INNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id
168-
LEFT JOIN " . ALLIANCE . " AS a ON a.alliance_id = u.user_ally_id
169-
LEFT JOIN " . PLANETS . " AS m ON m.planet_id = (SELECT mp.`planet_id`
170-
FROM " . PLANETS . " AS mp
171-
WHERE (mp.planet_galaxy=p.planet_galaxy AND
172-
mp.planet_system=p.planet_system AND
173-
mp.planet_planet=p.planet_planet AND
174-
mp.planet_type=3))
175-
WHERE (p.planet_galaxy='" . $this->_galaxy . "' AND
176-
p.planet_system='" . $this->_system . "' AND
177-
p.planet_type='1' AND
178-
(p.planet_planet>'0' AND
179-
p.planet_planet<='" . MAX_PLANET_IN_SYSTEM . "'))
180-
ORDER BY p.planet_planet;");
133+
$this->_galaxy_data = parent::$db->query(
134+
"SELECT
135+
(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,
136+
p.planet_debris_metal AS metal,
137+
p.planet_debris_crystal AS crystal,
138+
p.`planet_id` AS id_planet,
139+
p.planet_galaxy,
140+
p.planet_system,
141+
p.planet_planet,
142+
p.planet_type,
143+
p.planet_destroyed,
144+
p.planet_name,
145+
p.planet_image,
146+
p.planet_last_update,
147+
p.planet_user_id,
148+
u.user_id,
149+
u.user_ally_id,
150+
u.user_banned,
151+
se.setting_vacations_status,
152+
u.user_onlinetime,
153+
u.user_name,
154+
u.user_authlevel,
155+
s.user_statistic_total_rank,
156+
s.user_statistic_total_points,
157+
m.planet_id AS id_luna,
158+
m.planet_diameter,
159+
m.planet_temp_min,
160+
m.planet_destroyed AS destroyed_moon,
161+
m.planet_name AS name_moon,
162+
a.alliance_name,
163+
a.alliance_tag,
164+
a.alliance_web,
165+
(SELECT COUNT(user_id) AS `ally_members` FROM `" . USERS . "` WHERE `user_ally_id` = a.`alliance_id`) AS `ally_members`
166+
FROM " . PLANETS . " AS p
167+
INNER JOIN " . USERS . " AS u ON p.planet_user_id = u.user_id
168+
INNER JOIN " . SETTINGS . " AS se ON se.setting_user_id = u.user_id
169+
INNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id
170+
LEFT JOIN " . ALLIANCE . " AS a ON a.alliance_id = u.user_ally_id
171+
LEFT JOIN " . PLANETS . " AS m ON m.planet_id = (SELECT mp.`planet_id`
172+
FROM " . PLANETS . " AS mp
173+
WHERE (mp.planet_galaxy=p.planet_galaxy AND
174+
mp.planet_system=p.planet_system AND
175+
mp.planet_planet=p.planet_planet AND
176+
mp.planet_type=3))
177+
WHERE (p.planet_galaxy='" . $this->_galaxy . "' AND
178+
p.planet_system='" . $this->_system . "' AND
179+
p.planet_type='1' AND
180+
(p.planet_planet>'0' AND
181+
p.planet_planet<='" . MAX_PLANET_IN_SYSTEM . "'))
182+
ORDER BY p.planet_planet;"
183+
);
181184

182185
$parse = $this->_lang;
183186
$parse['js_path'] = XGP_ROOT . JS_PATH;

src/xgp3.0.0/upload/application/controllers/game/overview.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Overview extends XGPCore
3838
private $_lang;
3939
private $_current_user;
4040
private $_current_planet;
41+
private $_noob;
4142

4243
/**
4344
* __construct()
@@ -55,6 +56,7 @@ public function __construct()
5556
$this->_lang = parent::$lang;
5657
$this->_current_user = parent::$users->getUserData();
5758
$this->_current_planet = parent::$users->getPlanetData();
59+
$this->_noob = FunctionsLib::loadLibrary('NoobsProtectionLib');
5860

5961
$this->build_page();
6062
}
@@ -421,7 +423,7 @@ private function get_user_rank()
421423
$user_rank = '-';
422424
$total_rank = $this->_current_user['user_statistic_total_rank'] == '' ? $this->_current_planet['stats_users'] : $this->_current_user['user_statistic_total_rank'];
423425

424-
if ($this->_current_user['user_authlevel'] <= FunctionsLib::readConfig('stat_admin_level')) {
426+
if ($this->_noob->isRankVisible($this->_current_user['user_authlevel'])) {
425427
$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'] . ")";
426428
}
427429

src/xgp3.0.0/upload/application/controllers/game/search.php

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Search extends XGPCore
3434

3535
private $_current_user;
3636
private $_lang;
37+
private $_noob;
3738

3839
/**
3940
* __construct()
@@ -50,6 +51,7 @@ public function __construct()
5051

5152
$this->_lang = parent::$lang;
5253
$this->_current_user = parent::$users->getUserData();
54+
$this->_noob = FunctionsLib::loadLibrary('NoobsProtectionLib');
5355

5456
$this->build_page();
5557
}
@@ -71,18 +73,18 @@ public function __destruct()
7173
*/
7274
private function build_page()
7375
{
74-
$parse = $this->_lang;
75-
$type = isset($_POST['type']) ? $_POST['type'] : '';
76-
$searchtext = parent::$db->escapeValue(isset($_POST['searchtext']) ? $_POST['searchtext'] : '' );
77-
$search_results = '';
78-
76+
$parse = $this->_lang;
77+
$type = isset($_POST['type']) ? $_POST['type'] : '';
78+
$searchtext = parent::$db->escapeValue(isset($_POST['searchtext']) ? $_POST['searchtext'] : '' );
79+
$search_results = '';
80+
7981
if ($_POST) {
8082
switch ($type) {
8183
case 'playername':
8284
default:
8385
$table = parent::$page->getTemplate('search/search_user_table');
8486
$row = parent::$page->getTemplate('search/search_user_row');
85-
$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
87+
$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
8688
FROM " . USERS . " AS u
8789
INNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id
8890
INNER JOIN " . PLANETS . " AS p ON p.`planet_id` = u.user_home_planet_id
@@ -92,7 +94,7 @@ private function build_page()
9294
case 'planetname':
9395
$table = parent::$page->getTemplate('search/search_user_table');
9496
$row = parent::$page->getTemplate('search/search_user_row');
95-
$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
97+
$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
9698
FROM " . USERS . " AS u
9799
INNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id
98100
INNER JOIN " . PLANETS . " AS p ON p.`planet_id` = u.user_home_planet_id
@@ -141,7 +143,7 @@ private function build_page()
141143
$s['planet_name'] = $s['planet_name'];
142144
$s['username'] = $s['user_name'];
143145
$s['alliance_name'] = ($s['alliance_name'] != '') ? "<a href=\"game.php?page=alliance&mode=ainfo&allyid={$s['alliance_id']}\">{$s['alliance_name']}</a>" : '';
144-
$s['position'] = "<a href=\"game.php?page=statistics&start=" . $s['rank'] . "\">" . $s['rank'] . "</a>";
146+
$s['position'] = $this->setPosition($s['rank'], $s['user_authlevel']);
145147
$s['coordinated'] = "{$s['planet_galaxy']}:{$s['planet_system']}:{$s['planet_planet']}";
146148
$result_list .= parent::$page->parseTemplate($row, $s);
147149
} elseif ($type == 'allytag' or $type == 'allyname') {
@@ -166,6 +168,25 @@ private function build_page()
166168

167169
parent::$page->display(parent::$page->parseTemplate(parent::$page->getTemplate('search/search_body'), $parse));
168170
}
171+
172+
/**
173+
* Set the user position or not based on its level
174+
*
175+
* @param int $user_rank User rank
176+
* @param int $user_level User level
177+
*
178+
* @return string
179+
*/
180+
private function setPosition($user_rank, $user_level)
181+
{
182+
if ($this->_noob->isRankVisible($user_level)) {
183+
184+
return '<a href="game.php?page=statistics&start=' . $user_rank . '">' . $user_rank . '</a>';
185+
} else {
186+
187+
return '-';
188+
}
189+
}
169190
}
170191

171192
/* end of search.php */

src/xgp3.0.0/upload/application/libraries/GalaxyLib.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@ private function usernameBlock()
403403
$parse['username'] = $this->row_data['user_name'];
404404
$parse['current_rank'] = $this->row_data['user_statistic_total_rank'];
405405
$parse['start'] = (floor($this->row_data['user_statistic_total_rank'] / 100) * 100) + 1;
406+
407+
if (!$this->noob->isRankVisible($this->row_data['user_authlevel'])) {
408+
$parse['current_rank'] = '-';
409+
$parse['start'] = 0;
410+
}
406411

407412
if ($this->row_data['user_id'] != $this->current_user['user_id']) {
408413

src/xgp3.0.0/upload/application/libraries/NoobsProtectionLib.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@ class NoobsProtectionLib extends XGPCore
3131
private $protection;
3232
private $protectiontime;
3333
private $protectionmulti;
34+
private $allowed_level;
3435

3536
/**
3637
* __construct()
3738
*/
3839
public function __construct()
3940
{
40-
$this->protection = FunctionsLib::readConfig('noobprotection');
41-
$this->protectiontime = FunctionsLib::readConfig('noobprotectiontime');
42-
$this->protectionmulti = FunctionsLib::readConfig('noobprotectionmulti');
41+
$configs = FunctionsLib::readConfig('', true);
42+
43+
$this->protection = $configs['noobprotection'];
44+
$this->protectiontime = $configs['noobprotectiontime'];
45+
$this->protectionmulti = $configs['noobprotectionmulti'];
46+
$this->allowed_level = $configs['stat_admin_level'];
4347
}
4448

4549
/**
@@ -125,6 +129,22 @@ public function returnPoints($current_user_id, $other_user_id)
125129
);
126130
return $user_points;
127131
}
132+
133+
/**
134+
* Determines if the rank can be shown or not
135+
*
136+
* @param int $user_auth_level User authorization level (0-3)
137+
*
138+
* @return boolean
139+
*/
140+
public function isRankVisible($user_auth_level)
141+
{
142+
if ($user_auth_level <= $this->allowed_level) {
143+
return true;
144+
}
145+
146+
return false;
147+
}
128148
}
129149

130150
/* end of NoobsProtectionLib.php */

0 commit comments

Comments
 (0)