Exemplo n.º 1
0
        if (isset($_POST['lesson']['courseId']) && !empty($_POST['lesson']['courseId'])) {
            $v->addRule('courseId', 'numeric', true, 1, 99999, true);
        } else {
            $v->errors['courseId'] = $tr->__("You must create a course");
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            $error_lesson_add = $v->getMessageErrors();
        } else {
            $currentUser = new StudyPressUserWP();
            $id_lesson = $managerLesson->add(new Lesson(array('pictureUrl' => isset($v->sanitized['pictureurl']) ? $v->sanitized['pictureurl'] : '', 'name' => $v->sanitized['name'], 'author' => $currentUser->displayName(), 'authorId' => $currentUser->id(), 'courseId' => $v->sanitized['courseId'])));
            if (isset($v->sanitized['file']) && !empty($v->sanitized['file'])) {
                $urlFile = wp_get_attachment_url($v->sanitized['file']);
                $managerSlide = new SlideManager();
                $slide = new Slide(array('courseId' => $id_lesson, 'name' => $tr->__("Download the file"), 'content' => "<a href='" . $urlFile . "'>" . basename($urlFile, pathinfo($urlFile, PATHINFO_EXTENSION)) . "</a>"));
                $managerSlide->add($slide);
                $lesson = $managerLesson->getById($id_lesson);
                $postId = $managerLesson->post($lesson);
                $permalink = get_permalink($postId);
                $action = $lesson->getAuthor() . " " . $tr->__("shared a lesson") . " : " . "<a href='{$permalink}'>" . $lesson->getName() . "</a>";
                $imageUrl = $lesson->getPicture();
                $content = "<a href='{$permalink}'><img src='{$imageUrl}' width='150' height='150' /></a>";
                $managerLesson->shareOnGroupsBP($lesson, $action, $content);
            }
        }
    }
}
/*
|---------------------------------------------------------------------
| Supression de plusieurs Leçon
|---------------------------------------------------------------------
Exemplo n.º 2
0
        $resultLesson = $access->getResults("SELECT * FROM {$tableCourse}");
        $authors = array();
        foreach ($resultLesson as $lesson) {
            $managerLesson = new LessonManager();
            if ($a = get_user_by('login', $lesson['author'])) {
                $authors[] = $a->ID;
            }
            $lessonId = $managerLesson->add(new Lesson(array('name' => $lesson['nom'] != "" ? $lesson['nom'] : "Course", 'author' => $a ? $a->display_name : $user->displayName(), 'authorId' => $a ? $a->ID : $user->id(), 'description' => $lesson['cours_des'], 'duration' => $lesson['duration'], 'courseId' => $courseId)));
            if (!in_array($user->id(), $authors)) {
                $authors[] = $user->id();
            }
            if ($access->getVar("SHOW TABLES LIKE '{$tableSlides}'") == $tableSlides) {
                $slidesResult = $access->getResults("SELECT * FROM {$tableSlides} WHERE course_id = '" . $lesson['course_id'] . "'");
                $managerSlide = new SlideManager();
                foreach ($slidesResult as $slide) {
                    $managerSlide->add(new Slide(array('courseId' => $lessonId, 'name' => $slide['slides_name'] != "" ? $slide['slides_name'] : "Slide", 'content' => $slide['slides_content'], 'order' => $slide['slides_order'])));
                }
            }
        }
        $course->setAuthors($authors);
        $managerCourse->update($courseId, $course);
        add_action('admin_init', 'sp_notice_warning_migrate');
        function sp_notice_warning_migrate()
        {
            $sp_user = new StudyPressUserWP();
            add_user_meta($sp_user->id(), 'sp_menu_add_warning_migrate', true, true);
        }
    }
}
$access->query("DROP TABLE IF EXISTS {$tableSlides}");
$access->query("DROP TABLE IF EXISTS {$tableCategCourse} ");
Exemplo n.º 3
0
global $tr;
require_once '_AutoLoadClassAjax.php';
if (isset($_POST['type']) && $_POST['type'] === "add-slide") {
    if (isset($_POST['name']) && isset($_POST['content']) && isset($_POST['id_lesson'])) {
        $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')));
        $v->run();
        if (sizeof($v->errors) > 0) {
            header("HTTP/1.0 400 Bad Request");
            echo $v->getMessageErrors();
        } else {
            if ($managerLesson->getById($v->sanitized['id_lesson'])) {
                $managerSlide->add(new Slide(array('name' => $v->sanitized['name'], 'content' => $_POST['content'], 'courseId' => $v->sanitized['id_lesson'])));
                echo "true";
            }
        }
    } else {
        header("HTTP/1.0 400 Bad Request");
        $tr->_e("Please fill in all fields");
    }
}
if (isset($_POST['type']) && $_POST['type'] === "remove-slide") {
    if (isset($_POST['id_lesson']) && isset($_POST['id_slide'])) {
        $managerLesson = new LessonManager();
        $managerSlide = new SlideManager();
        $v = new validation();
        $v->addSource($_POST);
        $v->AddRules(array('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')));