Skip to content

Commit

Permalink
Merge pull request #6 from eve-seat/dev
Browse files Browse the repository at this point in the history
Merge v0.3 into master
  • Loading branch information
eve-seat committed Apr 17, 2014
2 parents 2f0cc6f + dabaa58 commit 0c7fd60
Show file tree
Hide file tree
Showing 15 changed files with 677 additions and 15 deletions.
117 changes: 117 additions & 0 deletions app/commands/SeatAddKey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?php

namespace Seat\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

use Pheal\Pheal;
use Seat\EveApi;
use Seat\EveApi\BaseApi;
use Seat\EveApi\Account;

class SeatAddKey extends Command {

/**
* The console command name.
*
* @var string
*/
protected $name = 'seat:add-key';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Adds a API Key to SeAT.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$keyID = $this->argument('keyID');
$vCode = $this->argument('vCode');

EveApi\BaseApi::validateKeyPair($keyID, $vCode);

$this->info('The key pair appear to be valid.');
$this->line('Checking if key exists in the database...');

if (!\SeatKey::where('keyID', $keyID)->first()) {

$this->info('keyID is not present in the database. Making the APIKeyInfo API call...');

// Setup a pheal instance and get some API data :D
BaseApi::bootstrap();
$pheal = new Pheal($keyID, $vCode);

// Get API Key Information
try {
$key_info = $pheal->accountScope->APIKeyInfo();

} catch (\Pheal\Exceptions\PhealException $e) {

$this->error('Unable to retreive key information. The erorr was: ' . $e->getCode() . ': ' . $e->getMessage());
return;
}

// Print some information about the key
$this->line('Key Type: ' . $key_info->key->type);
$this->line('Key Access Mask: ' . $key_info->key->accessMask);
$this->info('Characters on key: ');
foreach ($key_info->key->characters as $character)
$this->line(' - ' . $character->characterName . ' in corporation ' . $character->corporationName);

// Confirm adding the key
if ($this->confirm('Do you wish to add this key to the database? [yes|no]')) {

$key_info = new \SeatKey;

$key_info->keyID = $keyID;
$key_info->vCode = $vCode;
$key_info->isOk = 1;
$key_info->lastError = null;
$key_info->deleted_at = null;
$key_info->user_id = 1; // TODO: Fix this when the proper user management occurs
$key_info->save();

$this->info('Successfully saved the API key to the database.');
}


} else {

$this->error('keyID ' . $keyID . ' already exists in the database.');
}

}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return array(
array('keyID', InputArgument::REQUIRED, 'The keyID.'),
array('vCode', InputArgument::REQUIRED, 'The vCode.'),
);
}

}
2 changes: 1 addition & 1 deletion app/commands/scheduled/EveCorporationAssetsUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct()
*/
public function schedule(Schedulable $scheduler)
{
return $scheduler->setSchedule('*', '*/8', '*', '*', '*');
return $scheduler->setSchedule('0', '*/8', '*', '*', '*');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/config/seat.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
|
*/

'version' => '0.2',
'version' => '0.3',

);
22 changes: 19 additions & 3 deletions app/controllers/ApiKeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,38 @@ public function postNewKey()
$key_info = $pheal->accountScope->APIKeyInfo();

} catch (\Pheal\Exceptions\PhealException $e) {
$key_info = array('error' => $e->getCode() . ': ' . $e->getMessage());

return View::make('keys.ajax.errors')
->withErrors(array('error' => $e->getCode() . ': ' . $e->getMessage()));
}

// Here, based on the type of key, we will either call some further information,
// or just display what we have learned so far.
if ($key_info->key->type == 'Corporation') {

// Just return the view for corporation keys
return View::make('keys.ajax.corporation')
->with('keyID', Input::get('keyID'))
->with('vCode', Input::get('vCode'))
->with('key_info', $key_info)
->with('existance', SeatKey::where('keyID', Input::get('keyID'))->count());
}

// Get API Account Status Information
try {
$status_info = $pheal->accountScope->AccountStatus();

} catch (\Pheal\Exceptions\PhealException $e) {
$status_info = array('error' => $e->getCode() . ': ' . $e->getMessage());

return View::make('keys.ajax.errors')
->withErrors(array('error' => $e->getCode() . ': ' . $e->getMessage()));
}

// TODO: Think about adding a entry to the cache to mark a particular key as
// valid

// Return the view
return View::make('keys.ajax.check')
return View::make('keys.ajax.character')
->with('keyID', Input::get('keyID'))
->with('vCode', Input::get('vCode'))
->with('key_info', $key_info)
Expand Down
110 changes: 110 additions & 0 deletions app/controllers/CharacterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,116 @@ public function getView($characterID)
->with('assets', $assets);
}

/*
|--------------------------------------------------------------------------
| getSearchSkills()
|--------------------------------------------------------------------------
|
| Return a view to search character skills
|
*/

public function getSearchSkills()
{

return View::make('character.skillsearch.search');
}

/*
|--------------------------------------------------------------------------
| postSearchSkills()
|--------------------------------------------------------------------------
|
| Search for characters that have certain skills injected & their leverls
|
*/

public function postSearchSkills()
{

// Ensure we actually got an array...
if (!is_array(Input::get('skills')))
App::abort(404);

$filter = DB::table('character_charactersheet_skills')
->join('account_apikeyinfo_characters', 'character_charactersheet_skills.characterID', '=', 'account_apikeyinfo_characters.characterID')
->join('invTypes', 'character_charactersheet_skills.typeID', '=', 'invTypes.typeID')
->whereIn('character_charactersheet_skills.typeID', array_values(Input::get('skills')))
->orderBy('invTypes.typeName')
->get();

return View::make('character.skillsearch.ajax.result')
->with('filter', $filter);
}

/*
|--------------------------------------------------------------------------
| getSearchAssets()
|--------------------------------------------------------------------------
|
| Return a view to search character assets
|
*/

public function getSearchAssets()
{

return View::make('character.assetsearch.search');
}

/*
|--------------------------------------------------------------------------
| postSearchAssets()
|--------------------------------------------------------------------------
|
| Search for characters that have certain assets
|
*/

public function postSearchAssets()
{

if (!is_array(Input::get('items')))
App::abort(404);

// Seriously need to fix up this shit SQL, but not sure how to get this
// into Fluent correctly yet...

// Create a parameter list for use in our query
$plist = ':id_'.implode(',:id_', array_keys(Input::get('items')));
// Prepare the arguement list for the parameters list
$parms = array_combine(explode(",", $plist), Input::get('items'));

$assets = DB::select(
"SELECT *, CASE
when a.locationID BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=a.locationID-6000001)
when a.locationID BETWEEN 66014934 AND 67999999 then
(SELECT c.stationName FROM `eve_conquerablestationlist` AS c
WHERE c.stationID=a.locationID-6000000)
when a.locationID BETWEEN 60014861 AND 60014928 then
(SELECT c.stationName FROM `eve_conquerablestationlist` AS c
WHERE c.stationID=a.locationID)
when a.locationID BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=a.locationID)
when a.locationID>=61000000 then
(SELECT c.stationName FROM `eve_conquerablestationlist` AS c
WHERE c.stationID=a.locationID)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID=a.locationID) end
AS location,a.locationId AS locID FROM `character_assetlist` AS a
LEFT JOIN `invTypes` ON a.`typeID` = `invTypes`.`typeID`
JOIN `account_apikeyinfo_characters` on `account_apikeyinfo_characters`.`characterID` = a.`characterID`
WHERE `invTypes`.`typeID` IN ( $plist ) ORDER BY location",
$parms
);

return View::make('character.assetsearch.ajax.result')
->with('assets', $assets);
}

/*
|--------------------------------------------------------------------------
| getWalletDelta()
Expand Down
54 changes: 53 additions & 1 deletion app/controllers/HelperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,56 @@ public function postResolveNames()
// With all the work out of the way, return the $return array as Json
return Response::json($return);
}
}

/*
|--------------------------------------------------------------------------
| getAvailableSkills()
|--------------------------------------------------------------------------
|
| Return the currently available skills as a json object
|
*/

public function getAvailableSkills()
{

// Get the skills from the database
$skills = DB::table('invTypes')
->select(DB::raw('typeId as id'), DB::raw('typeName as text'))
->whereIn('groupID', function($groupQuery) {

$groupQuery->select('groupID')
->from('invGroups')
->whereIn('categoryID', function($categoryQuery) {

$categoryQuery->select('categoryID')
->from('invCategories')
->where('categoryName', 'skill');
});
})
->orderBy('typeName', 'asc')
->get();

return Response::json($skills);
}

/*
|--------------------------------------------------------------------------
| getAvailableSkills()
|--------------------------------------------------------------------------
|
| Return the currently available skills as a json object
|
*/

public function getAvailableItems()
{

$items = DB::table('invTypes')
->select(DB::raw('typeID as id'), DB::raw('typeName as text'))
->where('typeName', 'like', '%' . Input::get('q') . '%')
->get();

return Response::json($items);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class Fix5CorporationSheetOptionalAlliance extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::unprepared("ALTER TABLE `corporation_corporationsheet` CHANGE `allianceName` `allianceName` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT ''");
DB::unprepared("ALTER TABLE `corporation_corporationsheet` CHANGE `allianceID` `allianceID` INT(11) NULL");
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::unprepared("ALTER TABLE `corporation_corporationsheet` CHANGE `allianceName` `allianceName` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''");
DB::unprepared("ALTER TABLE `corporation_corporationsheet` CHANGE `allianceID` `allianceID` INT(11) NOT NULL");
}

}
1 change: 1 addition & 0 deletions app/start/artisan.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Artisan::add(new \Seat\Commands\SeatAPIFindNameByKey);
Artisan::add(new \Seat\Commands\SeatAPIFindSickKeys);
Artisan::add(new \Seat\Commands\SeatAPIDeleteKey);
Artisan::add(new \Seat\Commands\SeatAddKey);

// Scheduled SeAT Commands
Artisan::add(new \Seat\Commands\Scheduled\EveCharacterUpdater);
Expand Down
Loading

0 comments on commit 0c7fd60

Please sign in to comment.