course_access_details.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  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. For a full list of contributors, see "credits.txt".
  9. The full license can be read in "license.txt".
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. See the GNU General Public License for more details.
  15. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  16. Mail: info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * @author Thomas Depraetere
  22. * @author Hugues Peeters
  23. * @author Christophe Gesche
  24. * @author Sebastien Piraux
  25. *
  26. * @package dokeos.tracking
  27. ==============================================================================
  28. */
  29. // TODO: Is this file deprecated?
  30. /*
  31. ==============================================================================
  32. INIT SECTION
  33. ==============================================================================
  34. */
  35. $reqdate = $_REQUEST['reqdate'];
  36. $period = $_REQUEST['period'];
  37. $displayType = $_REQUEST['displayType'];
  38. // name of the language file that needs to be included
  39. $language_file = "tracking";
  40. include('../inc/global.inc.php');
  41. $interbreadcrumb[]= array ("url"=>"courseLog.php", "name"=> get_lang('ToolName'));
  42. $nameTools = get_lang('TrafficDetails');
  43. $htmlHeadXtra[] = "<style type='text/css'>
  44. /*<![CDATA[*/
  45. .secLine {background-color : #E6E6E6;}
  46. .content {padding-left : 15px;padding-right : 15px; }
  47. .specialLink{color : #0000FF;}
  48. /*]]>*/
  49. </style>
  50. <style media='print' type='text/css'>
  51. /*<![CDATA[*/
  52. td {border-bottom: thin dashed gray;}
  53. /*]]>*/
  54. </style>";
  55. //@todo use Database library
  56. $TABLETRACK_ACCESS = $_configuration['statistics_database']."`.`track_e_access";
  57. Display::display_header($nameTools,"Tracking");
  58. include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
  59. // the variables for the days and the months
  60. // Defining the shorts for the days
  61. $DaysShort = api_get_week_days_short();
  62. // Defining the days of the week to allow translation of the days
  63. $DaysLong = api_get_week_days_long();
  64. // Defining the months of the year to allow translation of the months
  65. $MonthsLong = api_get_months_long();
  66. $is_allowedToTrack = $is_courseAdmin;
  67. ?>
  68. <h3>
  69. <?php echo $nameTools ?>
  70. </h3>
  71. <table width="100%" cellpadding="2" cellspacing="3" border="0">
  72. <?php
  73. if( $is_allowedToTrack && $_configuration['tracking_enabled'])
  74. {
  75. if( !isset($reqdate) || $reqdate < 0 || $reqdate > 2149372861 )
  76. $reqdate = time();
  77. //** dislayed period
  78. echo "<tr><td><b>";
  79. switch($period)
  80. {
  81. case "year" :
  82. echo date(" Y", $reqdate);
  83. break;
  84. case "month" :
  85. echo $MonthsLong[date("n", $reqdate)-1].date(" Y", $reqdate);
  86. break;
  87. // default == day
  88. default :
  89. $period = "day";
  90. case "day" :
  91. echo $DaysLong[date("w" , $reqdate)].date(" d " , $reqdate).$MonthsLong[date("n", $reqdate)-1].date(" Y" , $reqdate);
  92. break;
  93. }
  94. echo "</b></tr></td>";
  95. //** menu
  96. echo "<tr>
  97. <td>
  98. ";
  99. echo " ".get_lang('PeriodToDisplay')." : [<a href='".api_get_self()."?period=year&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodYear')."</a>]
  100. [<a href='".api_get_self()."?period=month&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodMonth')."</a>]
  101. [<a href='".api_get_self()."?period=day&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodDay')."</a>]
  102. &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;
  103. ".get_lang('DetailView')." :
  104. ";
  105. switch($period)
  106. {
  107. case "year" :
  108. //-- if period is "year" display can be by month, day or hour
  109. echo " [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=month' class='specialLink'>".get_lang('PeriodMonth')."</a>]";
  110. case "month" :
  111. //-- if period is "month" display can be by day or hour
  112. echo " [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=day' class='specialLink'>".get_lang('PeriodDay')."</a>]";
  113. case "day" :
  114. //-- if period is "day" display can only be by hour
  115. echo " [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=hour' class='specialLink'>".get_lang('PeriodHour')."</a>]";
  116. break;
  117. }
  118. echo "&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;";
  119. switch($period)
  120. {
  121. case "year" :
  122. // previous and next date must be evaluated
  123. // 30 days should be a good approximation
  124. $previousReqDate = mktime(1,1,1,1,1,date("Y",$reqdate)-1);
  125. $nextReqDate = mktime(1,1,1,1,1,date("Y",$reqdate)+1);
  126. echo "
  127. [<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousYear')."</a>]
  128. [<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextYear')."</a>]
  129. ";
  130. break;
  131. case "month" :
  132. // previous and next date must be evaluated
  133. // 30 days should be a good approximation
  134. $previousReqDate = mktime(1,1,1,date("m",$reqdate)-1,1,date("Y",$reqdate));
  135. $nextReqDate = mktime(1,1,1,date("m",$reqdate)+1,1,date("Y",$reqdate));
  136. echo "
  137. [<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousMonth')."</a>]
  138. [<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextMonth')."</a>]
  139. ";
  140. break;
  141. case "day" :
  142. // previous and next date must be evaluated
  143. $previousReqDate = $reqdate - 86400;
  144. $nextReqDate = $reqdate + 86400;
  145. echo "
  146. [<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousDay')."</a>]
  147. [<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextDay')."</a>]
  148. ";
  149. break;
  150. }
  151. echo "
  152. </td>
  153. </tr>
  154. ";
  155. //**
  156. // display information about this period
  157. switch($period)
  158. {
  159. // all days
  160. case "year" :
  161. $sql = "SELECT UNIX_TIMESTAMP( `access_date` )
  162. FROM `$TABLETRACK_ACCESS`
  163. WHERE YEAR( `access_date` ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
  164. AND `access_cours_code` = '$_cid'
  165. AND `access_tool` IS NULL ";
  166. if($displayType == "month")
  167. {
  168. $sql .= "ORDER BY UNIX_TIMESTAMP( `access_date`)";
  169. $month_array = monthTab($sql);
  170. makeHitsTable($month_array,get_lang('PeriodMonth'));
  171. }
  172. elseif($displayType == "day")
  173. {
  174. $sql .= "ORDER BY DAYOFYEAR( `access_date`)";
  175. $days_array = daysTab($sql);
  176. makeHitsTable($days_array,get_lang('PeriodDay'));
  177. }
  178. else // by hours by default
  179. {
  180. $sql .= "ORDER BY HOUR( `access_date`)";
  181. $hours_array = hoursTab($sql);
  182. makeHitsTable($hours_array,get_lang('PeriodHour'));
  183. }
  184. break;
  185. // all days
  186. case "month" :
  187. $sql = "SELECT UNIX_TIMESTAMP( `access_date` )
  188. FROM `$TABLETRACK_ACCESS`
  189. WHERE MONTH(`access_date`) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
  190. AND YEAR( `access_date` ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
  191. AND `access_cours_code` = '$_cid'
  192. AND `access_tool` IS NULL ";
  193. if($displayType == "day")
  194. {
  195. $sql .= "ORDER BY DAYOFYEAR( `access_date`)";
  196. $days_array = daysTab($sql);
  197. makeHitsTable($days_array,get_lang('PeriodDay'));
  198. }
  199. else // by hours by default
  200. {
  201. $sql .= "ORDER BY HOUR( `access_date`)";
  202. $hours_array = hoursTab($sql);
  203. makeHitsTable($hours_array,get_lang('PeriodHour'));
  204. }
  205. break;
  206. // all hours
  207. case "day" :
  208. $sql = "SELECT UNIX_TIMESTAMP( `access_date` )
  209. FROM `$TABLETRACK_ACCESS`
  210. WHERE DAYOFMONTH(`access_date`) = DAYOFMONTH(FROM_UNIXTIME( '$reqdate' ) )
  211. AND MONTH(`access_date`) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
  212. AND YEAR( `access_date` ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
  213. AND `access_cours_code` = '$_cid'
  214. AND `access_tool` IS NULL
  215. ORDER BY HOUR( `access_date` )";
  216. $hours_array = hoursTab($sql,$reqdate);
  217. makeHitsTable($hours_array,get_lang('PeriodHour'));
  218. break;
  219. }
  220. }
  221. else // not allowed to track
  222. {
  223. if(!$_configuration['tracking_enabled'])
  224. {
  225. echo get_lang('TrackingDisabled');
  226. }
  227. else
  228. {
  229. api_not_allowed();
  230. }
  231. }
  232. ?>
  233. </table>
  234. <?php
  235. Display::display_footer();
  236. ?>