From 06eafb9c153b709de32a619f5dc01e8b6b5032fa Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 20 Jul 2021 21:59:51 +0200 Subject: [PATCH] Networksections can be updated now --- .../NetworksectionController.php | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/application/Networksection/NetworksectionController.php b/application/Networksection/NetworksectionController.php index 7dc9da5f0..5e2dc4609 100644 --- a/application/Networksection/NetworksectionController.php +++ b/application/Networksection/NetworksectionController.php @@ -2,6 +2,18 @@ class NetworksectionController extends mfBaseController { + protected function init() { + $this->needlogin=true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me",$me); + + if(!$me->isAdmin()) { + $this->redirect("Dashboard"); + } + } + protected function saveAction() { $r = $this->request; //var_dump($r);exit; @@ -21,16 +33,27 @@ class NetworksectionController extends mfBaseController { if(!is_array($sections) || !count($sections)) { $this->redirect("Network", "Index", [], "view=sections&net=".$network_id); - + } //var_dump($sections);exit; foreach($sections as $section_id => $name) { - if($section_id == "new") { + if($section_id == "new" && $name) { $section = NetworksectionModel::create(["network_id" => $network_id, "name" => $name]); //var_dump($section);exit; $section->save(); + continue; + } + + if(is_numeric($section_id)) { + $section = new Networksection($section_id); + if(!$section->id) { + continue; + } + $section->name = $name; + $section->edit_by = $this->me->id; + $section->save(); } }