Container::getRouter()->generate('administration'), 'name' => get_lang('PlatformAdmin')); set_time_limit(0); Display :: display_header($tool_name); if ($_POST['formSent']) { if (empty($_FILES['import_file']['tmp_name'])) { $error_message = get_lang('UplUploadFailed'); Display :: display_error_message($error_message, false); } else { $allowed_file_mimetype = array('zip'); $ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'], '.') + 1)); if (!in_array($ext_import_file, $allowed_file_mimetype)) { Display :: display_error_message(get_lang('YouMustImportAZipFile')); } else { $errors = import_pdfs($courses, $subDir); if (count($errors) == 0) { error_log('Course intros imported successfully in '.__FILE__.', line '.__LINE__); } } } } if (count($errors) != 0) { $error_message = ''; Display :: display_normal_message($error_message, false); } elseif ($_POST['formSent']) { Display :: display_confirmation_message('CourseIntroductionsAllImportesSuccessfully', false); } ?>

CourseCode_NameOfDocument_CourseName.pdf
e.g.
MAT101_Introduction_Mathematics-101.pdf
MAT102_Introduction_Mathematics-102.pdf
ENG101_Introduction_English-101.pdf
0) { // Build file info because handle_uploaded_document() needs it (name, type, size, tmp_name) $fileSize = filesize($baseDir.$uploadPath.$file); $docId = add_document($course, $subDir.'/'.$file, 'file', $fileSize, $parts[1].' '.substr($parts[2],0,-4)); if ($docId > 0) { if (!is_file($baseDir.$uploadPath.$file)) { error_log($baseDir.$uploadPath.$file.' does not exists in '.__FILE__); } if (is_file(api_get_path(SYS_COURSE_PATH).$course['path'].'/document'.$subDir.'/'.$file)) { error_log(api_get_path(SYS_COURSE_PATH).$course['path'].'/document'.$subDir.'/'.$file.' exists at destination in '.__FILE__); } if (!is_writeable(api_get_path(SYS_COURSE_PATH).$course['path'].'/document'.$subDir)) { error_log('Destination '.api_get_path(SYS_COURSE_PATH).$course['path'].'/document'.$subDir.' is NOT writeable in '.__FILE__); } // Place each file in its folder in each course $move = rename($baseDir.$uploadPath.$file, api_get_path(SYS_COURSE_PATH).$course['path'].'/document'.$subDir.'/'.$file); api_item_property_update($course, TOOL_DOCUMENT, $docId, 'DocumentAdded', api_get_user_id()); // Redo visibility api_set_default_visibility($docId, TOOL_DOCUMENT); $errors[] = array('Line' => 0, 'Code' => $course['code'], 'Title' => $course['title']); // Now add a link to the file from the Course description tool $link = '

Sílabo de la asignatura '.Display::return_icon('pdf.png').'

'; $course_description = new CourseDescription(); $session_id = api_get_session_id(); $course_description->set_course_id($course['real_id']); $course_description->set_session_id($session_id); $course_description->set_title('Presentación de la asignatura'); $course_description->set_content($link); $course_description->set_description_type(1); $course_description->insert(); } } else { error_log($parts[0].' is not a course, apparently'); $errors[] = array('Line' => 0, 'Code' => $parts[0], 'Title' => $parts[0].' - '.get_lang('CodeDoesNotExists')); } $i++; //found at least one entry that is not a dir or a . } if ($i == 0) { $errors[] = array('Line' => 0, 'Code' => '.', 'Title' => get_lang('NoPDFFoundAtRoot')); } return $errors; }