* #84 test data dump from CREST login * updated "credits" dialog (Google+ link) fixed login form layout * updated Cortex Data-Mapper * - #84 CREST Login (WIP) - New CREST controller - Database restructuring - improved type-casting for some controller functions - New login process - Fixed some bugs during the setup process (/setup root) - Added CREST request caching by response headers * pathfinder-84 [Feature Request] CREST Pilot Tracking, many smaller Bugfixes * pathfinder-84 [Feature Request] added develop JS files * closed #121 fixed wormhole signature type caching * closed #120 removed map-loading animation for larger maps (same behaviour as IGB) * closed #119 fixed wormhole signature id count * closed #114 Added check for already existing system when adding a new one. (fixed PDO 'duplicate entry' error) * closed #112 fixed DataTables error for missing "status" data (signature table) * closed #111 fixed convertDataToUTC(); client side date transformation * closed #109 fixed system TrueSec rounding * closed #103 fixed system updated timestamp in getData() * fixed CSS class for secStatus in Routes module * closed #121 fixed wormhole signature type caching * changed dateTime format from German to US format fixed some minor bugs in signatureTable module * closed #81 fixed "signature type" overwriting by "signature reader" update * closed #106 added new signature_types form C5/6 wormholes (gas/ore) * closed #129 fixed parameter hinting * closed #131 new "route search" algorithm, added current map systems to live search, added refresh/update functionality for each found route, added bulk route refresh function, added "meta map" route search (search on multiple maps), added route "filters" (restrict search on "stargates", "wormholes", "jumpbridges"), added route "filter" for wormholes (reduced/critical wormholes) closed #89 fixed "loop connections" on same system #84 added error messages for "invalid" CREST "Client ID" added "bootboxjs" (customized styled checkboxes/radio buttons) CSS only "Font Awesome" version upgrade 4.4.0 -> 4.61 "Bootbox.js" version upgrade 4.3.0 -> 4.4.0 fixed "system dialog" (added responsive layout) * closed #134 fixed db column type DT_INT (8 bytes) to DT_BIGINT * closed #138 added new cookie based login * closed #137 fixed javascript errors on trying to establish an "invalid" connection * - #84, #138 improved "character selection" on login page (expired cookies are deleted, character panel layout improvements) - added new "Server info panel" to the login page - added new cronjob to delete expired cookie authentication data * #138 enables character switching between characters which have same user * - PHP Framework upgrade 3.5.0 -> 3.5.1 (fixes some issues with CREST cURL caching, and SESSION management) - #138 added "cookie logout" to "logout" menu entry * - updated "feature page" with new feature descriptions and label - added some new images to the "feature gallery" - removed "beta" status from "magnetizing" feature on map menu - hide "server status" panel on "mobile" breakpoint * - #138 clear character authentication data on sold characters * closed #142 added custom "onsuspect()" session handler * #142 do not log suspect if no file is defined in pathfinder.ini * #142 added NullSec Data/Relic sites to C1/2/3 wormholes as signature option * #144 fixed "Character not found" warning * #144 fixed "Character not found" warning * closed #144 fixed broken routes panel in IGB * updated README.md for upcoming release * #147 response header validation * #149 changed comment for 'BASE' framework var * fixed map import * - added minimal SDE dump (EVE Online: Citadel) - #147 improved CREST API error logging (WIP) - improved SSO controller (removed access_token from public endpoints) * closed #154 added alliance maps to CREST API * - updated Gulp build dependencies - increased CREST timeout from 3s -> 4s - added "Accept" Headers for some CREST endpoints * cloased #147 * - closed #153 added character verification check for getAll(); Signatures Ajax endpoint * - updated README.md (added Slack developer chat information) * Bugfix frig holes (#159) * added missing frigate wormholes and fixed Q003 destination in shattered wormholes * changed C7 to 0.0 for Q003 * - fixed broken "graph" data for system * added a "failover" system for bad crest requests (HTTP status 5xx,.. ) * Red Gaint => Red Giant (#161) * closed #163 added CREST endpoint support for "waypoints" * fixed typo * closed #160 fixed tooltip container * - added new features to login page * closes #154 added alliance map support * fixed XML path for cronjobs * fixed a bug with inactive "private" maps * closes #175 added alternative environment configuration * - v1.0.0 build
214 lines
7.2 KiB
PHP
214 lines
7.2 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: exodus4d
|
|
* Date: 21.03.15
|
|
* Time: 21:59
|
|
*/
|
|
|
|
namespace Controller\Api;
|
|
use Controller;
|
|
use Model;
|
|
|
|
|
|
class Signature extends Controller\AccessController{
|
|
|
|
/**
|
|
* event handler
|
|
* @param \Base $f3
|
|
*/
|
|
function beforeroute(\Base $f3) {
|
|
// set header for all routes
|
|
header('Content-type: application/json');
|
|
parent::beforeroute($f3);
|
|
}
|
|
|
|
/**
|
|
* get signature data for systems
|
|
* -> return value of this is limited to a "SINGLE" system
|
|
* @param \Base $f3
|
|
*/
|
|
public function getAll($f3){
|
|
$signatureData = [];
|
|
$systemIds = (array)$f3->get('POST.systemIds');
|
|
|
|
if( !empty($systemIds) ){
|
|
$activeCharacter = $this->getCharacter();
|
|
|
|
if($activeCharacter){
|
|
/**
|
|
* @var Model\SystemModel $system
|
|
*/
|
|
$system = Model\BasicModel::getNew('SystemModel');
|
|
foreach($systemIds as $systemId){
|
|
$system->getById($systemId);
|
|
if(
|
|
!$system->dry() &&
|
|
$system->hasAccess($activeCharacter)
|
|
){
|
|
$signatureData = $system->getSignaturesData();
|
|
}
|
|
|
|
$system->reset();
|
|
}
|
|
}
|
|
}
|
|
|
|
echo json_encode($signatureData);
|
|
}
|
|
|
|
/**
|
|
* save or update a full signature data set
|
|
* or save/update just single or multiple signature data
|
|
* @param $f3
|
|
*/
|
|
public function save($f3){
|
|
$requestData = $f3->get('POST');
|
|
|
|
$signatureData = null;
|
|
|
|
$return = (object) [];
|
|
$return->error = [];
|
|
$return->signatures = [];
|
|
|
|
if( isset($requestData['signatures']) ){
|
|
// save multiple signatures
|
|
$signatureData = $requestData['signatures'];
|
|
}elseif( !empty($requestData) ){
|
|
// single signature
|
|
$signatureData = [$requestData];
|
|
}
|
|
|
|
if( !is_null($signatureData) ){
|
|
$activeCharacter = $this->getCharacter();
|
|
|
|
if($activeCharacter){
|
|
|
|
/**
|
|
* @var Model\SystemModel $system
|
|
*/
|
|
$system = Model\BasicModel::getNew('SystemModel');
|
|
|
|
// update/add all submitted signatures
|
|
foreach($signatureData as $data){
|
|
// this key should not be saved (it is an obj)
|
|
unset($data['updated']);
|
|
|
|
$system->getById( (int)$data['systemId']);
|
|
|
|
if(!$system->dry()){
|
|
// update/save signature
|
|
|
|
/**
|
|
* @var $signature Model\SystemSignatureModel
|
|
*/
|
|
$signature = null;
|
|
if( isset($data['pk']) ){
|
|
// try to get system by "primary key"
|
|
$signature = $system->getSignatureById($activeCharacter, (int)$data['pk']);
|
|
}elseif( isset($data['name']) ){
|
|
$signature = $system->getSignatureByName($activeCharacter, $data['name']);
|
|
}
|
|
|
|
if( is_null($signature) ){
|
|
$signature = Model\BasicModel::getNew('SystemSignatureModel');
|
|
}
|
|
|
|
if($signature->dry()){
|
|
// new signature
|
|
$signature->systemId = $system;
|
|
$signature->updatedCharacterId = $activeCharacter;
|
|
$signature->createdCharacterId = $activeCharacter;
|
|
$signature->setData($data);
|
|
}else{
|
|
// update signature
|
|
|
|
if(
|
|
isset($data['name']) &&
|
|
isset($data['value'])
|
|
){
|
|
// update single key => value pair
|
|
$newData = [
|
|
$data['name'] => $data['value']
|
|
];
|
|
|
|
// if groupID changed -> typeID set to 0
|
|
if($data['name'] == 'groupId'){
|
|
$newData['typeId'] = 0;
|
|
}
|
|
|
|
}else{
|
|
// update complete signature (signature reader dialog)
|
|
|
|
// systemId should not be updated
|
|
unset( $data['systemId'] );
|
|
|
|
// description should not be updated
|
|
unset( $data['description'] );
|
|
|
|
// prevent some data from overwrite manually changes
|
|
// wormhole typeID can not figured out/saved by the sig reader dialog
|
|
// -> type could not be identified -> do not overwrite them (e.g. sig update)
|
|
if(
|
|
$data['groupId'] == 5 ||
|
|
$data['typeId'] == 0
|
|
){
|
|
unset( $data['typeId'] );
|
|
}
|
|
|
|
$newData = $data;
|
|
}
|
|
|
|
if( $signature->hasChanged($newData) ){
|
|
// Character should only be changed if something else has changed
|
|
$signature->updatedCharacterId = $activeCharacter;
|
|
$signature->setData($newData);
|
|
}
|
|
}
|
|
|
|
$signature->save();
|
|
|
|
// get a fresh signature object with the new data. This is a bad work around!
|
|
// but i could not figure out what the problem was when using the signature model, saved above :(
|
|
// -> some caching problems
|
|
/**
|
|
* @var $newSignature Model\SystemSignatureModel
|
|
*/
|
|
$newSignature = Model\BasicModel::getNew('SystemSignatureModel');
|
|
$newSignature->getById( $signature->id, 0);
|
|
|
|
$return->signatures[] = $newSignature->getData();
|
|
|
|
$signature->reset();
|
|
}
|
|
|
|
$system->reset();
|
|
}
|
|
}
|
|
}
|
|
|
|
echo json_encode($return);
|
|
}
|
|
|
|
/**
|
|
* delete signatures
|
|
* @param \Base $f3
|
|
*/
|
|
public function delete($f3){
|
|
$signatureIds = $f3->get('POST.signatureIds');
|
|
$activeCharacter = $this->getCharacter();
|
|
|
|
/**
|
|
* @var Model\SystemSignatureModel $signature
|
|
*/
|
|
$signature = Model\BasicModel::getNew('SystemSignatureModel');
|
|
foreach($signatureIds as $signatureId){
|
|
$signature->getById($signatureId);
|
|
$signature->delete( $activeCharacter );
|
|
$signature->reset();
|
|
}
|
|
|
|
echo json_encode([]);
|
|
}
|
|
|
|
}
|