Start of echomail subscribing
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Models\{Address,System,SystemZone,Zone};
|
||||
use App\Models\{Address,Echoarea,System,SystemZone,Zone};
|
||||
use App\Rules\{FidoInteger,TwoByteInteger};
|
||||
|
||||
class SystemController extends Controller
|
||||
@@ -27,7 +28,7 @@ class SystemController extends Controller
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('add_address',TRUE);
|
||||
session()->flash('accordion','address');
|
||||
|
||||
$request->validate([
|
||||
'action' => 'required|in:region,host,node',
|
||||
@@ -222,7 +223,7 @@ class SystemController extends Controller
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('add_session',TRUE);
|
||||
session()->flash('accordion','session');
|
||||
|
||||
$validate = $request->validate([
|
||||
'zone_id' => 'required|exists:zones,id',
|
||||
@@ -293,7 +294,7 @@ class SystemController extends Controller
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('add_address',TRUE);
|
||||
session()->flash('accordion','address');
|
||||
|
||||
$sid = $o->system_id;
|
||||
$o->active = FALSE;
|
||||
@@ -313,13 +314,46 @@ class SystemController extends Controller
|
||||
public function del_session(System $o,Zone $zo)
|
||||
{
|
||||
$this->authorize('admin',$zo);
|
||||
session()->flash('add_session',TRUE);
|
||||
session()->flash('accordion','session');
|
||||
|
||||
$o->sessions()->detach($zo);
|
||||
|
||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the systems echoareas
|
||||
*
|
||||
* @param Request $request
|
||||
* @param System $o
|
||||
*/
|
||||
public function echoareas(Request $request,System $o)
|
||||
{
|
||||
$ao = $o->addresses->filter(function($item) use ($request) { return $item->zone->domain_id == $request->domain_id; })->first();
|
||||
|
||||
if (($request->method() == 'POST') && $request->post()) {
|
||||
session()->flash('accordion','echoarea');
|
||||
|
||||
// Ensure we have session details for this address.
|
||||
if (! $ao->session('sespass'))
|
||||
return redirect()->back()->withErrors('System doesnt belong to this network');
|
||||
|
||||
$ao->echoareas()->syncWithPivotValues($request->id,['subscribed'=>Carbon::now()]);
|
||||
|
||||
return redirect()->back()->with('success','Echoareas updated');;
|
||||
}
|
||||
|
||||
$eo = Echoarea::active()
|
||||
->where('domain_id',$request->domain_id)
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
return view('system.widget.echoarea')
|
||||
->with('o',$o)
|
||||
->with('ao',$ao)
|
||||
->with('echoareas',$eo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move address to another system
|
||||
*
|
||||
@@ -331,6 +365,8 @@ class SystemController extends Controller
|
||||
*/
|
||||
public function mov_address(Request $request,System $so,Address $o)
|
||||
{
|
||||
session()->flash('accordion','address');
|
||||
|
||||
// Quick check that this address belongs to this system
|
||||
if ($so->addresses->search(function($item) use ($o) { return $item->id == $o->id; }) === FALSE)
|
||||
abort(404);
|
||||
@@ -378,7 +414,7 @@ class SystemController extends Controller
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('add_address',TRUE);
|
||||
session()->flash('accordion','address');
|
||||
|
||||
$o->active = (! $o->active);
|
||||
$o->save();
|
||||
|
Reference in New Issue
Block a user