upload.scorm.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Process part of the SCORM sub-process for upload. This script MUST BE included by upload/index.php
  5. * as it prepares most of the variables needed here.
  6. * @package chamilo.upload
  7. * @author Yannick Warnier <ywarnier@beeznest.org>
  8. */
  9. /**
  10. * Process the SCORM package and return to the SCORM tool
  11. */
  12. $cwdir = getcwd();
  13. require_once '../newscorm/lp_upload.php';
  14. // Reinit current working directory as many functions in upload change it
  15. chdir($cwdir);
  16. $error = api_failure::get_last_failure();
  17. if ($error == 'upload_file_too_big') {
  18. $msg = urlencode(get_lang('UplFileTooBig'));
  19. $dialogtype = 'error';
  20. } else {
  21. if ($error == 'not_a_learning_path') {
  22. $msg = urlencode(get_lang('ScormUnknownPackageFormat'));
  23. $dialogtype = 'error';
  24. } elseif ($error == 'not_enough_space') {
  25. $msg = urlencode(
  26. get_lang('ScormNotEnoughSpaceInCourseToInstallPackage')
  27. );
  28. $dialogtype = 'error';
  29. } elseif ($error == 'not_scorm_content') {
  30. $msg = urlencode(get_lang('ScormPackageFormatNotScorm'));
  31. $dialogtype = 'error';
  32. } else {
  33. if (api_get_setting('search_enabled') == 'true') {
  34. require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
  35. $specific_fields = get_specific_field_list();
  36. foreach ($specific_fields as $specific_field) {
  37. $values = explode(',', trim($_POST[$specific_field['code']]));
  38. if (!empty($values)) {
  39. foreach ($values as $value) {
  40. $value = trim($value);
  41. if (!empty($value)) {
  42. add_specific_field_value(
  43. $specific_field['id'],
  44. api_get_course_id(),
  45. TOOL_LEARNPATH,
  46. $oScorm->lp_id,
  47. $value
  48. );
  49. }
  50. }
  51. }
  52. }
  53. }
  54. $msg = urlencode(get_lang('UplUploadSucceeded'));
  55. $dialogtype = 'confirmation';
  56. }
  57. }
  58. header('location: ../newscorm/lp_controller.php?action=list&dialog_box=' . $msg . '&dialogtype=' . $dialogtype);
  59. exit;