needlogin = true; $me = new User(); $me->loadMe(); $this->me = $me; $this->layout()->set("me", $me); if (!$me->is(["Admin"])) { $this->redirect("Dashboard"); } } protected function indexAction() { $this->layout()->setTemplate("LoggingCommunication/Index"); $loggingcommunications = LoggingCommunicationModel::getAll(); $this->layout()->set("loggingcommunications", $loggingcommunications); } protected function addAction() { $this->layout()->setTemplate("LoggingCommunication/Form"); } protected function editAction() { $id = $this->request->id; if (!is_numeric($id) || !$id) { $this->layout()->setFlash("Logging nicht gefunden", "error"); $this->redirect("LoggingCommunication"); } $loggingcommunications = new LoggingCommunication($id); if ($loggingcommunications->id != $id) { $this->layout()->setFlash("Logging nicht gefunden", "error"); $this->redirect("LoggingCommunication"); } $this->layout()->set("loggingcommunications", $loggingcommunications); return $this->addAction(); } protected function saveAction() { $r = $this->request; $id = $r->id; //var_dump($r->get());exit; if (is_numeric($id) && $id > 0) { $mode = "edit"; $loggingcommunications = new LoggingCommunication($id); if (!$loggingcommunications->id) { $this->layout()->setFlash("Logging nicht gefunden", "error"); $this->redirect("LoggingCommunication"); } } else { $mode = "add"; } $data = []; $data['type'] = trim($r->type); $data['message'] = trim($r->message); $data['response'] = trim($r->response); if (!$data['type']) { $data['type']=NULL; } if (!$data['message']) { $data['message']=NULL; } if (!$data['response']) { $data['response']=NULL; } // var_dump($_FILES); // var_dump($upload); // exit; if ($mode == "edit") { $loggingcommunications->update($data); } else { $loggingcommunications = LoggingCommunicationModel::create($data); } // var_dump($filestore); // exit; $id = $loggingcommunications->save(); if (!$id) { $this->layout()->setFlash("Logging konnte nicht angelegt werden", "error"); $this->redirect("LoggingCommunication"); } if ($mode == "edit") { $this->layout()->setFlash("Logging erfolgreich geƤndert", "success"); } else if ($mode = "add") { $this->layout()->setFlash("Logging erfolgreich angelegt", "success"); } $this->redirect("LoggingCommunication"); } protected function deleteAction() { $id = $this->request->id; $loggingcommunications = new LoggingCommunication($id); if (!$loggingcommunications->id || $loggingcommunications->id != $id) { $this->layout()->setFlash("Logging nicht gefunden.", "error"); $this->redirect("LoggingCommunication"); } $loggingcommunications->delete(); $this->redirect("LoggingCommunication"); } }