public function saveNewLesson() { if (!isset($_POST['nameEN']) || empty($_POST['nameEN']) || !isset($_POST['nameDE']) || empty($_POST['nameDE']) || !isset($_POST['points']) || empty($_POST['points'])) { $this->getView()->addErrorMessage('Please fill out all fields!'); $this->addLesson(); } else { $courseId = $this->secureString($_GET['id']); $nameEN = $this->secureString($_POST['nameEN']); $nameDE = $this->secureString($_POST['nameDE']); $points = $this->secureString($_POST['points']); if (Lesson::createLesson($courseId, $nameEN, $nameDE, $points)) { $this->getView()->addSuccessMessage('Lesson was successfully added.'); } else { $this->getView()->addErrorMessage('Lesson could not be added!'); } $this->defaultAction(); // create default tutorial page $newLesson = Lesson::getNewestLesson($courseId); $lessonId = $newLesson->getId(); $filePath = PAGE_DIR . "lessons/{$courseId}-{$lessonId}.html"; FileFunctions::createFile($filePath, "New lesson <strong>" . $newLesson->getName('en') . "</strong>"); } }