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 $_user_location = 'admin';
16 define('AT_INCLUDE_PATH', '../../../include/');
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 admin_authenticate(AT_ADMIN_PRIV_ENROLLMENT);
20 if (isset($_POST['cancel'])) {
21 $msg->addFeedback('CANCELLED');
22 header('Location: '.AT_BASE_HREF.'mods/_core/users/users.php');
24 } else if (isset($_POST['enrolled_unenroll'])) {
25 $_POST['id'] = intval($_POST['id']);
27 if (!is_array($_POST['enrolled'])) {
28 $msg->addError('NO_ITEM_SELECTED');
30 $cids = implode(',', $_POST['enrolled']);
31 $sql = "DELETE FROM ".TABLE_PREFIX."course_enrollment WHERE member_id={$_POST['id']} AND course_id IN ($cids)";
32 mysql_query($sql, $db);
34 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
35 header('Location: '.$_SERVER['PHP_SELF'] . '?id='.$_POST['id']);
38 } else if (isset($_POST['pending_remove'])) {
39 $_POST['id'] = intval($_POST['id']);
41 if (!is_array($_POST['pending'])) {
42 $msg->addError('NO_ITEM_SELECTED');
44 $cids = implode(',', $_POST['pending']);
45 $sql = "DELETE FROM ".TABLE_PREFIX."course_enrollment WHERE member_id={$_POST['id']} AND course_id IN ($cids)";
46 mysql_query($sql, $db);
48 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
49 header('Location: '.$_SERVER['PHP_SELF'] . '?id='.$_POST['id']);
52 } else if (isset($_POST['pending_enroll'])) {
53 $_POST['id'] = intval($_POST['id']);
55 if (!is_array($_POST['pending'])) {
56 $msg->addError('NO_ITEM_SELECTED');
58 $cids = implode(',', $_POST['pending']);
59 $sql = "UPDATE ".TABLE_PREFIX."course_enrollment SET approved='y' WHERE member_id={$_POST['id']} AND course_id IN ($cids)";
60 mysql_query($sql, $db);
62 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
63 header('Location: '.$_SERVER['PHP_SELF'] . '?id='.$_POST['id']);
66 } else if (isset($_POST['not_enrolled_enroll'])) {
67 $_POST['id'] = intval($_POST['id']);
69 if (!is_array($_POST['not_enrolled'])) {
70 $msg->addError('NO_ITEM_SELECTED');
72 foreach ($_POST['not_enrolled'] as $cid) {
73 $sql = "INSERT INTO ".TABLE_PREFIX."course_enrollment VALUES ({$_POST['id']}, $cid, 'y', 0, '', 0)";
74 mysql_query($sql, $db);
76 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
77 header('Location: '.$_SERVER['PHP_SELF'] . '?id='.$_POST['id']);
82 $id = intval($_GET['id']);
84 // add the user's name to the page heading:
85 $_pages['mods/_core/users/user_enrollment.php']['title'] = _AT('enrollment').': '.get_display_name($id);
87 require(AT_INCLUDE_PATH.'header.inc.php');
89 $sql = "SELECT login FROM ".TABLE_PREFIX."members WHERE member_id=$id";
90 $result = mysql_query($sql, $db);
92 if (!$row = mysql_fetch_assoc($result)) {
93 $msg->printErrors('USER_NOT_FOUND');
94 require(AT_INCLUDE_PATH.'footer.inc.php');
98 $enrollment = array();
99 $sql = "SELECT * FROM ".TABLE_PREFIX."course_enrollment WHERE member_id=$id";
100 $result = mysql_query($sql, $db);
101 while ($row = mysql_fetch_assoc($result)) {
102 $enrollment[$row['course_id']] = $row;
108 $not_enrolled = array();
110 foreach ($system_courses as $cid => $course) {
111 if ($course['member_id'] == $id) {
113 } else if (isset($enrollment[$cid]) && $enrollment[$cid]['approved'] == 'y') {
115 } else if (isset($enrollment[$cid]) && $enrollment[$cid]['approved'] == 'n') {
118 $not_enrolled[] = $cid;
124 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?id=<?php echo $id; ?>">
125 <input type="hidden" name="id" value="<?php echo $id; ?>"/>
126 <div class="input-form" style="min-width: 400px; width: 45%; float: left; margin: 5px">
128 <h3><?php echo _AT('instructor'); ?></h3>
129 <?php if ($instruct): ?>
131 <?php foreach ($instruct as $cid): ?>
132 <li><?php echo $system_courses[$cid]['title']; ?></li>
136 <?php echo _AT('none'); ?>
139 <div class="row buttons">
140 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>"/>
144 <div class="input-form" style="min-width: 400px; width: 45%; float: left; margin: 5px">
146 <h3><?php echo _AT('enrolled'); ?></h3>
147 <?php if ($enrolled): ?>
149 <?php foreach ($enrolled as $cid): ?>
150 <li><input type="checkbox" name="enrolled[]" value="<?php echo $cid; ?>" id="c<?php echo $cid; ?>"/><label for="c<?php echo $cid; ?>"><?php echo $system_courses[$cid]['title']; ?></label></li>
154 <?php echo _AT('none'); ?>
157 <div class="row buttons">
158 <?php if ($enrolled): ?>
159 <input type="submit" name="enrolled_unenroll" value="<?php echo _AT('unenroll'); ?>"/>
161 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>"/>
166 <div class="input-form" style="min-width: 400px; width: 45%; float: left; margin: 5px">
168 <h3><?php echo _AT('pending_enrollment'); ?></h3>
169 <?php if ($pending): ?>
171 <?php foreach ($pending as $cid): ?>
172 <li><input type="checkbox" name="pending[]" value="<?php echo $cid; ?>" id="c<?php echo $cid; ?>"/><label for="c<?php echo $cid; ?>"><?php echo $system_courses[$cid]['title']; ?></label></li>
176 <?php echo _AT('none'); ?>
179 <div class="row buttons">
180 <?php if ($pending): ?>
181 <input type="submit" name="pending_remove" value="<?php echo _AT('remove'); ?>"/>
182 <input type="submit" name="pending_enroll" value="<?php echo _AT('enroll'); ?>"/>
184 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>"/>
188 <div class="input-form" style="min-width: 400px; width: 45%; float: left; margin: 5px">
190 <h3><?php echo _AT('not_enrolled');?></h3>
191 <?php if ($not_enrolled): ?>
193 <?php foreach ($not_enrolled as $cid): ?>
194 <li><input type="checkbox" name="not_enrolled[]" value="<?php echo $cid; ?>" id="c<?php echo $cid; ?>"/><label for="c<?php echo $cid; ?>"><?php echo $system_courses[$cid]['title']; ?></label></li>
198 <?php echo _AT('none'); ?>
201 <div class="row buttons">
202 <?php if ($not_enrolled): ?>
203 <input type="submit" name="not_enrolled_enroll" value="<?php echo _AT('enroll'); ?>"/>
205 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>"/>
210 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>