'index.php', 'name' => get_lang('PlatformAdmin')); set_time_limit(0); Display :: display_header($tool_name); $archivePath = api_get_path(SYS_ARCHIVE_PATH); $archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive='; $course_list = CourseManager::get_courses_list(); $formSent = null; $courses = $selected_courses = array(); if (isset($_POST['formSent']) && $_POST['formSent']) { $formSent = $_POST['formSent']; $select_type = intval($_POST['select_type']); $file_type = 'csv'; if ($select_type == 2) { // Get selected courses from courses list in form sent $selected_courses = $_POST['course_code']; if (is_array($selected_courses)) { foreach ($course_list as $course) { if (!in_array($course['code'],$selected_courses)) continue; $courses[] = $course; } } } else { // Get all courses $courses = $course_list; } if (!empty($courses)) { if (!file_exists($archivePath)) { mkdir($archivePath, api_get_permissions_for_new_directories(), true); } $archiveFile = 'export_courses_list_'.date('Y-m-d_H-i-s').'.'.$file_type; $fp = fopen($archivePath.$archiveFile,'w'); if ($file_type == 'csv') { $add = "Code;Title;CourseCategory;Teacher;Language;OtherTeachers;Users;".PHP_EOL; foreach($courses as $course) { $course['code'] = str_replace(';',',',$course['code']); $course['title'] = str_replace(';',',',$course['title']); $course['category_code'] = str_replace(';',',',$course['category_code']); $course['tutor_name'] = str_replace(';',',',$course['tutor_name']); $course['course_language'] = str_replace(';',',',$course['course_language']); $course['course_users'] = CourseManager::get_user_list_from_course_code($course['code']); $course['students'] = ''; $course['teachers'] = ''; foreach ($course['course_users'] as $user) { if ($user['status_rel'] == 1) { $course['teachers'] .= $user['username'].'|'; } else { $course['students'] .= $user['username'].'|'; } } $course['students'] = substr($course['students'],0,-1); $course['teachers'] = substr($course['teachers'],0,-1); $add.= $course['code'].';'.$course['title'].';'.$course['category_code'].';'.$course['tutor_name'].';'.$course['course_language'].';'.$course['teachers'].';'.$course['students'].';'.PHP_EOL; } fputs($fp, $add); } fclose($fp); $msg = get_lang('CoursesListHasBeenExported').'
'.get_lang('ClickHereToDownloadTheFile').''; } else { $msg = get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty'); } } if (!empty($msg)) { Display::display_normal_message($msg, false); } // @todo use FormValidator! ?>
: