* #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
707 lines
20 KiB
PHP
707 lines
20 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: exodus4d
|
|
* Date: 16.02.15
|
|
* Time: 22:10
|
|
*/
|
|
|
|
namespace Model;
|
|
|
|
use Controller\Api\User;
|
|
use DB\SQL\Schema;
|
|
|
|
class MapModel extends BasicModel {
|
|
|
|
protected $table = 'map';
|
|
|
|
protected $fieldConf = [
|
|
'active' => [
|
|
'type' => Schema::DT_BOOL,
|
|
'nullable' => false,
|
|
'default' => 1,
|
|
'index' => true,
|
|
'after' => 'updated'
|
|
],
|
|
'scopeId' => [
|
|
'type' => Schema::DT_INT,
|
|
'index' => true,
|
|
'belongs-to-one' => 'Model\MapScopeModel',
|
|
'constraint' => [
|
|
[
|
|
'table' => 'map_scope',
|
|
'on-delete' => 'CASCADE'
|
|
]
|
|
]
|
|
],
|
|
'typeId' => [
|
|
'type' => Schema::DT_INT,
|
|
'index' => true,
|
|
'belongs-to-one' => 'Model\MapTypeModel',
|
|
'constraint' => [
|
|
[
|
|
'table' => 'map_type',
|
|
'on-delete' => 'CASCADE'
|
|
]
|
|
]
|
|
],
|
|
'name' => [
|
|
'type' => Schema::DT_VARCHAR128,
|
|
'nullable' => false,
|
|
'default' => ''
|
|
],
|
|
'icon' => [
|
|
'type' => Schema::DT_VARCHAR128,
|
|
'nullable' => false,
|
|
'default' => ''
|
|
],
|
|
'systems' => [
|
|
'has-many' => ['Model\SystemModel', 'mapId']
|
|
],
|
|
'connections' => [
|
|
'has-many' => ['Model\ConnectionModel', 'mapId']
|
|
],
|
|
'mapCharacters' => [
|
|
'has-many' => ['Model\CharacterMapModel', 'mapId']
|
|
],
|
|
'mapCorporations' => [
|
|
'has-many' => ['Model\CorporationMapModel', 'mapId']
|
|
],
|
|
'mapAlliances' => [
|
|
'has-many' => ['Model\AllianceMapModel', 'mapId']
|
|
]
|
|
];
|
|
|
|
protected $validate = [
|
|
'name' => [
|
|
'length' => [
|
|
'min' => 3
|
|
]
|
|
],
|
|
'icon' => [
|
|
'length' => [
|
|
'min' => 3
|
|
]
|
|
],
|
|
'scopeId' => [
|
|
'regex' => '/^[1-9]+$/'
|
|
],
|
|
'typeId' => [
|
|
'regex' => '/^[1-9]+$/'
|
|
]
|
|
];
|
|
|
|
/**
|
|
* set map data by an associative array
|
|
* @param $data
|
|
*/
|
|
public function setData($data){
|
|
|
|
foreach((array)$data as $key => $value){
|
|
|
|
if($key == 'created'){
|
|
continue;
|
|
}
|
|
|
|
if(!is_array($value)){
|
|
if($this->exists($key)){
|
|
$this->$key = $value;
|
|
}
|
|
}else{
|
|
// special array data
|
|
if($key == 'scope'){
|
|
$this->scopeId = (int)$value['id'];
|
|
}elseif($key == 'type'){
|
|
$this->typeId = (int)$value['id'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* get map data
|
|
* -> this includes system and connection data as well!
|
|
* @return \stdClass
|
|
*/
|
|
public function getData(){
|
|
// check if there is cached data
|
|
$mapDataAll = $this->getCacheData();
|
|
|
|
if(is_null($mapDataAll)){
|
|
// no cached map data found
|
|
|
|
$mapData = (object) [];
|
|
$mapData->id = $this->id;
|
|
$mapData->name = $this->name;
|
|
$mapData->icon = $this->icon;
|
|
$mapData->created = strtotime($this->created);
|
|
$mapData->updated = strtotime($this->updated);
|
|
|
|
// map scope
|
|
$mapData->scope = (object) [];
|
|
$mapData->scope->id = $this->scopeId->id;
|
|
$mapData->scope->name = $this->scopeId->name;
|
|
$mapData->scope->label = $this->scopeId->label;
|
|
|
|
// map type
|
|
$mapData->type = (object) [];
|
|
$mapData->type->id = $this->typeId->id;
|
|
$mapData->type->name = $this->typeId->name;
|
|
$mapData->type->classTab = $this->typeId->classTab;
|
|
|
|
// map access
|
|
$mapData->access = (object) [];
|
|
$mapData->access->user = [];
|
|
$mapData->access->corporation = [];
|
|
$mapData->access->alliance = [];
|
|
|
|
// get access object data -------------------------------------
|
|
if($this->isPrivate()){
|
|
$characters = $this->getCharacters();
|
|
$characterData = [];
|
|
foreach($characters as $character){
|
|
/**
|
|
* @var $character CharacterModel
|
|
*/
|
|
$characterData[] = $character->getData();
|
|
}
|
|
$mapData->access->character = $characterData;
|
|
} elseif($this->isCorporation()){
|
|
$corporations = $this->getCorporations();
|
|
$corporationData = [];
|
|
|
|
foreach($corporations as $corporation){
|
|
/**
|
|
* @var $corporation CorporationModel
|
|
*/
|
|
$corporationData[] = $corporation->getData();
|
|
}
|
|
$mapData->access->corporation = $corporationData;
|
|
} elseif($this->isAlliance()){
|
|
$alliances = $this->getAlliances();
|
|
$allianceData = [];
|
|
|
|
foreach($alliances as $alliance){
|
|
/**
|
|
* @var $alliance AllianceModel
|
|
*/
|
|
$allianceData[] = $alliance->getData();
|
|
}
|
|
$mapData->access->alliance = $allianceData;
|
|
}
|
|
|
|
// merge all data ---------------------------------------------
|
|
$mapDataAll = (object) [];
|
|
$mapDataAll->mapData = $mapData;
|
|
|
|
// map system data --------------------------------------------
|
|
$mapDataAll->systems = $this->getSystemData();
|
|
|
|
// map connection data ----------------------------------------
|
|
$mapDataAll->connections = $this->getConnectionData();
|
|
|
|
// max caching time for a map
|
|
// the cached date has to be cleared manually on any change
|
|
// this includes system, connection,... changes (all dependencies)
|
|
$this->updateCacheData($mapDataAll, '', 300);
|
|
}
|
|
|
|
return $mapDataAll;
|
|
}
|
|
|
|
/**
|
|
* search for a system by CCPs systemId
|
|
* @param int $systemId
|
|
* @return null|SystemModel
|
|
*/
|
|
public function getSystemByCCPId($systemId){
|
|
$system = null;
|
|
if( !empty($systems = $this->getSystems('systemId', (int)$systemId) ) ){
|
|
$system = $systems[0];
|
|
}
|
|
|
|
return $system;
|
|
}
|
|
|
|
/**
|
|
* search for a system by id
|
|
* @param int $systemId
|
|
* @return null|SystemModel
|
|
*/
|
|
public function getSystemById($systemId){
|
|
$system = null;
|
|
if( !empty($systems = $this->getSystems('id', (int)$systemId) ) ){
|
|
$system = $systems[0];
|
|
}
|
|
|
|
return $system;
|
|
}
|
|
|
|
/**
|
|
* get either all system models in this map
|
|
* -> or get a specific system by column filter
|
|
* @param string $column
|
|
* @param string $value
|
|
* @return array|mixed
|
|
*/
|
|
public function getSystems($column = '', $value = ''){
|
|
$systems = [];
|
|
|
|
$filterQuery = ['active = :active AND id > 0',
|
|
':active' => 1
|
|
];
|
|
|
|
// add more filter options....
|
|
if(
|
|
!empty($column) &&
|
|
!empty($value)
|
|
){
|
|
$filterQuery[0] .= ' AND ' . $column . ' = :value';
|
|
$filterQuery[':value'] = $value;
|
|
}
|
|
|
|
// orderBy x-Coordinate for smoother frontend animation (left to right)
|
|
$this->filter('systems', $filterQuery,
|
|
['order' => 'posX']
|
|
);
|
|
|
|
if($this->systems){
|
|
$systems = $this->systems;
|
|
}
|
|
|
|
return $systems;
|
|
}
|
|
|
|
/**
|
|
* get all system data for all systems in this map
|
|
* @return array
|
|
*/
|
|
public function getSystemData(){
|
|
|
|
$systems = $this->getSystems();
|
|
|
|
$systemData = [];
|
|
foreach($systems as $system){
|
|
/**
|
|
* @var $system SystemModel
|
|
*/
|
|
$systemData[] = $system->getData();
|
|
}
|
|
|
|
return $systemData;
|
|
}
|
|
|
|
/**
|
|
* get all connections in this map
|
|
* @return array|mixed
|
|
*/
|
|
public function getConnections(){
|
|
$this->filter('connections', [
|
|
'active = :active AND source > 0 AND target > 0',
|
|
':active' => 1
|
|
]);
|
|
|
|
$connections = [];
|
|
if($this->connections){
|
|
$connections = $this->connections;
|
|
}
|
|
|
|
return $connections;
|
|
}
|
|
|
|
/**
|
|
* get all connection data in this map
|
|
* @return array
|
|
*/
|
|
public function getConnectionData(){
|
|
$connections = $this->getConnections();
|
|
|
|
$connectionData = [];
|
|
foreach($connections as $connection){
|
|
/**
|
|
* @var $connection ConnectionModel
|
|
*/
|
|
$connectionData[] = $connection->getData();
|
|
}
|
|
|
|
return $connectionData;
|
|
}
|
|
|
|
/**
|
|
* set map access for an object (character, corporation or alliance)
|
|
* @param $obj
|
|
*/
|
|
public function setAccess($obj){
|
|
|
|
$newAccessGranted = false;
|
|
|
|
if($obj instanceof CharacterModel){
|
|
// private map
|
|
|
|
// check whether the user has already map access
|
|
$this->has('mapCharacters', ['active = 1 AND characterId = :characterId', ':characterId' => $obj->id]);
|
|
$result = $this->findone(['id = :id', ':id' => $this->id]);
|
|
|
|
if($result === false){
|
|
// grant access for the character
|
|
$characterMap = self::getNew('CharacterMapModel');
|
|
$characterMap-> characterId = $obj;
|
|
$characterMap->mapId = $this;
|
|
$characterMap->save();
|
|
|
|
$newAccessGranted = true;
|
|
}
|
|
} elseif($obj instanceof CorporationModel){
|
|
|
|
// check whether the corporation already has map access
|
|
$this->has('mapCorporations', ['active = 1 AND corporationId = :corporationId', ':corporationId' => $obj->id]);
|
|
$result = $this->findone(['id = :id', ':id' => $this->id]);
|
|
|
|
if($result === false){
|
|
// grant access for this corporation
|
|
$corporationMap = self::getNew('CorporationMapModel');
|
|
$corporationMap->corporationId = $obj;
|
|
$corporationMap->mapId = $this;
|
|
$corporationMap->save();
|
|
|
|
$newAccessGranted = true;
|
|
}
|
|
} elseif($obj instanceof AllianceModel){
|
|
|
|
// check whether the corporation already has map access
|
|
$this->has('mapAlliances', ['active = 1 AND allianceId = :allianceId', ':allianceId' => $obj->id]);
|
|
$result = $this->findone(['id = :id', ':id' => $this->id]);
|
|
|
|
if($result === false){
|
|
$allianceMap = self::getNew('AllianceMapModel');
|
|
$allianceMap->allianceId = $obj;
|
|
$allianceMap->mapId = $this;
|
|
$allianceMap->save();
|
|
|
|
$newAccessGranted = true;
|
|
}
|
|
}
|
|
|
|
if($newAccessGranted){
|
|
// mark this map as updated
|
|
$this->setUpdated();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* clear access for a given type of objects
|
|
* @param array $clearKeys
|
|
*/
|
|
public function clearAccess($clearKeys = ['character', 'corporation', 'alliance']){
|
|
|
|
foreach($clearKeys as $key){
|
|
switch($key){
|
|
case 'character':
|
|
foreach((array)$this->mapCharacters as $characterMapModel){
|
|
/**
|
|
* @var CharacterMapModel $characterMapModel
|
|
*/
|
|
$characterMapModel->erase();
|
|
};
|
|
break;
|
|
case 'corporation':
|
|
foreach((array)$this->mapCorporations as $corporationMapModel){
|
|
/**
|
|
* @var CorporationMapModel $corporationMapModel
|
|
*/
|
|
$corporationMapModel->erase();
|
|
};
|
|
break;
|
|
case 'alliance':
|
|
foreach((array)$this->mapAlliances as $allianceMapModel){
|
|
/**
|
|
* @var AllianceMapModel $allianceMapModel
|
|
*/
|
|
$allianceMapModel->erase();
|
|
};
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* checks weather a character has access to this map or not
|
|
* @param CharacterModel $characterModel
|
|
* @return bool
|
|
*/
|
|
public function hasAccess(CharacterModel $characterModel){
|
|
$hasAccess = false;
|
|
|
|
if( !$this->dry() ){
|
|
// get all maps the user has access to
|
|
// this includes corporation and alliance maps
|
|
$maps = $characterModel->getMaps();
|
|
foreach($maps as $map){
|
|
if($map->id === $this->id){
|
|
$hasAccess = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $hasAccess;
|
|
}
|
|
|
|
/**
|
|
* get all (private) characters for this map
|
|
* @return CharacterModel array
|
|
*/
|
|
private function getCharacters(){
|
|
$characters = [];
|
|
|
|
$this->filter('mapCharacters', ['active = ?', 1]);
|
|
|
|
if($this->mapCharacters){
|
|
foreach($this->mapCharacters as $characterMapModel){
|
|
$characters[] = $characterMapModel->characterId;
|
|
}
|
|
}
|
|
|
|
return $characters;
|
|
}
|
|
|
|
/**
|
|
* get all character models that are currently online "viewing" this map
|
|
* @return CharacterModel[]
|
|
*/
|
|
private function getActiveCharacters(){
|
|
$characters = [];
|
|
|
|
if($this->isPrivate()){
|
|
$activeCharacters = $this->getCharacters();
|
|
|
|
// add active character for each user
|
|
foreach($activeCharacters as $activeCharacter){
|
|
/**
|
|
* @var UserModel $user
|
|
*/
|
|
$characters[] = $activeCharacter;
|
|
}
|
|
}elseif($this->isCorporation()){
|
|
$corporations = $this->getCorporations();
|
|
|
|
foreach($corporations as $corporation){
|
|
/**
|
|
* @var CorporationModel $corporation
|
|
*/
|
|
$characters = array_merge($characters, $corporation->getCharacters());
|
|
}
|
|
}elseif($this->isAlliance()){
|
|
$alliances = $this->getAlliances();
|
|
|
|
foreach($alliances as $alliance){
|
|
/**
|
|
* @var AllianceModel $alliance
|
|
*/
|
|
$characters = array_merge($characters, $alliance->getCharacters());
|
|
}
|
|
}
|
|
|
|
return $characters;
|
|
}
|
|
|
|
/**
|
|
* get data for all characters that are currently online "viewing" this map
|
|
* -> the result of this function is cached!
|
|
* @return array
|
|
*/
|
|
private function getCharactersData(){
|
|
|
|
// check if there is cached data
|
|
$charactersData = $this->getCacheData('CHARACTERS');
|
|
|
|
if(is_null($charactersData)){
|
|
$charactersData = [];
|
|
$characters = $this->getActiveCharacters();
|
|
|
|
foreach($characters as $character){
|
|
$charactersData[] = $character->getData(true);
|
|
}
|
|
|
|
// cache active characters (if found)
|
|
if(!empty($charactersData)){
|
|
$this->updateCacheData($charactersData, 'CHARACTERS', 5);
|
|
}
|
|
}
|
|
|
|
return $charactersData;
|
|
}
|
|
|
|
/**
|
|
* get all corporations that have access to this map
|
|
* @return array
|
|
*/
|
|
public function getCorporations(){
|
|
$corporations = [];
|
|
|
|
if($this->isCorporation()){
|
|
$this->filter('mapCorporations', ['active = ?', 1]);
|
|
|
|
if($this->mapCorporations){
|
|
foreach($this->mapCorporations as $mapCorporation){
|
|
$corporations[] = $mapCorporation->corporationId;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $corporations;
|
|
}
|
|
|
|
/**
|
|
* get all alliances that have access to this map
|
|
* @return array
|
|
*/
|
|
public function getAlliances(){
|
|
$alliances = [];
|
|
|
|
if($this->isAlliance()){
|
|
$this->filter('mapAlliances', ['active = ?', 1]);
|
|
|
|
if($this->mapAlliances){
|
|
foreach($this->mapAlliances as $mapAlliance){
|
|
$alliances[] = $mapAlliance->allianceId;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $alliances;
|
|
}
|
|
|
|
/**
|
|
* delete this map and all dependencies
|
|
* @param CharacterModel $characterModel
|
|
*/
|
|
public function delete(CharacterModel $characterModel){
|
|
if( !$this->dry() ){
|
|
// check if character has access
|
|
if($this->hasAccess($characterModel)){
|
|
// all map related tables will be deleted on cascade
|
|
$this->erase();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* checks weather this map is private map
|
|
* @return bool
|
|
*/
|
|
public function isPrivate(){
|
|
$isPrivate = false;
|
|
|
|
if($this->typeId->id == 2){
|
|
$isPrivate = true;
|
|
}
|
|
|
|
return $isPrivate;
|
|
}
|
|
|
|
/**
|
|
* checks weather this map is corporation map
|
|
* @return bool
|
|
*/
|
|
public function isCorporation(){
|
|
$isCorporation = false;
|
|
|
|
if($this->typeId->id == 3){
|
|
$isCorporation = true;
|
|
}
|
|
|
|
return $isCorporation;
|
|
}
|
|
|
|
/**
|
|
* checks weather this map is alliance map
|
|
* @return bool
|
|
*/
|
|
public function isAlliance(){
|
|
$isAlliance = false;
|
|
|
|
if($this->typeId->id == 4){
|
|
$isAlliance = true;
|
|
}
|
|
|
|
return $isAlliance;
|
|
}
|
|
|
|
/**
|
|
* get all active characters (with active log)
|
|
* grouped by systems
|
|
* @return object
|
|
*/
|
|
public function getUserData(){
|
|
|
|
// get systems for this map
|
|
// the getData() function is cached. So this is more suitable than getSystems();
|
|
$mapDataAll = $this->getData();
|
|
|
|
// get data of characters which have with map access
|
|
$activeUserCharactersData = $this->getCharactersData();
|
|
|
|
$mapUserData = (object)[];
|
|
$mapUserData->config = (object)[];
|
|
$mapUserData->config->id = $this->id;
|
|
$mapUserData->data = (object)[];
|
|
$mapUserData->data->systems = [];
|
|
foreach($mapDataAll->systems as $systemData){
|
|
$systemUserData = (object)[];
|
|
$systemUserData->id = $systemData->systemId;
|
|
$systemUserData->user = [];
|
|
|
|
// check if a system has active characters
|
|
foreach($activeUserCharactersData as $key => $activeUserCharacterData){
|
|
|
|
if(isset($activeUserCharacterData->log)){
|
|
// user as log data
|
|
if($activeUserCharacterData->log->system->id == $systemData->systemId){
|
|
$systemUserData->user[] = $activeUserCharacterData;
|
|
|
|
// remove user from array -> speed up looping over characters.
|
|
// each userCharacter can only be active in a SINGLE system
|
|
unset($activeUserCharactersData[$key]);
|
|
}
|
|
}else{
|
|
// user has NO log data. If its an corp/ally map not each member is active
|
|
// user is not relevant for this function!
|
|
unset($activeUserCharactersData[$key]);
|
|
}
|
|
}
|
|
|
|
// add system if active users were found
|
|
if(count($systemUserData->user) > 0){
|
|
$mapUserData->data->systems[] = $systemUserData;
|
|
}
|
|
}
|
|
|
|
return $mapUserData;
|
|
}
|
|
|
|
/**
|
|
* save a map
|
|
* @return mixed
|
|
*/
|
|
public function save(){
|
|
|
|
$mapModel = parent::save();
|
|
|
|
// check if map type has changed and clear access objects
|
|
if( !$mapModel->dry() ){
|
|
if( $mapModel->isPrivate() ){
|
|
$mapModel->clearAccess(['corporation', 'alliance']);
|
|
}elseif( $mapModel->isCorporation() ){
|
|
$mapModel->clearAccess(['character', 'alliance']);
|
|
}elseif( $mapModel->isAlliance() ){
|
|
$mapModel->clearAccess(['character', 'corporation']);
|
|
}
|
|
}
|
|
|
|
return $mapModel;
|
|
}
|
|
|
|
}
|