online_master.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php // $Id: online_master.php 20467 2009-05-11 08:38:29Z ivantcholakov $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * Displays the master's picture and/or the video or audio file
  22. *
  23. * @author Olivier Brouckaert
  24. * @package dokeos.online
  25. ==============================================================================
  26. */
  27. define('FRAME','master');
  28. // name of the language file that needs to be included
  29. $language_file='chat';
  30. include('../inc/global.inc.php');
  31. $this_section=SECTION_COURSES;
  32. $init=intval($_GET['init']);
  33. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  34. $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  35. $tbl_online_link=Database::get_course_table(TABLE_ONLINE_LINK);
  36. $query="SELECT t1.user_id,username,picture_uri,t2.status FROM $tbl_user t1,$tbl_course_user t2 WHERE t1.user_id=t2.user_id AND course_code='$_cid' AND (t1.user_id='".$_user['user_id']."' OR t2.status='1')";
  37. $result=Database::query($query,__FILE__,__LINE__);
  38. while($row=Database::fetch_array($result))
  39. {
  40. if($row['user_id'] == $_user['user_id'])
  41. {
  42. $pseudoUser=$row['username'];
  43. }
  44. if($row['status'] == 1)
  45. {
  46. $picture_uri=$row['picture_uri'];
  47. }
  48. }
  49. $isAllowed=(empty($pseudoUser) || !$_cid)?false:true;
  50. $isMaster=$is_courseAdmin?true:false;
  51. if(!$isAllowed)
  52. {
  53. exit();
  54. }
  55. $pictureURL=api_get_path(WEB_CODE_PATH).'upload/users/';
  56. $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  57. $onlinePath=$documentPath.'online_files/';
  58. if(!is_dir($onlinePath))
  59. {
  60. if(is_file($onlinePath))
  61. {
  62. @unlink($onlinePath);
  63. }
  64. @mkdir($onlinePath,0777);
  65. @chmod($onlinePath,0777);
  66. }
  67. if($isMaster && $init)
  68. {
  69. $fp=fopen($onlinePath.'htmlarea.html','w');
  70. fputs($fp,get_lang('TextEditorDefault'));
  71. fclose($fp);
  72. if(!file_exists($onlinePath.'streaming.txt'))
  73. {
  74. $fp=fopen($onlinePath.'streaming.txt','w');
  75. fputs($fp,"http://www.dokeos.com/pub/01_discovery_high.mov\nmov");
  76. fclose($fp);
  77. }
  78. }
  79. if(!$isMaster)
  80. {
  81. if(!list($stream_url,$stream_type)=@file($onlinePath.'streaming.txt'))
  82. {
  83. $stream_url='';
  84. $stream_type='mp3';
  85. }
  86. else
  87. {
  88. $stream_url=rtrim($stream_url);
  89. $stream_type=rtrim($stream_type);
  90. }
  91. $query="SELECT id,name,url FROM $tbl_online_link ORDER BY name";
  92. $result=Database::query($query,__FILE__,__LINE__);
  93. $Links=Database::store_result($result);
  94. }
  95. include('header_frame.inc.php');
  96. ?>
  97. <?php if($isMaster): ?>
  98. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  99. <tr>
  100. <td width="1%" valign="middle"><a href="online_streaming.php"><img src="../img/conf.gif" border="0" alt="" title="<?php echo api_htmlentities(get_lang('Streaming'),ENT_QUOTES,$charset); ?>"></a></td>
  101. <td width="49%" align="left" nowrap="nowrap">&nbsp;<a href="online_streaming.php"><?php echo get_lang('Streaming'); ?></a></td>
  102. <td width="49%" align="right" nowrap="nowrap"><a href="online_htmlarea.php" target="online_working_area"><?php echo get_lang('WhiteBoard'); ?></a>&nbsp;</td>
  103. <td width="1%" valign="middle"><a href="online_htmlarea.php" target="online_working_area"><img src="../img/works.gif" border="0" alt="" title="<?php echo api_htmlentities(get_lang('WhiteBoard'),ENT_QUOTES,$charset); ?>"></a></td>
  104. </tr>
  105. </table>
  106. <br>
  107. <?php endif; ?>
  108. <table border="0" cellpadding="5" cellspacing="0" width="100%" <?php if(!$isMaster) echo 'height="100%"'; ?> >
  109. <tr>
  110. <?php if($isMaster || empty($stream_url)): ?>
  111. <td align="center" valign="middle"><img src="<?php if(empty($picture_uri)) echo '../img/unknown.jpg'; else echo $pictureURL.$picture_uri; ?>" border="0" height="120" alt=""></td>
  112. <?php elseif(!empty($stream_url) && $stream_type == 'mp3'): ?>
  113. <td width="1%" valign="middle"><img src="<?php if(empty($picture_uri)) echo '../img/unknown.jpg'; else echo $pictureURL.$picture_uri; ?>" border="0" height="120" alt=""></td>
  114. <td width="99%" valign="middle" align="center">
  115. <?php else: ?>
  116. <td align="center">
  117. <?php endif; ?>
  118. <?php
  119. if(!$isMaster && !empty($stream_url))
  120. {
  121. if($stream_type == 'mp3')
  122. {
  123. ?>
  124. <embed src="<?php echo $stream_url; ?>" width="30" height="60" autostart="true" loop="false" controls="PlayOnlyButton,StopButton" type="audio/x-pn-realaudio-plugin" pluginspage="http://www.real.com/player/index.html?src=000629realhome"></embed>
  125. <?php
  126. }
  127. elseif($stream_type == 'mp4')
  128. {
  129. ?>
  130. <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="160" height="120" type="application/x-oleobject">
  131. <param name="src" value="<?php echo $stream_url; ?>">
  132. <param name="autoplay" value="true">
  133. <param name="loop" value="true">
  134. <param name="cache" value="false">
  135. <embed src="<?php echo $stream_url; ?>" width="160" height="120" autoplay="true" loop="true" cache="false" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed>
  136. </object>
  137. <?php
  138. }
  139. elseif($stream_type == 'mov')
  140. {
  141. ?>
  142. <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="160" height="120" type="application/x-oleobject">
  143. <param name="src" value="<?php echo $stream_url; ?>">
  144. <param name="autoplay" value="true">
  145. <param name="loop" value="true">
  146. <param name="cache" value="false">
  147. <embed src="<?php echo $stream_url; ?>" width="160" height="120" autoplay="true" loop="true" cache="false" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed>
  148. </object>
  149. <?php
  150. }
  151. }
  152. ?>
  153. </td>
  154. </tr>
  155. </table>
  156. <?php if($isMaster): ?>
  157. <br>
  158. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  159. <tr>
  160. <td width="1%" valign="middle"><a href="online_links.php"><img src="../img/links.gif" border="0" alt="" title="<?php echo api_htmlentities(get_lang('Links'),ENT_QUOTES,$charset); ?>"></a></td>
  161. <td width="49%" align="left" nowrap="nowrap">&nbsp;<a href="online_links.php"><?php echo get_lang('Links'); ?></a></td>
  162. <td width="49%" align="right" nowrap="nowrap"><a href="online_working_area.php" target="online_working_area"><?php echo get_lang('Home'); ?></a>&nbsp;</td>
  163. <td width="1%" valign="middle"><a href="online_working_area.php" target="online_working_area"><img src="../img/home.gif" border="0" alt="" title="<?php echo api_htmlentities(get_lang('Home'),ENT_QUOTES,$charset); ?>"></a></td>
  164. </tr>
  165. </table>
  166. <?php endif; ?>
  167. <?php
  168. include('footer_frame.inc.php');
  169. ?>