record_audio.php 4.1 KB

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