diff --git a/fleet2.php b/fleet2.php
index fd87d0dc..2db5400e 100644
--- a/fleet2.php
+++ b/fleet2.php
@@ -202,22 +202,27 @@
'isUnionMissionAllowed' => false,
]);
+$joinableUnionsList = [];
+
if (
in_array(Flights\Enums\FleetMission::Attack, $AvailableMissions) &&
$targetPlanetDetails['id'] > 0
) {
- $SQLResult_CheckACS = doquery(
- "SELECT * FROM {{table}} WHERE (`users` LIKE '%|{$_User['id']}|%' OR `owner_id` = {$_User['id']}) AND `end_target_id` = {$targetPlanetDetails['id']} AND `start_time` > UNIX_TIMESTAMP();",
- 'acs'
- );
+ $joinableUnionFlights = FlightControl\Utils\Fetchers\fetchJoinableUnionFlights([
+ 'userId' => $_User['id'],
+ 'targetPlanetId' => $targetPlanetDetails['id'],
+ ]);
- if($SQLResult_CheckACS->num_rows > 0)
- {
- while($ACSData = $SQLResult_CheckACS->fetch_assoc())
- {
- $ACSData['fleets_count'] += 1;
- $ACSList[$ACSData['id']] = "{$ACSData['name']} ({$_Lang['fl_acs_fleets']}: {$ACSData['fleets_count']})";
- }
+ $joinableUnionsList = object_map($joinableUnionFlights, function ($unionFlight) use (&$_Lang) {
+ $joinedFleetsCount = $unionFlight['fleets_count'] + 1;
+
+ return [
+ "{$unionFlight['name']} ({$_Lang['fl_acs_fleets']}: {$joinedFleetsCount})",
+ $unionFlight['id']
+ ];
+ });
+
+ if (!empty($joinableUnionsList)) {
$AvailableMissions[] = Flights\Enums\FleetMission::UnitedAttack;
}
}
@@ -453,8 +458,8 @@
if (in_array(Flights\Enums\FleetMission::UnitedAttack, $AvailableMissions)) {
$_Lang['CreateACSList'] = '';
- foreach ($ACSList as $ID => $Name) {
- $_Lang['CreateACSList'] .= '';
+ foreach ($joinableUnionsList as $unionId => $unionDisplayData) {
+ $_Lang['CreateACSList'] .= '';
}
} else {
$_Lang['P_HideACSJoinList'] = $Hide;
diff --git a/modules/flightControl/_includes.php b/modules/flightControl/_includes.php
index 6c99c6f7..58e83ae0 100644
--- a/modules/flightControl/_includes.php
+++ b/modules/flightControl/_includes.php
@@ -50,6 +50,7 @@
include($includePath . './utils/factories/createUnionInvitationMessage.factory.php');
include($includePath . './utils/fetchers/fetchActiveSmartFleetsBlockadeEntries.fetcher.php');
include($includePath . './utils/fetchers/fetchBashValidatorFlightLogEntries.fetcher.php');
+ include($includePath . './utils/fetchers/fetchJoinableUnionFlights.fetcher.php');
include($includePath . './utils/fetchers/fetchMultiDeclaration.fetcher.php');
include($includePath . './utils/fetchers/fetchPlanetOwnerDetails.fetcher.php');
include($includePath . './utils/fetchers/fetchSavedShortcuts.fetcher.php');
diff --git a/modules/flightControl/utils/fetchers/fetchJoinableUnionFlights.fetcher.php b/modules/flightControl/utils/fetchers/fetchJoinableUnionFlights.fetcher.php
new file mode 100644
index 00000000..0747ff60
--- /dev/null
+++ b/modules/flightControl/utils/fetchers/fetchJoinableUnionFlights.fetcher.php
@@ -0,0 +1,34 @@
+ UNIX_TIMESTAMP() " .
+ ";"
+ );
+ $queryResult = doquery($query, 'acs');
+
+ return mapQueryResults($queryResult, function ($entry) {
+ return $entry;
+ });
+}
+
+?>