| @@ 157-166 (lines=10) @@ | ||
| 154 | $form->addElement('checkbox', 'unsubscribe', '', get_lang('UnsubscribeUserIfSubscriptionIsNotInFile')); |
|
| 155 | $form->addButtonImport(get_lang('Import')); |
|
| 156 | ||
| 157 | if ($form->validate()) { |
|
| 158 | $users_classes = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
| 159 | ||
| 160 | $errors = validate_data($users_classes); |
|
| 161 | if (count($errors) == 0) { |
|
| 162 | save_data($users_classes); |
|
| 163 | header('Location: class_list.php?action=show_message&message='.urlencode(get_lang('FileImported'))); |
|
| 164 | exit(); |
|
| 165 | } |
|
| 166 | } |
|
| 167 | ||
| 168 | Display :: display_header($tool_name); |
|
| 169 | api_display_tool_title($tool_name); |
|
| @@ 187-195 (lines=9) @@ | ||
| 184 | ||
| 185 | $ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'], '.') + 1)); |
|
| 186 | ||
| 187 | if (!in_array($ext_import_file, $allowed_file_mimetype)) { |
|
| 188 | Display :: display_error_message(get_lang('YouMustImportAFileAccordingToSelectedOption')); |
|
| 189 | } else { |
|
| 190 | $courses = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
| 191 | $errors = validate_data($courses); |
|
| 192 | if (count($errors) == 0) { |
|
| 193 | save_data($courses); |
|
| 194 | } |
|
| 195 | } |
|
| 196 | } |
|
| 197 | } |
|
| 198 | ||