[ Index ]
 

Code source de Claroline 188

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/claroline/tracking/ -> user_access_details.php (source)

   1  <?php // $Id: user_access_details.php,v 1.41 2007/01/25 11:38:38 moosh Exp $
   2  /**
   3   * CLAROLINE
   4   *
   5   * @version 1.6 *
   6   *
   7   * @copyright 2001-2007 Universite catholique de Louvain (UCL)
   8   * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE
   9   * @author see CREDITS.txt
  10   *
  11   */
  12  require  '../inc/claro_init_global.inc.php';
  13  
  14  $nameTools = get_lang('User access details');
  15  
  16  $interbredcrump[]= array ("url"=>"courseLog.php", "name"=> get_lang('Statistics'));
  17  
  18  $tbl_mdb_names       = claro_sql_get_main_tbl();
  19  $TABLEUSER           = $tbl_mdb_names['user'  ];
  20  $tbl_cdb_names       = claro_sql_get_course_tbl();
  21  $TABLETRACK_ACCESS        = $tbl_cdb_names['track_e_access'];
  22  $TABLETRACK_DOWNLOADS        = $tbl_cdb_names['track_e_downloads'];
  23  
  24  include get_path('incRepositorySys') . '/lib/statsUtils.lib.inc.php';
  25  
  26  $toolTitle['mainTitle'] = $nameTools;
  27  
  28  $is_allowedToTrack = claro_is_course_manager();
  29  
  30  include get_path('incRepositorySys') . '/claro_init_header.inc.php';
  31  
  32  if( $is_allowedToTrack && get_conf('is_trackingEnabled') )
  33  {
  34       if( isset($_REQUEST['cmd']) && ( $_REQUEST['cmd'] == 'tool' && !empty($_REQUEST['id']) ) )
  35      {
  36              // set the subtitle for the echo claro_html_tool_title function
  37              $sql = "SELECT `access_tlabel` AS `label`
  38                      FROM `" . $TABLETRACK_ACCESS . "`
  39                      WHERE `access_tid` = ". (int)$_REQUEST['id']."
  40                      GROUP BY `access_tid`" ;
  41  
  42              $viewedToolLabel = claro_sql_query_get_single_row($sql);
  43  
  44              if( isset($viewedToolLabel['label']) && isset($toolNameList[$viewedToolLabel['label']]) )
  45                      $toolTitle['subTitle'] = get_lang('Tool')." : ".$toolNameList[$viewedToolLabel['label']];
  46  
  47  
  48              // prepare SQL query
  49              $sql = "SELECT `nom` AS `lastName`,
  50                          `prenom` AS `firstName`,
  51                          MAX(UNIX_TIMESTAMP(`access_date`)) AS `data`,
  52                          COUNT(`access_date`) AS `nbr`
  53                      FROM `".$TABLETRACK_ACCESS."`
  54                      LEFT JOIN `".$TABLEUSER."`
  55                      ON `access_user_id` = `user_id`
  56                      WHERE `access_tid` = '". (int)$_REQUEST['id']."'
  57                      GROUP BY `nom`, `prenom`
  58                      ORDER BY `nom`, `prenom`";
  59      }
  60      elseif( isset($_REQUEST['cmd']) && ( $_REQUEST['cmd'] == 'doc' && !empty($_REQUEST['path']) ) )
  61      {
  62              // set the subtitle for the echo claro_html_tool_title function
  63              $toolTitle['subTitle'] = get_lang('Documents and Links')." : ". htmlspecialchars($_REQUEST['path']);
  64              // prepare SQL query
  65              $sql = "SELECT `nom` as `lastName`,
  66                          `prenom` as `firstName`,
  67                          MAX(UNIX_TIMESTAMP(`down_date`)) AS `data`,
  68                          COUNT(`down_date`) AS `nbr`
  69                      FROM `".$TABLETRACK_DOWNLOADS."`
  70                      LEFT JOIN `".$TABLEUSER."`
  71                      ON `down_user_id` = `user_id`
  72                      WHERE `down_doc_path` = '". addslashes($_REQUEST['path']) ."'
  73                      GROUP BY `nom`, `prenom`
  74                      ORDER BY `nom`, `prenom`";
  75      }
  76      else
  77      {
  78          $dialogBox = get_lang('Wrong operation');
  79      }
  80  
  81      echo claro_html_tool_title($toolTitle);
  82  
  83      if( isset($dialogBox) ) echo claro_html_message_box($dialogBox);
  84  
  85  
  86      // TODO  use datagrid
  87      echo '<br />' . "\n\n"
  88      .    '<table class="claroTable" border="0" cellpadding="5" cellspacing="1">' . "\n"
  89      .    '<tr class="headerX">'."\n"
  90      .    '<th>' . get_lang('Username') . '</th>' . "\n"
  91      .    '<th>' . get_lang('Last access') . '</th>' . "\n"
  92      .    '<th>' . get_lang('Access count') . '</th>' . "\n"
  93      .    '</tr>' . "\n"
  94      .    '<tbody>' . "\n\n"
  95      ;
  96  
  97      $i = 0;
  98      $anonymousCount = 0;
  99      if( isset($sql) )
 100      {
 101          $accessList = claro_sql_query_fetch_all($sql);
 102          // display the list
 103          foreach ( $accessList as $userAccess )
 104          {
 105              $userName = $userAccess['lastName']." ".$userAccess['firstName'];
 106              if( empty($userAccess['lastName']) )
 107              {
 108                   $anonymousCount = $userAccess['nbr'];
 109                  continue;
 110              }
 111              $i++;
 112              echo '<tr>' . "\n"
 113              .    '<td>' . $userName . '</td>' . "\n"
 114              .    '<td>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), $userAccess['data']) . '</td>' . "\n"
 115              .    '<td>' . $userAccess['nbr'] . '</td>' . "\n"
 116              .    '</tr>' . "\n\n"
 117              ;
 118          }
 119      }
 120      // in case of error or no results to display
 121      if( $i == 0 || !isset($sql) )
 122      {
 123          echo '<td colspan="3">' . "\n"
 124          .    '<center>' . get_lang('No result') . '</center>' . "\n"
 125          .    '</td>' . "\n\n"
 126          ;
 127      }
 128  
 129      echo '</tbody>' . "\n\n"
 130      .    '</table>' . "\n\n"
 131      ;
 132  
 133      if( $anonymousCount != 0 )
 134      {
 135          echo '<p>'.get_lang('Anonymous users access count : ').' '.$anonymousCount.'</p>'."\n";
 136      }
 137  
 138  }
 139  // not allowed
 140  else
 141  {
 142      if(!get_conf('is_trackingEnabled'))
 143      {
 144          echo get_lang('Tracking has been disabled by system administrator.');
 145      }
 146      else
 147      {
 148          echo get_lang('Not allowed');
 149      }
 150  }
 151  
 152  // footer
 153  include get_path('incRepositorySys') . '/claro_init_footer.inc.php';
 154  ?>


Généré le : Thu Nov 29 14:38:42 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics