Files
pathfinder/app/Controller/Api/System.php
Mark Friedrich 0c3d57e833 - BC Break: Required _PHP_ version changed >=7.1>=7.2
- NEW "plugin API" for custom UI modules, closed #913
- NEW live "Killstream" for killboard module, closed #909
- NEW "custom layout" UI settings, closed #470
2020-02-01 12:40:17 +01:00

95 lines
2.8 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: exodus4d
* Date: 08.02.15
* Time: 20:23
*/
namespace Exodus4D\Pathfinder\Controller\Api;
use Exodus4D\Pathfinder\Lib\Config;
use Exodus4D\Pathfinder\Controller;
use Exodus4D\Pathfinder\Model\Pathfinder;
class System extends Controller\AccessController {
/**
* set destination for system, station or structure
* @param \Base $f3
* @throws \Exception
*/
public function setDestination(\Base $f3){
$postData = (array)$f3->get('POST');
$return = (object) [];
$return->error = [];
$return->destData = [];
if(!empty($destData = (array)$postData['destData'])){
$activeCharacter = $this->getCharacter();
$return->clearOtherWaypoints = (bool)$postData['clearOtherWaypoints'];
$return->first = (bool)$postData['first'];
if($accessToken = $activeCharacter->getAccessToken()){
$options = [
'clearOtherWaypoints' => $return->clearOtherWaypoints,
'addToBeginning' => $return->first,
];
foreach($destData as $data){
$response = $f3->ccpClient()->setWaypoint((int)$data['id'], $accessToken, $options);
if(empty($response)){
$return->destData[] = $data;
}else{
$error = (object) [];
$error->type = 'error';
$error->message = $response['error'];
$return->error[] = $error;
}
}
}
}
echo json_encode($return);
}
/**
* send Rally Point poke
* @param \Base $f3
* @throws \Exception
*/
public function pokeRally(\Base $f3){
$rallyData = (array)$f3->get('POST');
$systemId = (int)$rallyData['systemId'];
$return = (object) [];
if($systemId){
$activeCharacter = $this->getCharacter();
/**
* @var $system Pathfinder\SystemModel
*/
$system = Pathfinder\AbstractPathfinderModel::getNew('SystemModel');
$system->getById($systemId);
if($system->hasAccess($activeCharacter)){
$rallyData['pokeDesktop'] = $rallyData['pokeDesktop'] === '1';
$rallyData['pokeMail'] = $rallyData['pokeMail'] === '1';
$rallyData['pokeSlack'] = $rallyData['pokeSlack'] === '1';
$rallyData['pokeDiscord'] = $rallyData['pokeDiscord'] === '1';
$rallyData['message'] = trim($rallyData['message']);
$system->sendRallyPoke($rallyData, $activeCharacter);
}
}
echo json_encode($return);
}
}