record_audio.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * This file allows record audio files.
  6. * @package chamilo.document
  7. */
  8. require_once __DIR__.'/../inc/global.inc.php';
  9. $_SESSION['whereami'] = 'document/voicerecord';
  10. $this_section = SECTION_COURSES;
  11. $groupRights = Session::read('group_member_with_upload_rights');
  12. $nameTools = get_lang('VoiceRecord');
  13. api_protect_course_script();
  14. api_block_anonymous_users();
  15. $document_data = DocumentManager::get_document_data_by_id(
  16. $_GET['id'],
  17. api_get_course_id(),
  18. true
  19. );
  20. if (empty($document_data)) {
  21. if (api_is_in_group()) {
  22. $group_properties = GroupManager::get_group_properties(
  23. api_get_group_id()
  24. );
  25. $document_id = DocumentManager::get_document_id(
  26. api_get_course_info(),
  27. $group_properties['directory']
  28. );
  29. $document_data = DocumentManager::get_document_data_by_id(
  30. $document_id,
  31. api_get_course_id()
  32. );
  33. }
  34. }
  35. $document_id = $document_data['id'];
  36. $dir = $document_data['path'];
  37. //make some vars
  38. $wamidir = $dir;
  39. if ($wamidir == "/") {
  40. $wamidir = "";
  41. }
  42. $wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir."/";
  43. $groupId = api_get_group_id();
  44. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  45. // Please, do not modify this dirname formatting
  46. if (strstr($dir, '..')) {
  47. $dir = '/';
  48. }
  49. if ($dir[0] == '.') {
  50. $dir = substr($dir, 1);
  51. }
  52. if ($dir[0] != '/') {
  53. $dir = '/'.$dir;
  54. }
  55. if ($dir[strlen($dir) - 1] != '/') {
  56. $dir .= '/';
  57. }
  58. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
  59. if (!is_dir($filepath)) {
  60. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  61. $dir = '/';
  62. }
  63. //groups //TODO: clean
  64. if (!empty($groupId)) {
  65. $interbreadcrumb[] = array("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
  66. $noPHP_SELF = true;
  67. $group = GroupManager :: get_group_properties($groupId);
  68. $path = explode('/', $dir);
  69. if ('/'.$path[1] != $group['directory']) {
  70. api_not_allowed(true);
  71. }
  72. }
  73. $interbreadcrumb[] = array("url" => "./document.php?id=".$document_id.'&'.api_get_cidreq(), "name" => get_lang('Documents'));
  74. if (!api_is_allowed_in_course()) {
  75. api_not_allowed(true);
  76. }
  77. if (!($is_allowed_to_edit || $groupRights ||
  78. DocumentManager::is_my_shared_folder(
  79. api_get_user_id(),
  80. Security::remove_XSS($dir),
  81. api_get_session_id()
  82. ))
  83. ) {
  84. api_not_allowed(true);
  85. }
  86. /* Header */
  87. Event::event_access_tool(TOOL_DOCUMENT);
  88. $display_dir = $dir;
  89. if (isset ($group)) {
  90. $display_dir = explode('/', $dir);
  91. unset($display_dir[0]);
  92. unset($display_dir[1]);
  93. $display_dir = implode('/', $display_dir);
  94. }
  95. // Interbreadcrumb for the current directory root path
  96. $counter = 0;
  97. if (isset($document_data['parents'])) {
  98. foreach ($document_data['parents'] as $document_sub_data) {
  99. //fixing double group folder in breadcrumb
  100. if (api_get_group_id()) {
  101. if ($counter == 0) {
  102. $counter++;
  103. continue;
  104. }
  105. }
  106. $interbreadcrumb[] = array(
  107. 'url' => $document_sub_data['document_url'],
  108. 'name' => $document_sub_data['title'],
  109. );
  110. $counter++;
  111. }
  112. }
  113. //make some vars
  114. $wamiuserid = api_get_user_id();
  115. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';
  116. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/recorder.js"></script>';
  117. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/gui.js"></script>';
  118. $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
  119. $actions = Display::toolbarButton(
  120. get_lang('BackTo').' '.get_lang('DocumentsOverview'),
  121. 'document.php?'.api_get_cidreq()."&id=$document_id",
  122. 'arrow-left',
  123. 'default',
  124. [],
  125. false
  126. );
  127. $template = new Template($nameTools);
  128. $template->assign('directory', $wamidir);
  129. $template->assign('user_id', api_get_user_id());
  130. $layout = $template->get_template('document/record_audio.tpl');
  131. $content = $template->fetch($layout);
  132. $template->assign(
  133. 'actions',
  134. Display::toolbarAction('toolbar', [$actions])
  135. );
  136. $template->assign('content', $content);
  137. $template->display_one_col_template();