2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
13 define('TR_INCLUDE_PATH', '../include/');
14 require(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'classes/DAO/UserCoursesDAO.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
17 require_once(TR_INCLUDE_PATH.'classes/DAO/CourseCategoriesDAO.class.php');
19 global $_current_user;
21 // clean up the session vars from the previous course
22 unset($_SESSION['course_id']);
24 $userCoursesDAO = new UserCoursesDAO();
25 $coursesDAO = new CoursesDAO();
26 $courseCategoriesDAO = new CourseCategoriesDAO();
28 if (isset($_GET['catid']) && trim($_GET['catid']) <> '') $catid = intval($_GET['catid']);
30 if (isset($_GET['action'], $_GET['cid']) && $_SESSION['user_id'] > 0)
32 $cid = intval($_GET['cid']);
34 if ($_GET['action'] == 'remove') $userCoursesDAO->Delete($_SESSION['user_id'], $cid);
35 if ($_GET['action'] == 'add') $userCoursesDAO->Create($_SESSION['user_id'], $cid, TR_USERROLE_VIEWER, 0);
37 $msg->addFeedback(ACTION_COMPLETED_SUCCESSFULLY);
40 // retrieve data to display
41 //if ($_SESSION['user_id'] > 0) {
42 // $courses = $userCoursesDAO->getByUserID($_SESSION['user_id']);
43 // $is_my_courses = true;
47 $courses = $coursesDAO->getByCategory($catid);
48 $is_for_category = true;
50 $courses = $coursesDAO->getByMostRecent();
53 require(TR_INCLUDE_PATH.'header.inc.php');
55 $curr_page_num = intval($_GET['p']);
56 if (!$curr_page_num) {
59 $savant->assign('courses', $courses);
60 $savant->assign('categories', $courseCategoriesDAO->getAll());
61 $savant->assign('curr_page_num', $curr_page_num);
62 if ($is_for_category) {
63 $savant->assign('title', _AT('search_results'));
65 $savant->assign('title', _AT('most_recent_courses'));
68 $savant->display('home/index_course.tmpl.php');
70 require(TR_INCLUDE_PATH.'footer.inc.php');