record_audio_wami.php 6.4 KB

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