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 /****************************************************************************/
15 define('AT_INCLUDE_PATH', '../../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 admin_authenticate(AT_ADMIN_PRIV_COURSES);
19 if (isset($_GET['view'], $_GET['id'])) {
20 header('Location:instructor_login.php?course='.$_GET['id']);
22 } else if (isset($_GET['edit'], $_GET['id'])) {
24 header('Location: ../../properties/admin/edit_course.php?course='.$_GET['id']);
26 } else if (isset($_GET['backups'], $_GET['id'])) {
27 header('Location: ../../backups/admin/index.php?course='.$_GET['id']);
29 } else if (isset($_GET['delete'], $_GET['id'])) {
30 header('Location: ../../properties/admin/delete_course.php?course='.$_GET['id']);
32 } else if (isset($_GET['delete']) || isset($_GET['backups']) || isset($_GET['edit']) || isset($_GET['view'])) {
33 $msg->addError('NO_ITEM_SELECTED');
36 require(AT_INCLUDE_PATH.'header.inc.php');
40 if ($_GET['reset_filter']) {
44 $orders = array('asc' => 'desc', 'desc' => 'asc');
45 $cols = array('title' => 1, 'login' => 1, 'access' => 1, 'created_date' => 1, 'cat_name' => 1);
46 $_access = array('public', 'protected', 'private');
48 if (isset($_GET['asc'])) {
50 $col = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'title';
51 } else if (isset($_GET['desc'])) {
53 $col = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'title';
60 if (isset($_GET['access']) && ($_GET['access'] != '') && isset($_access[$_GET['access']])) {
61 $access = 'C.access = \'' . $_access[$_GET['access']].'\'';
62 $page_string .= SEP.'access='.$_GET['access'];
67 if ($_GET['search']) {
68 $page_string .= SEP.'search='.urlencode($_GET['search']);
69 $search = $addslashes($_GET['search']);
70 $search = str_replace(array('%','_'), array('\%', '\_'), $search);
71 $search = '%'.$search.'%';
72 $search = "((C.title LIKE '$search') OR (C.description LIKE '$search'))";
77 // get number of courses on the system
78 $sql = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."courses C WHERE 1 AND $access AND $search";
79 $result = mysql_query($sql, $db);
80 $row = mysql_fetch_assoc($result);
81 $num_results = $row['cnt'];
83 $results_per_page = 100;
84 $num_pages = max(ceil($num_results / $results_per_page), 1);
85 $page = intval($_GET['p']);
89 $count = (($page-1) * $results_per_page) + 1;
90 $offset = ($page-1)*$results_per_page;
92 ${'highlight_'.$col} = ' style="background-color: #fff;"';
94 $sql = "SELECT COUNT(*) AS cnt, approved, course_id FROM ".TABLE_PREFIX."course_enrollment WHERE approved='y' OR approved='a' GROUP BY course_id, approved";
95 $result = mysql_query($sql, $db);
96 while ($row = mysql_fetch_assoc($result)) {
97 if ($row['approved'] == 'y') {
98 $row['cnt']--; // remove the instructor
100 $enrolled[$row['course_id']][$row['approved']] = $row['cnt'];
103 $sql = "SELECT C.*, M.login, T.cat_name FROM ".TABLE_PREFIX."members M INNER JOIN ".TABLE_PREFIX."courses C USING (member_id) LEFT JOIN ".TABLE_PREFIX."course_cats T USING (cat_id) WHERE 1 AND $access AND $search ORDER BY $col $order LIMIT $offset, $results_per_page";
104 $result = mysql_query($sql, $db);
106 $num_rows = mysql_num_rows($result);
109 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
110 <div class="input-form">
112 <h3><?php echo _AT('results_found', $num_results); ?></h3>
116 <?php echo _AT('access'); ?><br />
118 <input type="radio" name="access" value="0" id="s0" <?php if ($_GET['access'] == 0) { echo 'checked="checked"'; } ?> /><label for="s0"><?php echo _AT('public'); ?></label>
120 <input type="radio" name="access" value="1" id="s1" <?php if ($_GET['access'] == 1) { echo 'checked="checked"'; } ?> /><label for="s1"><?php echo _AT('protected'); ?></label>
122 <input type="radio" name="access" value="2" id="s2" <?php if ($_GET['access'] == 2) { echo 'checked="checked"'; } ?> /><label for="s2"><?php echo _AT('private'); ?></label>
124 <input type="radio" name="access" value="" id="s" <?php if ($_GET['access'] == '') { echo 'checked="checked"'; } ?> /><label for="s"><?php echo _AT('all'); ?></label>
128 <label for="search"><?php echo _AT('search'); ?> (<?php echo _AT('title').', '._AT('description'); ?>)</label><br />
129 <input type="text" name="search" id="search" size="20" value="<?php echo htmlspecialchars($_GET['search']); ?>" />
132 <div class="row buttons">
133 <input type="submit" name="filter" value="<?php echo _AT('filter'); ?>" />
134 <input type="submit" name="reset_filter" value="<?php echo _AT('reset_filter'); ?>" />
139 <?php print_paginator($page, $num_results, $page_string . SEP . $order .'='. $col, $results_per_page); ?>
141 <form name="form" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
143 <table class="data" summary="" rules="cols">
145 <?php if ($col == 'title'): ?>
149 <?php elseif($col == 'login'): ?>
153 <?php elseif($col == 'access'): ?>
157 <?php elseif($col == 'created_date'): ?>
161 <?php elseif($col == 'cat_name'): ?>
169 <th scope="col"> </th>
170 <th scope="col"><a href="mods/_core/courses/admin/courses.php?<?php echo $orders[$order]; ?>=title<?php echo $page_string; ?>"><?php echo _AT('title'); ?></a></th>
171 <th scope="col"><a href="mods/_core/courses/admin/courses.php?<?php echo $orders[$order]; ?>=login<?php echo $page_string; ?>"><?php echo _AT('Instructor'); ?></a></th>
172 <th scope="col"><a href="mods/_core/courses/admin/courses.php?<?php echo $orders[$order]; ?>=access<?php echo $page_string; ?>"><?php echo _AT('access'); ?></a></th>
173 <th scope="col"><a href="mods/_core/courses/admin/courses.php?<?php echo $orders[$order]; ?>=created_date<?php echo $page_string; ?>"><?php echo _AT('created_date'); ?></a></th>
174 <th scope="col"><a href="mods/_core/courses/admin/courses.php?<?php echo $orders[$order]; ?>=cat_name<?php echo $page_string; ?>"><?php echo _AT('category'); ?></a></th>
175 <th scope="col"><?php echo _AT('enrolled'); ?></th>
176 <th scope="col"><?php echo _AT('alumni'); ?></th>
181 <td colspan="8"><input type="submit" name="view" value="<?php echo _AT('view'); ?>" />
182 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />
183 <input type="submit" name="backups" value="<?php echo _AT('backups'); ?>" />
184 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /></td>
188 <?php if ($num_rows): ?>
189 <?php while ($row = mysql_fetch_assoc($result)): ?>
190 <tr onmousedown="document.form['m<?php echo $row['course_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['course_id']; ?>">
191 <td><input type="radio" name="id" value="<?php echo $row['course_id']; ?>" id="m<?php echo $row['course_id']; ?>" /></td>
192 <td><label for="m<?php echo $row['course_id']; ?>"><?php echo AT_print($row['title'], 'courses.title'); ?></label></td>
193 <td><?php echo AT_print($row['login'],'members.login'); ?></td>
194 <td><?php echo _AT($row['access']); ?></td>
195 <td><?php echo AT_date($startend_date_long_format, $row['created_date'], AT_DATE_UNIX_TIMESTAMP); ?></td>
196 <td><?php echo ($row['cat_name'] ? $row['cat_name'] : '-')?></td>
197 <td><?php echo ($enrolled[$row['course_id']]['y'] ? $enrolled[$row['course_id']]['y'] : 0); ?></td>
198 <td><?php echo ($enrolled[$row['course_id']]['a'] ? $enrolled[$row['course_id']]['a'] : 0); ?></td>
203 <td colspan="8"><?php echo _AT('none_found'); ?></td>
209 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>