示例#1
0
 public function actionLessons()
 {
     $tasks = ['Добавить' => 'show', 'Добавить' => 'add', 'Изменить' => 'edit', 'Удалить' => 'del'];
     $task = $_GET['task'];
     $id = $_GET['id'];
     $view = new View();
     $view->tasks = $tasks;
     if (!isset($task)) {
         $lessons = Lessons::getLessons($id);
         $view->lessons = $lessons;
         $view->display('admin/header.php');
         $view->display('admin/lessons/list.php');
         $view->display('admin/footer.php');
     } elseif ('add' == $task) {
         if (!empty($_POST)) {
             $id = Lessons::addLesson($_POST);
             header('Location: /?ctrl=Admin&act=Lessons&task=edit&id=' . $id);
         }
         $courses = Courses::getCourses();
         $view->courses = $courses;
         $view->display('admin/header.php');
         $view->display('admin/lessons/add.php');
         $view->display('admin/footer.php');
     } elseif ('edit' == $task && isset($id)) {
         if (!empty($_POST)) {
             Lessons::updateLesson($_POST);
         }
         $lesson = Lessons::getLesson($id);
         $courses = Courses::getCourses();
         $view->lesson = $lesson;
         $view->courses = $courses;
         $view->display('admin/header.php');
         $view->display('admin/lessons/edit.php');
         $view->display('admin/footer.php');
     } elseif ('del' == $task) {
         Courses::delCourse($id);
         header('Location: /?ctrl=Admin&act=Lessons');
     } else {
         $view->display('header.php');
         $view->display('404.php');
         $view->display('footer.php');
     }
 }
示例#2
0
 public function actionShowLessons()
 {
     $auth = Auth::checkAuth();
     $view = new View();
     $view->auth = $auth;
     if (!isset($_GET['id'])) {
         header("Location: /learns/");
     }
     if ($auth) {
         $user = Auth::getUser();
         $id = $_GET['id'];
         $course = Courses::getCourse($id);
         $lessons = Lessons::getLessons($id);
         $lessons_status = Users::getUserLessons($user->user_id, $id);
         $isUserCourse = Users::getUserCourse($user->user_id, $id);
         $view->user_login = $user->user_login;
         $view->user_group = $user->user_group;
         $view->lessons = $lessons;
         $view->lessons_status = $lessons_status;
         $view->course = $course;
         $view->display('header.php');
         $view->display('lessons/lessons_head.php');
         if (!$lessons) {
             $view->display('lessons/lessons_error.php');
         } else {
             if (!$isUserCourse) {
                 $view->display('lessons/lessons_list.php');
             } else {
                 $view->display('lessons/lessons_list_auth.php');
             }
         }
         $view->display('courses/course_info.php');
         $view->display('footer.php');
     } else {
         header("Location: /learns/");
     }
 }