- removed SDE database requirement from Pathfinder, #628
- improved "shattered" wormholes (e.g. UI updates on map, fixed broken statics,..), closed #647 - improved "route search" algorithm, WHs are no longer supposed to be "insecure"
This commit is contained in:
@@ -138,11 +138,10 @@ class Map extends Controller\AccessController {
|
||||
$return->connectionScopes = $connectionScopeData;
|
||||
|
||||
// get available wormhole types ---------------------------------------------------------------------------
|
||||
$wormholes = Model\BasicModel::getNew('WormholeModel');
|
||||
$rows = $wormholes->find('id > 0', null, $expireTimeSQL);
|
||||
$wormhole = Model\Universe\BasicUniverseModel::getNew('WormholeModel');
|
||||
$wormholesData = [];
|
||||
if($rows){
|
||||
foreach((array)$rows as $rowData){
|
||||
if($rows = $wormhole->find(null, ['order' => 'name asc'], $expireTimeSQL)){
|
||||
foreach($rows as $rowData){
|
||||
$wormholesData[$rowData->name] = $rowData->getData();
|
||||
}
|
||||
}
|
||||
@@ -741,12 +740,11 @@ class Map extends Controller\AccessController {
|
||||
// system belongs to the current map
|
||||
if(is_object($filteredMap->systems)){
|
||||
// update
|
||||
|
||||
/**
|
||||
* @var $system Model\SystemModel
|
||||
*/
|
||||
$system = $filteredMap->systems->current();
|
||||
$system->setData($systemData);
|
||||
$system->copyfrom($systemData, ['alias', 'status', 'position', 'locked', 'rallyUpdated', 'rallyPoke']);
|
||||
|
||||
if($system->save($activeCharacter)){
|
||||
$mapChanged = true;
|
||||
@@ -776,7 +774,6 @@ class Map extends Controller\AccessController {
|
||||
// connection belongs to the current map
|
||||
if(is_object($filteredMap->connections)){
|
||||
// update
|
||||
|
||||
/**
|
||||
* @var $connection Model\ConnectionModel
|
||||
*/
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
*/
|
||||
|
||||
namespace Controller\Api;
|
||||
|
||||
use Controller;
|
||||
use Controller\Ccp\Universe;
|
||||
use lib\Config;
|
||||
use Model;
|
||||
|
||||
|
||||
/**
|
||||
* Routes controller
|
||||
* Class Route
|
||||
@@ -101,6 +102,7 @@ class Route extends Controller\AccessController {
|
||||
* -> (e.g. new system added, connection added/updated, ...)
|
||||
* @param array $mapIds
|
||||
* @param array $filterData
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function setDynamicJumpData($mapIds = [], $filterData = []){
|
||||
// make sure, mapIds are integers (protect against SQL injections)
|
||||
@@ -177,7 +179,7 @@ class Route extends Controller\AccessController {
|
||||
`system_src`.`systemId` systemId,
|
||||
(
|
||||
SELECT
|
||||
GROUP_CONCAT( NULLIF(`system_tar`.`name`, NULL) SEPARATOR ':')
|
||||
GROUP_CONCAT( NULLIF(`system_tar`.`systemId`, NULL) SEPARATOR ':')
|
||||
FROM
|
||||
`connection` INNER JOIN
|
||||
`system` system_tar ON
|
||||
@@ -211,6 +213,17 @@ class Route extends Controller\AccessController {
|
||||
$rows = $this->getDB()->exec($query, null, $this->dynamicJumpDataCacheTime);
|
||||
|
||||
if(count($rows) > 0){
|
||||
// enrich $row data with static system data (from universe DB)
|
||||
$universe = new Universe();
|
||||
for($i = 0; $i < count($rows); $i++){
|
||||
if($staticData = $universe->getSystemData($rows[$i]['systemId'])){
|
||||
$rows[$i]['systemName'] = $staticData->name;
|
||||
$rows[$i]['constellationId'] = $staticData->constellation->id;
|
||||
$rows[$i]['regionId'] = $staticData->constellation->region->id;
|
||||
$rows[$i]['trueSec'] = $staticData->trueSec;
|
||||
}
|
||||
}
|
||||
|
||||
// update jump data for this instance
|
||||
$this->updateJumpData($rows);
|
||||
}
|
||||
@@ -229,7 +242,7 @@ class Route extends Controller\AccessController {
|
||||
foreach($rows as &$row){
|
||||
$regionId = (int)$row['regionId'];
|
||||
$constId = (int)$row['constellationId'];
|
||||
$systemName = strtoupper($row['systemName']);
|
||||
$systemName = (string)($row['systemName']);
|
||||
$systemId = (int)$row['systemId'];
|
||||
$secStatus = (float)$row['trueSec'];
|
||||
|
||||
@@ -242,19 +255,19 @@ class Route extends Controller\AccessController {
|
||||
}
|
||||
|
||||
// fill "idArray" data ------------------------------------------------------------------------------------
|
||||
if( !isset($this->idArray[$systemName]) ){
|
||||
$this->idArray[$systemName] = $systemId;
|
||||
if( !isset($this->idArray[$systemId]) ){
|
||||
$this->idArray[$systemId] = $systemName;
|
||||
}
|
||||
|
||||
// fill "jumpArray" data ----------------------------------------------------------------------------------
|
||||
if( !is_array($this->jumpArray[$systemName]) ){
|
||||
$this->jumpArray[$systemName] = [];
|
||||
if( !is_array($this->jumpArray[$systemId]) ){
|
||||
$this->jumpArray[$systemId] = [];
|
||||
}
|
||||
$this->jumpArray[$systemName] = array_merge( explode(':', strtoupper($row['jumpNodes'])), $this->jumpArray[$systemName] );
|
||||
$this->jumpArray[$systemId] = array_merge(array_map('intval', explode(':', $row['jumpNodes'])), $this->jumpArray[$systemId]);
|
||||
|
||||
// add systemId to end (if not already there)
|
||||
if(end($this->jumpArray[$systemName]) != $systemId){
|
||||
array_push($this->jumpArray[$systemName],$systemId);
|
||||
// add systemName to end (if not already there)
|
||||
if(end($this->jumpArray[$systemId]) != $systemName){
|
||||
array_push($this->jumpArray[$systemId], $systemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,24 +280,23 @@ class Route extends Controller\AccessController {
|
||||
private function filterJumpData($filterData = [], $keepSystems = []){
|
||||
if($filterData['flag'] == 'secure'){
|
||||
// remove all systems (TrueSec < 0.5) from search arrays
|
||||
$this->jumpArray = array_filter($this->jumpArray, function($jumpData) use($keepSystems) {
|
||||
|
||||
// systemId is always last entry
|
||||
$systemId = end($jumpData);
|
||||
$this->jumpArray = array_filter($this->jumpArray, function($systemId) use($keepSystems) {
|
||||
$systemNameData = $this->nameArray[$systemId];
|
||||
$systemSec = $systemNameData[3];
|
||||
|
||||
if($systemSec < 0.45 && !in_array($systemId, $keepSystems)){
|
||||
// remove system from nameArray as well
|
||||
if(
|
||||
$systemSec < 0.45 &&
|
||||
!in_array($systemId, $keepSystems) &&
|
||||
!preg_match('/^j\d+$/i', $this->idArray[$systemId]) // WHs are supposed to be "secure"
|
||||
){
|
||||
// remove system from nameArray and idArray
|
||||
unset($this->nameArray[$systemId]);
|
||||
// remove system from idArray as well
|
||||
$systemName = $systemNameData[0];
|
||||
unset($this->idArray[$systemName]);
|
||||
unset($this->idArray[$systemId]);
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}, ARRAY_FILTER_USE_KEY );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,16 +310,16 @@ class Route extends Controller\AccessController {
|
||||
$info = null;
|
||||
switch($option){
|
||||
case 'systemName':
|
||||
$info = $this->nameArray[ $systemId ][0];
|
||||
$info = $this->nameArray[$systemId][0];
|
||||
break;
|
||||
case 'regionId':
|
||||
$info = $this->nameArray[ $systemId ][1];
|
||||
$info = $this->nameArray[$systemId][1];
|
||||
break;
|
||||
case 'constellationId':
|
||||
$info = $this->nameArray[ $systemId ][2];
|
||||
$info = $this->nameArray[$systemId][2];
|
||||
break;
|
||||
case 'trueSec':
|
||||
$info = $this->nameArray[ $systemId ][3];
|
||||
$info = $this->nameArray[$systemId][3];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -387,13 +399,13 @@ class Route extends Controller\AccessController {
|
||||
|
||||
/**
|
||||
* get formatted jump node data
|
||||
* @param $systemName
|
||||
* @param int $systemId
|
||||
* @return array
|
||||
*/
|
||||
protected function getJumpNodeData($systemName) : array {
|
||||
protected function getJumpNodeData(int $systemId) : array {
|
||||
return [
|
||||
'system' => $systemName,
|
||||
'security' => $this->getSystemInfoBySystemId($this->idArray[$systemName], 'trueSec')
|
||||
'system' => $this->getSystemInfoBySystemId($systemId, 'systemName'),
|
||||
'security' => $this->getSystemInfoBySystemId($systemId, 'trueSec')
|
||||
];
|
||||
}
|
||||
|
||||
@@ -430,6 +442,7 @@ class Route extends Controller\AccessController {
|
||||
* @param array $mapIds
|
||||
* @param array $filterData
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
private function searchRouteCustom(int $systemFromId, int $systemToId, $searchDepth = 0, array $mapIds = [], array $filterData = []) : array {
|
||||
@@ -454,19 +467,16 @@ class Route extends Controller\AccessController {
|
||||
// --> don´t filter some systems (e.g. systemFrom, systemTo) even if they are are WH,LS,0.0
|
||||
$this->filterJumpData($filterData, [$systemFromId, $systemToId]);
|
||||
|
||||
$systemFrom = $this->getSystemInfoBySystemId($systemFromId, 'systemName');
|
||||
$systemTo = $this->getSystemInfoBySystemId($systemToId, 'systemName');
|
||||
|
||||
// search route -------------------------------------------------------------------------------------------
|
||||
|
||||
// jump counter
|
||||
$jumpNum = 0;
|
||||
$depthSearched = 0;
|
||||
|
||||
if( isset($this->jumpArray[$systemFrom]) ){
|
||||
if( isset($this->jumpArray[$systemFromId]) ){
|
||||
// check if the system we are looking for is a direct neighbour
|
||||
foreach( $this->jumpArray[$systemFrom] as $n ) {
|
||||
if ($n == $systemTo) {
|
||||
foreach( $this->jumpArray[$systemFromId] as $n ) {
|
||||
if ($n == $systemToId) {
|
||||
$jumpNum = 2;
|
||||
$routeData['route'][] = $this->getJumpNodeData($n);
|
||||
break;
|
||||
@@ -475,11 +485,11 @@ class Route extends Controller\AccessController {
|
||||
|
||||
// system is not a direct neighbour -> search recursive its neighbours
|
||||
if ($jumpNum == 0) {
|
||||
$searchResult = $this->graph_find_path( $this->jumpArray, $systemFrom, $systemTo, $searchDepth );
|
||||
$searchResult = $this->graph_find_path( $this->jumpArray, $systemFromId, $systemToId, $searchDepth );
|
||||
$depthSearched = $searchResult['depth'];
|
||||
foreach( $searchResult['path'] as $systemName ) {
|
||||
foreach( $searchResult['path'] as $systemId ) {
|
||||
if ($jumpNum > 0) {
|
||||
$routeData['route'][] = $this->getJumpNodeData($systemName);
|
||||
$routeData['route'][] = $this->getJumpNodeData($systemId);
|
||||
}
|
||||
$jumpNum++;
|
||||
}
|
||||
@@ -489,7 +499,7 @@ class Route extends Controller\AccessController {
|
||||
// route found
|
||||
$routeData['routePossible'] = true;
|
||||
// insert "from" system on top
|
||||
array_unshift($routeData['route'], $this->getJumpNodeData($systemFrom));
|
||||
array_unshift($routeData['route'], $this->getJumpNodeData($systemFromId));
|
||||
} else {
|
||||
// route not found
|
||||
$routeData['routePossible'] = false;
|
||||
@@ -512,6 +522,7 @@ class Route extends Controller\AccessController {
|
||||
* @param array $mapIds
|
||||
* @param array $filterData
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
private function searchRouteESI(int $systemFromId, int $systemToId, int $searchDepth = 0, array $mapIds = [], array $filterData = []) : array {
|
||||
@@ -540,18 +551,16 @@ class Route extends Controller\AccessController {
|
||||
$this->filterJumpData($filterData, [$systemFromId, $systemToId]);
|
||||
|
||||
$connections = [];
|
||||
foreach($this->jumpArray as $systemSourceName => $jumpData){
|
||||
foreach($this->jumpArray as $systemSourceId => $jumpData){
|
||||
$count = count($jumpData);
|
||||
if($count > 1){
|
||||
// ... should always > 1
|
||||
$systemSourceId = (int)$this->idArray[$systemSourceName];
|
||||
// loop all connections for current source system
|
||||
foreach($jumpData as $systemTargetName) {
|
||||
foreach($jumpData as $systemTargetId) {
|
||||
// skip last entry
|
||||
if(--$count <= 0){
|
||||
break;
|
||||
}
|
||||
$systemTargetId = (int)$this->idArray[$systemTargetName];
|
||||
|
||||
// systemIds exist and wer not removed before in filterJumpData()
|
||||
if($systemSourceId && $systemTargetId){
|
||||
@@ -599,8 +608,7 @@ class Route extends Controller\AccessController {
|
||||
$this->setStaticJumpData();
|
||||
|
||||
foreach($result['route'] as $systemId){
|
||||
$systemName = $this->getSystemInfoBySystemId($systemId, 'systemName');
|
||||
$routeData['route'][] = $this->getJumpNodeData($systemName);
|
||||
$routeData['route'][] = $this->getJumpNodeData($systemId);
|
||||
}
|
||||
}else{
|
||||
$depthSearched = $routeData['maxDepth'];
|
||||
|
||||
@@ -91,11 +91,11 @@ class Setup extends Controller\Controller {
|
||||
$return->countBuildAll = $categoryUniverseModel->getById($categoryId, 0)->getTypesCount(false);
|
||||
$return->progress = $percent($return->countAll, $return->countBuildAll);
|
||||
break;
|
||||
case 'SystemNeighbourModel':
|
||||
case 'SystemNeighbour':
|
||||
// Becomes deprecated with new Universe DB!!!
|
||||
$this->setupSystemJumpTable();
|
||||
|
||||
$return->countAll = 5214;
|
||||
$return->countAll = (int)$f3->get('REQUIREMENTS.DATA.NEIGHBOURS');
|
||||
$return->countBuild = Database::instance()->getRowCount('system_neighbour');
|
||||
$return->countBuildAll = $return->countBuild;
|
||||
$return->progress = $percent($return->countAll, $return->countBuildAll);
|
||||
@@ -144,67 +144,87 @@ class Setup extends Controller\Controller {
|
||||
* for system jump calculation. Call this function manually when CCP adds Systems/Stargates
|
||||
*/
|
||||
protected function setupSystemJumpTable(){
|
||||
$pfDB = $this->getDB('PF');
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
$universeDB = $this->getDB('UNIVERSE');
|
||||
|
||||
$query = "SELECT
|
||||
map_sys.solarSystemID system_id,
|
||||
map_sys.regionID region_id,
|
||||
map_sys.constellationID constellation_id,
|
||||
map_sys.solarSystemName system_name,
|
||||
ROUND( map_sys.security, 4) system_security,
|
||||
(
|
||||
SELECT
|
||||
GROUP_CONCAT( NULLIF(map_sys_inner.solarSystemName, NULL) SEPARATOR ':')
|
||||
`system`.`id` `systemId`,
|
||||
`system`.`name` `systemName`,
|
||||
`system`.`constellationId` `constellationId`,
|
||||
ROUND( `system`.`securityStatus`, 4) `trueSec`,
|
||||
`constellation`.`regionId` `regionId`,
|
||||
(
|
||||
SELECT
|
||||
GROUP_CONCAT( NULLIF(`sys_inner`.`id`, NULL) SEPARATOR ':')
|
||||
FROM
|
||||
`stargate` INNER JOIN
|
||||
`system` `sys_inner` ON
|
||||
`sys_inner`.`id` = `stargate`.`destinationSystemId`
|
||||
WHERE
|
||||
`stargate`.`systemId` = `system`.`id`
|
||||
) `jumpNodes`
|
||||
FROM
|
||||
mapSolarSystemJumps map_jump INNER JOIN
|
||||
mapSolarSystems map_sys_inner ON
|
||||
map_sys_inner.solarSystemID = map_jump.toSolarSystemID
|
||||
`system` INNER JOIN
|
||||
`constellation` ON
|
||||
`constellation`.`id` = `system`.`constellationId`
|
||||
WHERE
|
||||
map_jump.fromSolarSystemID = map_sys.solarSystemID
|
||||
) system_neighbours
|
||||
FROM
|
||||
mapSolarSystems map_sys
|
||||
HAVING
|
||||
-- skip systems without neighbors (e.g. WHs)
|
||||
system_neighbours IS NOT NULL
|
||||
";
|
||||
`constellation`.`regionId` != :regionIdJove1 AND
|
||||
`constellation`.`regionId` != :regionIdJove2 AND
|
||||
`constellation`.`regionId` != :regionIdJove3 AND
|
||||
(
|
||||
`system`.`security` = :ns OR
|
||||
`system`.`security` = :ls OR
|
||||
`system`.`security` = :hs
|
||||
)
|
||||
";
|
||||
|
||||
$rows = $ccpDB->exec($query);
|
||||
$rows = $universeDB->exec($query, [
|
||||
':regionIdJove1' => 10000017,
|
||||
':regionIdJove2' => 10000019,
|
||||
':regionIdJove3' => 10000004,
|
||||
':ns' => '0.0',
|
||||
':ls' => 'L',
|
||||
':hs' => 'H'
|
||||
]);
|
||||
|
||||
if(count($rows) > 0){
|
||||
// switch DB back to pathfinder DB
|
||||
if(count($rows)){
|
||||
$pfDB = $this->getDB('PF');
|
||||
|
||||
// clear cache table
|
||||
$pfDB->exec("TRUNCATE system_neighbour");
|
||||
|
||||
foreach($rows as $row){
|
||||
if(!$row['jumpNodes']){
|
||||
// should never happen!
|
||||
continue;
|
||||
}
|
||||
|
||||
$pfDB->exec("
|
||||
INSERT INTO
|
||||
system_neighbour(
|
||||
regionId,
|
||||
constellationId,
|
||||
systemName,
|
||||
systemId,
|
||||
jumpNodes,
|
||||
trueSec
|
||||
)
|
||||
VALUES(
|
||||
:regionId,
|
||||
:constellationId,
|
||||
:systemName,
|
||||
:systemId,
|
||||
:jumpNodes,
|
||||
:trueSec
|
||||
)",
|
||||
[
|
||||
':regionId' => $row['region_id'],
|
||||
':constellationId' => $row['constellation_id'],
|
||||
':systemName' => $row['system_name'],
|
||||
':systemId' => $row['system_id'],
|
||||
':jumpNodes' => $row['system_neighbours'],
|
||||
':trueSec' => $row['system_security']
|
||||
]);
|
||||
INSERT INTO
|
||||
system_neighbour(
|
||||
regionId,
|
||||
constellationId,
|
||||
systemName,
|
||||
systemId,
|
||||
jumpNodes,
|
||||
trueSec
|
||||
)
|
||||
VALUES(
|
||||
:regionId,
|
||||
:constellationId,
|
||||
:systemName,
|
||||
:systemId,
|
||||
:jumpNodes,
|
||||
:trueSec
|
||||
)",
|
||||
[
|
||||
':regionId' => $row['regionId'],
|
||||
':constellationId' => $row['constellationId'],
|
||||
':systemName' => $row['systemName'],
|
||||
':systemId' => $row['systemId'],
|
||||
':jumpNodes' => $row['jumpNodes'],
|
||||
':trueSec' => $row['trueSec']
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,127 +9,10 @@
|
||||
namespace Controller\Api;
|
||||
|
||||
use Controller;
|
||||
use Data\Mapper as Mapper;
|
||||
use Model;
|
||||
|
||||
class System extends Controller\AccessController {
|
||||
|
||||
private $mainQuery = "SELECT
|
||||
map_sys.constellationID `connstallation_id`,
|
||||
map_sys.solarSystemID `system_id`,
|
||||
map_sys.solarSystemName `system_name`,
|
||||
map_sys.security `system_security`,
|
||||
map_con.constellationName `constallation_name`,
|
||||
map_reg.regionID `region_id`,
|
||||
map_reg.regionName `region_name`,
|
||||
'0' `trueSec`,
|
||||
'' `type`,
|
||||
IFNULL(
|
||||
(
|
||||
SELECT
|
||||
LOWER( system_effect.typeName )
|
||||
FROM
|
||||
invTypes system_effect INNER JOIN
|
||||
mapDenormalize map_norm ON
|
||||
map_norm.typeID = system_effect.typeID
|
||||
WHERE
|
||||
system_effect.groupID = 995 AND
|
||||
map_norm.solarSystemID = map_sys.solarSystemID
|
||||
LIMIT 1
|
||||
), '') `effect`,
|
||||
IFNULL(
|
||||
(
|
||||
SELECT
|
||||
map_worm_class.wormholeClassID system_class
|
||||
FROM
|
||||
mapLocationWormholeClasses map_worm_class
|
||||
WHERE
|
||||
map_worm_class.locationID = map_sys.regionID
|
||||
LIMIT 1
|
||||
), 7) `security`
|
||||
FROM
|
||||
mapSolarSystems map_sys INNER JOIN
|
||||
mapConstellations map_con ON
|
||||
map_sys.constellationID = map_con.constellationID INNER JOIN
|
||||
mapRegions map_reg ON
|
||||
map_con.regionID = map_reg.regionID";
|
||||
|
||||
private $whereQuery = "";
|
||||
|
||||
// exclude Jove Space
|
||||
private $havingQuery = "HAVING
|
||||
security IS NOT NULL";
|
||||
|
||||
private $orderByQuery = "ORDER BY
|
||||
system_name";
|
||||
|
||||
private $limitQuery = "";
|
||||
|
||||
|
||||
/**
|
||||
* build query
|
||||
* @return string
|
||||
*/
|
||||
private function _getQuery(){
|
||||
$query = $this->mainQuery;
|
||||
$query .= ' ' . $this->whereQuery;
|
||||
$query .= ' ' . $this->havingQuery;
|
||||
$query .= ' ' . $this->orderByQuery;
|
||||
$query .= ' ' . $this->limitQuery;
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* get system Data from CCPs [SDE]
|
||||
* search column for IDs can be (solarSystemID, regionID, constellationID)
|
||||
* @param array $columnIDs
|
||||
* @param string $column
|
||||
* @return Model\SystemModel[]
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getSystemModelByIds($columnIDs = [], $column = 'solarSystemID'){
|
||||
|
||||
$systemModels = [];
|
||||
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
|
||||
$this->whereQuery = "WHERE
|
||||
map_sys." . $column . " IN (" . implode(',', $columnIDs) . ")";
|
||||
|
||||
$query = $this->_getQuery();
|
||||
|
||||
$rows = $ccpDB->exec($query, null, 60 * 60 * 24);
|
||||
|
||||
// format result
|
||||
$ccpSystemsData = (new Mapper\CcpSystemsMapper($rows))->getData();
|
||||
|
||||
foreach($ccpSystemsData as $ccpSystemData){
|
||||
/**
|
||||
* @var Model\SystemModel $system
|
||||
*/
|
||||
$system = Model\BasicModel::getNew('SystemModel');
|
||||
$system->setData($ccpSystemData);
|
||||
$systemModels[] = $system;
|
||||
}
|
||||
|
||||
return $systemModels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all static system Data from CCP DB (long cache timer)
|
||||
* @return array
|
||||
*/
|
||||
public function getSystems(){
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
$query = $this->_getQuery();
|
||||
$rows = $ccpDB->exec($query, null, 60 * 60 * 24);
|
||||
// format result
|
||||
$mapper = new Mapper\CcpSystemsMapper($rows);
|
||||
|
||||
return $mapper->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* save a new system to a a map
|
||||
* @param \Base $f3
|
||||
@@ -160,59 +43,36 @@ class System extends Controller\AccessController {
|
||||
}
|
||||
|
||||
if( isset($systemData['id']) ){
|
||||
// update existing system (e.g. changed system description) -------------------------------------------
|
||||
|
||||
// update existing system (e.g. set description) ------------------------------------------------------
|
||||
/**
|
||||
* @var $system Model\SystemModel
|
||||
*/
|
||||
$system = Model\BasicModel::getNew('SystemModel');
|
||||
$system->getById($systemData['id']);
|
||||
if( !$system->dry() ){
|
||||
if( $system->hasAccess($activeCharacter) ){
|
||||
// system model found
|
||||
$systemModel = $system;
|
||||
}
|
||||
if(
|
||||
!$system->dry() &&
|
||||
$system->hasAccess($activeCharacter)
|
||||
){
|
||||
// system model found
|
||||
// activate system (e.g. was inactive))
|
||||
$system->setActive(true);
|
||||
$systemModel = $system;
|
||||
}
|
||||
}elseif( isset($mapData['id']) ){
|
||||
// save NEW system ------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @var $map Model\MapModel
|
||||
*/
|
||||
$map = Model\BasicModel::getNew('MapModel');
|
||||
$map->getById($mapData['id']);
|
||||
if( $map->hasAccess($activeCharacter) ){
|
||||
// make sure system is not already on map
|
||||
// --> (e.g. multiple simultaneously save() calls for the same system)
|
||||
$systemModel = $map->getSystemByCCPId($systemData['systemId']);
|
||||
if( is_null($systemModel) ){
|
||||
// system not found on map -> get static system data (CCP DB)
|
||||
$systemModel = $map->getNewSystem($systemData['systemId']);
|
||||
$defaultStatusId = 1;
|
||||
}else{
|
||||
// system already exists (e.g. was inactive)
|
||||
$defaultStatusId = $systemModel->statusId;
|
||||
}
|
||||
|
||||
if( !is_null($systemModel) ){
|
||||
$systemModel->statusId = isset($systemData['statusId']) ? $systemData['statusId'] : $defaultStatusId;
|
||||
}
|
||||
|
||||
// map is not changeable for a system! (security)
|
||||
$systemData['mapId'] = $map;
|
||||
if($map->hasAccess($activeCharacter)){
|
||||
$systemModel = $map->getNewSystem($systemData['systemId']);
|
||||
}
|
||||
}
|
||||
|
||||
if( !is_null($systemModel) ){
|
||||
// "statusId" was set above
|
||||
unset($systemData['statusId']);
|
||||
unset($systemData['mapId']);
|
||||
|
||||
// set/update system
|
||||
$systemModel->setData($systemData);
|
||||
// activate system (e.g. was inactive))
|
||||
$systemModel->setActive(true);
|
||||
|
||||
// set/update system custom data
|
||||
$systemModel->copyfrom($systemData, ['locked', 'rallyUpdated', 'position', 'description']);
|
||||
|
||||
if($systemModel->save($activeCharacter)){
|
||||
// get data from "fresh" model (e.g. some relational data has changed: "statusId")
|
||||
@@ -220,7 +80,7 @@ class System extends Controller\AccessController {
|
||||
* @var $newSystemModel Model\SystemModel
|
||||
*/
|
||||
$newSystemModel = Model\BasicModel::getNew('SystemModel');
|
||||
$newSystemModel->getById( $systemModel->id, 0);
|
||||
$newSystemModel->getById( $systemModel->_id, 0);
|
||||
$newSystemModel->clearCacheData();
|
||||
$return->systemData = $newSystemModel->getData();
|
||||
|
||||
|
||||
@@ -70,8 +70,8 @@ class Universe extends Controller\AccessController {
|
||||
|
||||
$filter = [
|
||||
'id LIKE :id OR name LIKE :name',
|
||||
':id' => $search . '%',
|
||||
':name' => '%' . $search . '%'
|
||||
':id' => $search . '%', // -> match first
|
||||
':name' => '%' . $search . '%' // -> match between
|
||||
];
|
||||
$options = [
|
||||
'order' => 'name',
|
||||
|
||||
Reference in New Issue
Block a user