d752f2c51f6fb444a8185ab566ea089b4a95ecb9
[atutor.git] / docs / include / html / dropdowns / users_online.inc.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
15 global $db;
16 global $_base_path;
17 global $savant;
18 global $system_courses;
19
20 // global $_course_id is set when a guest accessing a public course. 
21 // This is to solve the issue that the google indexing fails as the session vars are lost.
22 global $_course_id;
23 if (isset($_SESSION['course_id'])) $_course_id = $_SESSION['course_id'];
24
25 ob_start(); 
26
27 $sql    = "SELECT * FROM ".TABLE_PREFIX."users_online WHERE course_id=$_course_id AND expiry>".time()." ORDER BY login";
28 $result = mysql_query($sql, $db);
29 if ($row = mysql_fetch_assoc($result)) {
30         echo '<ul style="padding: 0px; list-style: none;">';
31         do {
32                 $type = 'class="user"';
33                 if ($system_courses[$_course_id]['member_id'] == $row['member_id']) {
34                         $type = 'class="user instructor" title="'._AT('instructor').'"';
35                 }
36                 echo '<li style="padding: 3px 0px;"><a href="'.$_base_path.'profile.php?id='.$row['member_id'].'" '.$type.'>'.AT_print($row['login'], 'members.login').'</a></li>';
37         } while ($row = mysql_fetch_assoc($result));
38         echo '</ul>';
39 } else {
40         echo '<strong>'._AT('none_found').'</strong><br />';
41 }
42
43 echo '<strong>'._AT('guests_not_listed').'</strong>';
44
45 $savant->assign('dropdown_contents', ob_get_contents());
46 ob_end_clean();
47 $savant->assign('title', _AT('users_online'));
48 $savant->display('include/box.tmpl.php');
49 ?>