2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002 - 2009 */
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('AT_INCLUDE_PATH', 'include/');
14 require(AT_INCLUDE_PATH . 'vitals.inc.php');
16 if (isset($_GET['cid'])) {
17 header('Location: '.$_base_href.'content.php?cid='.intval($_GET['cid']));
21 if (isset($_SESSION['course_id']))
22 $course_id = $_SESSION['course_id'];
23 else if (isset($_GET['p_course'])) // is set when pretty url is turned on and a public course is accessed
24 $course_id = $_GET['p_course'];
25 else // is set when guests access protected course
26 $course_id = $_GET['course'];
28 require(AT_INCLUDE_PATH . '../mods/_standard/tests/lib/test_result_functions.inc.php');
30 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
31 $course_base_href = 'get.php/';
33 $course_base_href = 'content/' . $course_id . '/';
36 //query reading the type of home viewable. 0: icon view 1: detail view
37 $sql = "SELECT home_view FROM ".TABLE_PREFIX."courses WHERE course_id = $course_id";
38 $result = mysql_query($sql,$db);
39 $row= mysql_fetch_assoc($result);
40 $home_view = $row['home_view'];
42 // Enable drag and drop to reorder displayed modules when the module view mode is
43 // set to "detail view" and user role is instructor
44 if ($home_view == 1 && authenticate(AT_PRIV_ADMIN,AT_PRIV_RETURN))
47 <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-text.css" />
48 <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-theme-mist.css" />
49 <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-theme-hc.css" />
50 <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/components/reorderer/css/Reorderer.css" />
52 <script type="text/javascript">
54 jQuery(document).ready(function () {
55 var reorder_example_grid = fluid.reorderGrid("#details_view", {
57 movables : ".home_box"
60 afterMove: function (item, requestedPosition, movables) {
61 //save the state to the db
62 var myDivs = jQuery ("div[class^=home_box]", "#details_view");
63 var moved_modules = "";
65 if (myDivs.constructor.toString().indexOf("Array")) // myDivs is an array
67 for (i=0; i<myDivs.length; i++)
68 moved_modules += myDivs[i].id+"|";
70 moved_modules = moved_modules.substring(0, moved_modules.length-1); // remove the last "|"
72 if (moved_modules != "")
73 jQuery.post("'.AT_BASE_HREF.'move_module.php", { "moved_modules":moved_modules, "from":"course_index" }, function(data) {});
77 selected: "draggable_selected",
78 hover: "draggable_selected"
84 function remove_module(module)
86 jQuery.post("'.AT_BASE_HREF.'move_module.php", { "remove":module, "from":"course_index" }, function(data) {});
87 jQuery("div[id=\""+module.replace(/\//g,"-")+"\"]").remove();
95 require(AT_INCLUDE_PATH . 'header.inc.php');
97 /* the "home" links: */
98 $home_links = get_home_navigation();
99 $savant->assign('home_links', $home_links);
102 /* the news announcements: */
105 $page = isset($_GET['p']) ? intval($_GET['p']) : 1;
110 $module =& $moduleFactory->getModule(AT_MODULE_DIR_STANDARD.'/announcements');
111 if (!$module->isEnabled()) {
115 $sql = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."news WHERE course_id=$course_id";
116 $result = mysql_query($sql, $db);
119 if ($result && ($row = mysql_fetch_assoc($result))) {
120 $num_results = $row['cnt'];
121 $results_per_page = NUM_ANNOUNCEMENTS;
122 $num_pages = ceil($num_results / $results_per_page);
124 $count = (($page-1) * $results_per_page) + 1;
126 $offset = ($page-1)*$results_per_page;
128 $sql = "SELECT N.*, DATE_FORMAT(N.date, '%Y-%m-%d %H:%i:%s') AS date, first_name, last_name
129 FROM ".TABLE_PREFIX."news N, ".TABLE_PREFIX."members M
130 WHERE N.course_id=$course_id
131 AND N.member_id = M.member_id
132 ORDER BY date DESC LIMIT $offset, $results_per_page";
134 $result = mysql_query($sql, $db);
135 while ($row = mysql_fetch_assoc($result)) {
136 /* this can't be cached because it called _AT */
138 $news[$row['news_id']] = array(
139 'date' => AT_date( _AT('announcement_date_format'),
141 AT_DATE_MYSQL_DATETIME),
142 'author' => $row['first_name'] . ' ' . $row['last_name'],
143 'title' => AT_print($row['title'], 'news.title'),
144 'body' => format_content($row['body'], $row['formatting'], $glossary));
149 $sql = "SELECT banner FROM ".TABLE_PREFIX."courses WHERE course_id=$course_id";
150 $result = mysql_query($sql, $db);
151 if ($row = mysql_fetch_assoc($result)) {
152 $savant->assign('banner', AT_print($row['banner'], 'courses.banner'));
154 $savant->assign('banner', '');
157 $savant->assign('view_mode', $home_view);
158 $savant->assign('announcements', $news);
159 $savant->assign('num_pages', $num_pages);
160 $savant->assign('current_page', $page);
161 $savant->display('index.tmpl.php');
163 require(AT_INCLUDE_PATH.'footer.inc.php');