More work on user linking to existing defined system
This commit is contained in:
@@ -47,23 +47,23 @@ class Font
|
||||
*/
|
||||
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
|
||||
$text = trim(strtolower($this->text));
|
||||
$chars = collect();
|
||||
$chars[$this->text] = collect();
|
||||
|
||||
// Work out the characters we need
|
||||
foreach (array_unique(str_split($text)) as $c) {
|
||||
if (! $x=Arr::get(static::FONT,$c))
|
||||
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
|
||||
$space = TRUE;
|
||||
foreach ($chars->get($c) as $line => $x)
|
||||
foreach ($chars->get($c) as $x)
|
||||
if (array_pop($x) != 32) {
|
||||
$space = FALSE;
|
||||
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));
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
@@ -565,6 +588,10 @@ class SystemController extends Controller
|
||||
if ($request->isMethod('GET'))
|
||||
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);
|
||||
|
||||
// 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())
|
||||
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('o',$o);
|
||||
}
|
||||
|
Reference in New Issue
Block a user