map info module improvements, new system graph module, map info module refactoring, new CCP API Cronjob (jumps, kills,...)
This commit is contained in:
@@ -12,6 +12,8 @@ namespace Model;
|
||||
class ConnectionModel extends BasicModel{
|
||||
|
||||
protected $table = 'connection';
|
||||
protected $ttl = 5;
|
||||
protected $rel_ttl = 5;
|
||||
|
||||
protected $fieldConf = array(
|
||||
'mapId' => array(
|
||||
@@ -33,6 +35,13 @@ class ConnectionModel extends BasicModel{
|
||||
if(!is_array($value)){
|
||||
if($this->exists($key)){
|
||||
$this->$key = $value;
|
||||
|
||||
if($key == 'source'){
|
||||
// set mapId
|
||||
$sourceSystem = self::getNew('SystemModel');
|
||||
$sourceSystem->getById( $this->$key );
|
||||
$this->mapId = $sourceSystem->mapId;
|
||||
}
|
||||
}
|
||||
}elseif($key == 'type'){
|
||||
// json field
|
||||
@@ -41,6 +50,10 @@ class ConnectionModel extends BasicModel{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get connection data as array
|
||||
* @return array
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
$connectionData = [
|
||||
@@ -55,4 +68,52 @@ class ConnectionModel extends BasicModel{
|
||||
return $connectionData;
|
||||
}
|
||||
|
||||
/**
|
||||
* check object for model access
|
||||
* @param $accessObject
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess($accessObject){
|
||||
return $this->mapId->hasAccess($accessObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* check weather this model is valid or not
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(){
|
||||
|
||||
$isValid = true;
|
||||
// check if source/target belong to same map
|
||||
$sourceSystem = self::getNew('SystemModel');
|
||||
$sourceSystem->getById( $this->source );
|
||||
|
||||
$targetSystem = self::getNew('SystemModel');
|
||||
$targetSystem->getById( $this->target);
|
||||
|
||||
if(
|
||||
$sourceSystem->dry() ||
|
||||
$targetSystem->dry() ||
|
||||
$sourceSystem->mapId->id !== $targetSystem->mapId->id
|
||||
){
|
||||
$isValid = false;
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a connection
|
||||
* @param $accessObject
|
||||
*/
|
||||
public function delete($accessObject){
|
||||
|
||||
if(!$this->dry()){
|
||||
// check if editor has access
|
||||
if($this->hasAccess($accessObject)){
|
||||
$this->erase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user