- added custom/editable ship jump logs, #709
- fixed DB setup error: "`system`.`description` can´t have a default value", closed #701 - upgraded "lazyload" js lib `v1.9.5` → `v1.9.7` - upgraded multiple 3rd party NPM dependencies for Gulp build
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
namespace Controller\Api;
|
||||
|
||||
use Controller;
|
||||
use Model;
|
||||
|
||||
@@ -97,7 +98,7 @@ class Connection extends Controller\AccessController {
|
||||
$map = Model\BasicModel::getNew('MapModel');
|
||||
$map->getById($mapId);
|
||||
|
||||
if( $map->hasAccess($activeCharacter) ){
|
||||
if($map->hasAccess($activeCharacter)){
|
||||
foreach($connectionIds as $connectionId){
|
||||
if( $connection = $map->getConnectionById($connectionId) ){
|
||||
$connection->delete( $activeCharacter );
|
||||
|
||||
@@ -29,7 +29,6 @@ class GitHub extends Controller\Controller {
|
||||
/**
|
||||
* get HTTP request options for API (curl) request
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getRequestReleaseOptions() : array {
|
||||
$options = $this->getBaseRequestOptions();
|
||||
@@ -41,7 +40,6 @@ class GitHub extends Controller\Controller {
|
||||
* get HTTP request options for API (curl) request
|
||||
* @param string $text
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getRequestMarkdownOptions(string $text) : array {
|
||||
$params = [
|
||||
@@ -59,7 +57,6 @@ class GitHub extends Controller\Controller {
|
||||
/**
|
||||
* get release information from GitHub
|
||||
* @param \Base $f3
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function releases(\Base $f3){
|
||||
$cacheKey = 'CACHE_GITHUB_RELEASES';
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
namespace Controller\Api;
|
||||
|
||||
use Controller;
|
||||
use data\file\FileHandler;
|
||||
use lib\Config;
|
||||
@@ -50,7 +51,6 @@ class Map extends Controller\AccessController {
|
||||
* Get all required static config data for program initialization
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
public function initData(\Base $f3){
|
||||
// expire time in seconds
|
||||
@@ -221,6 +221,7 @@ class Map extends Controller\AccessController {
|
||||
|
||||
// universe category data ---------------------------------------------------------------------------------
|
||||
$return->universeCategories = [
|
||||
6 => Model\Universe\BasicUniverseModel::getNew('CategoryModel')->getById(6)->getData(['mass']),
|
||||
65 => Model\Universe\BasicUniverseModel::getNew('CategoryModel')->getById(65)->getData()
|
||||
];
|
||||
|
||||
@@ -572,11 +573,7 @@ class Map extends Controller\AccessController {
|
||||
|
||||
$return->mapData = $map->getData();
|
||||
}catch(Exception\ValidationException $e){
|
||||
$validationError = (object) [];
|
||||
$validationError->type = 'error';
|
||||
$validationError->field = $e->getField();
|
||||
$validationError->message = $e->getMessage();
|
||||
$return->error[] = $validationError;
|
||||
$return->error[] = $e->getError();
|
||||
}
|
||||
}else{
|
||||
// map access denied
|
||||
@@ -634,7 +631,6 @@ class Map extends Controller\AccessController {
|
||||
* -> if characters with map access found -> broadcast mapData to them
|
||||
* @param Model\MapModel $map
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
protected function broadcastMapAccess(Model\MapModel $map){
|
||||
@@ -708,7 +704,6 @@ class Map extends Controller\AccessController {
|
||||
* -> function is called continuously (trigger) by any active client
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
public function updateData(\Base $f3){
|
||||
$postData = (array)$f3->get('POST');
|
||||
@@ -848,7 +843,6 @@ class Map extends Controller\AccessController {
|
||||
* @param Model\MapModel[] $mapModels
|
||||
* @return array
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
protected function getFormattedMapsData($mapModels){
|
||||
$mapData = [];
|
||||
@@ -864,7 +858,6 @@ class Map extends Controller\AccessController {
|
||||
* -> function is called continuously by any active client
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
public function updateUserData(\Base $f3){
|
||||
$postData = (array)$f3->get('POST');
|
||||
@@ -1196,7 +1189,6 @@ class Map extends Controller\AccessController {
|
||||
* get map log data
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
public function getLogData(\Base $f3){
|
||||
$postData = (array)$f3->get('POST');
|
||||
|
||||
45
app/main/controller/api/rest/abstractrestcontroller.php
Normal file
45
app/main/controller/api/rest/abstractrestcontroller.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: exodu
|
||||
* Date: 13.10.2018
|
||||
* Time: 16:14
|
||||
*/
|
||||
|
||||
namespace Controller\Api\Rest;
|
||||
|
||||
use Controller;
|
||||
|
||||
abstract class AbstractRestController extends Controller\AccessController {
|
||||
|
||||
/**
|
||||
* get send data from request
|
||||
* API requests require "Content-Type: application/json"
|
||||
* -> $_POST does not include request data -> request BODY might contain JSON
|
||||
* @param \Base $f3
|
||||
* @return array
|
||||
*/
|
||||
protected function getRequestData(\Base $f3) : array {
|
||||
$data = [];
|
||||
if( !empty($body = $f3->get('BODY')) ){
|
||||
$bodyDecode = json_decode($body, true);
|
||||
if(($jsonError = json_last_error()) === JSON_ERROR_NONE){
|
||||
$data = $bodyDecode;
|
||||
}else{
|
||||
$f3->set('HALT', true);
|
||||
$f3->error(400, 'Request data: ' . json_last_error_msg());
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* render API response to client
|
||||
* @param $output
|
||||
*/
|
||||
protected function out($output){
|
||||
echo json_encode($output);
|
||||
}
|
||||
|
||||
}
|
||||
112
app/main/controller/api/rest/log.php
Normal file
112
app/main/controller/api/rest/log.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: exodu
|
||||
* Date: 13.10.2018
|
||||
* Time: 15:28
|
||||
*/
|
||||
|
||||
namespace Controller\Api\Rest;
|
||||
|
||||
use Model;
|
||||
|
||||
class Log extends AbstractRestController {
|
||||
|
||||
/**
|
||||
* put (insert) log data
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function put(\Base $f3){
|
||||
$requestData = $this->getRequestData($f3);
|
||||
$connectionData = [];
|
||||
|
||||
if($connectionId = (int)$requestData['connectionId']){
|
||||
$activeCharacter = $this->getCharacter();
|
||||
|
||||
/**
|
||||
* @var Model\ConnectionModel $connection
|
||||
*/
|
||||
$connection = Model\BasicModel::getNew('ConnectionModel');
|
||||
$connection->getById($connectionId);
|
||||
|
||||
if($connection->hasAccess($activeCharacter)){
|
||||
$log = $connection->getNewLog();
|
||||
$log->setData($requestData);
|
||||
$log->record = false; // log not recorded by ESI
|
||||
$log->save();
|
||||
|
||||
$connectionData[] = $log->getConnection()->getData(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
$this->out($connectionData);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete (deactivate) log data
|
||||
* @param \Base $f3
|
||||
* @param $params
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(\Base $f3, $params){
|
||||
$logId = (int)$params['id'];
|
||||
$connectionData = [];
|
||||
|
||||
if($log = $this->update($logId, ['active' => false])){
|
||||
$connectionData[] = $log->getConnection()->getData(true, true);
|
||||
}
|
||||
|
||||
$this->out($connectionData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update log data
|
||||
* @param \Base $f3
|
||||
* @param $params
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function patch(\Base $f3, $params){
|
||||
$logId = (int)$params['id'];
|
||||
$requestData = $this->getRequestData($f3);
|
||||
$connectionData = [];
|
||||
|
||||
if($log = $this->update($logId, $requestData)){
|
||||
$connectionData[] = $log->getConnection()->getData(true, true);
|
||||
}
|
||||
|
||||
$this->out($connectionData);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* update existing connectionLog with new data
|
||||
* @param int $logId
|
||||
* @param array $logData
|
||||
* @return bool|Model\ConnectionLogModel
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function update(int $logId, array $logData){
|
||||
$log = false;
|
||||
if($logId){
|
||||
$activeCharacter = $this->getCharacter();
|
||||
/**
|
||||
* @var Model\ConnectionLogModel $log
|
||||
*/
|
||||
$log = Model\BasicModel::getNew('ConnectionLogModel');
|
||||
$log->getById($logId, 0, false);
|
||||
|
||||
if($log->hasAccess($activeCharacter)){
|
||||
$log->setData($logData);
|
||||
|
||||
if(isset($logData['active'])){
|
||||
$log->setActive((bool)$logData['active']);
|
||||
}
|
||||
$log->save();
|
||||
}
|
||||
}
|
||||
return $log;
|
||||
}
|
||||
}
|
||||
@@ -414,7 +414,7 @@ class Route extends Controller\AccessController {
|
||||
* @param array $mapIds
|
||||
* @param array $filterData
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function searchRoute(int $systemFromId, int $systemToId, $searchDepth = 0, array $mapIds = [], array $filterData = []) : array {
|
||||
// search root by ESI API
|
||||
@@ -439,7 +439,6 @@ class Route extends Controller\AccessController {
|
||||
* @param array $filterData
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
private function searchRouteCustom(int $systemFromId, int $systemToId, $searchDepth = 0, array $mapIds = [], array $filterData = []) : array {
|
||||
// reset all previous set jump data
|
||||
@@ -519,7 +518,6 @@ class Route extends Controller\AccessController {
|
||||
* @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 {
|
||||
// reset all previous set jump data
|
||||
@@ -645,7 +643,6 @@ class Route extends Controller\AccessController {
|
||||
* search multiple route between two systems
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function search($f3){
|
||||
$requestData = (array)$f3->get('POST');
|
||||
|
||||
@@ -123,7 +123,6 @@ class Statistic extends Controller\AccessController {
|
||||
* @param int $yearEnd
|
||||
* @param int $weekEnd
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function queryStatistic( CharacterModel $character, $typeId, $yearStart, $weekStart, $yearEnd, $weekEnd){
|
||||
$data = [];
|
||||
|
||||
@@ -100,14 +100,8 @@ class System extends Controller\AccessController {
|
||||
$return->error = $systemModel->getErrors();
|
||||
}
|
||||
}catch(Exception\ValidationException $e){
|
||||
$validationError = (object) [];
|
||||
$validationError->type = 'error';
|
||||
$validationError->field = $e->getField();
|
||||
$validationError->message = $e->getMessage();
|
||||
$return->error[] = $validationError;
|
||||
$return->error[] = $e->getError();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +240,6 @@ class System extends Controller\AccessController {
|
||||
* send Rally Point poke
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function pokeRally(\Base $f3){
|
||||
$rallyData = (array)$f3->get('POST');
|
||||
|
||||
@@ -109,7 +109,6 @@ class User extends Controller\Controller{
|
||||
* -> return character data (if valid)
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
public function getCookieCharacter(\Base $f3){
|
||||
$data = $f3->get('POST');
|
||||
@@ -201,15 +200,10 @@ class User extends Controller\Controller{
|
||||
/**
|
||||
* log the current user out + clear character system log data
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
public function logout(\Base $f3){
|
||||
$this->logoutCharacter(false, true, true, true);
|
||||
|
||||
$return = (object) [];
|
||||
$return->reroute = rtrim(self::getEnvironmentData('URL'), '/') . $f3->alias('login');
|
||||
echo json_encode($return);
|
||||
$this->logoutCharacter($f3, false, true, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,17 +339,9 @@ class User extends Controller\Controller{
|
||||
}
|
||||
|
||||
}catch(Exception\ValidationException $e){
|
||||
$validationError = (object) [];
|
||||
$validationError->type = 'error';
|
||||
$validationError->field = $e->getField();
|
||||
$validationError->message = $e->getMessage();
|
||||
$return->error[] = $validationError;
|
||||
$return->error[] = $e->getError();
|
||||
}catch(Exception\RegistrationException $e){
|
||||
$registrationError = (object) [];
|
||||
$registrationError->type = 'error';
|
||||
$registrationError->field = $e->getField();
|
||||
$registrationError->message = $e->getMessage();
|
||||
$return->error[] = $registrationError;
|
||||
$return->error[] = $e->getError();
|
||||
}
|
||||
|
||||
// return new/updated user data
|
||||
@@ -394,10 +380,8 @@ class User extends Controller\Controller{
|
||||
sprintf(self::LOG_DELETE_ACCOUNT, $user->id, $user->name)
|
||||
);
|
||||
|
||||
$this->logoutCharacter(true, true, true, true);
|
||||
$this->logoutCharacter($f3, true, true, true, true);
|
||||
$user->erase();
|
||||
|
||||
$return->reroute = rtrim(self::getEnvironmentData('URL'), '/') . $f3->alias('login');
|
||||
}
|
||||
}else{
|
||||
// captcha not valid -> return error
|
||||
|
||||
Reference in New Issue
Block a user