v1.0.0 (#183)
* #84 test data dump from CREST login * updated "credits" dialog (Google+ link) fixed login form layout * updated Cortex Data-Mapper * - #84 CREST Login (WIP) - New CREST controller - Database restructuring - improved type-casting for some controller functions - New login process - Fixed some bugs during the setup process (/setup root) - Added CREST request caching by response headers * pathfinder-84 [Feature Request] CREST Pilot Tracking, many smaller Bugfixes * pathfinder-84 [Feature Request] added develop JS files * closed #121 fixed wormhole signature type caching * closed #120 removed map-loading animation for larger maps (same behaviour as IGB) * closed #119 fixed wormhole signature id count * closed #114 Added check for already existing system when adding a new one. (fixed PDO 'duplicate entry' error) * closed #112 fixed DataTables error for missing "status" data (signature table) * closed #111 fixed convertDataToUTC(); client side date transformation * closed #109 fixed system TrueSec rounding * closed #103 fixed system updated timestamp in getData() * fixed CSS class for secStatus in Routes module * closed #121 fixed wormhole signature type caching * changed dateTime format from German to US format fixed some minor bugs in signatureTable module * closed #81 fixed "signature type" overwriting by "signature reader" update * closed #106 added new signature_types form C5/6 wormholes (gas/ore) * closed #129 fixed parameter hinting * closed #131 new "route search" algorithm, added current map systems to live search, added refresh/update functionality for each found route, added bulk route refresh function, added "meta map" route search (search on multiple maps), added route "filters" (restrict search on "stargates", "wormholes", "jumpbridges"), added route "filter" for wormholes (reduced/critical wormholes) closed #89 fixed "loop connections" on same system #84 added error messages for "invalid" CREST "Client ID" added "bootboxjs" (customized styled checkboxes/radio buttons) CSS only "Font Awesome" version upgrade 4.4.0 -> 4.61 "Bootbox.js" version upgrade 4.3.0 -> 4.4.0 fixed "system dialog" (added responsive layout) * closed #134 fixed db column type DT_INT (8 bytes) to DT_BIGINT * closed #138 added new cookie based login * closed #137 fixed javascript errors on trying to establish an "invalid" connection * - #84, #138 improved "character selection" on login page (expired cookies are deleted, character panel layout improvements) - added new "Server info panel" to the login page - added new cronjob to delete expired cookie authentication data * #138 enables character switching between characters which have same user * - PHP Framework upgrade 3.5.0 -> 3.5.1 (fixes some issues with CREST cURL caching, and SESSION management) - #138 added "cookie logout" to "logout" menu entry * - updated "feature page" with new feature descriptions and label - added some new images to the "feature gallery" - removed "beta" status from "magnetizing" feature on map menu - hide "server status" panel on "mobile" breakpoint * - #138 clear character authentication data on sold characters * closed #142 added custom "onsuspect()" session handler * #142 do not log suspect if no file is defined in pathfinder.ini * #142 added NullSec Data/Relic sites to C1/2/3 wormholes as signature option * #144 fixed "Character not found" warning * #144 fixed "Character not found" warning * closed #144 fixed broken routes panel in IGB * updated README.md for upcoming release * #147 response header validation * #149 changed comment for 'BASE' framework var * fixed map import * - added minimal SDE dump (EVE Online: Citadel) - #147 improved CREST API error logging (WIP) - improved SSO controller (removed access_token from public endpoints) * closed #154 added alliance maps to CREST API * - updated Gulp build dependencies - increased CREST timeout from 3s -> 4s - added "Accept" Headers for some CREST endpoints * cloased #147 * - closed #153 added character verification check for getAll(); Signatures Ajax endpoint * - updated README.md (added Slack developer chat information) * Bugfix frig holes (#159) * added missing frigate wormholes and fixed Q003 destination in shattered wormholes * changed C7 to 0.0 for Q003 * - fixed broken "graph" data for system * added a "failover" system for bad crest requests (HTTP status 5xx,.. ) * Red Gaint => Red Giant (#161) * closed #163 added CREST endpoint support for "waypoints" * fixed typo * closed #160 fixed tooltip container * - added new features to login page * closes #154 added alliance map support * fixed XML path for cronjobs * fixed a bug with inactive "private" maps * closes #175 added alternative environment configuration * - v1.0.0 build
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
namespace Controller\Api;
|
||||
use Controller;
|
||||
use Model;
|
||||
|
||||
/**
|
||||
@@ -14,25 +15,23 @@ use Model;
|
||||
* Class Map
|
||||
* @package Controller\Api
|
||||
*/
|
||||
class Map extends \Controller\AccessController {
|
||||
class Map extends Controller\AccessController {
|
||||
|
||||
/**
|
||||
* event handler
|
||||
* @param $f3
|
||||
* @param \Base $f3
|
||||
*/
|
||||
function beforeroute($f3) {
|
||||
|
||||
function beforeroute(\Base $f3) {
|
||||
// set header for all routes
|
||||
header('Content-type: application/json');
|
||||
|
||||
parent::beforeroute($f3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all required static config data for program initialization
|
||||
* @param $f3
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function init($f3){
|
||||
public function init(\Base $f3){
|
||||
|
||||
// expire time in seconds
|
||||
$expireTimeHead = 60 * 60 * 12;
|
||||
@@ -40,10 +39,11 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
$f3->expire($expireTimeHead);
|
||||
|
||||
$initData = [];
|
||||
$return = (object) [];
|
||||
$return->error = [];
|
||||
|
||||
// static program data ------------------------------------------------
|
||||
$initData['timer'] = $f3->get('PATHFINDER.TIMER');
|
||||
$return->timer = $f3->get('PATHFINDER.TIMER');
|
||||
|
||||
// get all available map types ----------------------------------------
|
||||
$mapType = Model\BasicModel::getNew('MapTypeModel');
|
||||
@@ -60,7 +60,7 @@ class Map extends \Controller\AccessController {
|
||||
$mapTypeData[$rowData->name] = $data;
|
||||
|
||||
}
|
||||
$initData['mapTypes'] = $mapTypeData;
|
||||
$return->mapTypes = $mapTypeData;
|
||||
|
||||
// get all available map scopes ---------------------------------------
|
||||
$mapScope = Model\BasicModel::getNew('MapScopeModel');
|
||||
@@ -73,7 +73,7 @@ class Map extends \Controller\AccessController {
|
||||
];
|
||||
$mapScopeData[$rowData->name] = $data;
|
||||
}
|
||||
$initData['mapScopes'] = $mapScopeData;
|
||||
$return->mapScopes = $mapScopeData;
|
||||
|
||||
// get all available system status ------------------------------------
|
||||
$systemStatus = Model\BasicModel::getNew('SystemStatusModel');
|
||||
@@ -87,7 +87,7 @@ class Map extends \Controller\AccessController {
|
||||
];
|
||||
$systemScopeData[$rowData->name] = $data;
|
||||
}
|
||||
$initData['systemStatus'] = $systemScopeData;
|
||||
$return->systemStatus = $systemScopeData;
|
||||
|
||||
// get all available system types -------------------------------------
|
||||
$systemType = Model\BasicModel::getNew('SystemTypeModel');
|
||||
@@ -100,7 +100,7 @@ class Map extends \Controller\AccessController {
|
||||
];
|
||||
$systemTypeData[$rowData->name] = $data;
|
||||
}
|
||||
$initData['systemType'] = $systemTypeData;
|
||||
$return->systemType = $systemTypeData;
|
||||
|
||||
// get available connection scopes ------------------------------------
|
||||
$connectionScope = Model\BasicModel::getNew('ConnectionScopeModel');
|
||||
@@ -114,7 +114,7 @@ class Map extends \Controller\AccessController {
|
||||
];
|
||||
$connectionScopeData[$rowData->name] = $data;
|
||||
}
|
||||
$initData['connectionScopes'] = $connectionScopeData;
|
||||
$return->connectionScopes = $connectionScopeData;
|
||||
|
||||
// get available character status -------------------------------------
|
||||
$characterStatus = Model\BasicModel::getNew('CharacterStatusModel');
|
||||
@@ -128,24 +128,40 @@ class Map extends \Controller\AccessController {
|
||||
];
|
||||
$characterStatusData[$rowData->name] = $data;
|
||||
}
|
||||
$initData['characterStatus'] = $characterStatusData;
|
||||
$return->characterStatus = $characterStatusData;
|
||||
|
||||
// get max number of shared entities per map --------------------------
|
||||
$maxSharedCount = [
|
||||
'user' => $f3->get('PATHFINDER.MAX_SHARED_USER'),
|
||||
'character' => $f3->get('PATHFINDER.MAX_SHARED_CHARACTER'),
|
||||
'corporation' => $f3->get('PATHFINDER.MAX_SHARED_CORPORATION'),
|
||||
'alliance' => $f3->get('PATHFINDER.MAX_SHARED_ALLIANCE'),
|
||||
];
|
||||
$initData['maxSharedCount'] = $maxSharedCount;
|
||||
$return->maxSharedCount = $maxSharedCount;
|
||||
|
||||
echo json_encode($initData);
|
||||
// get program routes -------------------------------------------------
|
||||
$return->routes = [
|
||||
'ssoLogin' => $this->getF3()->alias( 'sso', ['action' => 'requestAuthorization'] )
|
||||
];
|
||||
|
||||
// get SSO error messages that should be shown immediately ------------
|
||||
// -> e.g. errors while character switch from previous HTTP requests
|
||||
if( $f3->exists(Controller\Ccp\Sso::SESSION_KEY_SSO_ERROR) ){
|
||||
$ssoError = (object) [];
|
||||
$ssoError->type = 'error';
|
||||
$ssoError->title = 'Login failed';
|
||||
$ssoError->message = $f3->get(Controller\Ccp\Sso::SESSION_KEY_SSO_ERROR);
|
||||
$return->error[] = $ssoError;
|
||||
$f3->clear(Controller\Ccp\Sso::SESSION_KEY_SSO_ERROR);
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* import new map data
|
||||
* @param $f3
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function import($f3){
|
||||
public function import(\Base $f3){
|
||||
$importData = (array)$f3->get('POST');
|
||||
|
||||
$return = (object) [];
|
||||
@@ -155,13 +171,23 @@ class Map extends \Controller\AccessController {
|
||||
isset($importData['typeId']) &&
|
||||
count($importData['mapData']) > 0
|
||||
){
|
||||
$user = $this->_getUser();
|
||||
$activeCharacter = $this->getCharacter();
|
||||
|
||||
if($user){
|
||||
$activeCharacter = $user->getActiveUserCharacter();
|
||||
if($activeCharacter){
|
||||
|
||||
/**
|
||||
* @var $map Model\MapModel
|
||||
*/
|
||||
$map = Model\BasicModel::getNew('MapModel');
|
||||
|
||||
/**
|
||||
* @var $system Model\SystemModel
|
||||
*/
|
||||
$system = Model\BasicModel::getNew('SystemModel');
|
||||
|
||||
/**
|
||||
* @var $connection Model\ConnectionModel
|
||||
*/
|
||||
$connection = Model\BasicModel::getNew('ConnectionModel');
|
||||
|
||||
foreach($importData['mapData'] as $mapData){
|
||||
@@ -194,8 +220,8 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
$system->setData($systemData);
|
||||
$system->mapId = $map;
|
||||
$system->createdCharacterId = $activeCharacter->characterId;
|
||||
$system->updatedCharacterId = $activeCharacter->characterId;
|
||||
$system->createdCharacterId = $activeCharacter;
|
||||
$system->updatedCharacterId = $activeCharacter;
|
||||
$system->save();
|
||||
|
||||
$tempSystemIdMapping[$oldId] = $system->id;
|
||||
@@ -203,7 +229,6 @@ class Map extends \Controller\AccessController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach($mapData['data']['connections'] as $connectionData){
|
||||
// check if source and target IDs match with new system ID
|
||||
if(
|
||||
@@ -226,15 +251,13 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
// map access info should not automatically imported
|
||||
if($map->isPrivate()){
|
||||
$map->setAccess($user);
|
||||
$map->setAccess($activeCharacter);
|
||||
}elseif($map->isCorporation()){
|
||||
$corporation = $activeCharacter->getCharacter()->getCorporation();
|
||||
if($corporation){
|
||||
if($corporation = $activeCharacter->getCorporation()){
|
||||
$map->setAccess($corporation);
|
||||
}
|
||||
}elseif($map->isAlliance()){
|
||||
$alliance = $activeCharacter->getCharacter()->getAlliance();
|
||||
if($alliance){
|
||||
if($alliance = $activeCharacter->getAlliance()){
|
||||
$map->setAccess($alliance);
|
||||
}
|
||||
}
|
||||
@@ -260,7 +283,7 @@ class Map extends \Controller\AccessController {
|
||||
}
|
||||
}else{
|
||||
// user not found
|
||||
$return->error[] = $this->getUserLoggedOffError();
|
||||
$return->error[] = $this->getLogoutError();
|
||||
}
|
||||
}else{
|
||||
// map data missing
|
||||
@@ -276,25 +299,28 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
/**
|
||||
* save a new map or update an existing map
|
||||
* @param $f3
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function save($f3){
|
||||
public function save(\Base $f3){
|
||||
$formData = (array)$f3->get('POST.formData');
|
||||
|
||||
$return = (object) [];
|
||||
$return->error = [];
|
||||
|
||||
if( isset($formData['id']) ){
|
||||
$activeCharacter = $this->getCharacter(0);
|
||||
|
||||
$user = $this->_getUser(0);
|
||||
if($activeCharacter){
|
||||
|
||||
if($user){
|
||||
/**
|
||||
* @var $map Model\MapModel
|
||||
*/
|
||||
$map = Model\BasicModel::getNew('MapModel');
|
||||
$map->getById( (int)$formData['id'] );
|
||||
|
||||
if(
|
||||
$map->dry() ||
|
||||
$map->hasAccess($user)
|
||||
$map->hasAccess($activeCharacter)
|
||||
){
|
||||
// new map
|
||||
$map->setData($formData);
|
||||
@@ -303,118 +329,117 @@ class Map extends \Controller\AccessController {
|
||||
// save global map access. Depends on map "type"
|
||||
if($map->isPrivate()){
|
||||
|
||||
// share map between users -> set access
|
||||
if(isset($formData['mapUsers'])){
|
||||
// share map between characters -> set access
|
||||
if(isset($formData['mapCharacters'])){
|
||||
// avoid abuse -> respect share limits
|
||||
$accessUsers = array_slice( $formData['mapUsers'], 0, $f3->get('PATHFINDER.MAX_SHARED_USER') );
|
||||
$accessCharacters = array_slice( $formData['mapCharacters'], 0, $f3->get('PATHFINDER.MAX_SHARED_CHARACTER') );
|
||||
|
||||
// clear map access. In case something has removed from access list
|
||||
$map->clearAccess();
|
||||
|
||||
$tempUser = Model\BasicModel::getNew('UserModel');
|
||||
/**
|
||||
* @var $tempCharacter Model\CharacterModel
|
||||
*/
|
||||
$tempCharacter = Model\BasicModel::getNew('CharacterModel');
|
||||
|
||||
foreach($accessUsers as $userId){
|
||||
$tempUser->getById( (int)$userId );
|
||||
foreach($accessCharacters as $characterId){
|
||||
$tempCharacter->getById( (int)$characterId );
|
||||
|
||||
if(
|
||||
!$tempUser->dry() &&
|
||||
$tempUser->shared == 1 // check if map shared is enabled
|
||||
!$tempCharacter->dry() &&
|
||||
$tempCharacter->shared == 1 // check if map shared is enabled
|
||||
){
|
||||
$map->setAccess($tempUser);
|
||||
$map->setAccess($tempCharacter);
|
||||
}
|
||||
|
||||
$tempUser->reset();
|
||||
$tempCharacter->reset();
|
||||
}
|
||||
}
|
||||
|
||||
// the current user itself should always have access
|
||||
// the current character itself should always have access
|
||||
// just in case he removed himself :)
|
||||
$map->setAccess($user);
|
||||
$map->setAccess($activeCharacter);
|
||||
}elseif($map->isCorporation()){
|
||||
$activeCharacter = $user->getActiveUserCharacter();
|
||||
$corporation = $activeCharacter->getCorporation();
|
||||
|
||||
if($activeCharacter){
|
||||
$corporation = $activeCharacter->getCharacter()->getCorporation();
|
||||
if($corporation){
|
||||
// the current user has to have a corporation when
|
||||
// working on corporation maps!
|
||||
|
||||
if($corporation){
|
||||
// the current user has to have a corporation when
|
||||
// working on corporation maps!
|
||||
// share map between corporations -> set access
|
||||
if(isset($formData['mapCorporations'])){
|
||||
// avoid abuse -> respect share limits
|
||||
$accessCorporations = array_slice( $formData['mapCorporations'], 0, $f3->get('PATHFINDER.MAX_SHARED_CORPORATION') );
|
||||
|
||||
// share map between corporations -> set access
|
||||
if(isset($formData['mapCorporations'])){
|
||||
// avoid abuse -> respect share limits
|
||||
$accessCorporations = array_slice( $formData['mapCorporations'], 0, $f3->get('PATHFINDER.MAX_SHARED_CORPORATION') );
|
||||
// clear map access. In case something has removed from access list
|
||||
$map->clearAccess();
|
||||
|
||||
// clear map access. In case something has removed from access list
|
||||
$map->clearAccess();
|
||||
/**
|
||||
* @var $tempCorporation Model\CorporationModel
|
||||
*/
|
||||
$tempCorporation = Model\BasicModel::getNew('CorporationModel');
|
||||
|
||||
$tempCorporation = Model\BasicModel::getNew('CorporationModel');
|
||||
foreach($accessCorporations as $corporationId){
|
||||
$tempCorporation->getById( (int)$corporationId );
|
||||
|
||||
foreach($accessCorporations as $corporationId){
|
||||
$tempCorporation->getById( (int)$corporationId );
|
||||
|
||||
if(
|
||||
!$tempCorporation->dry() &&
|
||||
$tempCorporation->shared == 1 // check if map shared is enabled
|
||||
){
|
||||
$map->setAccess($tempCorporation);
|
||||
}
|
||||
|
||||
$tempCorporation->reset();
|
||||
if(
|
||||
!$tempCorporation->dry() &&
|
||||
$tempCorporation->shared == 1 // check if map shared is enabled
|
||||
){
|
||||
$map->setAccess($tempCorporation);
|
||||
}
|
||||
}
|
||||
|
||||
// the corporation of the current user should always have access
|
||||
$map->setAccess($corporation);
|
||||
$tempCorporation->reset();
|
||||
}
|
||||
}
|
||||
|
||||
// the corporation of the current user should always have access
|
||||
$map->setAccess($corporation);
|
||||
}
|
||||
}elseif($map->isAlliance()){
|
||||
$activeCharacter = $user->getActiveUserCharacter();
|
||||
$alliance = $activeCharacter->getAlliance();
|
||||
|
||||
if($activeCharacter){
|
||||
$alliance = $activeCharacter->getCharacter()->getAlliance();
|
||||
if($alliance){
|
||||
// the current user has to have a alliance when
|
||||
// working on alliance maps!
|
||||
|
||||
if($alliance){
|
||||
// the current user has to have a alliance when
|
||||
// working on alliance maps!
|
||||
// share map between alliances -> set access
|
||||
if(isset($formData['mapAlliances'])){
|
||||
// avoid abuse -> respect share limits
|
||||
$accessAlliances = array_slice( $formData['mapAlliances'], 0, $f3->get('PATHFINDER.MAX_SHARED_ALLIANCE') );
|
||||
|
||||
// share map between alliances -> set access
|
||||
if(isset($formData['mapAlliances'])){
|
||||
// avoid abuse -> respect share limits
|
||||
$accessAlliances = array_slice( $formData['mapAlliances'], 0, $f3->get('PATHFINDER.MAX_SHARED_ALLIANCE') );
|
||||
// clear map access. In case something has removed from access list
|
||||
$map->clearAccess();
|
||||
|
||||
// clear map access. In case something has removed from access list
|
||||
$map->clearAccess();
|
||||
/**
|
||||
* @var $tempAlliance Model\AllianceModel
|
||||
*/
|
||||
$tempAlliance = Model\BasicModel::getNew('AllianceModel');
|
||||
|
||||
$tempAlliance = Model\BasicModel::getNew('AllianceModel');
|
||||
foreach($accessAlliances as $allianceId){
|
||||
$tempAlliance->getById( (int)$allianceId );
|
||||
|
||||
foreach($accessAlliances as $allianceId){
|
||||
$tempAlliance->getById( (int)$allianceId );
|
||||
|
||||
if(
|
||||
!$tempAlliance->dry() &&
|
||||
$tempAlliance->shared == 1 // check if map shared is enabled
|
||||
){
|
||||
$map->setAccess($tempAlliance);
|
||||
}
|
||||
|
||||
$tempAlliance->reset();
|
||||
if(
|
||||
!$tempAlliance->dry() &&
|
||||
$tempAlliance->shared == 1 // check if map shared is enabled
|
||||
){
|
||||
$map->setAccess($tempAlliance);
|
||||
}
|
||||
|
||||
$tempAlliance->reset();
|
||||
}
|
||||
|
||||
// the alliance of the current user should always have access
|
||||
$map->setAccess($alliance);
|
||||
}
|
||||
|
||||
// the alliance of the current user should always have access
|
||||
$map->setAccess($alliance);
|
||||
}
|
||||
}
|
||||
// reload the same map model (refresh)
|
||||
// this makes sure all data is up2date
|
||||
$map->getById( $map->id, 0 );
|
||||
|
||||
|
||||
$return->mapData = $map->getData();
|
||||
|
||||
}else{
|
||||
// map access denied
|
||||
$captchaError = (object) [];
|
||||
@@ -423,7 +448,6 @@ class Map extends \Controller\AccessController {
|
||||
$return->error[] = $captchaError;
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
// map id field missing
|
||||
$idError = (object) [];
|
||||
@@ -437,17 +461,19 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
/**
|
||||
* delete a map and all dependencies
|
||||
* @param $f3
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function delete($f3){
|
||||
public function delete(\Base $f3){
|
||||
$mapData = (array)$f3->get('POST.mapData');
|
||||
$activeCharacter = $this->getCharacter();
|
||||
|
||||
$user = $this->_getUser();
|
||||
|
||||
if($user){
|
||||
if($activeCharacter){
|
||||
/**
|
||||
* @var $map Model\MapModel
|
||||
*/
|
||||
$map = Model\BasicModel::getNew('MapModel');
|
||||
$map->getById($mapData['id']);
|
||||
$map->delete($user);
|
||||
$map->delete( $activeCharacter );
|
||||
}
|
||||
|
||||
echo json_encode([]);
|
||||
@@ -455,34 +481,28 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
/**
|
||||
* update map data
|
||||
* function is called continuously
|
||||
* @param $f3
|
||||
* -> function is called continuously (trigger) by any active client
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function updateData($f3){
|
||||
|
||||
// cache time(s) per user should be equal or less than this function is called
|
||||
// prevent request flooding
|
||||
$responseTTL = $f3->get('PATHFINDER.TIMER.UPDATE_SERVER_MAP.DELAY') / 1000;
|
||||
public function updateData(\Base $f3){
|
||||
$mapData = (array)$f3->get('POST.mapData');
|
||||
|
||||
$user = $this->_getUser();
|
||||
$activeCharacter = $this->getCharacter();
|
||||
|
||||
$return = (object) [];
|
||||
$return->error = [];
|
||||
|
||||
if($user){
|
||||
// -> get active character
|
||||
$activeCharacter = $user->getActiveUserCharacter();
|
||||
if($activeCharacter){
|
||||
|
||||
$cacheKey = 'user_map_data_' . $activeCharacter->id;
|
||||
$cacheKey = 'user_map_data_' . $activeCharacter->_id;
|
||||
|
||||
// if there is any system/connection change data submitted -> save new data
|
||||
if(
|
||||
$f3->exists($cacheKey) === false ||
|
||||
!empty($mapData)
|
||||
!empty($mapData) ||
|
||||
!$f3->exists($cacheKey)
|
||||
){
|
||||
|
||||
// get current map data ========================================================
|
||||
$maps = $user->getMaps();
|
||||
$maps = $activeCharacter->getMaps();
|
||||
|
||||
// loop all submitted map data that should be saved
|
||||
// -> currently there will only be ONE map data change submitted -> single loop
|
||||
@@ -532,7 +552,7 @@ class Map extends \Controller\AccessController {
|
||||
unset($systemData['updated']);
|
||||
$system = $filteredMap->systems->current();
|
||||
$system->setData($systemData);
|
||||
$system->updatedCharacterId = $activeCharacter->characterId;
|
||||
$system->updatedCharacterId = $activeCharacter;
|
||||
$system->save();
|
||||
|
||||
// a system belongs to ONE map -> speed up for multiple maps
|
||||
@@ -561,7 +581,7 @@ class Map extends \Controller\AccessController {
|
||||
unset($connectionData['updated']);
|
||||
$connection = $filteredMap->connections->current();
|
||||
$connection->setData($connectionData);
|
||||
$connection->save($user);
|
||||
$connection->save();
|
||||
|
||||
// a connection belongs to ONE map -> speed up for multiple maps
|
||||
unset($connectionData[$i]);
|
||||
@@ -574,6 +594,11 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
// format map Data for return
|
||||
$return->mapData = self::getFormattedMapData($maps);
|
||||
|
||||
// cache time(s) per user should be equal or less than this function is called
|
||||
// prevent request flooding
|
||||
$responseTTL = (int)$f3->get('PATHFINDER.TIMER.UPDATE_SERVER_MAP.DELAY') / 1000;
|
||||
|
||||
$f3->set($cacheKey, $return, $responseTTL);
|
||||
}else{
|
||||
// get from cache
|
||||
@@ -582,23 +607,24 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
}else{
|
||||
// user logged off
|
||||
$return->error[] = $this->getUserLoggedOffError();
|
||||
$return->error[] = $this->getLogoutError();
|
||||
}
|
||||
|
||||
echo json_encode( $return );
|
||||
}
|
||||
|
||||
/**
|
||||
* get formatted map data
|
||||
* @param $mapModels
|
||||
* @return Model\MapModel[]
|
||||
* @return array
|
||||
*/
|
||||
public static function getFormattedMapData($mapModels){
|
||||
|
||||
$mapData = [];
|
||||
foreach($mapModels as $mapModel){
|
||||
|
||||
foreach($mapModels as &$mapModel){
|
||||
/**
|
||||
* @var $mapModel Model\MapModel
|
||||
*/
|
||||
$allMapData = $mapModel->getData();
|
||||
|
||||
$mapData[] = [
|
||||
'config' => $allMapData->mapData,
|
||||
'data' => [
|
||||
@@ -613,33 +639,23 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
/**
|
||||
* update map data api
|
||||
* function is called continuously
|
||||
* @param $f3
|
||||
* -> function is called continuously by any active client
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function updateUserData($f3){
|
||||
|
||||
// cache time(s) should be equal or less than request trigger time
|
||||
// prevent request flooding
|
||||
$responseTTL = $f3->get('PATHFINDER.TIMER.UPDATE_SERVER_USER_DATA.DELAY') / 1000;
|
||||
|
||||
// if the cache key will be set -> cache request
|
||||
$cacheKey = null;
|
||||
|
||||
public function updateUserData(\Base $f3){
|
||||
$return = (object) [];
|
||||
$return->error = [];
|
||||
$activeCharacter = $this->getCharacter(0);
|
||||
|
||||
$user = $this->_getUser();
|
||||
|
||||
if($user){
|
||||
if($activeCharacter){
|
||||
|
||||
if( !empty($f3->get('POST.mapIds')) ){
|
||||
$mapIds = (array)$f3->get('POST.mapIds');
|
||||
// check if data for specific system is requested
|
||||
$systemData = (array)$f3->get('POST.systemData');
|
||||
|
||||
|
||||
// update current location (IGB data)
|
||||
$user->updateCharacterLog(60 * 5);
|
||||
// update current location
|
||||
// -> suppress temporary timeout errors
|
||||
$activeCharacter = $activeCharacter->updateLog(['suppressTimeoutErrors' => true]);
|
||||
|
||||
// if data is requested extend the cache key in order to get new data
|
||||
$requestSystemData = (object) [];
|
||||
@@ -649,24 +665,23 @@ class Map extends \Controller\AccessController {
|
||||
// IMPORTANT for now -> just update a single map (save performance)
|
||||
$mapIds = array_slice($mapIds, 0, 1);
|
||||
|
||||
// the userMasData is cached per map (this must be changed if multiple maps
|
||||
// the userMapData is cached per map (this must be changed if multiple maps
|
||||
// will be allowed in future...
|
||||
$tempId = (int)$mapIds[0];
|
||||
$cacheKey = 'user_data_' . $tempId . '_' . $requestSystemData->systemId;
|
||||
|
||||
if( $f3->exists($cacheKey) === false ){
|
||||
if( !$f3->exists($cacheKey) ){
|
||||
foreach($mapIds as $mapId){
|
||||
$map = $user->getMap($mapId);
|
||||
$map = $activeCharacter->getMap( (int)$mapId);
|
||||
|
||||
if( !is_null($map) ){
|
||||
$return->mapUserData[] = $map->getUserData();
|
||||
|
||||
// request signature data for a system if user has map access!
|
||||
if( $map->id === $requestSystemData->mapId ){
|
||||
$system = $map->getSystem( $requestSystemData->systemId );
|
||||
$system = $map->getSystemById( $requestSystemData->systemId );
|
||||
|
||||
if( !is_null($system) ){
|
||||
// data for the current selected system
|
||||
// data for currently selected system
|
||||
$return->system = $system->getData();
|
||||
$return->system->signatures = $system->getSignaturesData();
|
||||
}
|
||||
@@ -674,6 +689,10 @@ class Map extends \Controller\AccessController {
|
||||
}
|
||||
}
|
||||
|
||||
// cache time (seconds) should be equal or less than request trigger time
|
||||
// prevent request flooding
|
||||
$responseTTL = (int)$f3->get('PATHFINDER.TIMER.UPDATE_SERVER_USER_DATA.DELAY') / 1000;
|
||||
|
||||
// cache response
|
||||
$f3->set($cacheKey, $return, $responseTTL);
|
||||
}else{
|
||||
@@ -686,14 +705,12 @@ class Map extends \Controller\AccessController {
|
||||
|
||||
// get current user data -> this should not be cached because each user has different personal data
|
||||
// even if they have multiple characters using the same map!
|
||||
$return->userData = $user->getData();
|
||||
|
||||
$return->userData = $activeCharacter->getUser()->getData();
|
||||
}else{
|
||||
// user logged off
|
||||
$return->error[] = $this->getUserLoggedOffError();
|
||||
$return->error[] = $this->getLogoutError();
|
||||
}
|
||||
|
||||
|
||||
echo json_encode( $return );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user