record_audio_wami.php 6.5 KB

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