Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.0.2 #3019

Merged
merged 26 commits into from
Aug 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
69ec83d
Fix upload image error (#2984)
partydragen Aug 6, 2022
05fc221
Fix non-string config values not saving properly (#2983)
samerton Aug 6, 2022
f2c60a9
Remove mentions of "pre-release" from installer (#2985)
tadhgboyle Aug 6, 2022
46fd4b4
Fix API error name
Derkades Aug 6, 2022
3726a17
Make update check more resilient to API being down (#2987)
tadhgboyle Aug 7, 2022
cdd7d85
Better module/template version check (#2994)
tadhgboyle Aug 7, 2022
98fe4b7
Add ability to rate limit via Validate class (#2998)
samerton Aug 7, 2022
eee47b3
Add croatian language (#2990)
Derkades Aug 7, 2022
a73e4bc
Display PHP version in die() when version is not acceptable
tadhgboyle Aug 7, 2022
8dba3c3
Fix active language file value (#3004)
tadhgboyle Aug 8, 2022
0922950
Revert image upload changes
partydragen Aug 8, 2022
38eb2fd
Fix several profile images issues
partydragen Aug 8, 2022
fbbc44b
Fix upload image language
partydragen Aug 8, 2022
5d56470
Better missing/extra migration exception page (#3005)
tadhgboyle Aug 11, 2022
26525ec
Merge pull request #3006 from NamelessMC/bugfix/fix-profile-images
samerton Aug 11, 2022
5b996f3
Allow selecting an MC server to use for group sync options (#2991)
tadhgboyle Aug 12, 2022
469bebc
Rework user sessions system (#3000)
partydragen Aug 13, 2022
b70cedc
Add OAuth to pages to not store as `last_page`
tadhgboyle Aug 13, 2022
26d5cc0
Merge pull request #3015 from NamelessMC/fix/oauth-login-error
samerton Aug 13, 2022
52e9559
Remake tab initialization (#3009)
PadowYT2 Aug 13, 2022
be5c947
Logout rework (#3008)
samerton Aug 13, 2022
49ba64f
Display each OAuth providers redirect URL & misc fixes to template (#…
tadhgboyle Aug 13, 2022
aa73c47
Fix exception when user id is null in email_error table (#3012)
partydragen Aug 13, 2022
ace91ac
Convert two factor disabling to post request
samerton Aug 13, 2022
db1290c
Merge pull request #3018 from NamelessMC/feature/tfa-disable-rework
samerton Aug 13, 2022
8d4178b
Bump to 2.0.2
samerton Aug 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow selecting an MC server to use for group sync options (#2991)
  • Loading branch information
tadhgboyle authored Aug 12, 2022
commit 5b996f376734fb6858ab4d98f7c0927e0f25ddf4
4 changes: 3 additions & 1 deletion custom/languages/en_UK.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@
"admin/group_sync": "Group Sync",
"admin/group_sync_info": "You can configure the API to automatically update a user's website group when their integration group is changed. Simply enter the integration group name\/ID and the website group it will be synchronised with the below rules.",
"admin/group_sync_logs": "Group Sync Changes",
"admin/group_sync_plugin_not_set_up": "In-game plugin is not set up",
"admin/group_sync_server": "Select a Minecraft server to use for group sync",
"admin/group_sync_plugin_not_set_up": "In-game plugin is not set up or no group sync server has been selected",
"admin/group_sync_rule_created_successfully": "The group sync rule has been created successfully.",
"admin/group_sync_rule_deleted_successfully": "The group sync rule has been deleted successfully.",
"admin/group_sync_rules_updated_successfully": "Group sync rules have been updated successfully.",
Expand Down Expand Up @@ -392,6 +393,7 @@
"admin/no_custom_pages": "No pages have been created yet.",
"admin/no_default_server": "No default server",
"admin/no_email_errors": "No email errors logged.",
"admin/no_group_sync_server": "No group sync server",
"admin/no_hooks_yet": "There are no webhooks yet.",
"admin/no_item_selected": "No items selected",
"admin/no_notices": "No notices.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,27 @@
<div class="form-group">
<label for="inputDefaultServer">{$DEFAULT_SERVER}</label>
<select id="inputDefaultServer" class="form-control" name="default_server">
{if $SERVERS|count > 1}
<option value="none" {if $DEFAULT_SERVER_VALUE eq 0} selected{/if}>{$NO_DEFAULT_SERVER}</option>
{if isset($SERVERS) && count($SERVERS)}
<option value="none" {if $DEFAULT_SERVER_VALUE eq 0} selected{/if}>{$NO_DEFAULT_SERVER}</option>
{foreach from=$SERVERS item=server}
<option value="{$server.id}" {if $server.is_default eq 1} selected{/if}>{$server.name}</option>
{/foreach}
{else}
<option value="none" selected>{$NO_SERVERS}</option>
{/if}
</select>
</div>

<div class="form-group">
<label for="inputGroupSyncServer">{$GROUP_SYNC_SERVER}</label>
<select id="inputGroupSyncServer" class="form-control" name="group_sync_server">
{if isset($SERVERS) && count($SERVERS)}
{foreach from=$SERVERS item=server}
<option value="{$server.id}" {if $server.is_default eq 1} selected{/if}>{$server.name}</option>
{/foreach}
<option value="none" {if $GROUP_SYNC_SERVER_VALUE eq 0}selected{/if}>{$NO_GROUP_SYNC_SERVER}</option>
{foreach from=$SERVERS item=server}
<option value="{$server.id}" {if $GROUP_SYNC_SERVER_VALUE eq $server.id} selected{/if}>{$server.name}</option>
{/foreach}
{else}
<option value="none" selected>{$NO_SERVERS}</option>
{/if}
</select>
</div>
Expand Down Expand Up @@ -208,4 +222,4 @@

</body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ public function getColumnType(): string {
}

public function shouldEnable(): bool {
return count($this->getSelectionOptions()) > 0;
return Util::getSetting('group_sync_mc_server') != 0 && count($this->getSelectionOptions()) > 0;
}

public function getSelectionOptions(): array {
$row = DB::getInstance()->query('SELECT `groups` FROM `nl2_query_results` ORDER BY `id` DESC LIMIT 1')->first();
$row = DB::getInstance()->query(
'SELECT `groups` FROM `nl2_query_results` WHERE `server_id` = ? ORDER BY `id` DESC LIMIT 1',
[Util::getSetting('group_sync_mc_server')]
)->first();

if ($row === null) {
// Plugin is not set up
// Plugin is not set up and/or they did not select a server to source groups from/default server
return [];
}

Expand Down
10 changes: 7 additions & 3 deletions modules/Core/includes/endpoints/ServerInfoEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function execute(Nameless2API $api): void {
}

$group_sync_log = [];
$should_group_sync = $serverId == Util::getSetting('group_sync_mc_server');

try {
$integration = Integrations::getInstance()->getIntegration('Minecraft');
Expand All @@ -73,9 +74,12 @@ public function execute(Nameless2API $api): void {
$integrationUser = new IntegrationUser($integration, $uuid, 'identifier');
if ($integrationUser->exists()) {
$this->updateUsername($integrationUser, $player);
$log = $this->updateGroups($integrationUser, $player);
if (count($log)) {
$group_sync_log[] = $log;

if ($should_group_sync) {
$log = $this->updateGroups($integrationUser, $player);
if (count($log)) {
$group_sync_log[] = $log;
}
}

if (isset($player['placeholders']) && count($player['placeholders'])) {
Expand Down
2 changes: 2 additions & 0 deletions modules/Core/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,7 @@ public static function addUserAction($title, $link): void {

public function getDebugInfo(): array {
$servers = [];
$group_sync_server_id = Util::getSetting('group_sync_mc_server');
foreach (DB::getInstance()->get('mc_servers', ['id', '<>', 0])->results() as $server) {
$servers[(int)$server->id] = [
'id' => (int)$server->id,
Expand All @@ -1611,6 +1612,7 @@ public function getDebugInfo(): array {
'port' => $server->port,
'query_port' => $server->query_port,
'bedrock' => (bool)$server->bedrock,
'group_sync_server' => $server->id == $group_sync_server_id,
];
}

Expand Down
15 changes: 15 additions & 0 deletions modules/Core/pages/panel/minecraft_servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,12 @@
$new_default = 0;
}

if (isset($_POST['group_sync_server']) && is_numeric($_POST['group_sync_server'])) {
$new_group_sync_server = $_POST['group_sync_server'];
} else {
$new_group_sync_server = 0;
}

if (isset($_POST['external_query']) && $_POST['external_query'] == 1) {
$external = 1;
} else {
Expand Down Expand Up @@ -526,6 +532,9 @@
}
}

// Group sync server
Util::setSetting('group_sync_mc_server', $new_group_sync_server);

// External query
$external_query_id = DB::getInstance()->get('settings', ['name', 'external_query'])->results();
$external_query_id = $external_query_id[0];
Expand Down Expand Up @@ -600,6 +609,9 @@
$status_page = DB::getInstance()->get('settings', ['name', 'status_page'])->results();
$status_page = $status_page[0]->value;

$group_sync_server = DB::getInstance()->get('settings', ['name', 'group_sync_mc_server'])->results();
$group_sync_server = $group_sync_server[0]->value;

// Query interval
$cache->setCache('server_query_cache');
if ($cache->isCached('query_interval')) {
Expand Down Expand Up @@ -632,6 +644,9 @@
'DEFAULT_SERVER' => $language->get('admin', 'default_server'),
'DEFAULT_SERVER_VALUE' => $default,
'NO_DEFAULT_SERVER' => $language->get('admin', 'no_default_server'),
'GROUP_SYNC_SERVER' => $language->get('admin', 'group_sync_server'),
'GROUP_SYNC_SERVER_VALUE' => $group_sync_server,
'NO_GROUP_SYNC_SERVER' => $language->get('admin', 'no_group_sync_server'),
'QUERY_INTERVAL' => $language->get('admin', 'query_interval'),
'QUERY_INTERVAL_VALUE' => $query_interval,
'EXTERNAL_QUERY' => $language->get('admin', 'external_query'),
Expand Down