2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
13 if (!defined('AT_INCLUDE_PATH')) { exit; }
\r
18 * Generates the tabs for the enroll admin page
\r
20 * @return string The tabs for the enroll_admin page
\r
21 * @author Shozub Qureshi
\r
23 function get_tabs() {
\r
24 //these are the _AT(x) variable names and their include file
\r
25 /* tabs[tab_id] = array(tab_name, file_name, accesskey) */
\r
26 $tabs[0] = array('enrolled', 'enroll_admin.php', 'e');
\r
27 $tabs[1] = array('unenrolled', 'enroll_admin.php', 'u');
\r
28 //$tabs[2] = array('assistants', 'enroll_admin.php', 'a');
\r
29 $tabs[2] = array('alumni', 'enroll_admin.php', 'a');
\r
35 * Generates the html for the enrollment tables
\r
37 * @param string $condition the condition to be imposed in the sql query (approved = y/n/a)
\r
38 * @param string $col the column to be sorted
\r
39 * @param string $order the sorting order (DESC or ASC)
\r
40 * @param int $unenr is one if the unenrolled list is being generated
\r
41 * @author Shozub Qureshi
\r
42 * @author Joel Kronenberg
\r
44 function generate_table($condition, $col, $order, $unenr, $filter) {
\r
47 if ($filter['role'] == -1) {
\r
48 $condition .= ' AND CE.privileges<>0';
\r
50 if ($filter['group'] > 0) {
\r
51 $sql = "SELECT member_id FROM ".TABLE_PREFIX."groups_members WHERE group_id=".$filter['group'];
\r
52 $result = mysql_query($sql, $db);
\r
53 while ($row = mysql_fetch_assoc($result)) {
\r
54 $members_list .= ',' . $row['member_id'];
\r
56 $condition .= ' AND CE.member_id IN (0'.$members_list.')';
\r
58 if (isset($filter['status'])) {
\r
59 $condition .= ' AND M.status='.$filter['status'];
\r
62 //output list of enrolled students
\r
63 $sql = "SELECT CE.member_id, CE.role, M.login, M.first_name, M.last_name, M.email, M.status
\r
64 FROM ".TABLE_PREFIX."course_enrollment CE, ".TABLE_PREFIX."members M
\r
65 WHERE CE.course_id=$_SESSION[course_id] AND CE.member_id=M.member_id AND ($condition)
\r
66 ORDER BY $col $order";
\r
67 $result = mysql_query($sql, $db);
\r
69 //if table is empty display message
\r
70 if (mysql_num_rows($result) == 0) {
\r
71 echo '<tr><td colspan="6">'._AT('none_found').'</td></tr>';
\r
73 while ($row = mysql_fetch_assoc($result)) {
\r
74 echo '<tr onmousedown="document.selectform[\'m' . $row['member_id'] . '\'].checked = !document.selectform[\'m' . $row['member_id'] . '\'].checked;">';
\r
78 if ($row['member_id'] == $_SESSION['member_id']) {
\r
79 $act = 'disabled="disabled"';
\r
82 echo '<input type="checkbox" name="id[]" value="'.$row['member_id'].'" id="m'.$row['member_id'].'" ' . $act . ' onmouseup="this.checked=!this.checked" title="'.AT_print($row['login'], 'members.login').'" />';
\r
83 echo AT_print($row['login'], 'members.login') . '</td>';
\r
84 echo '<td>' . AT_print($row['first_name'], 'members.name') . '</td>';
\r
85 echo '<td>' . AT_print($row['last_name'], 'members.name') . '</td>';
\r
86 echo '<td>' . AT_print($row['email'], 'members.email') . '</td>';
\r
88 //if role not already assigned, assign role to be student
\r
89 //and we are not vieiwing list of unenrolled students
\r
91 if ($row['status'] == AT_STATUS_DISABLED) {
\r
92 echo _AT('disabled');
\r
93 } else if ($row['status'] == AT_STATUS_UNCONFIRMED) {
\r
94 echo _AT('unconfirmed');
\r
95 } else if ($row['role'] == '' && $unenr != 1) {
\r
96 echo _AT('Student');
\r
97 } else if ($unenr == 1) {
\r
100 echo AT_print($row['role'], 'members.role');
\r
111 * Generates the html for the SORTED enrollment tables
\r
113 * @param int $curr_tab the current tab (enrolled, unenrolled or alumni)
\r
114 * @author Shozub Qureshi
\r
116 function display_columns ($curr_tab) {
\r
120 <th scope="col"><input type="checkbox" value="<?php echo _AT('select_all'); ?>" id="all" title="<?php echo _AT('select_all'); ?>" name="selectall" onclick="CheckAll();" /> <a href="mods/_core/enrolment/index.php?<?php echo $orders[$order]; ?>=login<?php echo SEP;?>current_tab=<?php echo $curr_tab; ?>"><?php echo _AT('login_name'); ?></a></th>
\r
122 <th scope="col"><a href="mods/_core/enrolment/index.php?<?php echo $orders[$order]; ?>=first_name<?php echo SEP;?>current_tab=<?php echo $curr_tab; ?>"><?php echo _AT('first_name'); ?></a></th>
\r
124 <th scope="col"><a href="mods/_core/enrolmentt/index.php?<?php echo $orders[$order]; ?>=last_name<?php echo SEP;?>current_tab=<?php echo $curr_tab; ?>"><?php echo _AT('last_name'); ?></a></th>
\r
126 <th scope="col"><a href="mods/_core/enrolment/index.php?<?php echo $orders[$order]; ?>=email<?php echo SEP;?>current_tab=<?php echo $curr_tab; ?>"><?php echo _AT('email'); ?></a></th>
\r
128 <th scope="col"><a href="mods/_core/enrolment/index.php?<?php echo $orders[$order]; ?>=role<?php echo SEP;?>current_tab=<?php echo $curr_tab; ?>"><?php echo _AT('role').'/'._AT('status'); ?></a></th>
\r