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

Source for file logins_details.php

Documentation is available at logins_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. $uInfo $_REQUEST['uInfo'];
  41. if!isset($_REQUEST['reqdate']) )
  42.     $reqdate time();
  43. else
  44.     $reqdate $_REQUEST['reqdate'];
  45. $period $_REQUEST['period'];
  46. if(!isset($_REQUEST['view']))
  47.     $view ="0000000";
  48. else
  49.     $view $_REQUEST['view'];
  50.  
  51. // name of the language file that needs to be included 
  52. $language_file "tracking";
  53. include('../inc/global.inc.php');
  54.  
  55. $interbreadcrumb[]array ("url"=>"../user/user.php""name"=> get_lang('Users'));
  56.  
  57. $nameTools get_lang('ToolName');
  58.  
  59. $htmlHeadXtra["<style type='text/css'>
  60. /*<![CDATA[*/
  61. .secLine {background-color : #E6E6E6;}
  62. .content {padding-left : 15px;padding-right : 15px; }
  63. .specialLink{color : #0000FF;}
  64. /*]]>*/
  65. </style>
  66. <style media='print' type='text/css'>
  67. /*<![CDATA[*/
  68. td {border-bottom: thin dashed gray;}
  69. /*]]>*/
  70. </style>";
  71.  
  72. $TABLECOURSUSER            Database::get_main_table(TABLE_MAIN_COURSE_USER);
  73. $TABLECOURSE_GROUPSUSER Database::get_course_table(TABLE_GROUP_USER);
  74. $TABLEUSER            Database::get_main_table(TABLE_MAIN_USER);
  75. $TABLETRACK_ACCESS      Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
  76. Display::display_header($nameTools"Tracking");
  77. include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
  78.  
  79. // the variables for the days and the months
  80. // Defining the shorts for the days
  81. $DaysShort array (get_lang("SundayShort")get_lang("MondayShort")get_lang("TuesdayShort")get_lang("WednesdayShort")get_lang("ThursdayShort")get_lang("FridayShort")get_lang("SaturdayShort"));
  82. // Defining the days of the week to allow translation of the days
  83. $DaysLong array (get_lang("SundayLong")get_lang("MondayLong")get_lang("TuesdayLong")get_lang("WednesdayLong")get_lang("ThursdayLong")get_lang("FridayLong")get_lang("SaturdayLong"));
  84. // Defining the months of the year to allow translation of the months
  85. $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"));
  86. // Defining the months of the year to allow translation of the months
  87. $MonthsShort array (get_lang("JanuaryShort")get_lang("FebruaryShort")get_lang("MarchShort")get_lang("AprilShort")get_lang("MayShort")get_lang("JuneShort")get_lang("JulyShort")get_lang("AugustShort")get_lang("SeptemberShort")get_lang("OctoberShort")get_lang("NovemberShort")get_lang("DecemberShort"));
  88.  
  89. $is_allowedToTrack $is_groupTutor// allowed to track only user of one group
  90. $is_allowedToTrackEverybodyInCourse $is_courseAdmin// allowed to track all student in course
  91. ?>
  92. <h3>
  93.     <?php echo $nameTools ?>
  94. </h3>
  95. <table width="100%" cellpadding="2" cellspacing="3" border="0">
  96. <?php
  97. // check if uid is tutor of this group
  98.  
  99. if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse && $_configuration['tracking_enabled')
  100. {
  101.     if$is_allowedToTrackEverybodyInCourse )
  102.     {
  103.         $sql "SELECT `u`.`firstname`,`u`.`lastname`, `u`.`email`
  104.                     FROM $TABLECOURSUSER cu , $TABLEUSER u
  105.                     WHERE `cu`.`user_id` = `u`.`user_id`
  106.                         AND `cu`.`course_code` = '$_cid'
  107.                         AND `u`.`user_id` = '$uInfo'";
  108.     }
  109.     else
  110.     {
  111.         $sql "SELECT `u`.`firstname`,`u`.`lastname`, `u`.`email`
  112.                     FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
  113.                     WHERE `gu`.`user_id` = `u`.`user_id`
  114.                         AND `gu`.`group_id` = '$_gid'
  115.                         AND `u`.`user_id` = '$uInfo'";
  116.     }
  117.     $query api_sql_query($sql,__FILE__,__LINE__);
  118.     $res @mysql_fetch_array($query);
  119.     if(is_array($res))
  120.     {
  121.         $res[2== "" $res2 get_lang('NoEmail'$res2 Display::encrypted_mailto_link($res[2]);
  122.  
  123.         echo "<tr><td>";
  124.         echo $informationsAbout." : <br>";
  125.         echo "<ul>\n"
  126.                 ."<li>".get_lang('FirstName')." : ".$res[0]."</li>\n"
  127.                 ."<li>".get_lang('LastName')." : ".$res[1]."</li>\n"
  128.                 ."<li>".get_lang('Email')." : ".$res2."</li>\n"
  129.                 ."</ul>";
  130.         echo "</td></tr>";
  131.         /******* MENU ********/
  132.         echo "<tr>
  133.                 <td>
  134.                 [<a href='userLog.php?uInfo=$uInfo&view=$view'>".get_lang('Back')."</a>]
  135.         ";
  136.         echo "  &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;
  137.                 [<a href='".api_get_self()."?uInfo=$uInfo&view=$view&period=week&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodWeek')."</a>]
  138.                 [<a href='".api_get_self()."?uInfo=$uInfo&view=$view&period=month&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodMonth')."</a>]
  139.                 &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;
  140.         ";
  141.         switch($period)
  142.         {
  143.             case "week" :
  144.                 // previous and next date must be evaluated
  145.                 $previousReqDate $reqdate 7*86400;
  146.                 $nextReqDate $reqdate 7*86400;
  147.                 echo   "
  148.                     [<a href='".api_get_self()."?uInfo=$uInfo&view=$view&period=week&reqdate=$previousReqDate' class='specialLink'>".get_lang('PreviousWeek')."</a>]
  149.                     [<a href='".api_get_self()."?uInfo=$uInfo&view=$view&period=week&reqdate=$nextReqDate' class='specialLink'>".get_lang('NextWeek')."</a>]
  150.                 ";
  151.                 break;
  152.             default :
  153.                 $period "month";
  154.             case "month" :
  155.                 // previous and next date must be evaluated
  156.                 // 30 days should be a good approximation
  157.                 $previousReqDate mktime(1,1,1,date("m",$reqdate)-1,1,date("Y",$reqdate));
  158.                 $nextReqDate mktime(1,1,1,date("m",$reqdate)+1,1,date("Y",$reqdate));
  159.                 echo   "
  160.                     [<a href='".api_get_self()."?uInfo=$uInfo&view=$view&period=month&reqdate=$previousReqDate' class='specialLink'>".get_lang('PreviousMonth')."</a>]
  161.                     [<a href='".api_get_self()."?uInfo=$uInfo&view=$view&period=month&reqdate=$nextReqDate' class='specialLink'>".get_lang('NextMonth')."</a>]
  162.                 ";
  163.                 break;
  164.  
  165.  
  166.         }
  167.         echo "
  168.                 </td>
  169.             </tr>
  170.         ";
  171.         /******* END OF MENU ********/
  172.  
  173.         switch($period)
  174.         {
  175.             case "month" :
  176.                 $sql "SELECT `access_date`
  177.                             FROM $TABLETRACK_ACCESS
  178.                             WHERE `access_user_id` = '$uInfo'
  179.                             AND `access_cours_code` = '".$_cid."'
  180.                             AND MONTH(`access_date`) = MONTH( FROM_UNIXTIME('$reqdate') )
  181.                             AND YEAR(`access_date`) = YEAR(FROM_UNIXTIME('$reqdate'))
  182.                             GROUP BY DAYOFMONTH(`access_date`)
  183.                             ORDER BY `access_date` ASC";
  184.                 $displayedDate $MonthsLong[date("n"$reqdate)-1].date(" Y"$reqdate);
  185.                  break;
  186.             case "week" :
  187.                 $sql "SELECT `access_date`
  188.                             FROM $TABLETRACK_ACCESS
  189.                             WHERE `access_user_id` = '$uInfo'
  190.                             AND `access_cours_code` = '".$_cid."'
  191.                             AND WEEK(`access_date`) = WEEK( FROM_UNIXTIME('$reqdate') )
  192.                             AND YEAR(`access_date`) = YEAR(FROM_UNIXTIME('$reqdate'))
  193.                             GROUP BY DAYOFMONTH(`access_date`)
  194.                             ORDER BY `access_date` ASC";
  195.                 $weeklowreqdate ($reqdate-(86400*date("w" $reqdate)));
  196.                 $weekhighreqdate ($reqdate+(86400*(6-date("w" $reqdate)) ));
  197.                 $displayedDate get_lang('From')." ".date("d " $weeklowreqdate).$MonthsLong[date("n"$weeklowreqdate)-1].date(" Y" $weeklowreqdate)
  198.                                 ." ".get_lang('To')." ".date("d " $weekhighreqdate ).$MonthsLong[date("n"$weekhighreqdate)-1].date(" Y" $weekhighreqdate);
  199.                 break;
  200.         }
  201.         echo "<tr><td>";
  202.         $results getManyResults1Col($sql);
  203.         /*** display of the displayed period  ***/
  204.         echo "<table width='100%' cellpadding='2' cellspacing='1' border='0' align=center>";
  205.         echo "<td bgcolor='#E6E6E6'>".$displayedDate."</td>";
  206.         if (is_array($results))
  207.         {
  208.             for ($j $j sizeof($results)$j++)
  209.             {
  210.                 $timestamp strtotime($results[$j]);
  211.                 //$beautifulDate = $langDay_of_weekNames['long'][date("w" , $timestamp)].date(" d " , $timestamp);
  212.                 //$beautifulHour = date("H : i" , $timestamp);
  213.                 $beautifulDateTime format_locale_date($dateTimeFormatLong,$timestamp);
  214.                 echo "<tr>";
  215.                 echo "<td style='padding-left : 40px;' valign='top'>".$beautifulDateTime."</td>";
  216.                 echo"</tr>";
  217.                 // $limit is used to select only results between $results[$j] (current login) and next one
  218.                 if$j == sizeof($results) )
  219.                     $limit date("Y-m-d H:i:s",$nextReqDate);
  220.                 else
  221.                     $limit $results[$j+1];
  222.                 // select all access to tool between displayed date and next displayed date or now() if
  223.                 // displayed date is the last login date
  224.                 $sql "SELECT `access_tool`, count(`access_tool`)
  225.                             FROM $TABLETRACK_ACCESS
  226.                             WHERE `access_user_id` = '$uInfo'
  227.                                 AND `access_tool` IS NOT NULL
  228.                                 AND `access_date` > '".$results[$j]."'
  229.                                 AND `access_date` < '".$limit."'
  230.                                 AND `access_cours_code` = '".$_cid."'
  231.                             GROUP BY `access_tool`
  232.                             ORDER BY `access_tool` ASC";
  233.                 $results2 getManyResults2Col($sql);
  234.  
  235.                 if (is_array($results2))
  236.                 {
  237.                     echo "<tr><td colspan='2'>\n";
  238.                     echo "<table width='50%' cellpadding='0' cellspacing='0' border='0'>\n";
  239.                     for($k $k count($results2$k++)
  240.                     {
  241.                             echo "<tr>\n";
  242.                             echo "<td width='70%' style='padding-left : 60px;'>".get_lang($results2[$k][0])."</td>\n";
  243.                             echo "<td width='30%' align='right' style='padding-right : 40px'>".$results2[$k][1]." ".get_lang('Visits')."</td>\n";
  244.                             echo "</tr>";
  245.  
  246.                     }
  247.                     echo "</table>\n";
  248.                     echo "</td></tr>\n";
  249.                 }
  250.                 $previousDate $value;
  251.             }
  252.  
  253.         }
  254.         else
  255.         {
  256.             echo "<tr>";
  257.             echo "<td colspan='2' bgcolor='#eeeeee'><center>".get_lang('NoResult')."</center></td>";
  258.             echo "</tr>";
  259.         }
  260.         echo "</table>";
  261.         echo "</td></tr>";
  262.     }
  263.     else
  264.     {
  265.         echo get_lang('ErrorUserNotInGroup');
  266.     }
  267.  
  268. }
  269. // not allowed
  270. else
  271. {
  272.     if(!$_configuration['tracking_enabled'])
  273.     {
  274.         echo get_lang('TrackingDisabled');
  275.     }
  276.     else
  277.     {
  278.         api_not_allowed();
  279.     }
  280. }
  281. ?>
  282.  
  283. </table>
  284.  
  285. <?php
  286. ?>

Documentation generated on Thu, 12 Jun 2008 14:01:12 -0500 by phpDocumentor 1.4.1