/* the 'content_path' field in the content table will be set to this path. */ /* $package_base_name_url comes from the URL file name (NOT the file name of the actual file we open)*/ if (!$package_base_name && $package_base_name_url) { $package_base_name = substr($package_base_name_url, 0, -4); } else { if (!$package_base_name) { $package_base_name = substr($_FILES['file']['name'], 0, -4); } } // create course if (isset($_POST['hide_course'])) { $access = 'private'; } else { $access = 'public'; } $course_id = $coursesDAO->Create($_SESSION['user_id'], 'top', $access, $package_base_name, $package_base_description, '', '', '', '', $package_primay_lang, '', ''); $package_base_name = strtolower($package_base_name); $package_base_name = str_replace(array('\'', '"', ' ', '|', '\\', '/', '<', '>', ':'), '_', $package_base_name); $package_base_name = preg_replace("/[^A-Za-z0-9._\\-]/", '', $package_base_name); if (is_dir(TR_TEMP_DIR . $course_id . '/' . $package_base_name)) { $package_base_name .= '_' . date('ymdHis'); } if ($package_base_path) { $package_base_path = implode('/', $package_base_path); } elseif (empty($package_base_path)) { $package_base_path = ''; } if ($xml_base_path) { $package_base_path = $xml_base_path . $package_base_path; mkdir(TR_TEMP_DIR . $course_id . '/' . $xml_base_path); $package_base_name = $xml_base_path . $package_base_name;
$access = 'private'; } else { $access = 'public'; } if ($_course_id > 0) { // update an existing course $coursesDAO->UpdateField($_course_id, 'title', $_POST['title']); $coursesDAO->UpdateField($_course_id, 'category_id', $_POST['category_id']); $coursesDAO->UpdateField($_course_id, 'primary_language', $_POST['pri_lang']); $coursesDAO->UpdateField($_course_id, 'description', $_POST['description']); $coursesDAO->UpdateField($_course_id, 'copyright', $_POST['copyright']); $coursesDAO->UpdateField($_course_id, 'access', $access); $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); } else { // create a new course if ($course_id = $coursesDAO->Create($_SESSION['user_id'], 'top', $access, $_POST['title'], $_POST['description'], null, null, null, $_POST['copyright'], $_POST['pri_lang'], null, null)) { $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); header('Location: ' . TR_BASE_HREF . 'home/course/index.php?_course_id=' . $course_id); exit; } } } } // display if ($_course_id > 0) { $savant->assign('course_id', $_course_id); $savant->assign('course_row', $coursesDAO->get($_course_id)); } global $onload; $onload = "document.form.title.focus();"; require TR_INCLUDE_PATH . 'header.inc.php';
// added by Cindy Li on Jan 10, 2010 // generate a course_id if the import is not into an existing course if (!isset($_POST['_course_id'])) { if (isset($_POST['hide_course'])) { $access = 'private'; } else { $access = 'public'; } if (isset($course_primary_lang) && $course_primary_lang != '') { $langcode_and_charset = explode('-', $course_primary_lang); // $course_primary_lang = Utility::get3LetterLangCode($langcode_and_charset[0]); $course_primary_lang = $langcode_and_charset[0]; } else { $course_primary_lang = DEFAULT_LANGUAGE_CODE; } $_course_id = $coursesDAO->Create($_SESSION['user_id'], 'top', $access, $course_title, $course_description, '', '', '', '', $course_primary_lang, '', ''); check_available_size($_course_id); // insert author role into table "user_courses" $userCoursesDAO = new UserCoursesDAO(); $userCoursesDAO->Create($_SESSION['user_id'], $_course_id, TR_USERROLE_AUTHOR, 0); } else { $_course_id = $_POST['_course_id']; } // end of added by Cindy Li on Jan 10, 2010 /* generate a unique new package base path based on the package file name and date as needed. */ /* the package name will be the dir where the content for this package will be put, as a result */ /* the 'content_path' field in the content table will be set to this path. */ /* $package_base_name_url comes from the URL file name (NOT the file name of the actual file we open)*/ if (!$package_base_name && $package_base_name_url) { $package_base_name = substr($package_base_name_url, -6); } else {