dokeos-tracking
[ class tree: dokeos-tracking ] [ index: dokeos-tracking ] [ all elements ]

Source for file course_access_details.php

Documentation is available at course_access_details.php

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

Documentation generated on Thu, 12 Jun 2008 13:13:57 -0500 by phpDocumentor 1.4.1