blacklist added to services site

This commit is contained in:
2019-10-28 05:20:05 -05:00
parent a9105b05eb
commit 4e2ff481f5
10 changed files with 260 additions and 3 deletions

View File

@@ -20,6 +20,12 @@ use App\Models\User\UserPermission;
use App\Models\User\UserRole;
use App\Models\Admin\AllowedLogin;
/**
* The PurgeUsers command takes care of updating any user changes in terms of login role, as well as purging any users without at least
* the 'User' role. This command heavily relies on ESI being available. If no ESI is available, then the function does nothing, in order to prevent
* unwanted changes.
*/
class PurgeUsers extends Command
{
/**

View File

@@ -0,0 +1,122 @@
<?php
namespace App\Http\Controllers;
//Internal Library
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Log;
//Library
use App\Library\Lookups\NewLookupHelper;
//Models
use App\Models\Character\BlacklistUser;
class BlacklistController extends Controller
{
public function __construct() {
$this->middleware('auth');
$this->middleware('role:User');
}
public function AddToBlacklist(Request $request) {
//Middleware needed for the function
$this->middleware('permission:alliance.recruiter');
//Validate the user input
$this->validate($request, [
'name' => 'required',
'reason' => 'required',
]);
//Create the library variable
$lookup = new NewLookupHelper;
//See if the character is already on the list
$count = BlacklistUser::where([
'name' => $request->name,
])->count();
//If the count is 0, then add the character to the blacklist
if($count === 0) {
//Get the character id from the universe end point
$charId = $lookup->CharacterNameToId($request->name);
//Insert the character into the blacklist table
BlacklistUser::insert([
'character_id' => $charId,
'name' => $request->name,
'reason' => $request->reason,
]);
} else {
//Return the view
return view('blacklist.add')->with('error', 'Character is already on the black list.');
}
//Return the view
return view('blacklist.list')->with('success', 'Character added to the blacklist');
}
public function RemoveFromBlacklist(Request $request) {
//Middleware needed
$this->middleware('permission:alliance.recruiter');
//Validate the input request
$this->validate($request, [
'name' => 'required',
]);
//Delete the blacklist character
BlacklistUser::where([
'name' => $request->name,
])->delete();
//Return the view
return view('blacklist.list')->with('success', 'Character removed from the blacklist.');
}
public function DisplayBlacklist() {
//Middleware needed
$this->middleware('permission:corp.recruiter');
//Get the entire blacklist
$blacklist = BlacklistUser::all();
//Return the view with the data
return view('blacklist.list')->with('blacklist', $blacklist);
}
public function SearchInBlacklist(Request $request) {
//Middleware needed
$this->middleware('permission:corp.recruiter');
//Validate the input from the form
$this->validate($request, [
'name' => 'required',
]);
//Get the data being requested
$blacklistCount = BlacklistUser::where([
'name' => $request->name,
])->count();
//If the count for the blacklist is greater than 0, then get the details, and send it to the view
if($blacklistCount > 0) {
//Try to find the user in the blacklist
$blacklist = BlacklistUser::where([
'name' => $request->name,
])->first();
//Send the data to the view
return view('blacklist.list')->with('blacklist', $blacklist)
->with('success', 'Name was found on the blacklist');
} else {
//If they aren't found, then null out the blacklist variable, and send to the view
$blacklist = null;
return view('blacklist.list')->with('blacklist', $blacklist)
->with('error', 'Name was not found on the blacklist.');
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Models\Character;
use Illuminate\Database\Eloquent\Model;
class BlacklistUser extends Model
{
//Table Name
public $table = 'blacklisted_characters';
//Timestamps
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'character_id',
'name',
'reason',
];
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBlacklistTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if(!Schema::hasTable('alliance_blacklist')) {
Schema::create('alliance_blacklist', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('character_id')->unique();
$table->string('name')->unique();
$table->text('reason');
$table->timestamps();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('alliance_blacklist');
}
}

View File

@@ -0,0 +1,16 @@
@extends('layouts.b4')
@section('content')
<div class="container">
{!! Form::open(['action' => 'Corps\BlacklistController@AddToBlacklist', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('name', 'Character Name') }}
{{ Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'CCP Antiquarian']) }}
</div>
<div class="form-group">
{{ Form::label('reason', 'Reason') }}
{{ Form::textarea('reason', '', ['class' => 'form-control', 'placeholder' => 'Just another antiquated dev.']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
@endsection

View File

@@ -0,0 +1,32 @@
@extends('layouts.b4')
@section('content')
<div class="container">
<div class="card">
<div class="card-header">
<h2>Alliance Blacklist</h2>
</div>
<div class="card-body">
@if($blacklist != null)
<table class="table table-bordered table-striped">
<thead>
<th>Character Id</th>
<th>Character Name</th>
<th>Reason</th>
</thead>
<tbody>
@foreach($blacklist as $bl)
<tr>
<td>{{ $bl->characer_id }}</td>
<td>{{ $bl->name }}</td>
<td>{{ $bl->reason }}</td>
</tr>
@endforeach
</tbody>
</table>
@else
<b><h3>No Characters Found</h3></b>
@endif
</div>
</div>
</div>
@endsection

View File

@@ -0,0 +1,12 @@
@extends('layouts.b4')
@section('content')
<div class="container">
{!! Form::open(['action' => 'Corps\BlacklistController@RemoveFromBlacklist', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('name', 'Character Name') }}
{{ Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'CCP Antiquarian']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
@endsection

View File

@@ -279,7 +279,7 @@ class ClassLoader
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
}
/**

View File

@@ -17,6 +17,7 @@ return array(
'App\\Console\\Commands\\HoldingFinancesCommand' => $baseDir . '/app/Console/Commands/Finances/HoldingFinances.php',
'App\\Console\\Commands\\MoonMailerCommand' => $baseDir . '/app/Console/Commands/Moons/MoonMailer.php',
'App\\Console\\Commands\\PiTransactionsCommand' => $baseDir . '/app/Console/Commands/Finances/PiTransactions.php',
'App\\Console\\Commands\\PurgeUsers' => $baseDir . '/app/Console/Commands/Users/PurgeUsers.php',
'App\\Console\\Commands\\UpdateMoonPriceCommand' => $baseDir . '/app/Console/Commands/Moons/UpdateMoonPricing.php',
'App\\Console\\Commands\\UpdateMoonRental' => $baseDir . '/app/Console/Commands/Moons/UpdateMoonRental.php',
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
@@ -24,6 +25,7 @@ return array(
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Auth\\EsiScopeController' => $baseDir . '/app/Http/Controllers/Auth/EsiScopeController.php',
'App\\Http\\Controllers\\Auth\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php',
'App\\Http\\Controllers\\BlacklistController' => $baseDir . '/app/Http/Controllers/Corps/BlacklistController.php',
'App\\Http\\Controllers\\Contracts\\ContractAdminController' => $baseDir . '/app/Http/Controllers/Contracts/ContractAdminController.php',
'App\\Http\\Controllers\\Contracts\\ContractController' => $baseDir . '/app/Http/Controllers/Contracts/ContractController.php',
'App\\Http\\Controllers\\Controller' => $baseDir . '/app/Http/Controllers/Controller.php',
@@ -32,7 +34,9 @@ return array(
'App\\Http\\Controllers\\Fuel\\FuelController' => $baseDir . '/app/Http/Controllers/Logistics/FuelController.php',
'App\\Http\\Controllers\\LiveSearch' => $baseDir . '/app/Http/Controllers/LiveSearch.php',
'App\\Http\\Controllers\\Logistics\\LogisticsController' => $baseDir . '/app/Http/Controllers/Logistics/LogisticsController.php',
'App\\Http\\Controllers\\Logistics\\StructureRequestController' => $baseDir . '/app/Http/Controllers/Logistics/StructureRequestController.php',
'App\\Http\\Controllers\\Market\\MarketController' => $baseDir . '/app/Http/Controllers/Market/MarketController.php',
'App\\Http\\Controllers\\Moons\\MoonLedgerController' => $baseDir . '/app/Http/Controllers/Moons/MoonLedgerController.php',
'App\\Http\\Controllers\\Moons\\MoonsAdminController' => $baseDir . '/app/Http/Controllers/Moons/MoonsAdminController.php',
'App\\Http\\Controllers\\Moons\\MoonsController' => $baseDir . '/app/Http/Controllers/Moons/MoonsController.php',
'App\\Http\\Controllers\\SRP\\SRPAdminController' => $baseDir . '/app/Http/Controllers/SRP/SRPAdminController.php',
@@ -58,7 +62,6 @@ return array(
'App\\Jobs\\ProcessStructureJob' => $baseDir . '/app/Jobs/ProcessStructureJob.php',
'App\\Jobs\\ProcessWalletJournalJob' => $baseDir . '/app/Jobs/ProcessWalletJournalJob.php',
'App\\Jobs\\ProcessWalletTransactionJob' => $baseDir . '/app/Jobs/ProcessWallettransactionJob.php',
'App\\Jobs\\SendEveMailJob' => $baseDir . '/app/Jobs/SendEveMailJob.php',
'App\\Library\\Assets\\AssetHelper' => $baseDir . '/app/Library/Assets/AssetHelper.php',
'App\\Library\\Contracts\\EveContractsHelper' => $baseDir . '/app/Library/Contracts/EveContractsHelper.php',
'App\\Library\\Esi\\Esi' => $baseDir . '/app/Library/Esi/Esi.php',
@@ -75,6 +78,7 @@ return array(
'App\\Library\\Finances\\StructureIndustryTax' => $baseDir . '/app/Library/Finances/StructureIndustryTax.php',
'App\\Library\\Lookups\\LookupHelper' => $baseDir . '/app/Library/Lookups/LookupHelper.php',
'App\\Library\\Lookups\\NewLookupHelper' => $baseDir . '/app/Library/Lookups/NewLookupHelper.php',
'App\\Library\\Moons\\MiningLedgerHelper' => $baseDir . '/app/Library/Moons/MiningLedgerHelper.php',
'App\\Library\\Moons\\MoonCalc' => $baseDir . '/app/Library/Moons/MoonCalc.php',
'App\\Library\\SRP\\SRPHelper' => $baseDir . '/app/Library/SRP/SRPHelper.php',
'App\\Library\\Structures\\StructureHelper' => $baseDir . '/app/Library/Structures/StructureHelper.php',

View File

@@ -480,6 +480,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Console\\Commands\\HoldingFinancesCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Finances/HoldingFinances.php',
'App\\Console\\Commands\\MoonMailerCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Moons/MoonMailer.php',
'App\\Console\\Commands\\PiTransactionsCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Finances/PiTransactions.php',
'App\\Console\\Commands\\PurgeUsers' => __DIR__ . '/../..' . '/app/Console/Commands/Users/PurgeUsers.php',
'App\\Console\\Commands\\UpdateMoonPriceCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Moons/UpdateMoonPricing.php',
'App\\Console\\Commands\\UpdateMoonRental' => __DIR__ . '/../..' . '/app/Console/Commands/Moons/UpdateMoonRental.php',
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
@@ -487,6 +488,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Auth\\EsiScopeController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/EsiScopeController.php',
'App\\Http\\Controllers\\Auth\\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController.php',
'App\\Http\\Controllers\\BlacklistController' => __DIR__ . '/../..' . '/app/Http/Controllers/Corps/BlacklistController.php',
'App\\Http\\Controllers\\Contracts\\ContractAdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/Contracts/ContractAdminController.php',
'App\\Http\\Controllers\\Contracts\\ContractController' => __DIR__ . '/../..' . '/app/Http/Controllers/Contracts/ContractController.php',
'App\\Http\\Controllers\\Controller' => __DIR__ . '/../..' . '/app/Http/Controllers/Controller.php',
@@ -495,7 +497,9 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Http\\Controllers\\Fuel\\FuelController' => __DIR__ . '/../..' . '/app/Http/Controllers/Logistics/FuelController.php',
'App\\Http\\Controllers\\LiveSearch' => __DIR__ . '/../..' . '/app/Http/Controllers/LiveSearch.php',
'App\\Http\\Controllers\\Logistics\\LogisticsController' => __DIR__ . '/../..' . '/app/Http/Controllers/Logistics/LogisticsController.php',
'App\\Http\\Controllers\\Logistics\\StructureRequestController' => __DIR__ . '/../..' . '/app/Http/Controllers/Logistics/StructureRequestController.php',
'App\\Http\\Controllers\\Market\\MarketController' => __DIR__ . '/../..' . '/app/Http/Controllers/Market/MarketController.php',
'App\\Http\\Controllers\\Moons\\MoonLedgerController' => __DIR__ . '/../..' . '/app/Http/Controllers/Moons/MoonLedgerController.php',
'App\\Http\\Controllers\\Moons\\MoonsAdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/Moons/MoonsAdminController.php',
'App\\Http\\Controllers\\Moons\\MoonsController' => __DIR__ . '/../..' . '/app/Http/Controllers/Moons/MoonsController.php',
'App\\Http\\Controllers\\SRP\\SRPAdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/SRP/SRPAdminController.php',
@@ -521,7 +525,6 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Jobs\\ProcessStructureJob' => __DIR__ . '/../..' . '/app/Jobs/ProcessStructureJob.php',
'App\\Jobs\\ProcessWalletJournalJob' => __DIR__ . '/../..' . '/app/Jobs/ProcessWalletJournalJob.php',
'App\\Jobs\\ProcessWalletTransactionJob' => __DIR__ . '/../..' . '/app/Jobs/ProcessWallettransactionJob.php',
'App\\Jobs\\SendEveMailJob' => __DIR__ . '/../..' . '/app/Jobs/SendEveMailJob.php',
'App\\Library\\Assets\\AssetHelper' => __DIR__ . '/../..' . '/app/Library/Assets/AssetHelper.php',
'App\\Library\\Contracts\\EveContractsHelper' => __DIR__ . '/../..' . '/app/Library/Contracts/EveContractsHelper.php',
'App\\Library\\Esi\\Esi' => __DIR__ . '/../..' . '/app/Library/Esi/Esi.php',
@@ -538,6 +541,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Library\\Finances\\StructureIndustryTax' => __DIR__ . '/../..' . '/app/Library/Finances/StructureIndustryTax.php',
'App\\Library\\Lookups\\LookupHelper' => __DIR__ . '/../..' . '/app/Library/Lookups/LookupHelper.php',
'App\\Library\\Lookups\\NewLookupHelper' => __DIR__ . '/../..' . '/app/Library/Lookups/NewLookupHelper.php',
'App\\Library\\Moons\\MiningLedgerHelper' => __DIR__ . '/../..' . '/app/Library/Moons/MiningLedgerHelper.php',
'App\\Library\\Moons\\MoonCalc' => __DIR__ . '/../..' . '/app/Library/Moons/MoonCalc.php',
'App\\Library\\SRP\\SRPHelper' => __DIR__ . '/../..' . '/app/Library/SRP/SRPHelper.php',
'App\\Library\\Structures\\StructureHelper' => __DIR__ . '/../..' . '/app/Library/Structures/StructureHelper.php',