2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
\r
6 /* Adaptive Technology Resource Centre / University of Toronto */
\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
15 define('AT_INCLUDE_PATH', '../../include/');
\r
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
\r
17 authenticate(AT_PRIV_ENROLLMENT);
\r
18 require(AT_INCLUDE_PATH.'lib/enroll.inc.php');
\r
20 /************ GETTING INFO FROM CREATE/IMPORT CALLS **********/
\r
21 if (isset($_POST['addmore'])) {
\r
22 //$msg->addFeedback('ADDMORE');
\r
23 header('Location: create_course_list.php');
\r
25 } else if (isset($_POST['return'])) {
\r
26 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
27 header('Location: index.php');
\r
29 } else if (isset($_POST['cancel'])) {
\r
30 $msg->addFeedback('CANCELLED');
\r
31 header('Location: index.php');
\r
33 } else if (isset($_POST['submit']) && !$_POST['verify']) {
\r
34 //CREATE COURSE LIST!!!!!!
\r
35 if ($_POST['from'] == 'create') {
\r
36 if (empty($_POST['first_name1']) && empty($_POST['last_name1']) && empty($_POST['email1'])) {
\r
37 $msg->addError('INCOMPLETE');
\r
38 header('Location: ./create_course_list.php');
\r
42 while ($_POST['first_name'.$j] || $_POST['last_name'.$j] || $_POST['email'.$j]) {
\r
43 $students[] = checkUserInfo(array('fname' => $_POST['first_name'.$j], 'lname' => $_POST['last_name'.$j], 'email' => $_POST['email'.$j]));
\r
48 //IMPORT COURSE LIST!!!!!!
\r
49 else if ($_POST['from'] == 'import') {
\r
50 if ($_FILES['file']['size'] < 1) {
\r
51 $msg->addError('FILE_EMPTY');
\r
52 header('Location: ./import_course_list.php');
\r
55 $fp = fopen($_FILES['file']['tmp_name'],'r');
\r
57 while ($data = fgetcsv($fp, 100000, ',')) {
\r
59 $num_fields = count($data);
\r
60 if ($num_fields == 3) {
\r
61 $students[] = checkUserInfo(array('fname' => $data[0], 'lname' => $data[1], 'email' => $data[2]));
\r
62 } else if ($num_fields != 1) {
\r
63 $errors = array('INCORRECT_FILE_FORMAT', $line_number);
\r
64 $msg->addError($errors);
\r
65 header('Location: ./import_course_list.php');
\r
67 } else if (($num_fields == 1) && (trim($data[0]) != '')) {
\r
68 $errors = array('INCORRECT_FILE_FORMAT', $line_number);
\r
69 $msg->addError($errors);
\r
70 header('Location: ./import_course_list.php');
\r
77 /************* INFO GATHERED **************/
\r
79 require(AT_INCLUDE_PATH.'header.inc.php');
\r
82 if ($_POST['verify']) {
\r
83 for ($i=0; $i<$_POST['count']; $i++) {
\r
84 $info = array('fname' => $_POST['fname'.$i], 'lname' => $_POST['lname'.$i], 'email' => $_POST['email'.$i], 'uname' => $_POST['uname'.$i], 'remove' => $_POST['remove'.$i]);
\r
85 $students[] = checkUserInfo($info);
\r
87 if (!empty($students[$i]['err_email']) || !empty($students[$i]['err_uname'])) {
\r
88 $still_errors = TRUE;
\r
92 /**************************************************************************/
\r
93 // !!!!!!STEP 3 - INSERT INTO DB !!!!!!!
\r
94 if (!$still_errors && (isset($_POST['submit_unenr']) || isset($_POST['submit_enr']))) {
\r
97 if (isset($_POST['submit_unenr'])) {
\r
101 add_users($students, $enroll, $_SESSION['course_id']);
\r
103 $msg->printFeedbacks(); ?>
\r
105 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="finalform" />
\r
106 <div class="input-form">
\r
107 <div class="row buttons">
\r
108 <input type="submit" name="addmore" value="<?php echo _AT('add_more'); ?>" />
\r
109 <input type="submit" name="return" value="<?php echo _AT('done'); ?>" />
\r
117 // STEP 2 - INTERNAL VERIFICATION
\r
118 if ($still_errors || !isset($_POST['verify']) || isset($_POST['resubmit'])) { ?>
\r
120 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
\r
121 <input type="hidden" name="verify" value="1" />
\r
122 <input type="hidden" name="count" value="<?php echo count($students); ?>" />
\r
124 <table class="data static" summary="" rules="cols">
\r
127 <th scope="col"><?php echo _AT('status'); ?></th>
\r
128 <th scope="col"><?php echo _AT('first_name'); ?></th>
\r
129 <th scope="col"><?php echo _AT('last_name'); ?></th>
\r
130 <th scope="col"><?php echo _AT('email'); ?></th>
\r
131 <th scope="col"><?php echo _AT('login_name'); ?></th>
\r
132 <th scope="col"><?php echo _AT('remove'); ?></th>
\r
138 if (is_array($students)) {
\r
140 foreach ($students as $student) {
\r
141 echo '<tr><small>';
\r
142 echo '<td><span style="color: red;">';
\r
145 if(!empty($student['err_email'])) {
\r
146 echo $student['err_email'];
\r
149 if(!empty($student['err_uname'])) {
\r
150 if(!empty($student['err_email'])) {
\r
153 echo $student['err_uname'];
\r
155 if (empty($student['err_uname']) && empty($student['err_email'])) {
\r
157 if ($student['remove']) {
\r
158 echo '</span><span style="color: purple;">'._AT('removed');
\r
159 } else if ($student['err_disabled']) {
\r
160 echo '</span><span style="color: purple;">'._AT('disabled');
\r
161 } else if (!empty($student['exists'])) {
\r
162 echo '</span><span style="color: green;">'._AT('ok').' - '.$student['exists'];
\r
164 echo '</span><span style="color: green;">'._AT('ok');
\r
169 echo '</span></td>';
\r
171 if (empty($student['exists'])) {
\r
172 echo '<td><input type="text" name="fname'.$i.'" value="'.$student['fname'].'" /></td>';
\r
173 echo '<td><input type="text" name="lname'.$i.'" value="'.$student['lname'].'" /></td>';
\r
174 echo '<td><input type="text" name="email'.$i.'" value="'.$student['email'].'" /></td>';
\r
175 echo '<td><input type="text" name="uname'.$i.'" value="'.$student['uname'].'" />';
\r
176 echo '<td><input type="checkbox" ';
\r
177 echo ($student['remove'] ? 'checked="checked" value="on"' : '');
\r
178 echo 'name="remove'.$i.'" />';
\r
180 echo '<input type="hidden" name="fname'.$i.'" value="'.$student['fname'].'" />';
\r
181 echo '<input type="hidden" name="lname'.$i.'" value="'.$student['lname'].'" />';
\r
182 echo '<input type="hidden" name="email'.$i.'" value="'.$student['email'].'" />';
\r
183 echo '<input type="hidden" name="uname'.$i.'" value="'.$student['uname'].'" />';
\r
185 echo '<td>'.AT_print($student['fname'], 'members.first_name').'</td>';
\r
186 echo '<td>'.AT_print($student['lname'], 'members.last_name').'</td>';
\r
187 echo '<td>'.AT_print($student['email'], 'members.email').'</td>';
\r
188 echo '<td>'.AT_print($student['uname'], 'members.login').'</td>';
\r
189 echo '<td><input type="checkbox" ';
\r
190 echo ($student['remove'] ? 'checked="checked" value="on"' : '');
\r
191 echo 'name="remove'.$i.'" />';
\r
200 if ($still_errors || $err_count>0) {
\r
201 $dsbld = 'disabled="disabled"';
\r
207 <input type="submit" name="resubmit" value="<?php echo _AT('resubmit'); ?>" />
\r
208 <input type="submit" name="submit_enr" value="<?php echo _AT('list_add_enrolled_list'); ?>" <?php echo $dsbld; ?> />
\r
217 require(AT_INCLUDE_PATH.'footer.inc.php');
\r