Dokeos PHP Cross Reference Learning Management Systems

Source: /main/tracking/logins_details.php - 289 lines - 11772 bytes - Summary - Text - Print

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

title

Description

title

Description

title

Description

title

title

Body