upload_nanogong_file.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file allows creating new svg and png documents with an online editor.
  5. *
  6. * @package chamilo.document
  7. *
  8. * @author Juan Carlos Raña Trabado
  9. * @since 5/mar/2011
  10. */
  11. /**
  12. * Code
  13. */
  14. require_once '../../../inc/global.inc.php';
  15. api_protect_course_script();
  16. api_block_anonymous_users();
  17. if (!isset($_GET['filename']) || !isset($_GET['file_field'])) {
  18. api_not_allowed(false);
  19. exit;
  20. }
  21. $courseInfo = api_get_course_info();
  22. $fileUpload = null;
  23. if (is_uploaded_file($_FILES[$_GET['file_field']]['tmp_name'])) {
  24. $fileUpload = $_FILES[$_GET['file_field']];
  25. } else {
  26. exit;
  27. }
  28. $output = false;
  29. $documentData = DocumentManager::upload_document($_FILES, $_GET['path'], null, null, 0, 'overwrite', false, $output);
  30. if (!empty($documentData)) {
  31. $newDocId = $documentData['id'];
  32. $newMp3DocumentId = DocumentManager::addAndConvertWavToMp3(
  33. $documentData,
  34. $courseInfo,
  35. api_get_session_id(),
  36. api_get_user_id(),
  37. 'overwrite',
  38. true
  39. );
  40. if ($newMp3DocumentId) {
  41. $newDocId = $newMp3DocumentId;
  42. }
  43. if (isset($_REQUEST['lp_item_id']) && !empty($_REQUEST['lp_item_id'])) {
  44. $lpItemId = $_REQUEST['lp_item_id'];
  45. /** @var learnpath $lp */
  46. $lp = isset($_SESSION['oLP']) ? $_SESSION['oLP'] : null;
  47. if (!empty($lp)) {
  48. $lp->set_modified_on();
  49. $lpItem = new learnpathItem($lpItemId);
  50. $lpItem->add_audio_from_documents($newDocId);
  51. }
  52. }
  53. }