<?php if (!defined('ABSPATH')) { exit; } wp_enqueue_media(); global $tr; $managerCourse = new CourseManager(); $error_course_add = ""; $error_course_remove = ""; $user = new StudyPressUserWP(); if ($user->isAdministrator()) { if (isset($_POST['add'])) { if (isset($_POST['course']) && !empty($_POST['course'])) { $v1 = new validation(); $v2 = new validation(); $v1->addSource($_POST['course']); $v1->addRule('name', 'string', true, 1, 200, true); $v1->addRule('desc', 'string', true, 0, 999999, true); if (isset($_POST['course']['pictureId']) && !empty($_POST['course']['pictureId'])) { $v1->addRule('pictureId', 'numeric', true, 1, 999999, true); } foreach ($_POST['course'] as $key => $value) { if (preg_match('/^[0-9]{1,}$/', $key)) { $v1->addRule($key . "", 'numeric', true, 1, 200, true); } } if (isset($_POST['course']['users'])) { $v2->addSource($_POST['course']['users']); foreach ($_POST['course']['users'] as $key => $value) { if (preg_match('/^[0-9]{1,}$/', $key)) {
global $tr; $user = new StudyPressUserWP(); $managerCourse = new CourseManager(); $course = null; $error_course_update = ""; $error_course_add = ""; if (isset($_GET['id']) && !empty($_GET['id'])) { $v = new validation(); $v->addSource($_GET); $v->addRule('id', 'numeric', true, 1, 9999999, true); $v->run(); if (!sizeof($v->errors) > 0) { $course = $managerCourse->getById($v->sanitized['id']); if ($course) { if (isset($_POST['update'])) { if ($user->isAdministrator()) { if (isset($_POST['course']) && isset($_POST['course']['categories']) && isset($_POST['course']['users'])) { $v1 = new validation(); $v2 = new validation(); $v3 = new validation(); $v1->addSource($_POST['course']); $v2->addSource($_POST['course']['categories']); $v3->addSource($_POST['course']['users']); //rule Image if (isset($_POST['course']['pictureId']) && !empty($_POST['course']['pictureId'])) { $v1->addRule('pictureId', 'numeric', true, 1, 999999, true); } $v1->AddRules(array('id' => array('type' => 'numeric', "required" => true, 'min' => '1', 'max' => '999999', 'trim' => true), 'name' => array('type' => 'string', "required" => true, 'min' => '1', 'max' => '200', 'trim' => true), 'description' => array('type' => 'string', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true))); foreach ($_POST['course']['categories'] as $key => $value) { if (preg_match('/^[0-9]{1,}$/', $key)) { $v2->addRule($key . "", 'numeric', true, 1, 99999, true);
public function getCoursesByAuthor($authorId) { $user = new StudyPressUserWP($authorId); if ($user->isAdministrator()) { return $this->getAll(); } $courses = array(); $result = $this->_access->getResults($this->_access->prepare("SELECT " . StudyPressDB::COL_ID_COURSE_USERS_N_COURSE . " FROM " . StudyPressDB::getTableName_CourseUsers() . " WHERE " . StudyPressDB::COL_ID_USERS_USERS_N_COURSE . " = '%d' ORDER BY " . StudyPressDB::COL_ID_COURSE_USERS_N_COURSE . " DESC ", $authorId)); foreach ($result as $row) { $id = $row[StudyPressDB::COL_ID_COURSE_USERS_N_COURSE]; $course = $this->getById($id); array_push($courses, $course); } return $courses; }
$tr->_e("Author"); ?> </th> <th><?php $tr->_e("Publication"); ?> </th> </tr> </thead> <tbody> <?php $__lessons = array(); $currentUser = new StudyPressUserWP(); if ($currentUser->isAdministrator()) { $__lessons = $managerLesson->getAllWithoutSlides(); } else { $__courses = $managerCourse->getCoursesByAuthor($currentUser->id()); foreach ($__courses as $c) { $_lessons = $managerLesson->getLessonsOfCourse($c->getId()); $__lessons = array_merge($__lessons, $_lessons); } } if (empty($__lessons)) { echo "<tr><td colspan='5'>" . $tr->__("No lessons") . "</td></tr>"; } else { foreach ($__lessons as $row) { $url_mod_lesson = "?page=mod-lesson&id=" . $row->getId(); $url_delete_lesson = "?page=id_Cours&type=delete&id=" . $row->getId(); ?>
</h1> <div class="container-fluid"> <?php sp_display_link_help(); $user = new StudyPressUserWP(); ?> <div class="row"> <div class="<?php echo $user->isAdministrator() ? "col-md-8" : "col-md-12"; ?> "> <h3><?php $tr->_e('All courses'); ?> </h3> <div class="alert alert-danger" role="alert" <?php echo $error_course_remove == '' ? 'style=\'display:none\'' : ''; ?> > <?php echo $error_course_remove; ?> </div> <form action="" method="post" id="sp-reload">
<?php /** * Created by PhpStorm. * User: Salim * Date: 11/03/2015 * Time: 14:39 */ $sp_user = new StudyPressUserWP(); if ($sp_user->isAdministrator()) { add_action('admin_notices', 'sp_notice_menu_course'); function sp_notice_menu_course() { $sp_user = new StudyPressUserWP(); global $tr; $user_id = $sp_user->id(); if (!get_user_meta($user_id, 'sp_menu_course_ignore_notice')) { ?> <div class="update-nag"> <?php echo $tr->__("This is a fresh installation of StudyPress. Don't forget to go to Appearance -> Menus -> Screen Options, and activate 'Course' option. ") . " | <a href='?page=id_Cours&sp_nag_ignore=0'>" . $tr->__('Hide Notice') . "</a><br/>"; ?> <?php echo $tr->__("If courses does not appear in your web site, on your dashboard, go to 'Settings' -> 'Permalinks' and just click on 'Save changes' without changing anything. "); ?> </div> <?php } }