Skip to content

Commit

Permalink
Various Fixes & Version Info
Browse files Browse the repository at this point in the history
  • Loading branch information
velocity23 committed Dec 31, 2024
1 parent eebf73c commit 54424a9
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 9 deletions.
6 changes: 3 additions & 3 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ function accessDenied()
$ac = -1;
if (!array_key_exists($route['aircraftLiveryId'], $dbaircraft)) {
Aircraft::add($route['aircraftLiveryId'], $lowrank->id);
$ac = Aircraft::nextId() - 1;
$ac = Aircraft::lastId();
} else {
$ac = $dbaircraft[$route['aircraftLiveryId']]->id;
}
Expand All @@ -877,7 +877,7 @@ function accessDenied()
'arr' => $route['arrivalIcao'],
'duration' => $route['flightTime'],
]);
Route::addAircraft(Route::nextId() - 1, $ac);
Route::addAircraft(Route::lastId(), $ac);
}
VANet::deleteCodeshare($codeshare["id"]);
Cache::delete('badge_codeshares');
Expand Down Expand Up @@ -1069,7 +1069,7 @@ function accessDenied()
"arr" => Input::get('arr'),
"duration" => Input::get('duration'),
]);
$routeId = Route::nextId() - 1;
$routeId = Route::lastId();
foreach (Input::get('aircraft') as $a) {
Route::addAircraft($routeId, $a);
}
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/OauthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function auth_callback()
if ($user->vanetLogin($profile['sub'])) {
if (!$user->data()->vanet_memberid) VANet::refreshMembership($user);
$this->redirect(Session::exists('login_redirect') ? Session::get('login_redirect') : '/home');
} elseif (!$profile['vanet_admin']) {
} elseif ($profile['vanet_admin']) {
$id = User::nextId();
$user->create([
'id' => $id,
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/admin/AdminRoutesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function create()
"duration" => Time::strToSecs(Input::get('duration')),
"notes" => $notes,
]);
$id = Route::nextId() - 1;
$id = Route::lastId();
foreach (explode(',', Input::get('aircraft')) as $acId) {
Route::addAircraft($id, $acId);
}
Expand Down
4 changes: 2 additions & 2 deletions classes/controllers/admin/CodesharesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private function import()
$ac = -1;
if (!array_key_exists($route['aircraftLiveryId'], $dbaircraft)) {
Aircraft::add($route['aircraftLiveryId'], $lowrank->id);
$ac = Aircraft::nextId() - 1;
$ac = Aircraft::lastId();
} else {
$ac = $dbaircraft[$route['aircraftLiveryId']]->id;
}
Expand All @@ -136,7 +136,7 @@ private function import()
'arr' => $route['arrivalIcao'],
'duration' => $route['flightTime'],
]);
Route::addAircraft(Route::nextId() - 1, $ac);
Route::addAircraft(Route::lastId(), $ac);
}
VANet::deleteCodeshare($codeshare["id"]);
Cache::delete('badge_codeshares');
Expand Down
10 changes: 10 additions & 0 deletions classes/data/Aircraft.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,16 @@ public static function nextId()
return $table->Auto_increment;
}

/**
* @return int
*/
public static function lastId()
{
self::init();
$data = self::$_db->query("SELECT MAX(id) AS value FROM aircraft")->results();
return $data[0]->value;
}

public static function unlockedAtRank($rankId)
{
self::init();
Expand Down
10 changes: 10 additions & 0 deletions classes/data/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ public static function nextId()
return $table->Auto_increment;
}

/**
* @return int
*/
public static function lastId()
{
self::init();
$data = self::$_db->query("SELECT MAX(id) AS value FROM routes")->results();
return $data[0]->value;
}

/**
* @return array
* @param int $fltnum Flight Number
Expand Down
19 changes: 19 additions & 0 deletions updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -1629,5 +1629,24 @@
"queries": [],
"deletedFiles": [],
"newFolders": []
},
{
"tag": "v2.5.8",
"name": "Version 2.5.8",
"date": "2024-12-31",
"notes": "Various bug fixes",
"prerelease": false,
"useUpdater": true,
"files": [
"classes/controllers/admin/RoutesController.php",
"classes/data/Route.php",
"classes/controllers/admin/CodesharesController.php",
"classes/controllers/OauthController.php",
"classes/data/Aircraft.php",
"api.php"
],
"queries": [],
"deletedFiles": [],
"newFolders": []
}
]
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tag": "v2.5.7",
"name": "Version 2.5.7",
"tag": "v2.5.8",
"name": "Version 2.5.8",
"prerelease": false
}

0 comments on commit 54424a9

Please sign in to comment.