record_audio.php 4.0 KB

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