More work on user linking to existing defined system
This commit is contained in:
parent
14f28c5263
commit
05528f1c33
@ -47,23 +47,23 @@ class Font
|
|||||||
*/
|
*/
|
||||||
private function chars(): Collection
|
private function chars(): Collection
|
||||||
{
|
{
|
||||||
static $chars = NULL;
|
static $chars = [];
|
||||||
|
|
||||||
if (is_null($chars) && $this->text) {
|
if ($this->text && empty($chars[$this->text])) {
|
||||||
// Trim any leading/trailing spaces
|
// Trim any leading/trailing spaces
|
||||||
$text = trim(strtolower($this->text));
|
$text = trim(strtolower($this->text));
|
||||||
$chars = collect();
|
$chars[$this->text] = collect();
|
||||||
|
|
||||||
// Work out the characters we need
|
// Work out the characters we need
|
||||||
foreach (array_unique(str_split($text)) as $c) {
|
foreach (array_unique(str_split($text)) as $c) {
|
||||||
if (! $x=Arr::get(static::FONT,$c))
|
if (! $x=Arr::get(static::FONT,$c))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$chars->put($c,$x);
|
$chars[$this->text]->put($c,$x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $chars ?: collect();
|
return $chars[$this->text] ?: collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +94,7 @@ class Font
|
|||||||
|
|
||||||
// If the last character is a space, we'll reduce the width
|
// If the last character is a space, we'll reduce the width
|
||||||
$space = TRUE;
|
$space = TRUE;
|
||||||
foreach ($chars->get($c) as $line => $x)
|
foreach ($chars->get($c) as $x)
|
||||||
if (array_pop($x) != 32) {
|
if (array_pop($x) != 32) {
|
||||||
$space = FALSE;
|
$space = FALSE;
|
||||||
break;
|
break;
|
||||||
|
32
app/Console/Commands/UserCodeSend.php
Normal file
32
app/Console/Commands/UserCodeSend.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
|
||||||
|
use App\Models\{Address,User};
|
||||||
|
use App\Notifications\AddressLink;
|
||||||
|
|
||||||
|
class UserCodeSend extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'user:code:send'
|
||||||
|
.' {ftn : FTN to send link code to}'
|
||||||
|
.' {email : User to send the link to}';
|
||||||
|
|
||||||
|
protected $description = 'Send a link to a user';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$ao = Address::findFTN($this->argument('ftn'));
|
||||||
|
$uo = User::where('email',$this->argument('email'))->singleOrFail();
|
||||||
|
|
||||||
|
Notification::route('netmail',$ao->parent())->notify(new AddressLink($ao,$uo));
|
||||||
|
}
|
||||||
|
}
|
@ -556,6 +556,29 @@ class SystemController extends Controller
|
|||||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id));
|
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function system_link(Request $request)
|
||||||
|
{
|
||||||
|
if (! $request->system_id)
|
||||||
|
return redirect('user/system/register');
|
||||||
|
|
||||||
|
$s = Setup::findOrFail(config('app.id'))->system;
|
||||||
|
$so = System::findOrFail($request->system_id);
|
||||||
|
|
||||||
|
$ca = NULL;
|
||||||
|
$la = NULL;
|
||||||
|
foreach ($s->addresses as $ao) {
|
||||||
|
if ($ca=$so->match($ao->zone))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ca->count() && $la=$ca->pop())
|
||||||
|
Notification::route('netmail',$la)->notify(new AddressLink($la,Auth::user()));
|
||||||
|
|
||||||
|
return view('user.system.register_send')
|
||||||
|
->with('la',$la)
|
||||||
|
->with('o',$so);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register system
|
* register system
|
||||||
*/
|
*/
|
||||||
@ -565,6 +588,10 @@ class SystemController extends Controller
|
|||||||
if ($request->isMethod('GET'))
|
if ($request->isMethod('GET'))
|
||||||
return view('user.system.register');
|
return view('user.system.register');
|
||||||
|
|
||||||
|
if ($request->action != 'create')
|
||||||
|
return view('user.system.widget.register_confirm')
|
||||||
|
->with('o',System::findOrFail($request->system_id));
|
||||||
|
|
||||||
$o = System::findOrNew($request->system_id);
|
$o = System::findOrNew($request->system_id);
|
||||||
|
|
||||||
// If the system exists, and we are 'register', we'll start the address claim process
|
// If the system exists, and we are 'register', we'll start the address claim process
|
||||||
@ -575,7 +602,7 @@ class SystemController extends Controller
|
|||||||
if ($validate->count())
|
if ($validate->count())
|
||||||
Notification::route('netmail',$x=$validate->first())->notify(new AddressLink($x,Auth::user()));
|
Notification::route('netmail',$x=$validate->first())->notify(new AddressLink($x,Auth::user()));
|
||||||
|
|
||||||
return view('user.system.widget.register_confirm')
|
return view('user.system.widget.register_send')
|
||||||
->with('validate',$validate)
|
->with('validate',$validate)
|
||||||
->with('o',$o);
|
->with('o',$o);
|
||||||
}
|
}
|
||||||
|
28
resources/views/user/system/register_send.blade.php
Normal file
28
resources/views/user/system/register_send.blade.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<!-- $o = System::class -->
|
||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('htmlheader_title')
|
||||||
|
Link System
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="greyframe titledbox shadow0xb0">
|
||||||
|
<h2 class="cap">Register System</h2>
|
||||||
|
|
||||||
|
@if($la)
|
||||||
|
<p>OK, here's what we are going to do. I'm going to send you a routed netmail to <strong class="highlight">{{ $la->ftn }}</strong> with a code - please follow the instructions
|
||||||
|
in that netmail.</p>
|
||||||
|
<p>Once the code is validated, this system will be assigned to you.</p>
|
||||||
|
@else
|
||||||
|
<p>I cant validate that <strong class="highlight">{{ $o->name }}</strong> is your system, we dont share common zones.</p>
|
||||||
|
<p>You might want to talk to an admin.</p>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- @todo Fix with CSS -->
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
@ -1,13 +1,41 @@
|
|||||||
<!-- $o = System::class -->
|
<!-- $o = System::class -->
|
||||||
<form class="row g-0 needs-validation" method="post" autocomplete="off" novalidate>
|
<h3>System Details:</h3>
|
||||||
|
<table class="monotable">
|
||||||
|
<tr>
|
||||||
|
<th>System</th>
|
||||||
|
<th>{{ $o->name }}</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Sysop</th>
|
||||||
|
<th>{{ $o->sysop }}</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Location</th>
|
||||||
|
<th>{{ $o->location }}</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Networks</th>
|
||||||
|
<th>{{ $o->addresses->pluck('ftn')->join(', ') }}</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Address</th>
|
||||||
|
<th>{{ $o->access_mailer }}</th>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p>If the details are above are not correct, then please contact the (ZC) to have them corrected first.</p>
|
||||||
|
|
||||||
|
<p>Otherwise, if all is good, we'll send a netmail to <strong class="highlight">{{ $o->sysop }}</strong> at <strong class="highlight">{{ $o->access_mailer }}</strong></p> with further details.
|
||||||
|
|
||||||
|
<form class="row g-0 needs-validation" method="post" autocomplete="off" action="{{ url('user/system/link') }}" novalidate>
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
@if($validate->count())
|
<input type="hidden" name="system_id" value="{{ $o->id }}">
|
||||||
<p>OK, here's what we are going to do. I'm going to send you a routed netmail with a code - please follow the instructions
|
<input type="hidden" name="name" value="{{ $o->name }}">
|
||||||
in that netmail.</p>
|
|
||||||
<p>Once the code is validated, this system will be assigned to you.</p>
|
<div class="row">
|
||||||
@else
|
<div class="col-12 pb-2">
|
||||||
<p>I cant validate that <strong class="highlight">{{ $o->name }}</strong> is your system, we share now common zones.</p>
|
<input type="submit" name="action" class="btn btn-success" value="Link">
|
||||||
<p>You might want to talk to an admin.</p>
|
</div>
|
||||||
@endif
|
</div>
|
||||||
</form>
|
</form>
|
@ -93,6 +93,7 @@ Route::middleware(['auth','verified','activeuser'])->group(function () {
|
|||||||
->where('o','[0-9]+');
|
->where('o','[0-9]+');
|
||||||
|
|
||||||
Route::match(['get','post'],'user/system/register',[SystemController::class,'system_register']);
|
Route::match(['get','post'],'user/system/register',[SystemController::class,'system_register']);
|
||||||
|
Route::match(['post'],'user/system/link',[SystemController::class,'system_link']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('network/{o}',[HomeController::class,'network']);
|
Route::get('network/{o}',[HomeController::class,'network']);
|
||||||
|
Loading…
Reference in New Issue
Block a user