- added new "select connection" feature to map - ctrl + click for multiselect, closed #174 - added new "wormhole type" table to "Jump info" dialog, closed #174 - added new re-order drag&drop feature for pannels, #470 closed #234 - fixed PHP-Doc comments - added @throw statements - fixed some Javascript memory leaks with infinite counters - updated "Peity jQuery plugin" `3.2.0` -> `3.2.1`
This commit is contained in:
@@ -19,6 +19,9 @@ class AccessController extends Controller {
|
||||
* @param \Base $f3
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
function beforeroute(\Base $f3, $params): bool {
|
||||
if($return = parent::beforeroute($f3, $params)){
|
||||
@@ -47,6 +50,8 @@ class AccessController extends Controller {
|
||||
* get current character and check if it is a valid character
|
||||
* @param \Base $f3
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function isLoggedIn(\Base $f3): bool {
|
||||
$loginCheck = false;
|
||||
@@ -66,6 +71,7 @@ class AccessController extends Controller {
|
||||
* @param \Base $f3
|
||||
* @param Model\CharacterModel $character
|
||||
* @return bool
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
private function checkLogTimer(\Base $f3, Model\CharacterModel $character){
|
||||
$loginCheck = false;
|
||||
@@ -97,6 +103,9 @@ class AccessController extends Controller {
|
||||
* -> send over TCP Socket
|
||||
* @param Model\MapModel $map
|
||||
* @return int (number of active connections for this map)
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
protected function broadcastMapData(Model\MapModel $map){
|
||||
$mapData = $this->getFormattedMapData($map);
|
||||
@@ -107,6 +116,8 @@ class AccessController extends Controller {
|
||||
* get formatted Map Data
|
||||
* @param Model\MapModel $map
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getFormattedMapData(Model\MapModel $map){
|
||||
$mapData = $map->getData();
|
||||
|
||||
@@ -34,6 +34,8 @@ class Admin extends Controller{
|
||||
* @param \Base $f3
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
function beforeroute(\Base $f3, $params): bool {
|
||||
$return = parent::beforeroute($f3, $params);
|
||||
@@ -63,6 +65,7 @@ class Admin extends Controller{
|
||||
/**
|
||||
* event handler after routing
|
||||
* @param \Base $f3
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function afterroute(\Base $f3) {
|
||||
// js view (file)
|
||||
@@ -81,6 +84,7 @@ class Admin extends Controller{
|
||||
* returns valid admin $characterModel for current user
|
||||
* @param \Base $f3
|
||||
* @return CharacterModel|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getAdminCharacter(\Base $f3){
|
||||
$adminCharacter = null;
|
||||
@@ -148,6 +152,7 @@ class Admin extends Controller{
|
||||
* @param \Base $f3
|
||||
* @param array $params
|
||||
* @param null $character
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function dispatch(\Base $f3, $params, $character = null){
|
||||
if($character instanceof CharacterModel){
|
||||
@@ -191,6 +196,7 @@ class Admin extends Controller{
|
||||
* @param CharacterModel $character
|
||||
* @param int $kickCharacterId
|
||||
* @param int $minutes
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function kickCharacter(CharacterModel $character, $kickCharacterId, $minutes){
|
||||
$kickOptions = self::KICK_OPTIONS;
|
||||
@@ -220,6 +226,7 @@ class Admin extends Controller{
|
||||
* @param CharacterModel $character
|
||||
* @param int $banCharacterId
|
||||
* @param int $value
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function banCharacter(CharacterModel $character, $banCharacterId, $value){
|
||||
$banCharacters = $this->filterValidCharacters($character, $banCharacterId);
|
||||
@@ -267,6 +274,7 @@ class Admin extends Controller{
|
||||
* get log file for "admin" logs
|
||||
* @param string $type
|
||||
* @return \Log
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
static function getLogger($type = 'ADMIN'){
|
||||
return parent::getLogger('ADMIN');
|
||||
|
||||
@@ -17,6 +17,7 @@ class Access extends Controller\AccessController {
|
||||
* search character/corporation or alliance by name
|
||||
* @param \Base $f3
|
||||
* @param $params
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function search($f3, $params){
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ 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
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function save(\Base $f3){
|
||||
$postData = (array)$f3->get('POST');
|
||||
|
||||
@@ -21,6 +21,7 @@ class GitHub extends Controller\Controller {
|
||||
/**
|
||||
* get HTTP request options for API (curl) request
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getRequestOptions(){
|
||||
$requestOptions = [
|
||||
@@ -36,6 +37,7 @@ class GitHub extends Controller\Controller {
|
||||
/**
|
||||
* get release information from GitHub
|
||||
* @param $f3
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function releases($f3){
|
||||
$cacheKey = 'CACHE_GITHUB_RELEASES';
|
||||
|
||||
@@ -71,6 +71,8 @@ class Map extends Controller\AccessController {
|
||||
/**
|
||||
* Get all required static config data for program initialization
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
public function init(\Base $f3){
|
||||
// expire time in seconds
|
||||
@@ -159,6 +161,15 @@ class Map extends Controller\AccessController {
|
||||
}
|
||||
$return->connectionScopes = $connectionScopeData;
|
||||
|
||||
// get available wormhole types ---------------------------------------------------------------------------
|
||||
$wormholes = Model\BasicModel::getNew('WormholeModel');
|
||||
$rows = $wormholes->find('id > 0', null, $expireTimeSQL);
|
||||
$wormholesData = [];
|
||||
foreach((array)$rows as $rowData){
|
||||
$wormholesData[$rowData->name] = $rowData->getData();
|
||||
}
|
||||
$return->wormholes = $wormholesData;
|
||||
|
||||
// get available character status -------------------------------------------------------------------------
|
||||
$characterStatus = Model\BasicModel::getNew('CharacterStatusModel');
|
||||
$rows = $characterStatus->find('active = 1', null, $expireTimeSQL);
|
||||
@@ -223,6 +234,7 @@ class Map extends Controller\AccessController {
|
||||
/**
|
||||
* import new map data
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
*/
|
||||
public function import(\Base $f3){
|
||||
$importData = (array)$f3->get('POST');
|
||||
@@ -367,6 +379,7 @@ class Map extends Controller\AccessController {
|
||||
/**
|
||||
* save a new map or update an existing map
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save(\Base $f3){
|
||||
$formData = (array)$f3->get('POST.formData');
|
||||
@@ -563,6 +576,7 @@ class Map extends Controller\AccessController {
|
||||
/**
|
||||
* delete a map and all dependencies
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete(\Base $f3){
|
||||
$mapData = (array)$f3->get('POST.mapData');
|
||||
@@ -597,6 +611,9 @@ class Map extends Controller\AccessController {
|
||||
* -> if characters with map access found -> broadcast mapData to them
|
||||
* @param Model\MapModel $map
|
||||
* @param array $characterIds
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
protected function broadcastMapAccess($map, $characterIds){
|
||||
$mapAccess = [
|
||||
@@ -614,6 +631,7 @@ class Map extends Controller\AccessController {
|
||||
* broadcast map delete information to clients
|
||||
* @param int $mapId
|
||||
* @return bool|string
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
protected function broadcastMapDeleted($mapId){
|
||||
return (new Socket( Config::getSocketUri() ))->sendData('mapDeleted', $mapId);
|
||||
@@ -623,6 +641,7 @@ class Map extends Controller\AccessController {
|
||||
* get map access tokens for current character
|
||||
* -> send access tokens via TCP Socket for WebSocket auth
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAccessData(\Base $f3){
|
||||
$return = (object) [];
|
||||
@@ -656,6 +675,8 @@ class Map extends Controller\AccessController {
|
||||
* update map data
|
||||
* -> function is called continuously (trigger) by any active client
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
public function updateData(\Base $f3){
|
||||
$mapData = (array)$f3->get('POST.mapData');
|
||||
@@ -805,6 +826,8 @@ class Map extends Controller\AccessController {
|
||||
* get formatted map data
|
||||
* @param Model\MapModel[] $mapModels
|
||||
* @return array
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
protected function getFormattedMapsData($mapModels){
|
||||
$mapData = [];
|
||||
@@ -819,6 +842,8 @@ class Map extends Controller\AccessController {
|
||||
* update map data api
|
||||
* -> function is called continuously by any active client
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
public function updateUserData(\Base $f3){
|
||||
$return = (object) [];
|
||||
@@ -896,6 +921,7 @@ class Map extends Controller\AccessController {
|
||||
* @param Model\CharacterModel $character
|
||||
* @param Model\MapModel $map
|
||||
* @return Model\MapModel
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function updateMapData(Model\CharacterModel $character, Model\MapModel $map){
|
||||
|
||||
@@ -1056,21 +1082,34 @@ class Map extends Controller\AccessController {
|
||||
}
|
||||
}
|
||||
|
||||
// save connection ------------------------------------------------------------------------------------
|
||||
if(
|
||||
$addConnection &&
|
||||
$sourceExists &&
|
||||
$targetExists &&
|
||||
$sourceSystem &&
|
||||
$targetSystem &&
|
||||
!$map->searchConnection( $sourceSystem, $targetSystem )
|
||||
$targetSystem
|
||||
){
|
||||
$connection = $map->getNewConnection($sourceSystem, $targetSystem);
|
||||
$connection = $map->saveConnection($connection, $character);
|
||||
// get updated maps object
|
||||
if($connection){
|
||||
$map = $connection->mapId;
|
||||
$mapDataChanged = true;
|
||||
$connection = $map->searchConnection( $sourceSystem, $targetSystem);
|
||||
|
||||
// save connection --------------------------------------------------------------------------------
|
||||
if(
|
||||
$addConnection &&
|
||||
!$connection
|
||||
){
|
||||
$connection = $map->getNewConnection($sourceSystem, $targetSystem);
|
||||
$connection = $map->saveConnection($connection, $character);
|
||||
// get updated maps object
|
||||
if($connection){
|
||||
$map = $connection->mapId;
|
||||
$mapDataChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// log jump mass ----------------------------------------------------------------------------------
|
||||
if(
|
||||
$connection &&
|
||||
$connection->isWormhole()
|
||||
){
|
||||
$connection->logMass($log);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1087,9 +1126,13 @@ class Map extends Controller\AccessController {
|
||||
/**
|
||||
* get connectionData
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getConnectionData (\Base $f3){
|
||||
$postData = (array)$f3->get('POST');
|
||||
|
||||
$addData = (array)$postData['addData'];
|
||||
$filterData = (array)$postData['filterData'];
|
||||
$connectionData = [];
|
||||
|
||||
if($mapId = (int)$postData['mapId']){
|
||||
@@ -1102,13 +1145,27 @@ class Map extends Controller\AccessController {
|
||||
$map->getById($mapId);
|
||||
|
||||
if($map->hasAccess($activeCharacter)){
|
||||
$connections = $map->getConnections('wh');
|
||||
foreach($connections as $connection){
|
||||
$data = $connection->getData(true);
|
||||
// skip connections whiteout signature data
|
||||
if($data->signatures){
|
||||
$connectionData[] = $data;
|
||||
// get specific connections by id
|
||||
$connectionIds = null;
|
||||
if(is_array($postData['connectionIds'])){
|
||||
$connectionIds = $postData['connectionIds'];
|
||||
}
|
||||
|
||||
$connections = $map->getConnections($connectionIds, 'wh');
|
||||
foreach($connections as $connection){
|
||||
$check = true;
|
||||
$data = $connection->getData(in_array('signatures', $addData), in_array('logs', $addData));
|
||||
// filter result
|
||||
if(in_array('signatures', $filterData) && !$data->signatures){
|
||||
$check = false;
|
||||
}
|
||||
|
||||
if(in_array('logs', $filterData) && !$data->logs){
|
||||
$check = false;
|
||||
}
|
||||
|
||||
if($check){
|
||||
$connectionData[] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1120,6 +1177,8 @@ 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');
|
||||
|
||||
@@ -509,6 +509,8 @@ 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');
|
||||
|
||||
@@ -18,6 +18,7 @@ class Signature extends Controller\AccessController {
|
||||
* get signature data for systems
|
||||
* -> return value of this is limited to a "SINGLE" system
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getAll(\Base $f3){
|
||||
$signatureData = [];
|
||||
@@ -50,6 +51,7 @@ class Signature extends Controller\AccessController {
|
||||
* save or update a full signature data set
|
||||
* or save/update just single or multiple signature data
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function save(\Base $f3){
|
||||
$requestData = $f3->get('POST');
|
||||
@@ -221,6 +223,7 @@ class Signature extends Controller\AccessController {
|
||||
/**
|
||||
* delete signatures
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(\Base $f3){
|
||||
$signatureIds = $f3->get('POST.signatureIds');
|
||||
|
||||
@@ -123,6 +123,7 @@ 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 = [];
|
||||
@@ -231,6 +232,7 @@ class Statistic extends Controller\AccessController {
|
||||
/**
|
||||
* get statistics data
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getData(\Base $f3){
|
||||
$postData = (array)$f3->get('POST');
|
||||
|
||||
@@ -175,6 +175,7 @@ class System extends Controller\AccessController {
|
||||
/**
|
||||
* save a new system to a a map
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function save(\Base $f3){
|
||||
$postData = (array)$f3->get('POST');
|
||||
@@ -278,6 +279,7 @@ class System extends Controller\AccessController {
|
||||
* get system log data from CCP API import
|
||||
* system Kills, Jumps,....
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function graphData(\Base $f3){
|
||||
$graphData = [];
|
||||
@@ -329,6 +331,8 @@ class System extends Controller\AccessController {
|
||||
* get system data for all systems within a constellation
|
||||
* @param \Base $f3
|
||||
* @param array $params
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function constellationData(\Base $f3, $params){
|
||||
$return = (object) [];
|
||||
@@ -363,6 +367,7 @@ class System extends Controller\AccessController {
|
||||
/**
|
||||
* set destination for specific systemIds
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setDestination(\Base $f3){
|
||||
$postData = (array)$f3->get('POST');
|
||||
@@ -405,6 +410,8 @@ 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');
|
||||
@@ -437,6 +444,7 @@ class System extends Controller\AccessController {
|
||||
* delete systems and all its connections from map
|
||||
* -> set "active" flag
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(\Base $f3){
|
||||
$mapId = (int)$f3->get('POST.mapId');
|
||||
|
||||
@@ -44,6 +44,7 @@ class User extends Controller\Controller{
|
||||
* @param Model\CharacterModel $characterModel
|
||||
* @param string $browserTabId
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function loginByCharacter(Model\CharacterModel &$characterModel, string $browserTabId){
|
||||
$login = false;
|
||||
@@ -108,6 +109,8 @@ class User extends Controller\Controller{
|
||||
* validate cookie character information
|
||||
* -> return character data (if valid)
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
public function getCookieCharacter(\Base $f3){
|
||||
$data = $f3->get('POST');
|
||||
@@ -188,6 +191,7 @@ class User extends Controller\Controller{
|
||||
/**
|
||||
* delete the character log entry for the current active (main) character
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteLog(\Base $f3){
|
||||
if($activeCharacter = $this->getCharacter()){
|
||||
@@ -198,6 +202,8 @@ 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);
|
||||
@@ -211,6 +217,7 @@ class User extends Controller\Controller{
|
||||
* remote open ingame information window (character, corporation or alliance) Id
|
||||
* -> the type is auto-recognized by CCP
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
*/
|
||||
public function openIngameWindow(\Base $f3){
|
||||
$data = $f3->get('POST');
|
||||
@@ -241,6 +248,7 @@ class User extends Controller\Controller{
|
||||
* -> a fresh user automatically generated on first login with a new character
|
||||
* -> see SSO login
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
*/
|
||||
public function saveAccount(\Base $f3){
|
||||
$data = $f3->get('POST');
|
||||
@@ -361,6 +369,8 @@ class User extends Controller\Controller{
|
||||
/**
|
||||
* delete current user account from DB
|
||||
* @param \Base $f3
|
||||
* @throws Exception
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
public function deleteAccount(\Base $f3){
|
||||
$data = $f3->get('POST.formData');
|
||||
|
||||
@@ -52,6 +52,7 @@ class Sso extends Api\User{
|
||||
* redirect user to CCP SSO page and request authorization
|
||||
* -> cf. Controller->getCookieCharacters() ( equivalent cookie based login)
|
||||
* @param \Base $f3
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function requestAdminAuthorization($f3){
|
||||
// store browser tabId to be "targeted" after login
|
||||
@@ -66,6 +67,8 @@ class Sso extends Api\User{
|
||||
* redirect user to CCP SSO page and request authorization
|
||||
* -> cf. Controller->getCookieCharacters() ( equivalent cookie based login)
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function requestAuthorization($f3){
|
||||
$params = $f3->get('GET');
|
||||
@@ -135,6 +138,7 @@ class Sso extends Api\User{
|
||||
* @param \Base $f3
|
||||
* @param array $scopes
|
||||
* @param string $rootAlias
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
private function rerouteAuthorization(\Base $f3, $scopes = [], $rootAlias = 'login'){
|
||||
if( !empty( Controller\Controller::getEnvironmentData('CCP_SSO_CLIENT_ID') ) ){
|
||||
@@ -166,6 +170,8 @@ class Sso extends Api\User{
|
||||
* callback handler for CCP SSO user Auth
|
||||
* -> see requestAuthorization()
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function callbackAuthorization($f3){
|
||||
$getParams = (array)$f3->get('GET');
|
||||
@@ -305,6 +311,8 @@ class Sso extends Api\User{
|
||||
/**
|
||||
* login by cookie name
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function login(\Base $f3){
|
||||
$data = (array)$f3->get('GET');
|
||||
@@ -343,6 +351,7 @@ class Sso extends Api\User{
|
||||
* -> else try to refresh auth and get fresh "access_token"
|
||||
* @param bool $authCode
|
||||
* @return null|\stdClass
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function getSsoAccessData($authCode){
|
||||
$accessData = null;
|
||||
@@ -362,6 +371,7 @@ class Sso extends Api\User{
|
||||
* verify authorization code, and get an "access_token" data
|
||||
* @param $authCode
|
||||
* @return \stdClass
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function verifyAuthorizationCode($authCode){
|
||||
$requestParams = [
|
||||
@@ -377,6 +387,7 @@ class Sso extends Api\User{
|
||||
* -> if "access_token" is expired, this function gets a fresh one
|
||||
* @param $refreshToken
|
||||
* @return \stdClass
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function refreshAccessToken($refreshToken){
|
||||
$requestParams = [
|
||||
@@ -393,6 +404,7 @@ class Sso extends Api\User{
|
||||
* OR by providing a valid "refresh_token"
|
||||
* @param $requestParams
|
||||
* @return \stdClass
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function requestAccessData($requestParams){
|
||||
$verifyAuthCodeUrl = self::getVerifyAuthorizationCodeEndpoint();
|
||||
@@ -457,6 +469,7 @@ class Sso extends Api\User{
|
||||
* -> if more character information is required, use ESI "characters" endpoints request instead
|
||||
* @param $accessToken
|
||||
* @return mixed|null
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function verifyCharacterData($accessToken){
|
||||
$verifyUserUrl = self::getVerifyUserEndpoint();
|
||||
@@ -492,6 +505,7 @@ class Sso extends Api\User{
|
||||
* get character data
|
||||
* @param int $characterId
|
||||
* @return object
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getCharacterData($characterId){
|
||||
$characterData = (object) [];
|
||||
@@ -601,6 +615,7 @@ class Sso extends Api\User{
|
||||
* get CCP SSO url from configuration file
|
||||
* -> throw error if url is broken/missing
|
||||
* @return string
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
static function getSsoUrlRoot(){
|
||||
$url = '';
|
||||
@@ -630,6 +645,7 @@ class Sso extends Api\User{
|
||||
/**
|
||||
* get logger for SSO logging
|
||||
* @return \Log
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
static function getSSOLogger(){
|
||||
return parent::getLogger('SSO');
|
||||
|
||||
@@ -17,6 +17,7 @@ class Universe extends Controller {
|
||||
/**
|
||||
* Set up "Universe" Database
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setupDB(\Base $f3){
|
||||
$this->setupRegions($f3);
|
||||
@@ -26,6 +27,7 @@ class Universe extends Controller {
|
||||
/**
|
||||
* get all regions from CCP and store region data
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function setupRegions(\Base $f3){
|
||||
$this->getDB('UNIVERSE');
|
||||
@@ -50,6 +52,7 @@ class Universe extends Controller {
|
||||
/**
|
||||
* get all constellations from CCP and store constellation data
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function setupConstellations(\Base $f3){
|
||||
$this->getDB('UNIVERSE');
|
||||
|
||||
@@ -63,6 +63,7 @@ class Controller {
|
||||
* @param \Base $f3
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
function beforeroute(\Base $f3, $params): bool {
|
||||
// initiate DB connection
|
||||
@@ -107,6 +108,7 @@ class Controller {
|
||||
|
||||
/**
|
||||
* init new Session handler
|
||||
* @param \Base $f3
|
||||
*/
|
||||
protected function initSession(\Base $f3){
|
||||
$sessionCacheKey = $f3->get('SESSION_CACHE');
|
||||
@@ -117,6 +119,7 @@ class Controller {
|
||||
* @param $session
|
||||
* @param $sid
|
||||
* @return bool
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
$onSuspect = function($session, $sid){
|
||||
self::getLogger('SESSION_SUSPECT')->write( sprintf(
|
||||
@@ -181,6 +184,7 @@ class Controller {
|
||||
* set/update logged in cookie by character model
|
||||
* -> store validation data in DB
|
||||
* @param Model\CharacterModel $character
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function setLoginCookie(Model\CharacterModel $character){
|
||||
if( $this->getCookieState() ){
|
||||
@@ -237,6 +241,8 @@ class Controller {
|
||||
* @param array $cookieData
|
||||
* @param bool $checkAuthorization
|
||||
* @return Model\CharacterModel[]
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getCookieCharacters($cookieData = [], $checkAuthorization = true){
|
||||
$characters = [];
|
||||
@@ -341,6 +347,7 @@ class Controller {
|
||||
* get current character data from session
|
||||
* ->
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getSessionCharacterData(){
|
||||
$data = [];
|
||||
@@ -417,6 +424,7 @@ class Controller {
|
||||
* get current user
|
||||
* @param int $ttl
|
||||
* @return Model\UserModel|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getUser($ttl = 0){
|
||||
$user = null;
|
||||
@@ -463,6 +471,8 @@ class Controller {
|
||||
* @param bool $deleteSession
|
||||
* @param bool $deleteLog
|
||||
* @param bool $deleteCookie
|
||||
* @throws \Exception
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
protected function logoutCharacter(bool $all = false, bool $deleteSession = true, bool $deleteLog = true, bool $deleteCookie = false){
|
||||
$sessionCharacterData = (array)$this->getF3()->get(Api\User::SESSION_KEY_CHARACTERS);
|
||||
@@ -581,6 +591,7 @@ class Controller {
|
||||
/**
|
||||
* get a custom userAgent string for API calls
|
||||
* @return string
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getUserAgent(){
|
||||
$userAgent = '';
|
||||
@@ -598,6 +609,7 @@ class Controller {
|
||||
* -> on HTTP request -> render error page
|
||||
* @param \Base $f3
|
||||
* @return bool
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function showError(\Base $f3){
|
||||
|
||||
@@ -817,6 +829,7 @@ class Controller {
|
||||
* get the current registration status
|
||||
* 0=registration stop |1=new registration allowed
|
||||
* @return int
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
static function getRegistrationStatus(){
|
||||
return (int)Config::getPathfinderData('registration.status');
|
||||
@@ -827,6 +840,7 @@ class Controller {
|
||||
* -> set in pathfinder.ini
|
||||
* @param string $type
|
||||
* @return \Log|null
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
static function getLogger($type){
|
||||
return LogController::getLogger($type);
|
||||
@@ -856,6 +870,7 @@ class Controller {
|
||||
* health check for ICP socket -> ping request
|
||||
* @param $ttl
|
||||
* @param $load
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
static function checkTcpSocket($ttl, $load){
|
||||
(new Socket( Config::getSocketUri(), $ttl ))->sendData('healthCheck', $load);
|
||||
|
||||
@@ -34,6 +34,7 @@ class LogController extends \Prefab {
|
||||
/**
|
||||
* get columns from ActivityLogModel that can be uses as counter
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getActivityLogColumns(): array{
|
||||
if(empty($this->activityLogColumns)){
|
||||
@@ -56,6 +57,7 @@ class LogController extends \Prefab {
|
||||
* -> this buffered data can be stored somewhere (e.g. DB) before HTTP response
|
||||
* -> should be cleared afterwards!
|
||||
* @param MapLog $log
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function push(MapLog $log){
|
||||
$action = $log->getAction();
|
||||
@@ -161,6 +163,7 @@ class LogController extends \Prefab {
|
||||
* get Logger instance
|
||||
* @param string $type
|
||||
* @return \Log|null
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public static function getLogger($type){
|
||||
$logFiles = Config::getPathfinderData('logfiles');
|
||||
|
||||
@@ -15,6 +15,8 @@ class MapController extends AccessController {
|
||||
|
||||
/**
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function init(\Base $f3) {
|
||||
$character = $this->getCharacter();
|
||||
|
||||
@@ -85,6 +85,7 @@ class Setup extends Controller {
|
||||
'Model\ConstellationWormholeModel',
|
||||
|
||||
'Model\ConnectionModel',
|
||||
'Model\ConnectionLogModel',
|
||||
'Model\SystemSignatureModel',
|
||||
|
||||
'Model\ActivityLogModel',
|
||||
@@ -139,6 +140,7 @@ class Setup extends Controller {
|
||||
* @param \Base $f3
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
function beforeroute(\Base $f3, $params): bool {
|
||||
// init dbLib class. Manages all DB connections
|
||||
@@ -161,6 +163,7 @@ class Setup extends Controller {
|
||||
|
||||
/**
|
||||
* @param \Base $f3
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function afterroute(\Base $f3) {
|
||||
// js view (file)
|
||||
@@ -194,6 +197,7 @@ class Setup extends Controller {
|
||||
* works as dispatcher for setup functions
|
||||
* -> for security reasons all /setup "routes" are dispatched by GET params
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function init(\Base $f3){
|
||||
$params = $f3->get('GET');
|
||||
@@ -760,6 +764,7 @@ class Setup extends Controller {
|
||||
* get default map config
|
||||
* @param \Base $f3
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getMapsDefaultConfig(\Base $f3): array {
|
||||
$matrix = \Matrix::instance();
|
||||
@@ -1245,6 +1250,7 @@ class Setup extends Controller {
|
||||
/**
|
||||
* get Socket information (TCP (internal)), (WebSocket (clients))
|
||||
* @return array
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
protected function getSocketInformation(){
|
||||
// $ttl for health check
|
||||
@@ -1298,6 +1304,7 @@ class Setup extends Controller {
|
||||
|
||||
/** get indexed (cache) data information
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getIndexData(){
|
||||
// active DB and tables are required for obtain index data
|
||||
@@ -1509,6 +1516,7 @@ class Setup extends Controller {
|
||||
/**
|
||||
* clear all character authentication (Cookie) data
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function invalidateCookies(\Base $f3){
|
||||
$this->getDB('PF');
|
||||
|
||||
@@ -38,6 +38,7 @@ class CharacterUpdate {
|
||||
* -> see deactivateLogData()
|
||||
* >> php index.php "/cron/deleteLogData"
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
function deleteLogData(\Base $f3){
|
||||
DB\Database::instance()->getDB('PF');
|
||||
@@ -80,6 +81,7 @@ class CharacterUpdate {
|
||||
* clean up outdated character data e.g. kicked until status
|
||||
* >> php index.php "/cron/cleanUpCharacterData"
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
function cleanUpCharacterData(\Base $f3){
|
||||
DB\Database::instance()->getDB('PF');
|
||||
@@ -111,6 +113,7 @@ class CharacterUpdate {
|
||||
* authentication data is used for cookie based login
|
||||
* >> php index.php "/cron/deleteAuthenticationData"
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
function deleteAuthenticationData($f3){
|
||||
DB\Database::instance()->getDB('PF');
|
||||
|
||||
@@ -22,6 +22,7 @@ class MapUpdate {
|
||||
* deactivate all "private" maps whose lifetime is over
|
||||
* >> php index.php "/cron/deactivateMapData"
|
||||
* @param \Base $f3
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
function deactivateMapData(\Base $f3){
|
||||
$privateMapLifetime = (int)Config::getMapsDefaultConfig('private.lifetime');
|
||||
@@ -45,6 +46,7 @@ class MapUpdate {
|
||||
* delete all deactivated maps
|
||||
* >> php index.php "/cron/deleteMapData"
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
function deleteMapData(\Base $f3){
|
||||
$pfDB = DB\Database::instance()->getDB('PF');
|
||||
@@ -82,6 +84,7 @@ class MapUpdate {
|
||||
* delete expired EOL connections
|
||||
* >> php index.php "/cron/deleteEolConnections"
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
function deleteEolConnections(\Base $f3){
|
||||
$eolExpire = (int)$f3->get('PATHFINDER.CACHE.EXPIRE_CONNECTIONS_EOL');
|
||||
@@ -125,6 +128,7 @@ class MapUpdate {
|
||||
* delete expired WH connections after max lifetime for wormholes is reached
|
||||
* >> php index.php "/cron/deleteExpiredConnections"
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
function deleteExpiredConnections(\Base $f3){
|
||||
$whExpire = (int)$f3->get('PATHFINDER.CACHE.EXPIRE_CONNECTIONS_WH');
|
||||
|
||||
@@ -116,6 +116,7 @@ class Database extends \Prefab {
|
||||
* @param string $password
|
||||
* @param string $alias
|
||||
* @return SQL|null
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function connect($dns, $name, $user, $password, $alias){
|
||||
$db = null;
|
||||
@@ -285,6 +286,7 @@ class Database extends \Prefab {
|
||||
/**
|
||||
* get logger for DB logging
|
||||
* @return \Log
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
static function getLogger(){
|
||||
return LogController::getLogger('ERROR');
|
||||
|
||||
@@ -67,6 +67,7 @@ class Monolog extends \Prefab {
|
||||
* -> this buffered data can be stored/logged somewhere (e.g. DB/file) at any time
|
||||
* -> should be cleared afterwards!
|
||||
* @param Logging\AbstractLog $log
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function push(Logging\AbstractLog $log){
|
||||
// check whether $log should be "grouped" by common handlers
|
||||
|
||||
@@ -24,6 +24,7 @@ class CcpClient extends \Prefab {
|
||||
* get ApiClient instance
|
||||
* @param \Base $f3
|
||||
* @return ApiClient|null
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getClient(\Base $f3){
|
||||
$client = null;
|
||||
@@ -43,6 +44,7 @@ class CcpClient extends \Prefab {
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getUserAgent(){
|
||||
$userAgent = '';
|
||||
@@ -68,6 +70,7 @@ class CcpClient extends \Prefab {
|
||||
* @param $name
|
||||
* @param $arguments
|
||||
* @return array|mixed
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function __call($name, $arguments){
|
||||
$return = [];
|
||||
|
||||
@@ -208,6 +208,7 @@ class Config extends \Prefab {
|
||||
/**
|
||||
* get SMTP config values
|
||||
* @return \stdClass
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
static function getSMTPConfig(): \stdClass{
|
||||
$config = new \stdClass();
|
||||
@@ -252,6 +253,7 @@ class Config extends \Prefab {
|
||||
* get email for notifications by hive key
|
||||
* @param $key
|
||||
* @return mixed
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
static function getNotificationMail($key){
|
||||
return self::getPathfinderData('notification' . ($key ? '.' . $key : ''));
|
||||
@@ -262,6 +264,7 @@ class Config extends \Prefab {
|
||||
* -> read from pathfinder.ini
|
||||
* @param string $mapType
|
||||
* @return mixed
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
static function getMapsDefaultConfig($mapType = ''){
|
||||
if( $mapConfig = self::getPathfinderData('map' . ($mapType ? '.' . $mapType : '')) ){
|
||||
|
||||
@@ -68,6 +68,7 @@ abstract class AbstractCharacterLog extends AbstractChannelLog{
|
||||
/**
|
||||
* get character thumbnailUrl
|
||||
* @return string
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getThumbUrl(): string {
|
||||
$url = '';
|
||||
|
||||
@@ -426,6 +426,7 @@ abstract class AbstractLog implements LogInterface {
|
||||
/**
|
||||
* get __construct() parameters for ZMQHandler() call
|
||||
* @return array
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
protected function getHandlerParamsZMQ(): array {
|
||||
$params = [];
|
||||
|
||||
@@ -60,6 +60,7 @@ class LogCollection extends AbstractLog {
|
||||
/**
|
||||
* add a new log object to this collection
|
||||
* @param AbstractLog $log
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addLog(AbstractLog $log){
|
||||
if(!$this->collection->contains($log)){
|
||||
@@ -113,6 +114,7 @@ class LogCollection extends AbstractLog {
|
||||
|
||||
/**
|
||||
* @param string $tag
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setTag(string $tag){
|
||||
$currentTag = parent::getTag();
|
||||
@@ -147,6 +149,7 @@ class LogCollection extends AbstractLog {
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getChannelName() : string{
|
||||
return $this->getPrimaryLog()->getChannelName();
|
||||
@@ -154,6 +157,7 @@ class LogCollection extends AbstractLog {
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getLevel() : string{
|
||||
return $this->getPrimaryLog()->getLevel();
|
||||
@@ -161,6 +165,7 @@ class LogCollection extends AbstractLog {
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function hasBuffer() : bool{
|
||||
return $this->getPrimaryLog()->hasBuffer();
|
||||
@@ -168,6 +173,7 @@ class LogCollection extends AbstractLog {
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getTempData() : array{
|
||||
return $this->getPrimaryLog()->getTempData();
|
||||
|
||||
@@ -37,6 +37,7 @@ class RallyLog extends AbstractCharacterLog{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getThumbUrl() : string{
|
||||
$url = '';
|
||||
|
||||
@@ -179,6 +179,7 @@ abstract class AbstractSlackWebhookHandler extends Handler\AbstractProcessingHan
|
||||
* @param array $attachment
|
||||
* @param array $characterData
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function setAuthor(array $attachment, array $characterData): array {
|
||||
if( !empty($characterData['id']) && !empty($characterData['name'])){
|
||||
|
||||
@@ -15,6 +15,7 @@ class SlackMapWebhookHandler extends AbstractSlackWebhookHandler {
|
||||
/**
|
||||
* @param array $record
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getSlackData(array $record) : array{
|
||||
$postData = parent::getSlackData($record);
|
||||
|
||||
@@ -15,6 +15,7 @@ class SlackRallyWebhookHandler extends AbstractSlackWebhookHandler {
|
||||
/**
|
||||
* @param array $record
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function getSlackData(array $record) : array{
|
||||
$postData = parent::getSlackData($record);
|
||||
|
||||
@@ -87,9 +87,10 @@ class Socket {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $task
|
||||
* @param string $task
|
||||
* @param string $load
|
||||
* @return bool|string
|
||||
* @throws \ZMQSocketException
|
||||
*/
|
||||
public function sendData(string $task, $load = ''){
|
||||
$response = false;
|
||||
|
||||
@@ -100,6 +100,7 @@ class Web extends \Web {
|
||||
* @param array $additionalOptions
|
||||
* @param int $retryCount request counter for failed call
|
||||
* @return array|FALSE|mixed
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function request($url,array $options = null, $additionalOptions = [], $retryCount = 0 ) {
|
||||
$f3 = \Base::instance();
|
||||
|
||||
@@ -52,6 +52,7 @@ abstract class AbstractMapTrackingModel extends BasicModel implements LogModelIn
|
||||
* @param $key
|
||||
* @param $val
|
||||
* @return bool
|
||||
* @throws \Exception\ValidationException
|
||||
*/
|
||||
protected function validate_notDry($key, $val): bool {
|
||||
$valid = true;
|
||||
@@ -92,7 +93,7 @@ abstract class AbstractMapTrackingModel extends BasicModel implements LogModelIn
|
||||
/**
|
||||
* validates all required columns of this class
|
||||
* @return bool
|
||||
* @throws \Exception\ValidationException
|
||||
* @throws \Exception\DatabaseException
|
||||
*/
|
||||
public function isValid(): bool {
|
||||
if($valid = parent::isValid()){
|
||||
|
||||
@@ -57,6 +57,7 @@ class AllianceModel extends BasicModel {
|
||||
/**
|
||||
* get all maps for this alliance
|
||||
* @return array|mixed
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function getMaps(){
|
||||
$maps = [];
|
||||
|
||||
@@ -822,6 +822,7 @@ abstract class BasicModel extends \DB\Cortex {
|
||||
* debug log function
|
||||
* @param string $text
|
||||
* @param string $type
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public static function log($text, $type = 'DEBUG'){
|
||||
Controller\LogController::getLogger($type)->write($text);
|
||||
|
||||
@@ -139,25 +139,25 @@ class CharacterLogModel extends BasicModel {
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
$logData = (object) [];
|
||||
$logData->system = (object) [];
|
||||
$logData->system->id = (int)$this->systemId;
|
||||
$logData->system->name = $this->systemName;
|
||||
$logData = (object) [];
|
||||
$logData->system = (object) [];
|
||||
$logData->system->id = (int)$this->systemId;
|
||||
$logData->system->name = $this->systemName;
|
||||
|
||||
$logData->ship = (object) [];
|
||||
$logData->ship->typeId = (int)$this->shipTypeId;
|
||||
$logData->ship->typeName = $this->shipTypeName;
|
||||
$logData->ship->id = $this->shipId;
|
||||
$logData->ship->name = $this->shipName;
|
||||
$logData->ship->mass = $this->shipMass;
|
||||
$logData->ship = (object) [];
|
||||
$logData->ship->typeId = (int)$this->shipTypeId;
|
||||
$logData->ship->typeName = $this->shipTypeName;
|
||||
$logData->ship->id = $this->shipId;
|
||||
$logData->ship->name = $this->shipName;
|
||||
$logData->ship->mass = $this->shipMass;
|
||||
|
||||
$logData->station = (object) [];
|
||||
$logData->station->id = (int)$this->stationId;
|
||||
$logData->station->name = $this->stationName;
|
||||
$logData->station = (object) [];
|
||||
$logData->station->id = (int)$this->stationId;
|
||||
$logData->station->name = $this->stationName;
|
||||
|
||||
$logData->structure = (object) [];
|
||||
$logData->structure->id = (int)$this->structureId;
|
||||
$logData->structure->name = $this->structureName;
|
||||
$logData->structure = (object) [];
|
||||
$logData->structure->id = (int)$this->structureId;
|
||||
$logData->structure->name = $this->structureName;
|
||||
|
||||
return $logData;
|
||||
}
|
||||
@@ -166,6 +166,7 @@ class CharacterLogModel extends BasicModel {
|
||||
* setter for systemId
|
||||
* @param int $systemId
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function set_systemId($systemId){
|
||||
if($systemId > 0){
|
||||
@@ -219,6 +220,7 @@ class CharacterLogModel extends BasicModel {
|
||||
/**
|
||||
* update session data for active character
|
||||
* @param int $systemId
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function updateCharacterSessionLocation(int $systemId){
|
||||
$controller = new Controller();
|
||||
|
||||
@@ -471,6 +471,7 @@ class CharacterModel extends BasicModel {
|
||||
/**
|
||||
* get ESI API "access_token" from OAuth
|
||||
* @return bool|string
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function getAccessToken(){
|
||||
$accessToken = false;
|
||||
@@ -541,6 +542,7 @@ class CharacterModel extends BasicModel {
|
||||
* checks whether this character is authorized to log in
|
||||
* -> check corp/ally whitelist config (pathfinder.ini)
|
||||
* @return bool
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function isAuthorized(){
|
||||
$authStatus = 'UNKNOWN';
|
||||
@@ -596,6 +598,7 @@ class CharacterModel extends BasicModel {
|
||||
/**
|
||||
* get pathfinder roleId
|
||||
* @return int
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function requestRoleId(){
|
||||
$roleId = self::ROLES['MEMBER'];
|
||||
@@ -614,6 +617,7 @@ class CharacterModel extends BasicModel {
|
||||
/**
|
||||
* request all corporation roles granted to this character
|
||||
* @return array
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
protected function requestRoles(){
|
||||
$rolesData = [];
|
||||
@@ -655,6 +659,7 @@ class CharacterModel extends BasicModel {
|
||||
* -> API request for character log data
|
||||
* @param array $additionalOptions (optional) request options for cURL request
|
||||
* @return CharacterModel
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function updateLog($additionalOptions = []){
|
||||
$deleteLog = false;
|
||||
@@ -874,6 +879,7 @@ class CharacterModel extends BasicModel {
|
||||
/**
|
||||
* update character data from CCPs ESI API
|
||||
* @return array (some status messages)
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function updateFromESI(){
|
||||
$status = [];
|
||||
@@ -938,6 +944,7 @@ class CharacterModel extends BasicModel {
|
||||
* get mapModel by id and check if user has access
|
||||
* @param $mapId
|
||||
* @return MapModel|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getMap($mapId){
|
||||
/**
|
||||
@@ -957,6 +964,7 @@ class CharacterModel extends BasicModel {
|
||||
/**
|
||||
* get all accessible map models for this character
|
||||
* @return MapModel[]
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function getMaps(){
|
||||
$this->filter(
|
||||
|
||||
@@ -57,6 +57,7 @@ class CharacterStatusModel extends BasicModel {
|
||||
* @param null $table
|
||||
* @param null $fields
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function setup($db=null, $table=null, $fields=null){
|
||||
$status = parent::setup($db,$table,$fields);
|
||||
|
||||
84
app/main/model/connectionlogmodel.php
Normal file
84
app/main/model/connectionlogmodel.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: exodu
|
||||
* Date: 05.11.2017
|
||||
* Time: 17:51
|
||||
*/
|
||||
|
||||
namespace Model;
|
||||
|
||||
use DB\SQL\Schema;
|
||||
|
||||
class ConnectionLogModel extends BasicModel {
|
||||
|
||||
protected $table = 'connection_log';
|
||||
|
||||
protected $fieldConf = [
|
||||
'active' => [
|
||||
'type' => Schema::DT_BOOL,
|
||||
'nullable' => false,
|
||||
'default' => 1,
|
||||
'index' => true
|
||||
],
|
||||
'connectionId' => [
|
||||
'type' => Schema::DT_INT,
|
||||
'index' => true,
|
||||
'belongs-to-one' => 'Model\ConnectionModel',
|
||||
'constraint' => [
|
||||
[
|
||||
'table' => 'connection',
|
||||
'on-delete' => 'CASCADE'
|
||||
]
|
||||
]
|
||||
],
|
||||
'shipTypeId' => [
|
||||
'type' => Schema::DT_INT,
|
||||
'index' => true
|
||||
],
|
||||
'shipTypeName' => [
|
||||
'type' => Schema::DT_VARCHAR128,
|
||||
'nullable' => false,
|
||||
'default' => ''
|
||||
],
|
||||
'shipMass' => [
|
||||
'type' => Schema::DT_FLOAT,
|
||||
'nullable' => false,
|
||||
'default' => 0
|
||||
],
|
||||
'characterId' => [
|
||||
'type' => Schema::DT_INT,
|
||||
'index' => true
|
||||
],
|
||||
'characterName' => [
|
||||
'type' => Schema::DT_VARCHAR128,
|
||||
'nullable' => false,
|
||||
'default' => ''
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* get connection log data
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function getData() : \stdClass {
|
||||
$logData = (object) [];
|
||||
$logData->id = $this->id;
|
||||
|
||||
$logData->connection = (object) [];
|
||||
$logData->connection->id = $this->get('connectionId', true);
|
||||
|
||||
$logData->ship = (object) [];
|
||||
$logData->ship->typeId = (int)$this->shipTypeId;
|
||||
$logData->ship->typeName = $this->shipTypeName;
|
||||
$logData->ship->mass = $this->shipMass;
|
||||
|
||||
$logData->created = (object) [];
|
||||
$logData->created->created = strtotime($this->created);
|
||||
$logData->created->character = (object) [];
|
||||
$logData->created->character->id = $this->characterId;
|
||||
$logData->created->character->name = $this->characterName;
|
||||
|
||||
return $logData;
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,9 @@ class ConnectionModel extends AbstractMapTrackingModel {
|
||||
],
|
||||
'signatures' => [
|
||||
'has-many' => ['Model\SystemSignatureModel', 'connectionId']
|
||||
],
|
||||
'connectionLog' => [
|
||||
'has-many' => ['Model\ConnectionLogModel', 'connectionId']
|
||||
]
|
||||
];
|
||||
|
||||
@@ -101,20 +104,21 @@ class ConnectionModel extends AbstractMapTrackingModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* get connection data as array
|
||||
* get connection data
|
||||
* @param bool $addSignatureData
|
||||
* @param bool $addLogData
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function getData($addSignatureData = false){
|
||||
public function getData($addSignatureData = false, $addLogData = false){
|
||||
$connectionData = (object) [];
|
||||
$connectionData->id = $this->id;
|
||||
$connectionData->source = $this->source->id;
|
||||
$connectionData->target = $this->target->id;
|
||||
$connectionData->scope = $this->scope;
|
||||
$connectionData->type = $this->type;
|
||||
$connectionData->updated = strtotime($this->updated);
|
||||
$connectionData->created = strtotime($this->created);
|
||||
$connectionData->eolUpdated = strtotime($this->eolUpdated);
|
||||
$connectionData->id = $this->id;
|
||||
$connectionData->source = $this->source->id;
|
||||
$connectionData->target = $this->target->id;
|
||||
$connectionData->scope = $this->scope;
|
||||
$connectionData->type = $this->type;
|
||||
$connectionData->updated = strtotime($this->updated);
|
||||
$connectionData->created = strtotime($this->created);
|
||||
$connectionData->eolUpdated = strtotime($this->eolUpdated);
|
||||
|
||||
if($addSignatureData){
|
||||
if( !empty($signaturesData = $this->getSignaturesData()) ){
|
||||
@@ -122,6 +126,12 @@ class ConnectionModel extends AbstractMapTrackingModel {
|
||||
}
|
||||
}
|
||||
|
||||
if($addLogData){
|
||||
if( !empty($logsData = $this->getLogsData()) ){
|
||||
$connectionData->logs = $logsData;
|
||||
}
|
||||
}
|
||||
|
||||
return $connectionData;
|
||||
}
|
||||
|
||||
@@ -193,6 +203,7 @@ class ConnectionModel extends AbstractMapTrackingModel {
|
||||
/**
|
||||
* check whether this model is valid or not
|
||||
* @return bool
|
||||
* @throws \Exception\DatabaseException
|
||||
*/
|
||||
public function isValid(): bool {
|
||||
if($valid = parent::isValid()){
|
||||
@@ -218,6 +229,7 @@ class ConnectionModel extends AbstractMapTrackingModel {
|
||||
* @param ConnectionModel $self
|
||||
* @param $pkeys
|
||||
* @return bool
|
||||
* @throws \Exception\DatabaseException
|
||||
*/
|
||||
public function beforeInsertEvent($self, $pkeys){
|
||||
// check for "default" connection type and add them if missing
|
||||
@@ -269,6 +281,7 @@ class ConnectionModel extends AbstractMapTrackingModel {
|
||||
/**
|
||||
* @param string $action
|
||||
* @return Logging\LogInterface
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function newLog($action = ''): Logging\LogInterface{
|
||||
return $this->getMap()->newLog($action)->setTempData($this->getLogObjectData());
|
||||
@@ -330,11 +343,29 @@ class ConnectionModel extends AbstractMapTrackingModel {
|
||||
return $signatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all jump logs that are connected with this connection
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getLogs(){
|
||||
$logs = [];
|
||||
$this->filter('connectionLog', [
|
||||
'active = :active',
|
||||
':active' => 1
|
||||
]);
|
||||
|
||||
if($this->connectionLog){
|
||||
$logs = $this->connectionLog;
|
||||
}
|
||||
|
||||
return $logs;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all signature data linked to this connection
|
||||
* @return array
|
||||
*/
|
||||
public function getSignaturesData(){
|
||||
public function getSignaturesData() : array {
|
||||
$signaturesData = [];
|
||||
$signatures = $this->getSignatures();
|
||||
|
||||
@@ -345,6 +376,36 @@ class ConnectionModel extends AbstractMapTrackingModel {
|
||||
return $signaturesData;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all connection log data linked to this connection
|
||||
* @return array
|
||||
*/
|
||||
public function getLogsData() : array{
|
||||
$logsData = [];
|
||||
$logs = $this->getLogs();
|
||||
|
||||
foreach($logs as $log){
|
||||
$logsData[] = $log->getData();
|
||||
}
|
||||
|
||||
return $logsData;
|
||||
}
|
||||
|
||||
public function logMass(CharacterLogModel $characterLog){
|
||||
if( !$characterLog->dry() ){
|
||||
$log = $this->rel('connectionLog');
|
||||
$log->shipTypeId = $characterLog->shipTypeId;
|
||||
$log->shipTypeName = $characterLog->shipTypeName;
|
||||
$log->shipMass = $characterLog->shipMass;
|
||||
$log->characterId = $characterLog->characterId->_id;
|
||||
$log->characterName = $characterLog->characterId->name;
|
||||
$log->connectionId = $this;
|
||||
$log->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* overwrites parent
|
||||
* @param null $db
|
||||
|
||||
@@ -66,6 +66,7 @@ class ConnectionScopeModel extends BasicModel{
|
||||
* @param null $table
|
||||
* @param null $fields
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function setup($db=null, $table=null, $fields=null){
|
||||
$status = parent::setup($db,$table,$fields);
|
||||
|
||||
@@ -128,6 +128,7 @@ class CorporationModel extends BasicModel {
|
||||
/**
|
||||
* get all maps for this corporation
|
||||
* @return MapModel[]
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function getMaps(){
|
||||
$maps = [];
|
||||
|
||||
@@ -181,6 +181,8 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* get map data
|
||||
* -> this includes system and connection data as well!
|
||||
* @return \stdClass
|
||||
* @throws PathfinderException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getData(){
|
||||
// check if there is cached data
|
||||
@@ -294,6 +296,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* @param string $key
|
||||
* @param string $val
|
||||
* @return bool
|
||||
* @throws \Exception\ValidationException
|
||||
*/
|
||||
protected function validate_name(string $key, string $val): bool {
|
||||
$valid = true;
|
||||
@@ -309,6 +312,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* @param string $key
|
||||
* @param string $val
|
||||
* @return bool
|
||||
* @throws \Exception\ValidationException
|
||||
*/
|
||||
protected function validate_slackWebHookURL(string $key, string $val): bool {
|
||||
$valid = true;
|
||||
@@ -401,6 +405,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* -> check for "inactive" systems on this map first!
|
||||
* @param int $systemId
|
||||
* @return SystemModel
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getNewSystem($systemId){
|
||||
// check for "inactive" system
|
||||
@@ -510,6 +515,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
/**
|
||||
* get all system data for all systems in this map
|
||||
* @return \stdClass[]
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getSystemData(){
|
||||
$systemData = [];
|
||||
@@ -545,10 +551,11 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
|
||||
/**
|
||||
* get all connections in this map
|
||||
* @param null $connectionIds
|
||||
* @param string $scope
|
||||
* @return ConnectionModel[]
|
||||
*/
|
||||
public function getConnections($scope = ''){
|
||||
public function getConnections($connectionIds = null, $scope = ''){
|
||||
$connections = [];
|
||||
|
||||
$query = [
|
||||
@@ -561,6 +568,11 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
$query[':scope'] = $scope;
|
||||
}
|
||||
|
||||
if(!empty($connectionIds)){
|
||||
$query[0] .= ' AND id IN (?)';
|
||||
$query[] = $connectionIds;
|
||||
}
|
||||
|
||||
$this->filter('connections', $query);
|
||||
|
||||
if($this->connections){
|
||||
@@ -591,6 +603,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
/**
|
||||
* set map access for an object (character, corporation or alliance)
|
||||
* @param $obj
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setAccess($obj){
|
||||
|
||||
@@ -689,6 +702,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* checks whether a character has access to this map or not
|
||||
* @param CharacterModel $characterModel
|
||||
* @return bool
|
||||
* @throws PathfinderException
|
||||
*/
|
||||
public function hasAccess(CharacterModel $characterModel){
|
||||
$hasAccess = false;
|
||||
@@ -834,6 +848,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
/**
|
||||
* @param string $action
|
||||
* @return Logging\LogInterface
|
||||
* @throws PathfinderException
|
||||
*/
|
||||
public function newLog($action = ''): Logging\LogInterface{
|
||||
$logChannelData = $this->getLogChannelData();
|
||||
@@ -901,6 +916,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
/**
|
||||
* check if "activity logging" is enabled for this map type
|
||||
* @return bool
|
||||
* @throws PathfinderException
|
||||
*/
|
||||
public function isActivityLogEnabled(): bool {
|
||||
return $this->logActivity && (bool) Config::getMapsDefaultConfig($this->typeId->name)['log_activity_enabled'];
|
||||
@@ -909,6 +925,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
/**
|
||||
* check if "history logging" is enabled for this map type
|
||||
* @return bool
|
||||
* @throws PathfinderException
|
||||
*/
|
||||
public function isHistoryLogEnabled(): bool {
|
||||
return $this->logHistory && (bool) Config::getMapsDefaultConfig($this->typeId->name)['log_history_enabled'];
|
||||
@@ -946,6 +963,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* check if "E-Mail" Log is enabled for this map
|
||||
* @param string $type
|
||||
* @return bool
|
||||
* @throws PathfinderException
|
||||
*/
|
||||
public function isMailSendEnabled(string $type): bool{
|
||||
$enabled = false;
|
||||
@@ -1005,6 +1023,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* @param string $type
|
||||
* @param bool $addJson
|
||||
* @return \stdClass
|
||||
* @throws PathfinderException
|
||||
*/
|
||||
public function getSMTPConfig(string $type, bool $addJson = true): \stdClass{
|
||||
$config = Config::getSMTPConfig();
|
||||
@@ -1141,6 +1160,8 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* get all active characters (with active log)
|
||||
* grouped by systems
|
||||
* @return \stdClass
|
||||
* @throws PathfinderException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getUserData(){
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ class MapScopeModel extends BasicModel{
|
||||
* @param null $table
|
||||
* @param null $fields
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function setup($db=null, $table=null, $fields=null){
|
||||
$status = parent::setup($db,$table,$fields);
|
||||
|
||||
@@ -87,6 +87,7 @@ class MapTypeModel extends BasicModel{
|
||||
* @param null $table
|
||||
* @param null $fields
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function setup($db=null, $table=null, $fields=null){
|
||||
$status = parent::setup($db,$table,$fields);
|
||||
|
||||
@@ -410,6 +410,7 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
/**
|
||||
* @param string $action
|
||||
* @return Logging\LogInterface
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function newLog($action = ''): Logging\LogInterface{
|
||||
return $this->getMap()->newLog($action)->setTempData($this->getLogObjectData());
|
||||
@@ -567,6 +568,7 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
* -> send to an Email
|
||||
* @param array $rallyData
|
||||
* @param CharacterModel $characterModel
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function sendRallyPoke(array $rallyData, CharacterModel $characterModel){
|
||||
// rally log needs at least one handler to be valid
|
||||
|
||||
@@ -169,6 +169,7 @@ class SystemSignatureModel extends AbstractMapTrackingModel {
|
||||
* @param string $key
|
||||
* @param string $val
|
||||
* @return bool
|
||||
* @throws \Exception\ValidationException
|
||||
*/
|
||||
protected function validate_name(string $key, string $val): bool {
|
||||
$valid = true;
|
||||
@@ -182,6 +183,7 @@ class SystemSignatureModel extends AbstractMapTrackingModel {
|
||||
/**
|
||||
* @param string $action
|
||||
* @return Logging\LogInterface
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
public function newLog($action = ''): Logging\LogInterface{
|
||||
return $this->getMap()->newLog($action)->setTempData($this->getLogObjectData());
|
||||
|
||||
@@ -83,6 +83,7 @@ class SystemStatusModel extends BasicModel {
|
||||
* @param null $table
|
||||
* @param null $fields
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function setup($db=null, $table=null, $fields=null){
|
||||
$status = parent::setup($db,$table,$fields);
|
||||
|
||||
@@ -45,6 +45,7 @@ class SystemTypeModel extends BasicModel {
|
||||
* @param null $table
|
||||
* @param null $fields
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function setup($db=null, $table=null, $fields=null){
|
||||
$status = parent::setup($db,$table,$fields);
|
||||
|
||||
@@ -54,4 +54,13 @@ class ConstellationModel extends BasicUniverseModel {
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $accessToken
|
||||
* @param array $additionalOptions
|
||||
*/
|
||||
protected function loadData(int $id, string $accessToken = '', array $additionalOptions = []){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,4 +33,13 @@ class RegionModel extends BasicUniverseModel {
|
||||
'has-many' => ['Model\Universe\ConstellationModel', 'regionId']
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $accessToken
|
||||
* @param array $additionalOptions
|
||||
*/
|
||||
protected function loadData(int $id, string $accessToken = '', array $additionalOptions = []){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ class UserModel extends BasicModel {
|
||||
* -> ! caution ! this function returns sensitive data! (e.g. email,..)
|
||||
* -> user getSimpleData() for faster performance and public user data
|
||||
* @return \stdClass
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
@@ -93,6 +94,7 @@ class UserModel extends BasicModel {
|
||||
* @param UserModel $self
|
||||
* @param $pkeys
|
||||
* @return bool
|
||||
* @throws Exception\PathfinderException
|
||||
* @throws Exception\RegistrationException
|
||||
*/
|
||||
public function beforeInsertEvent($self, $pkeys){
|
||||
@@ -135,6 +137,7 @@ class UserModel extends BasicModel {
|
||||
/**
|
||||
* checks whether user has a valid email address and pathfinder has a valid SMTP config
|
||||
* @return bool
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
protected function isMailSendEnabled() : bool{
|
||||
return Config::isValidSMTPConfig($this->getSMTPConfig());
|
||||
@@ -143,6 +146,7 @@ class UserModel extends BasicModel {
|
||||
/**
|
||||
* get SMTP config for this user
|
||||
* @return \stdClass
|
||||
* @throws Exception\PathfinderException
|
||||
*/
|
||||
protected function getSMTPConfig() : \stdClass{
|
||||
$config = Config::getSMTPConfig();
|
||||
@@ -155,6 +159,7 @@ class UserModel extends BasicModel {
|
||||
* @param string $key
|
||||
* @param string $val
|
||||
* @return bool
|
||||
* @throws Exception\ValidationException
|
||||
*/
|
||||
protected function validate_name(string $key, string $val): bool {
|
||||
$valid = true;
|
||||
@@ -173,6 +178,7 @@ class UserModel extends BasicModel {
|
||||
* @param string $key
|
||||
* @param string $val
|
||||
* @return bool
|
||||
* @throws Exception\ValidationException
|
||||
*/
|
||||
protected function validate_email(string $key, string $val): bool {
|
||||
$valid = true;
|
||||
@@ -207,6 +213,7 @@ class UserModel extends BasicModel {
|
||||
* @param int $characterId
|
||||
* @param bool $objectCheck
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getSessionCharacterData($characterId = 0, $objectCheck = true){
|
||||
$data = [];
|
||||
@@ -289,6 +296,7 @@ class UserModel extends BasicModel {
|
||||
* -> EITHER - the current active one for the current user
|
||||
* -> OR - get the first active one
|
||||
* @return null|CharacterModel
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getActiveCharacter(){
|
||||
$activeCharacter = null;
|
||||
|
||||
@@ -59,47 +59,27 @@ class WormholeModel extends BasicModel {
|
||||
*/
|
||||
protected $addStaticFields = false;
|
||||
|
||||
/**
|
||||
* format mass values
|
||||
* - no decimal separator
|
||||
* - char '.' for thousands separator
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
static function formatMassValue($value){
|
||||
return number_format( $value, 0, '', '.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* get wormhole data as object
|
||||
* @return object
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
$systemStaticData = (object) [];
|
||||
$systemStaticData->name = $this->name;
|
||||
$systemStaticData->security = $this->security;
|
||||
|
||||
// total (max) available wormhole mass
|
||||
$systemStaticData->massTotal = (object) [];
|
||||
$systemStaticData->massTotal->value = $this->massTotal;
|
||||
$systemStaticData->massTotal->format = self::formatMassValue($this->massTotal) . ' Kg';
|
||||
$systemStaticData->massTotal = $this->massTotal;
|
||||
|
||||
// individual jump mass (max) per jump
|
||||
$systemStaticData->massIndividual = (object) [];
|
||||
$systemStaticData->massIndividual->value = $this->massIndividual;
|
||||
$systemStaticData->massIndividual->format = self::formatMassValue($this->massIndividual) . ' Kg';
|
||||
$systemStaticData->massIndividual = $this->massIndividual;
|
||||
|
||||
// lifetime (max) for this wormhole
|
||||
$systemStaticData->maxStableTime = (object) [];
|
||||
$systemStaticData->maxStableTime->value = $this->maxStableTime;
|
||||
$systemStaticData->maxStableTime->format = $this->maxStableTime . ' h';
|
||||
$systemStaticData->maxStableTime = $this->maxStableTime;
|
||||
|
||||
// mass regeneration value per day
|
||||
if($this->massRegeneration > 0){
|
||||
$systemStaticData->massRegeneration = (object) [];
|
||||
$systemStaticData->massRegeneration->value = $this->massRegeneration;
|
||||
$systemStaticData->massRegeneration->format = self::formatMassValue($this->massRegeneration) . ' Kg/day';
|
||||
$systemStaticData->massRegeneration = $this->massRegeneration;
|
||||
}
|
||||
|
||||
return $systemStaticData;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[PATHFINDER]
|
||||
NAME = Pathfinder
|
||||
; installed version (used for CSS/JS cache busting)
|
||||
VERSION = v1.3.0
|
||||
VERSION = v1.3.1
|
||||
; contact information [optional]
|
||||
CONTACT = https://github.com/exodus4d
|
||||
; public contact email [optional]
|
||||
|
||||
Reference in New Issue
Block a user