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 /****************************************************************/
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
16 if (isset($_POST['enroll'])) {
19 $msg->addError('NO_STUDENT_SELECTED');
20 $_GET['tab'] = $_POST['tab'];
23 foreach ($_POST['id'] as $elem) {
24 $text .= 'id'.$i.'='.$elem.SEP;
27 header('Location: enroll_edit.php?'.$text.'func=enroll'.SEP.'tab=0'.SEP.'course_id='.$course_id);
30 } else if (isset($_POST['unenroll'])) {
31 // different from a plain delete. This removes from groups as well.
33 $msg->addError('NO_STUDENT_SELECTED');
34 $_GET['tab'] = $_POST['tab'];
37 foreach ($_POST['id'] as $elem) {
38 $text .= 'id'.$i.'='.$elem.SEP;
41 header('Location: enroll_edit.php?'.$text.'func=unenroll'.SEP.'tab=1'.SEP.'course_id='.$course_id);
44 } else if (isset($_POST['role'])) {
46 $msg->addError('NO_STUDENT_SELECTED');
47 $_GET['tab'] = $_POST['tab'];
50 foreach ($_POST['id'] as $elem) {
51 $text .= 'mid'.$i.'='.$elem.SEP;
54 header('Location: privileges.php?'.$text.SEP.'course_id='.$course_id);
57 } else if (isset($_POST['alumni'])) {
59 $msg->addError('NO_STUDENT_SELECTED');
60 $_GET['tab'] = $_POST['tab'];
63 foreach ($_POST['id'] as $elem) {
64 $text .= 'id'.$i.'='.$elem.SEP;
67 header('Location: enroll_edit.php?'.$text.'func=alumni'.SEP.'tab=2'.SEP.'course_id='.$course_id);
74 if ($_GET['reset_filter']) {
80 if (isset($_GET['role']) && ($_GET['role'] != '')) {
81 $filter['role'] = intval($_GET['role']);
84 if (isset($_GET['status']) && ($_GET['status'] != '')) {
85 $filter['status'] = intval($_GET['status']);
88 if (isset($_GET['group']) && ($_GET['group'] != '')) {
89 $filter['group'] = intval($_GET['group']);
92 require(AT_INCLUDE_PATH.'../mods/_core/enrolment/html/enroll_tab_functions.inc.php');
97 $num_tabs = count($tabs);
99 for ($i=0; $i < $num_tabs; $i++) {
100 if (isset($_POST['button_'.$i]) && ($_POST['button_'.$i] != -1)) {
102 $_POST['current_tab'] = $i;
107 //get present tab if specified
108 if ($_GET['current_tab']) {
109 $current_tab = $_GET['current_tab'];
110 $_POST['current_tab'] = $_GET['current_tab'];
113 $orders = array('asc' => 'desc', 'desc' => 'asc');
114 $cols = array('login' => 1, 'first_name' => 1, 'second_name' => 1, 'last_name' => 1, 'email' => 1);
116 if (isset($_GET['asc'])) {
118 $col = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'login';
119 } else if (isset($_GET['desc'])) {
121 $col = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'login';
127 $view_select = intval($_POST['view_select']);
129 // the possible tabs. order matters.
130 $tabs = array('enrolled', 'assistants', 'alumni', 'pending_enrollment', 'not_enrolled');
133 // Remove Not Enrolled tab if system preference is turned off 1.6.2
134 if($_config['allow_instructor_registration'] != 1){
138 $num_tabs = count($tabs);
139 if (isset($_REQUEST['tab'])) {
140 $current_tab = intval($_REQUEST['tab']);
143 if (!isset($current_tab)) {
147 if (isset($_GET['match']) && $_GET['match'] == 'one') {
148 $checked_match_one = ' checked="checked"';
149 $page_string .= SEP.'match=one';
151 $_GET['match'] = 'all';
152 $checked_match_all = ' checked="checked"';
153 $page_string .= SEP.'match=all';
156 if (admin_authenticate(AT_ADMIN_PRIV_ENROLLMENT, TRUE)) {
157 $page_string .= SEP.'course_id='.$course_id;
160 if ($_GET['search']) {
161 $page_string .= SEP.'search='.urlencode($_GET['search']);
162 $search = $addslashes($_GET['search']);
163 $search = explode(' ', $search);
165 if ($_GET['match'] == 'all') {
172 foreach ($search as $term) {
174 $term = str_replace(array('%','_'), array('\%', '\_'), $term);
176 $term = '%'.$term.'%';
177 $sql .= "((M.first_name LIKE '$term') OR (M.second_name LIKE '$term') OR (M.last_name LIKE '$term') OR (M.email LIKE '$term') OR (M.login LIKE '$term')) $predicate";
180 $sql = '('.substr($sql, 0, -strlen($predicate)).')';
186 $instructor_id = $system_courses[$course_id]['member_id'];
187 // retrieve all the members of this course (used later to get all those who aren't in this course)
188 $course_enrollment = get_group_concat('course_enrollment', 'member_id', "course_id=$course_id AND member_id<>$instructor_id");
189 $course_enrollment .= ','.$instructor_id;
191 $tab_counts = array();
192 $tab_sql_counts = array();
193 $tab_sql_counts[0] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE CE.course_id=$course_id
194 AND CE.approved='y' AND M.member_id<>$instructor_id AND CE.privileges=0 AND $search";
195 $tab_sql_counts[1] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE CE.course_id=$course_id
196 AND CE.approved='y' AND CE.privileges>0 AND $search";
197 $tab_sql_counts[2] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE CE.course_id=$course_id
198 AND approved='a' AND $search";
199 $tab_sql_counts[3] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE CE.course_id=$course_id
200 AND approved='n' AND $search";
201 $tab_sql_counts[4] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."members M WHERE M.status>1 AND M.member_id NOT IN ($course_enrollment) AND $search";
203 foreach ($tab_sql_counts as $tab => $sql) {
204 if ($tab == 3 && $system_courses[$course_id]['access'] != 'private') {
205 $tab_counts[$tab] = 0;
207 $result = mysql_query($sql);
208 $row = mysql_fetch_assoc($result);
209 $tab_counts[$tab] = $row['cnt'];
214 if ($current_tab == 0) {
216 $sql = "SELECT CE.member_id, CE.privileges, CE.approved, M.login, M.first_name, M.second_name, M.last_name, M.email
217 FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id)
218 WHERE CE.course_id=$course_id AND approved='y' AND M.member_id<>$instructor_id AND CE.privileges=0 AND $search
219 ORDER BY $col $order";
220 } else if ($current_tab == 1) {
222 $sql = "SELECT CE.member_id, CE.approved, CE.privileges, M.login, M.first_name, M.second_name, M.last_name, M.email
223 FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id)
224 WHERE CE.course_id=$course_id AND CE.approved='y' AND CE.privileges>0 AND $search
225 ORDER BY $col $order";
227 } else if ($current_tab == 3) {
229 if ($system_courses[$course_id]['access'] == 'private') {
230 $sql = "SELECT CE.member_id, CE.approved, CE.privileges, M.login, M.first_name, M.second_name, M.last_name, M.email
231 FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id)
232 WHERE CE.course_id=$course_id AND approved='n' AND $search
233 ORDER BY $col $order";
235 // not sure what this is about
236 // $sql_cnt = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."members WHERE 0";
237 $sql = "SELECT login FROM ".TABLE_PREFIX."members WHERE 0";
239 } else if ($current_tab == 2) {
241 $sql = "SELECT CE.member_id, CE.approved, CE.privileges, M.login, M.first_name, M.second_name, M.last_name, M.email
242 FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id)
243 WHERE CE.course_id=$course_id AND approved='a' AND $search
244 ORDER BY $col $order";
245 } else { // current_tab == 4
247 // $sql_cnt= "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."members M WHERE M.status>1 AND M.member_id NOT IN ($course_enrollment) AND $search";
249 $sql = "SELECT M.member_id, M.login, M.first_name, M.second_name, M.last_name, M.email FROM ".TABLE_PREFIX."members M WHERE M.member_id NOT IN ($course_enrollment) AND M.status>1 AND $search ORDER BY $col $order";
252 $results_per_page = 50;
254 $num_pages = max(ceil($tab_counts[$current_tab] / $results_per_page), 1);
255 $page = intval($_GET['p']);
259 $count = (($page-1) * $results_per_page) + 1;
260 $offset = ($page-1)*$results_per_page;
261 $sql .= " LIMIT $offset, $results_per_page";
263 $enrollment_result = mysql_query($sql, $db);
264 $page_string_w_tab = $page_string . SEP . 'tab='.$current_tab;
265 require(AT_INCLUDE_PATH.'header.inc.php');
269 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
270 <input type="hidden" name="tab" value="<?php echo $current_tab; ?>"/>
271 <input type="hidden" name="course_id" value="<?php echo $course_id; ?>"/>
272 <div class="input-form">
273 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('search'); ?></legend>
274 <?php if (admin_authenticate(AT_ADMIN_PRIV_ENROLLMENT, TRUE)): ?>
276 <label for="course"><?php echo _AT('course'); ?></label><br/>
277 <select name="course_id" id="course">
279 $sql = "SELECT course_id, title FROM ".TABLE_PREFIX."courses ORDER BY title";
280 $result = mysql_query($sql, $db);
281 while ($courses_row = mysql_fetch_assoc($result)) {
282 if ($courses_row['course_id'] == $course_id) {
283 echo '<option value="'.$courses_row['course_id'].'" selected="selected">'.validate_length($courses_row['title'], 45,VALIDATE_LENGTH_FOR_DISPLAY).'</option>';
285 echo '<option value="'.$courses_row['course_id'].'">'.validate_length($courses_row['title'],45,VALIDATE_LENGTH_FOR_DISPLAY).'</option>';
293 <label for="search"><?php echo _AT('search'); ?> (<?php echo _AT('login_name').', '._AT('first_name').', '._AT('second_name').', '._AT('last_name') .', '._AT('email'); ?>)</label><br />
294 <input type="text" name="search" id="search" size="40" value="<?php echo htmlspecialchars($_GET['search']); ?>" />
296 <?php echo _AT('search_match'); ?>:
297 <input type="radio" name="match" value="all" id="match_all" <?php echo $checked_match_all; ?> /><label for="match_all"><?php echo _AT('search_all_words'); ?></label> <input type="radio" name="match" value="one" id="match_one" <?php echo $checked_match_one; ?> /><label for="match_one"><?php echo _AT('search_any_word'); ?></label>
300 <div class="row buttons">
301 <input type="submit" name="filter" value="<?php echo _AT('filter'); ?>" />
302 <input type="submit" name="reset_filter" value="<?php echo _AT('reset_filter'); ?>" />
308 <?php print_paginator($page, $tab_counts[$current_tab], $page_string_w_tab . SEP . $order .'='. $col, $results_per_page); ?>
310 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="selectform">
311 <input type="hidden" name="tab" value="<?php echo $current_tab; ?>" />
312 <input type="hidden" name="course_id" value="<?php echo $course_id; ?>"/>
314 <ul id="etabbed-list">
315 <?php for ($i = 0; $i< $num_tabs; $i++): ?>
316 <?php if ($current_tab == $i): ?>
317 <li class="prefs_tab_selected"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?tab=<?php echo $i.$page_string; ?>" class="active"><strong><?php echo _AT($tabs[$i]); ?> - <?php echo $tab_counts[$i]; ?></strong></a></li>
319 <li class="prefs_tab"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?tab=<?php echo $i.$page_string; ?>"><?php echo _AT($tabs[$i]); ?> - <?php echo $tab_counts[$i]; ?></a></li>
325 <table class="data" style="width:95%;" summary="" rules="cols" >
327 <?php if ($col == 'login'): ?>
331 <?php elseif($col == 'first_name'): ?>
335 <?php elseif($col == 'second_name'): ?>
339 <?php elseif($col == 'last_name'): ?>
343 <?php elseif($col == 'email'): ?>
350 <th scope="col" align="left"><input type="checkbox" value="<?php echo _AT('select_all'); ?>" id="all" title="<?php echo _AT('select_all'); ?>" name="selectall" onclick="CheckAll();" /></th>
352 <th scope="col"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $orders[$order]; ?>=login<?php echo $page_string_w_tab;?>"><?php echo _AT('login_name'); ?></a></th>
354 <th scope="col"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $orders[$order]; ?>=first_name<?php echo $page_string_w_tab;?>"><?php echo _AT('first_name'); ?></a></th>
356 <th scope="col"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $orders[$order]; ?>=second_name<?php echo $page_string_w_tab;?>"><?php echo _AT('second_name'); ?></a></th>
358 <th scope="col"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $orders[$order]; ?>=last_name<?php echo $page_string_w_tab;?>"><?php echo _AT('last_name'); ?></a></th>
360 <th scope="col"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $orders[$order]; ?>=email<?php echo $page_string_w_tab;?>"><?php echo _AT('email'); ?></a></th>
366 <?php if ($current_tab == 0): ?>
367 <input type="submit" name="role" value="<?php echo _AT('privileges'); ?>" />
368 <input type="submit" name="unenroll" value="<?php echo _AT('remove'); ?>" />
369 <input type="submit" name="alumni" value="<?php echo _AT('mark_alumni'); ?>" />
370 <?php elseif ($current_tab == 1): ?>
371 <input type="submit" name="role" value="<?php echo _AT('privileges'); ?>" />
372 <input type="submit" name="unenroll" value="<?php echo _AT('remove'); ?>" />
374 <?php elseif ($current_tab == 2): ?>
375 <input type="submit" name="enroll" value="<?php echo _AT('enroll'); ?>" />
376 <input type="submit" name="unenroll" value="<?php echo _AT('remove'); ?>" />
378 <?php elseif ($current_tab == 3): ?>
379 <input type="submit" name="enroll" value="<?php echo _AT('enroll'); ?>" />
380 <input type="submit" name="unenroll" value="<?php echo _AT('remove'); ?>" />
382 <?php elseif ($current_tab == 4): ?>
383 <input type="submit" name="enroll" value="<?php echo _AT('enroll'); ?>" />
389 <?php if ($tab_counts[$current_tab]): ?>
390 <?php while ($row = mysql_fetch_assoc($enrollment_result)): ?>
391 <tr onmousedown="document.selectform['m<?php echo $row['member_id']; ?>'].checked = !document.selectform['m<?php echo $row['member_id']; ?>'].checked; togglerowhighlight(this, 'm<?php echo $row['member_id']; ?>');" id="rm<?php echo $row['member_id']; ?>">
392 <td><input type="checkbox" name="id[]" value="<?php echo $row['member_id']; ?>" id="m<?php echo $row['member_id']; ?>" onmouseup="this.checked=!this.checked" title="<?php echo AT_print($row['login'], 'members.login'); ?>" /></td>
393 <td><?php echo AT_print($row['login'], 'members.login'); ?></td>
394 <td><?php echo AT_print($row['first_name'], 'members.name'); ?></td>
395 <td><?php echo AT_print($row['second_name'], 'members.name'); ?></td>
396 <td><?php echo AT_print($row['last_name'], 'members.name'); ?></td>
397 <td><?php echo AT_print($row['email'], 'members.email'); ?></td>
402 <td colspan="6"><?php echo _AT('none_found'); ?></td>
409 <script language="JavaScript" type="text/javascript">
411 function CheckAll() {
412 for (var i=0;i<document.selectform.elements.length;i++) {
413 var e = document.selectform.elements[i];
414 if ((e.name == 'id[]') && (e.type=='checkbox')) {
415 e.checked = document.selectform.selectall.checked;
416 togglerowhighlight(document.getElementById("r" + e.id), e.id);
421 function togglerowhighlight(obj, boxid) {
422 if (document.getElementById(boxid).checked) {
423 obj.className = 'selected';
430 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>