Dokeos PHP Cross Reference Learning Management Systems

Source: /whoisonlinesession.php - 138 lines - 4075 bytes - Summary - Text - Print

   1  <?php
   2  /* For licensing terms, see /dokeos_license.txt */
   3  
   4  // name of the language file that needs to be included
   5  $language_file = array ('index', 'chat', 'tracking');
   6  
   7  include_once  './main/inc/global.inc.php';
   8  api_block_anonymous_users();
   9  
  10  $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  11  $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  12  $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  13  
  14  /*
  15  -----------------------------------------------------------
  16      Header
  17      include the HTTP, HTML headers plus the top banner
  18  -----------------------------------------------------------
  19  */
  20  
  21  Display::display_header(get_lang('UserOnlineListSession'));
  22  ?>
  23  <br /><br />
  24  <table class="data_table" width="60%">
  25      <tr class="tableName">
  26          <td colspan="4">
  27              <strong><?php echo get_lang('UserOnlineListSession'); ?></strong>
  28          </td>
  29      </tr>
  30      <tr>
  31          <th>
  32              <?php echo get_lang('Name'); ?>
  33          </th>
  34          <th>
  35              <?php echo get_lang('InCourse'); ?>
  36          </th>
  37          <th>
  38              <?php echo get_lang('Email'); ?>
  39          </th>
  40          <th>
  41              <?php echo get_lang('Chat'); ?>
  42          </th>
  43      </tr>
  44  <?php
  45      $session_is_coach = array();
  46      if (isset($_user['user_id']) && $_user['user_id'] != '') {
  47          $_user['user_id'] = intval($_user['user_id']);
  48          $result = Database::query("SELECT DISTINCT id,
  49                                          name,
  50                                          date_start,
  51                                          date_end
  52                                      FROM $tbl_session as session
  53                                      INNER JOIN $tbl_session_course_user as srcru
  54                                          ON srcru.id_user = ".$_user['user_id']." AND srcru.status=2
  55                                          AND session.id = srcru.id_session
  56                                      ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  57  
  58          while ($session = Database:: fetch_array($result)) {
  59              $session_is_coach[$session['id']] = $session;
  60          }
  61  
  62          $result = Database::query("SELECT DISTINCT id,
  63                                          name,
  64                                          date_start,
  65                                          date_end
  66                                  FROM $tbl_session as session
  67                                  WHERE session.id_coach = ".$_user['user_id']."
  68                                  ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  69          while ($session = Database:: fetch_array($result)) {
  70              $session_is_coach[$session['id']] = $session;
  71          }
  72  
  73          $students_online = array();
  74          foreach ($session_is_coach as $session) {
  75              $sql = "SELECT     DISTINCT last_access.access_user_id,
  76                              last_access.access_date,
  77                              last_access.access_cours_code,
  78                              last_access.access_session_id,
  79                              ".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." as name,
  80                              user.email
  81                      FROM ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)." AS last_access
  82                      INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user
  83                          ON user.user_id = last_access.access_user_id
  84                      WHERE access_session_id='".$session['id']."'
  85                      AND NOW()-access_date<1000 GROUP BY access_user_id";
  86  
  87              $result = Database::query($sql, __FILE__, __LINE__);
  88  
  89              while($user_list = Database::fetch_array($result)) {
  90                  $students_online[$user_list['access_user_id']] = $user_list;
  91              }
  92          }
  93  
  94          if (count($students_online) > 0) {
  95              foreach ($students_online as $student_online) {
  96                  echo "<tr>
  97                          <td>
  98                      ";
  99                  echo $student_online['name'];
 100                  echo "    </td>
 101                          <td align='center'>
 102                       ";
 103                  echo $student_online['access_cours_code'];
 104                  echo "    </td>
 105                          <td align='center'>
 106                       ";
 107                               if (!empty($student_online['email'])) {
 108                                  echo $student_online['email'];
 109                               } else {
 110                                   echo get_lang('NoEmail');
 111                               }
 112                  echo "    </td>
 113                          <td align='center'>
 114                       ";
 115                  echo '<a href="main/chat/chat.php?cidReq='.$student_online['access_cours_code'].'&id_session='.$student_online['access_session_id'].'"> -> </a>';
 116                  echo "    </td>
 117                      </tr>
 118                       ";
 119              }
 120          } else {
 121              echo '    <tr>
 122                          <td colspan="4">
 123                              '.get_lang('NoOnlineStudents').'
 124                          </td>
 125                      </tr>
 126                   ';
 127          }
 128      }
 129  ?>
 130  </table>
 131  <?php
 132  
 133  /*
 134  ==============================================================================
 135          FOOTER
 136  ==============================================================================
 137  */
 138  Display::display_footer();

title

Description

title

Description

title

Description

title

title

Body