2 /****************************************************************************/
4 /****************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************************/
16 $_user_location = 'users';
18 define('AT_INCLUDE_PATH', '../include/');
19 require(AT_INCLUDE_PATH.'vitals.inc.php');
21 if ($_SESSION['valid_user'] !== true) {
22 require(AT_INCLUDE_PATH.'header.inc.php');
24 $info = array('INVALID_USER', $_SESSION['course_id']);
25 $msg->printInfos($info);
27 require(AT_INCLUDE_PATH.'footer.inc.php');
33 // Get the course catagories
34 $sql = "SELECT * FROM ".TABLE_PREFIX."course_cats ORDER BY cat_name";
35 $result = mysql_query($sql,$db);
36 if(mysql_num_rows($result) != 0){
37 while($row = mysql_fetch_assoc($result)){
38 $current_cats[$row['cat_id']] = $row['cat_name'];
39 $parent_cats[$row['cat_id']] = $row['cat_parent'];
40 $cat_cats[$row['cat_id']] = $row['cat_id'];
45 $sql = "SELECT E.approved, E.last_cid, C.* FROM ".TABLE_PREFIX."course_enrollment E, ".TABLE_PREFIX."courses C WHERE E.member_id=$_SESSION[member_id] AND E.course_id=C.course_id ORDER BY C.title";
46 $result = mysql_query($sql,$db);
49 while ($row = mysql_fetch_assoc($result)) {
50 /* get tests for these courses: */
51 $tests['tests'] = array();
52 $sql3 = "SELECT test_id, title FROM ".TABLE_PREFIX."tests WHERE course_id=$row[course_id] AND (TO_DAYS(start_date) <= TO_DAYS(NOW()) AND TO_DAYS(end_date) >= TO_DAYS(NOW())) AND format=1";
53 $result3 = mysql_query($sql3,$db);
54 while ($row3 = mysql_fetch_assoc($result3)) {
55 $tests['tests'][] = $row3;
58 $courses[] = array_merge($row, (array) $tests);
61 function get_category_name($cat_id) {
63 $sql = "SELECT cat_name FROM ".TABLE_PREFIX."course_cats WHERE cat_id=".$cat_id;
64 $result = mysql_query($sql,$db);
65 $row = mysql_fetch_assoc($result);
67 if ($row['cat_name'] == '') {
68 $row['cat_name'] = _AT('cats_uncategorized');
70 return $row['cat_name'];
74 //$_SESSION['first_login'] = true; //for testing
75 if ($_SESSION['first_login']) {
76 $msg->addInfo(array('FIRST_PREFS', $_base_path.'users/pref_wizard/index.php'));
79 if (!$courses && get_instructor_status())
80 $msg->addInfo('NO_COURSES_INST');
82 $msg->addInfo('NO_COURSES');
85 //sort function for all_news
86 function all_news_cmp($a, $b){
87 if ($b['time'] < $a['time']){
89 } elseif ($b['time'] > $a['time']){
95 $all_news = array(); //all news
97 $module_status_bits = AT_MODULE_STATUS_ENABLED;
98 $module_type_bits = AT_MODULE_TYPE_STANDARD + AT_MODULE_TYPE_EXTRA;
100 $module_list = $moduleFactory->getModules($module_status_bits, $module_type_bits, $sort = TRUE);
102 foreach($module_list as $key=>$obj) {
103 $news = $obj->getNews();
104 while(!empty($news)){
105 $current_item = array_pop($news);
106 array_push($all_news, $current_item);
110 usort($all_news, 'all_news_cmp');
112 $savant->assign('all_news', $all_news);
113 $savant->assign('courses', $courses);
116 $savant->display('users/index.tmpl.php');