record_audio_wami.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file allows record wav files.
  5. *
  6. * @package chamilo.document
  7. *
  8. * @author Juan Carlos Raña Trabado herodoto@telefonica.net
  9. * @since 5/april/2012
  10. */
  11. require_once '../inc/global.inc.php';
  12. $_SESSION['whereami'] = 'document/voicerecord';
  13. $this_section = SECTION_COURSES;
  14. $nameTools = get_lang('VoiceRecord');
  15. api_protect_course_script();
  16. api_block_anonymous_users();
  17. $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
  18. if (empty($document_data)) {
  19. if (api_is_in_group()) {
  20. $group_properties = GroupManager::get_group_properties(api_get_group_id());
  21. $document_id = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
  22. $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
  23. }
  24. }
  25. $document_id = $document_data['id'];
  26. $dir = $document_data['path'];
  27. //make some vars
  28. $wamidir=$dir;
  29. if($wamidir=="/"){
  30. $wamidir="";
  31. }
  32. $wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir."/";
  33. $groupId = api_get_group_id();
  34. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  35. // Please, do not modify this dirname formatting
  36. if (strstr($dir, '..')) {
  37. $dir = '/';
  38. }
  39. if ($dir[0] == '.') {
  40. $dir = substr($dir, 1);
  41. }
  42. if ($dir[0] != '/') {
  43. $dir = '/'.$dir;
  44. }
  45. if ($dir[strlen($dir) - 1] != '/') {
  46. $dir .= '/';
  47. }
  48. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
  49. if (!is_dir($filepath)) {
  50. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  51. $dir = '/';
  52. }
  53. //groups //TODO: clean
  54. if (!empty($groupId)) {
  55. $interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
  56. $noPHP_SELF = true;
  57. $group = GroupManager :: get_group_properties($groupId);
  58. $path = explode('/', $dir);
  59. if ('/'.$path[1] != $group['directory']) {
  60. api_not_allowed(true);
  61. }
  62. }
  63. $interbreadcrumb[] = array("url" => "./document.php?id=".$document_id.'&'.api_get_cidreq(), "name" => get_lang('Documents'));
  64. if (!$is_allowed_in_course) {
  65. api_not_allowed(true);
  66. }
  67. if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
  68. DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
  69. api_not_allowed(true);
  70. }
  71. /* Header */
  72. Event::event_access_tool(TOOL_DOCUMENT);
  73. $display_dir = $dir;
  74. if (isset ($group)) {
  75. $display_dir = explode('/', $dir);
  76. unset ($display_dir[0]);
  77. unset ($display_dir[1]);
  78. $display_dir = implode('/', $display_dir);
  79. }
  80. // Interbreadcrumb for the current directory root path
  81. $counter = 0;
  82. if (isset($document_data['parents'])) {
  83. foreach($document_data['parents'] as $document_sub_data) {
  84. //fixing double group folder in breadcrumb
  85. if (api_get_group_id()) {
  86. if ($counter == 0) {
  87. $counter++;
  88. continue;
  89. }
  90. }
  91. $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
  92. $counter++;
  93. }
  94. }
  95. //make some vars
  96. $wamiuserid = api_get_user_id();
  97. Display :: display_header($nameTools, 'Doc');
  98. echo '<div class="actions">';
  99. echo '<a href="document.php?id='.$document_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
  100. echo '</div>';
  101. ?>
  102. <!-- swfobject is a commonly used library to embed Flash content https://ajax.googleapis.com/ajax/libs/swfobject/2.2/ -->
  103. <script type="text/javascript" src="<?php echo api_get_path(WEB_LIBRARY_PATH) ?>swfobject/swfobject.js"></script>
  104. <!-- Setup the recorder interface -->
  105. <script type="text/javascript" src="<?php echo api_get_path(WEB_LIBRARY_PATH) ?>wami-recorder/recorder.js"></script>
  106. <!-- GUI code... take it or leave it -->
  107. <script type="text/javascript" src="<?php echo api_get_path(WEB_LIBRARY_PATH) ?>wami-recorder/gui.js"></script>
  108. <script type="text/javascript">
  109. function newNameRecord() {
  110. location.reload(true)
  111. }
  112. function setupRecorder() {
  113. var nospaces =document.getElementById("audio_title").value;
  114. var audioname = nospaces.replace(/ /gi, "");
  115. if(audioname==""){
  116. return;
  117. }else{
  118. document.getElementById('audio_title').readOnly = true;
  119. //document.getElementById('audio_title').style.display='none';
  120. document.getElementById('audio_button').style.display='none';
  121. Wami.setup({
  122. id : "wami",
  123. onReady : setupGUI
  124. });
  125. }
  126. }
  127. function setupGUI() {
  128. var waminame = document.getElementById("audio_title").value+".wav";//adding name file and extension
  129. var waminame_play=waminame;
  130. var gui = new Wami.GUI({
  131. id : "wami",
  132. singleButton : true,
  133. recordUrl : "<?php echo api_get_path(WEB_LIBRARY_PATH) ?>wami-recorder/record_document.php?waminame="+waminame+"&wamidir=<?php echo $wamidir; ?>&wamiuserid=<?php echo $wamiuserid; ?>",
  134. playUrl : "<?php echo $wamiurlplay; ?>"+waminame_play,
  135. buttonUrl : "<?php echo api_get_path(WEB_LIBRARY_PATH) ?>wami-recorder/buttons.png",
  136. swfUrl : "<?php echo api_get_path(WEB_LIBRARY_PATH) ?>wami-recorder/Wami.swf"
  137. });
  138. gui.setPlayEnabled(false);
  139. }
  140. </script>
  141. <div id="wami" style="margin-top:10px;"></div>
  142. <div align="center" style="margin-top:150px;">
  143. <form name="form_wami_recorder">
  144. <input placeholder="<?php echo get_lang('InputNameHere'); ?>" type="text" id="audio_title"><br/>
  145. <button type="button" value="" onclick="setupRecorder()" id="audio_button" /><?php echo get_lang('Activate'); ?></button>
  146. <button type="button" value="" onclick="newNameRecord()" id="new_name" /><?php echo get_lang('Reload'); ?></button>
  147. <?php echo Display :: return_icon('info3.gif', get_lang('WamiNeedFilename').' '.get_lang('WamiFlashDialog'), array('align' => 'absmiddle', 'hspace' => '3px'), false); ?>
  148. </form>
  149. </div>
  150. <div align="center" id="audio_message_1" style="display:inline">
  151. <?php Display::display_normal_message(get_lang('WamiNeedFilename').' '.get_lang('WamiStartRecorder'), false); ?>
  152. </div>
  153. <script>
  154. if (navigator.appName == 'Microsoft Internet Explorer') {
  155. document.getElementById('wami').style.marginLeft='400px';
  156. }else{
  157. document.getElementById('wami').style.marginLeft='510px';
  158. }
  159. </script>
  160. <?php
  161. Display :: display_footer();