Files
pathfinder/app/main/model/alliancemodel.php
Exodus4D a8edf39697 - new "logging" system for map/system/signature/connection changes, closed #271
- new map change log to Slack channel
- new "rally point" logging to Slack channel
- new "rally point" poke options (e.g. custom message), closed #295
- new log options for WebSocket installations
- added ship "mass" logging (backend only), #313
- added map logging to Slack, #326
- added "ESI error rate" limit detection
- added "Monolog" as new logging library (Composer dependency)
- added "Swiftmailer" as new eMail library (Composer dependency)
- added Support for Redis session hander (performance boost)
- improved character select panels (visible "online" status)
- improved "activity logging" (more DB columns added to check)
- improved eMail logging (HTML template support)
- improved "delete map" now become "inactive" for some days before delete
- improved character logout handling
- improved /setup page for DB bootstrap (new button for DB create if not exists)
- fixed broken ship tracking (ship name re-added)
- fixed broken ship tracking for multiple chars on different browser tabs
- fixed broken cursor coordinates, closed #518
- fixed null pointer "charactermodel.php->isActive():925" closed #529
- fixed broken "scroll offset", closed #533 closed #534
- Updated "validation" library JS v0.10.1 -> v0.11.9
- Updated ORM Mapper _Cortex_ v1.5.0-dev -> v1.5.0
- and many more....
2017-10-22 17:58:34 +02:00

116 lines
2.7 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: exodus4d
* Date: 17.05.15
* Time: 20:43
*/
namespace Model;
use DB\SQL\Schema;
use lib\Config;
class AllianceModel extends BasicModel {
protected $table = 'alliance';
protected $fieldConf = [
'active' => [
'type' => Schema::DT_BOOL,
'nullable' => false,
'default' => 1,
'index' => true
],
'name' => [
'type' => Schema::DT_VARCHAR128,
'nullable' => false,
'default' => ''
],
'shared' => [
'type' => Schema::DT_BOOL,
'nullable' => false,
'default' => 0
],
'allianceCharacters' => [
'has-many' => ['Model\CharacterModel', 'allianceId']
],
'mapAlliances' => [
'has-many' => ['Model\AllianceMapModel', 'allianceId']
]
];
/**
* get all alliance data
* @return \stdClass
*/
public function getData(){
$allianceData = (object) [];
$allianceData->id = $this->id;
$allianceData->name = $this->name;
$allianceData->shared = $this->shared;
return $allianceData;
}
/**
* get all maps for this alliance
* @return array|mixed
*/
public function getMaps(){
$maps = [];
$this->filter('mapAlliances',
['active = ?', 1],
['order' => 'created']
);
if($this->mapAlliances){
$mapCount = 0;
foreach($this->mapAlliances as $mapAlliance){
if(
$mapAlliance->mapId->isActive() &&
$mapCount < Config::getMapsDefaultConfig('alliance')['max_count']
){
$maps[] = $mapAlliance->mapId;
$mapCount++;
}
}
}
return $maps;
}
/**
* get all characters in this alliance
* @param array $characterIds
* @param array $options
* @return array
*/
public function getCharacters($characterIds = [], $options = []){
$characters = [];
$filter = ['active = ?', 1];
if( !empty($characterIds) ){
$filter[0] .= ' AND id IN (?)';
$filter[] = $characterIds;
}
$this->filter('allianceCharacters', $filter);
if($options['hasLog']){
// just characters with active log data
$this->has('allianceCharacters.characterLog', ['active = ?', 1]);
}
if($this->allianceCharacters){
foreach($this->allianceCharacters as $character){
$characters[] = $character;
}
}
return $characters;
}
}