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
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.'../mods/_core/enrolment/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
78 /************* INFO GATHERED **************/
\r
80 require(AT_INCLUDE_PATH.'header.inc.php');
\r
83 if ($_POST['verify']) {
\r
84 for ($i=0; $i<$_POST['count']; $i++) {
\r
85 $info = array('fname' => $_POST['fname'.$i], 'lname' => $_POST['lname'.$i], 'email' => $_POST['email'.$i], 'uname' => $_POST['uname'.$i], 'remove' => $_POST['remove'.$i]);
\r
86 $students[] = checkUserInfo($info);
\r
88 if (!empty($students[$i]['err_email']) || !empty($students[$i]['err_uname'])) {
\r
89 $still_errors = TRUE;
\r
93 /**************************************************************************/
\r
94 // !!!!!!STEP 3 - INSERT INTO DB !!!!!!!
\r
95 if (!$still_errors && (isset($_POST['submit_unenr']) || isset($_POST['submit_enr']))) {
\r
98 if (isset($_POST['submit_unenr'])) {
\r
102 add_users($students, $enroll, $_SESSION['course_id']);
\r
106 <div id="container">
\r
107 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="finalform" />
\r
108 <div class="input-form">
\r
110 $msg->printFeedbacks();
\r
112 <div class="row buttons">
\r
113 <input type="submit" name="addmore" value="<?php echo _AT('add_more'); ?>" />
\r
114 <input type="submit" name="return" value="<?php echo _AT('done'); ?>" />
\r
117 </form></div><?php
\r
122 // STEP 2 - INTERNAL VERIFICATION
\r
123 if ($still_errors || !isset($_POST['verify']) || isset($_POST['resubmit'])) { ?>
\r
125 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
\r
126 <input type="hidden" name="verify" value="1" />
\r
127 <input type="hidden" name="count" value="<?php echo count($students); ?>" />
\r
129 <table class="data static" summary="" rules="cols">
\r
132 <th scope="col"><?php echo _AT('status'); ?></th>
\r
133 <th scope="col"><?php echo _AT('first_name'); ?></th>
\r
134 <th scope="col"><?php echo _AT('last_name'); ?></th>
\r
135 <th scope="col"><?php echo _AT('email'); ?></th>
\r
136 <th scope="col"><?php echo _AT('login_name'); ?></th>
\r
137 <th scope="col"><?php echo _AT('remove'); ?></th>
\r
143 if (is_array($students)) {
\r
145 foreach ($students as $student) {
\r
146 echo '<tr><small>';
\r
147 echo '<td><span style="color: red;">';
\r
150 if(!empty($student['err_email'])) {
\r
151 echo $student['err_email'];
\r
154 if(!empty($student['err_uname'])) {
\r
155 if(!empty($student['err_email'])) {
\r
158 echo $student['err_uname'];
\r
160 if (empty($student['err_uname']) && empty($student['err_email'])) {
\r
162 if ($student['remove']) {
\r
163 echo '</span><span style="color: purple;">'._AT('removed');
\r
164 } else if ($student['err_disabled']) {
\r
165 echo '</span><span style="color: purple;">'._AT('disabled');
\r
166 } else if (!empty($student['exists'])) {
\r
167 echo '</span><span style="color: green;">'._AT('ok').' - '.$student['exists'];
\r
169 echo '</span><span style="color: green;">'._AT('ok');
\r
174 echo '</span></td>';
\r
176 if (empty($student['exists'])) {
\r
177 echo '<td><input type="text" name="fname'.$i.'" value="'.$student['fname'].'" /></td>';
\r
178 echo '<td><input type="text" name="lname'.$i.'" value="'.$student['lname'].'" /></td>';
\r
179 echo '<td><input type="text" name="email'.$i.'" value="'.$student['email'].'" /></td>';
\r
180 echo '<td><input type="text" name="uname'.$i.'" value="'.$student['uname'].'" />';
\r
181 echo '<td><input type="checkbox" ';
\r
182 echo ($student['remove'] ? 'checked="checked" value="on"' : '');
\r
183 echo 'name="remove'.$i.'" />';
\r
185 echo '<input type="hidden" name="fname'.$i.'" value="'.$student['fname'].'" />';
\r
186 echo '<input type="hidden" name="lname'.$i.'" value="'.$student['lname'].'" />';
\r
187 echo '<input type="hidden" name="email'.$i.'" value="'.$student['email'].'" />';
\r
188 echo '<input type="hidden" name="uname'.$i.'" value="'.$student['uname'].'" />';
\r
190 echo '<td>'.AT_print($student['fname'], 'members.first_name').'</td>';
\r
191 echo '<td>'.AT_print($student['lname'], 'members.last_name').'</td>';
\r
192 echo '<td>'.AT_print($student['email'], 'members.email').'</td>';
\r
193 echo '<td>'.AT_print($student['uname'], 'members.login').'</td>';
\r
194 echo '<td><input type="checkbox" ';
\r
195 echo ($student['remove'] ? 'checked="checked" value="on"' : '');
\r
196 echo 'name="remove'.$i.'" />';
\r
205 if ($still_errors || $err_count>0) {
\r
206 $dsbld = 'disabled="disabled"';
\r
212 <input type="submit" name="resubmit" value="<?php echo _AT('resubmit'); ?>" />
\r
213 <input type="submit" name="submit_enr" value="<?php echo _AT('list_add_enrolled_list'); ?>" <?php echo $dsbld; ?> />
\r
222 require(AT_INCLUDE_PATH.'footer.inc.php');
\r