} } if (isset($_POST['type']) && $_POST['type'] === "update-slide") { if (isset($_POST['name']) && isset($_POST['content']) && isset($_POST['id_slide']) && isset($_POST['id_slide'])) { $managerLesson = new LessonManager(); $managerSlide = new SlideManager(); $v = new validation(); $v->addSource($_POST); $v->AddRules(array('name' => array('type' => 'string', 'required' => 'true', 'min' => '1', 'max' => '200', 'trim' => 'true'), 'id_lesson' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true'), 'id_slide' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true'))); $v->run(); if (sizeof($v->errors) > 0) { header("HTTP/1.0 400 Bad Request"); echo $v->getMessageErrors(); } else { $lesson = $managerLesson->getById($v->sanitized['id_lesson']); $slide = $managerSlide->getById($v->sanitized['id_slide']); if ($lesson && $slide) { $slide->setContent($_POST['content']); $slide->setName($v->sanitized['name']); $managerSlide->update($v->sanitized['id_slide'], $slide); echo "true"; } } } } //Ajouter une note if (isset($_POST['type']) && $_POST['type'] === "add-note") { if (isset($_POST['note']) && isset($_POST['id_lesson'])) { $managerLesson = new LessonManager(); $v = new validation(); $v->addSource($_POST);