More changes to use form.select component. Re-engineered user BBS registration
This commit is contained in:
@@ -49,6 +49,9 @@ class SystemController extends Controller
|
||||
$o->autohold = FALSE;
|
||||
$o->save();
|
||||
|
||||
if ($o->wasRecentlyCreated)
|
||||
$o->users()->attach(Auth::id());
|
||||
|
||||
$mailers = collect($request->post('mailer_details'))
|
||||
->filter(function($item) { return $item['port']; })
|
||||
->transform(function($item) { $item['active'] = Arr::get($item,'active',FALSE); return $item; });
|
||||
@@ -621,39 +624,19 @@ class SystemController extends Controller
|
||||
*/
|
||||
public function register(SystemRegisterRequest $request)
|
||||
{
|
||||
if ($request->action === 'register' && $request->name && is_numeric($request->name))
|
||||
return view('user.system.widget.register_confirm')
|
||||
->with('o',System::findOrFail($request->name));
|
||||
// During the BBS linking process, if the user selected a system will link to confirm it
|
||||
if ($request->action === 'register' && $request->system_id && is_numeric($request->system_id))
|
||||
return redirect()
|
||||
->to(sprintf('user/system/register_confirm/%d',$request->system_id));
|
||||
|
||||
$o = System::findOrNew(is_numeric($request->system_id) ? $request->system_id : NULL);
|
||||
// Re-flash our previously input data, we must be creating a new system
|
||||
session()->flashInput([
|
||||
'name'=>$request->system_id,
|
||||
'sysop'=>Auth::user()->name,
|
||||
]);
|
||||
|
||||
// If the system doesnt exist, we'll create it
|
||||
if (! $o->exist) {
|
||||
$o->sysop = Auth::user()->name;
|
||||
|
||||
foreach (['name','zt_id','location','phone','method','address','port'] as $item)
|
||||
if ($request->{$item})
|
||||
$o->{$item} = $request->{$item};
|
||||
|
||||
$o->active = TRUE;
|
||||
}
|
||||
|
||||
if ($request->post('submit')) {
|
||||
Auth::user()->systems()->save($o);
|
||||
|
||||
// @todo if the system already exists and part of one of our networks, we'll need to send the registration email to confirm the address.
|
||||
// @todo mark the system (or addresses) as "pending" at this stage until it is confirmed
|
||||
return redirect()->to(url('system/addedit',$o->id));
|
||||
}
|
||||
|
||||
// Re-flash our previously input data
|
||||
if ($request->old)
|
||||
session()->flashInput($request->old);
|
||||
|
||||
return view('system.widget.system')
|
||||
->with('action',$request->action)
|
||||
->with('o',$o)
|
||||
->with('errors',new ViewErrorBag);
|
||||
return redirect()
|
||||
->to('system/addedit');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -56,8 +56,11 @@ class SystemRegisterRequest extends FormRequest
|
||||
return [];
|
||||
|
||||
$so = $this->route('o');
|
||||
|
||||
// When we have selected a system during the register/linking process
|
||||
if ((! $so) && ($request->action === 'register'))
|
||||
return [];
|
||||
// If system ID is not numeric, then its a new system
|
||||
return is_numeric($request->system_id) ? ['system_id'=>'required|exists:systems,id'] : [];
|
||||
|
||||
return array_filter(array_merge([
|
||||
'name' => 'required|min:3',
|
||||
@@ -68,14 +71,16 @@ class SystemRegisterRequest extends FormRequest
|
||||
'port' => 'nullable|digits_between:2,5',
|
||||
'method' => 'nullable|numeric',
|
||||
'mailer_details.*' => 'nullable|array',
|
||||
// @todo Port should be present if active is true
|
||||
'mailer_details.*.port' => 'nullable|digits_between:2,5',
|
||||
'mailer_details.*.active' => 'sometimes|boolean',
|
||||
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/|unique:systems,zt_id,'.($so ? $so->id : 0),
|
||||
'pkt_type' => ['required',Rule::in(array_keys(Packet::PACKET_TYPES))],
|
||||
],($so && $so->exists) ? [
|
||||
'users' => 'nullable|array|min:1|max:2',
|
||||
'active' => 'required|boolean',
|
||||
'hold' => 'sometimes|boolean',
|
||||
'pollmode' => 'required|integer|min:0|max:2',
|
||||
],($so && $so->exists) ? [
|
||||
'users' => 'nullable|array|min:1|max:2',
|
||||
'heartbeat' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
|
Reference in New Issue
Block a user