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 if (!defined('TR_INCLUDE_PATH')) { exit; }
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'classes/DAO/UserCoursesDAO.class.php');
17 // can only be used by login user
18 if (!isset($_SESSION['user_id']) || $_SESSION['user_id'] == 0) return;
20 global $savant, $_course_id;
22 $userCoursesDAO = new UserCoursesDAO();
25 // The main page can be home/index.php or home/search.php
26 // Find out the caller URL and direct the page back to the caller
27 // after adding/removing the course from "My Courses"
28 list($caller_url, $url_param) = Utility::getRefererURLAndParams();
30 // retrieve data to display
31 if ($_SESSION['user_id'] > 0) {
32 $my_courses = $userCoursesDAO->getByUserID($_SESSION['user_id']);
35 if (!is_array($my_courses)) {
37 $output = _AT('none_found');
39 $num_of_courses = count($my_courses);
41 $output .= '<ol class="remove-margin-left">'."\n";
43 foreach ($my_courses as $row) {
44 // only display the first 200 character of course description
46 if ($row['role'] == TR_USERROLE_AUTHOR) {
47 $output .= ' <li class="mine" title="'. _AT('my_authoring_course').': '. $row['title'].'"> '."\n";
49 $output .= ' <li class="theirs" title="'. _AT('others_course').': '. $row['title'].'">'."\n";
51 $output .= ' <a href="'. TR_BASE_HREF.'home/course/index.php?_course_id='. $row['course_id'].'"'.(($_course_id == $row['course_id']) ? ' class="selected-sidemenu"' : '').'>'.$row['title'].'</a>'."\n";
52 if ($row['role'] == TR_USERROLE_VIEWER) {
53 $output .= ' <a href="'. TR_BASE_HREF.'home/'. $caller_url.'action=remove'.SEP.'cid='. $row['course_id'].'">'."\n";
54 $output .= ' <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/bookmark_remove.png" alt="'. htmlspecialchars(_AT('remove_from_list')).'" title="'. htmlspecialchars(_AT('remove_from_list')).'" border="0" />'."\n";
55 $output .= ' </a>'."\n";
57 if ($row['role'] == NULL && $_SESSION['user_id']>0) {
58 $output .= ' <a href="'. TR_BASE_HREF.'home/'. $caller_url.'action=add'.SEP.'cid='. $row['course_id'].'">'."\n";
59 $output .= ' <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/bookmark_add.png" alt="'. htmlspecialchars(_AT('add_into_list')).'" title="'. htmlspecialchars(_AT('add_into_list')).'" border="0" />'."\n";
60 $output .= ' </a>'."\n";
62 //$output .= ' <a href="'. TR_BASE_HREF.'home/ims/ims_export.php?course_id='. $row['course_id'].'">'."\n";
63 //$output .= ' <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/export.png" alt="'. _AT('download_content_package').'" title="'. _AT('download_content_package').'" border="0" />'."\n";
64 //$output .= ' </a>'."\n";
65 //if ($row['role'] == TR_USERROLE_AUTHOR) {
66 //$output .= ' <a href="'. TR_BASE_HREF.'home/imscc/ims_export.php?course_id='. $row['course_id'].'">'."\n";
67 //$output .= ' <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/export_cc.png" alt="'. _AT('download_common_cartridge').'" title="'. _AT('download_common_cartridge').'" border="0" />'."\n";
68 //$output .= ' </a>'."\n";
70 $output .= ' </li>'."\n";
72 $output .= '</ol>'."\n";
74 $savant->assign('title', _AT('my_courses').' '.'('.$num_of_courses.')');
75 $savant->assign('dropdown_contents', $output);
76 //$savant->assign('default_status', "hide");
78 $savant->display('include/box.tmpl.php');