Files
pathfinder/app/main/controller/api/connection.php
Exodus4D a8edf39697 - new "logging" system for map/system/signature/connection changes, closed #271
- new map change log to Slack channel
- new "rally point" logging to Slack channel
- new "rally point" poke options (e.g. custom message), closed #295
- new log options for WebSocket installations
- added ship "mass" logging (backend only), #313
- added map logging to Slack, #326
- added "ESI error rate" limit detection
- added "Monolog" as new logging library (Composer dependency)
- added "Swiftmailer" as new eMail library (Composer dependency)
- added Support for Redis session hander (performance boost)
- improved character select panels (visible "online" status)
- improved "activity logging" (more DB columns added to check)
- improved eMail logging (HTML template support)
- improved "delete map" now become "inactive" for some days before delete
- improved character logout handling
- improved /setup page for DB bootstrap (new button for DB create if not exists)
- fixed broken ship tracking (ship name re-added)
- fixed broken ship tracking for multiple chars on different browser tabs
- fixed broken cursor coordinates, closed #518
- fixed null pointer "charactermodel.php->isActive():925" closed #529
- fixed broken "scroll offset", closed #533 closed #534
- Updated "validation" library JS v0.10.1 -> v0.11.9
- Updated ORM Mapper _Cortex_ v1.5.0-dev -> v1.5.0
- and many more....
2017-10-22 17:58:34 +02:00

127 lines
4.0 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: exodus4d
* Date: 01.03.15
* Time: 18:37
*/
namespace Controller\Api;
use Controller;
use Model;
class Connection extends Controller\AccessController {
/**
* save a new connection or updates an existing (drag/drop) between two systems
* if a connection is changed (drag&drop) to another system. -> this function is called for update
* @param \Base $f3
*/
public function save(\Base $f3){
$postData = (array)$f3->get('POST');
$return = (object) [];
$return->error = [];
$return->connectionData = (object) [];
if(
isset($postData['connectionData']) &&
isset($postData['mapData'])
){
$mapData = (array)$postData['mapData'];
$connectionData = (array)$postData['connectionData'];
$activeCharacter = $this->getCharacter();
// get map model and check map access
/**
* @var Model\MapModel $map
*/
$map = Model\BasicModel::getNew('MapModel');
$map->getById( (int)$mapData['id'] );
if( $map->hasAccess($activeCharacter) ){
$source = $map->getSystemById( $connectionData['source'] );
$target = $map->getSystemById( $connectionData['target'] );
if(
!is_null($source) &&
!is_null($target)
){
/**
* @var $connection Model\ConnectionModel
*/
$connection = Model\BasicModel::getNew('ConnectionModel');
$connection->getById( (int)$connectionData['id'] );
// search if systems are neighbors
$routeController = new Route();
$routeController->initJumpData();
$route = $routeController->findRoute($connectionData['sourceName'], $connectionData['targetName'], 1);
if($route['routePossible'] == true){
// systems are next to each other
$connectionData['scope'] = 'stargate';
$connectionData['type'] = ['stargate'];
}elseif($connectionData['scope'] == 'stargate'){
// connection scope changed -> this can not be a stargate
$connectionData['scope'] = 'wh';
$connectionData['type'] = ['wh_fresh'];
}
$connectionData['mapId'] = $map;
$connection->setData($connectionData);
if($connection->save($activeCharacter)){
$return->connectionData = $connection->getData();
// broadcast map changes
$this->broadcastMapData($connection->mapId);
}else{
$return->error = $connection->getErrors();
}
}
}
}
echo json_encode($return);
}
/**
* delete connection
* @param \Base $f3
* @throws \Exception
*/
public function delete(\Base $f3){
$mapId = (int)$f3->get('POST.mapId');
$connectionIds = (array)$f3->get('POST.connectionIds');
if($mapId){
$activeCharacter = $this->getCharacter();
/**
* @var Model\MapModel $map
*/
$map = Model\BasicModel::getNew('MapModel');
$map->getById($mapId);
if( $map->hasAccess($activeCharacter) ){
foreach($connectionIds as $connectionId){
if( $connection = $map->getConnectionById($connectionId) ){
$connection->delete( $activeCharacter );
$connection->reset();
}
}
// broadcast map changes
$this->broadcastMapData($map);
}
}
echo json_encode([]);
}
}