'index.php', 'name' => get_lang('PlatformAdmin')]; set_time_limit(0); if ($_POST['formSent']) { if (empty($_FILES['import_file']['tmp_name'])) { $error_message = get_lang('UplUploadFailed'); Display::addFlash(Display::return_message($error_message, 'error', false)); } else { $allowed_file_mimetype = ['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::addFlash( Display::return_message( get_lang('YouMustImportAZipFile'), 'error' ) ); } else { $errors = import_pdfs($subDir); if (count($errors) == 0) { error_log('Course intros imported successfully in '.__FILE__.', line '.__LINE__); } } } } if (count($errors) != 0) { $error_message = '
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 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[] = ['Line' => 0, 'Code' => $course['code'], 'Title' => $course['title']]; // Now add a link to the file from the Course description tool $link = 'CourseCode_NameOfDocument_CourseName.pdf e.g. MAT101_Introduction_to_Mathematics-101.pdf MAT102_Introduction_to_Mathematics-102.pdf ENG101_Introduction_to_English-101.pdf
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('Course presentation'); $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[] = ['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[] = ['Line' => 0, 'Code' => '.', 'Title' => get_lang('NoPDFFoundAtRoot')]; } return $errors; }