<?php require_once '_AutoLoadClassAjax.php'; if (isset($_POST['id']) && !empty($_POST['id'])) { $v = new validation(); $v->addSource($_POST); $v->addRule('id', 'numeric', true, 1, 99999, true); $v->run(); if (sizeof($v->errors) === 0) { $managerLesson = new LessonManager(); $managerQuiz = new QuizManager(); $activity = $managerLesson->getById($v->sanitized['id']); if (!$activity) { $activity = $managerQuiz->getById($v->sanitized['id']); } if ($activity) { if (StudyPressUserWP::isLoggedIn()) { $currentUserId = new StudyPressUserWP(); $currentUserId = $currentUserId->id(); $managerLesson->setVisitedActivity($currentUserId, $activity->getId()); } } } }
} wp_enqueue_media(); global $tr; $managerLesson = new LessonManager(); $managerCourse = new CourseManager(); $error_lesson_add = ""; $error_lesson_remove = ""; if (isset($_GET['type']) && $_GET['type'] === "delete" && isset($_GET['id'])) { $validation = new validation(); $validation->addSource(array('id' => $_GET['id'])); $validation->addRule('id', 'numeric', true, 0, 1000000, true); $validation->run(); if (sizeof($validation->errors) > 0) { $error_lesson_remove = $validation->getMessageErrors(); } else { $lesson = $managerLesson->getById($validation->sanitized['id']); if ($lesson != null) { $managerLesson->delete($validation->sanitized['id']); if ($managerLesson->isError()) { $error_lesson_remove = $managerLesson->getMessageError(); } } } } if (isset($_POST['add'])) { if (isset($_POST['lesson']) && !empty($_POST['lesson'])) { $v = new validation(); $v->addSource($_POST['lesson']); $v->addRule('name', 'string', true, 1, 200, true); if (isset($_POST['lesson']['pictureurl']) && !empty($_POST['lesson']['pictureurl'])) { $v->addRule('pictureurl', 'numeric', true, 1, 999999, true);
if ($c['bp_shareResult'] = 'true') { $v = new validation(); $v->addSource($_POST); $v->addRule('quizId', 'numeric', true, 1, 9999999, true); $v->run(); if (sizeof($v->errors) > 0) { header("HTTP/1.0 400 Bad Request"); echo $v->getMessageErrors(); } else { $manager = new QuizManager(); $type = "quiz"; $activity = $manager->getById($v->sanitized['quizId']); if (!$activity) { $manager = new LessonManager(); $type = "lesson"; $activity = $manager->getById($v->sanitized['quizId']); } if ($activity) { if (StudyPressUserWP::isLoggedIn()) { $user = new StudyPressUserWP(); if ($manager->isDone($v->sanitized['quizId'], $user->id())) { if (function_exists('bp_is_active') && bp_is_active('groups')) { $permalink = get_permalink($activity->getPostId()); $med_image_url = $activity->getPicture(); if ($type === "quiz") { $resultQuiz = $manager->getResultOfQuizByUser($v->sanitized['quizId'], $user->id()); if (!$resultQuiz) { exit; } if (isset($_POST['type_share']) && $_POST['type_share'] === 'result') { $action = $user->displayName() . " " . $tr->__("obtained") . " " . $resultQuiz->getNote() . "% " . $tr->__("in") . " : <a href='{$permalink}'>" . $activity->getName() . "</a>";
if (isset($_POST['id_lesson'])) { require_once '_AutoLoadClassAjax.php'; global $tr; $managerLesson = new LessonManager(); $v = new validation(); $v->addSource($_POST); $v->AddRules(array('id_lesson' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true'))); $v->run(); /* * Si un/des champs ne est/sont pas valide(s)... * */ if (sizeof($v->errors) > 0) { header("HTTP/1.0 400 Bad Request"); } else { $lesson = $managerLesson->getById($v->sanitized['id_lesson']); if ($lesson) { $result = ""; if (count($lesson->getSlides())) { foreach ($lesson->getSlides() as $slide) { ?> <li id="li-sotable" class="ui-state-default btn btn-default" data-id="<?php echo $slide->id(); ?> "> <span class="float-left"> <span class="glyphicon glyphicon-resize-vertical " aria-hidden="true"></span> <?php echo $slide->getNiceName();