upload_nanogong_file.php 1.5 KB

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