diff --git a/whoisonline.php b/whoisonline.php
index d0cc362f75..b87e6d60cc 100644
--- a/whoisonline.php
+++ b/whoisonline.php
@@ -1,382 +1,382 @@
-
- function show_image(image,width,height) {
- width = parseInt(width) + 20;
- height = parseInt(height) + 20;
- window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
- }
-
-';
-$htmlHeadXtra[] = '';
-$htmlHeadXtra[] = '';
-$htmlHeadXtra[] = ' ';
-$htmlHeadXtra[] = '';
-if ($_GET['chatid'] != '') {
- //send out call request
- $time = time();
- $time = date("Y-m-d H:i:s", $time);
- $chatid = addslashes($_GET['chatid']);
- if ($_GET['chatid']==strval(intval($_GET['chatid']))) {
- $sql="update $track_user_table set chatcall_user_id = '".Database::escape_string($_user['user_id'])."', chatcall_date = '".Database::escape_string($time)."', chatcall_text = '' where (user_id = ".(int)Database::escape_string($chatid).")";
- $result=api_sql_query($sql,__FILE__,__LINE__);
- //redirect caller to chat
- header("Location: ".$_configuration['code_append']."chat/chat.php?".api_get_cidreq()."&origin=whoisonline&target=".Security::remove_XSS($chatid));
- exit;
- }
-}
-
-
-/**
- * Displays a sortable table with the list of online users.
- * @param array $user_list
- */
-function display_user_list($user_list, $_plugins)
-{
- global $charset;
- if ($_GET["id"]=='') {
- $extra_params = array();
- $course_url = '';
- if(strlen($_GET['cidReq']) > 0) {
- $extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
- $course_url = '&cidReq='.Security::remove_XSS($_GET['cidReq']);
- }
- foreach ($user_list as $user) {
- $uid=$user[0];
- $user_info = api_get_user_info($uid);
- $table_row = array();
- $url = '?id='.$uid.$course_url;
- $image_array=UserManager::get_user_picture_path_by_id($uid,'system',false,true);
-
- $friends_profile = UserFriend::get_picture_user($uid, $image_array['file'], 92, 'medium_', ' width="90" height="90" ');
- //reduce image
- $table_row[] = '
';
- $table_row[] = ''.$user_info['firstName'].' '.$user_info['lastName'].' ';
-
- //$table_row[] = ''.$user_info['lastName'].' ';
-
- if (api_get_setting('show_email_addresses') == 'true') {
- $table_row[] = Display::encrypted_mailto_link($user_info['mail']);
- }
- $user_anonymous=api_get_anonymous_id();
- if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>$user_anonymous && api_get_user_id()<>0) {
- if ($user_info['user_id'] != api_get_user_id() && !api_is_anonymous($user_info['user_id'])) {
- $user_relation=UserFriend::get_relation_between_contacts(api_get_user_id(),$user_info['user_id']);
- if ($user_relation==0 || $user_relation==6) {
- $table_row[] = ''.Display :: return_icon('add_multiple_users.gif', get_lang('SocialAddToFriends')).' '.get_lang('SocialAddToFriends').'
- '.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).' '.get_lang('SendAMessage').' ';
- } else {
- $table_row[] = ''.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).' '.get_lang('SendAMessage').' ';
- }
- }
- }
- $table_data[] = $table_row;
- }
- $table_header[] = array(get_lang('UserPicture'),false,'width="90"');
- $table_header[] = array(get_lang('Name'),true);
- //$table_header[] = array(get_lang('LastName'),true);
-
- if (api_get_setting('show_email_addresses') == 'true') {
- $table_header[] = array(get_lang('Email'),true);
- }
- $user_anonymous=api_get_anonymous_id();
- if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>$user_anonymous && api_get_user_id()<>0) {
- $table_header[] = array(get_lang('Friends'),false,'width="200"');
- }
- /*this feature is deprecated
- if ( api_get_setting('allow_message_tool')=='true' && isset($_SESSION['_user'])) {
- $table_header[] = array(get_lang('SendMessage'),true);
- }
- */
- $sorting_options['column'] = (isset ($_GET['column']) ? (int)$_GET['column'] : 2);
- /*if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true' ) {
- //send_invitation_friend_user();
- echo '
';
- echo '';
- }*/
- }
-}
-/**
- * Displays the information of an individual user
- * @param int $user_id
- */
-function display_individual_user($user_id)
-{
- global $interbreadcrumb;
- $safe_user_id = Database::escape_string($user_id);
-
- // to prevent a hacking attempt: http://www.dokeos.com/forum/viewtopic.php?t=5363
- $user_table=Database::get_main_table(TABLE_MAIN_USER);
- $sql = "SELECT * FROM $user_table WHERE user_id='".$safe_user_id."'";
- $result=api_sql_query($sql,__FILE__,__LINE__);
- if (Database::num_rows($result)==1) {
- $user_object = Database::fetch_object($result);
- $name = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? ' ('.get_lang('Me').') ' : '' );
- $alt = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? ' ('.get_lang('Me').')' : '');
- $status = ($user_object->status == COURSEMANAGER ? get_lang('Teacher') : get_lang('Student'));
- $interbreadcrumb[]=array("url" => "whoisonline.php","name" => get_lang('UsersOnLineList'));
- Display::display_header($alt);
- echo '';
- echo $alt;
- echo '
';
- echo '';
- if (strlen(trim($user_object->picture_uri)) > 0) {
- $sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id,'system');
- $sysdir = $sysdir_array['dir'];
- $webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id,'web');
- $webdir = $webdir_array['dir'];
- $fullurl=$webdir.$user_object->picture_uri;
- $system_image_path=$sysdir.$user_object->picture_uri;
- list($width, $height, $type, $attr) = getimagesize($system_image_path);
- $resizing = (($height > 200) ? 'height="200"' : '');
- $height += 30;
- $width += 30;
- $window_name = 'window'.uniqid('');
- // get the path,width and height from original picture
- $big_image = $webdir.'big_'.$user_object->picture_uri;
- $big_image_size = @getimagesize(api_url_to_local_path($big_image));
- $big_image_width= $big_image_size[0];
- $big_image_height= $big_image_size[1];
- $url_big_image = $big_image.'?rnd='.time();
- echo '
';
- global $user_anonymous;
- if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>$user_anonymous && api_get_user_id()<>0) {
- echo '
';
- echo '
'.get_lang('ViewSharedProfile').' ';
- echo '
';
- }
- } else {
- echo Display::return_icon('unknown.jpg',get_lang('Unknown'));
- echo '
';
- }
-
- if (api_get_setting("show_email_addresses") == "true")
- {
- echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'
';
- }
- echo $status.'
';
- echo '
';
- if ($user_object->competences) {
- echo ''.get_lang('MyCompetences').'
';
- echo ''.$user_object->competences.' ';
- }
- if ($user_object->diplomas) {
- echo ''.get_lang('MyDiplomas').'
';
- echo ''.$user_object->diplomas.' ';
- }
- if ($user_object->teach) {
- echo ''.get_lang('MyTeach').'
';
- echo ''.$user_object->teach.' ';;
- }
- display_productions($user_object->user_id);
- if ($user_object->openarea) {
- echo ''.get_lang('MyPersonalOpenArea').'
';
- echo ''.$user_object->openarea.' ';
- }
- }
- else
- {
- Display::display_header(get_lang('UsersOnLineList'));
- echo '';
- echo get_lang('UsersOnLineList');
- echo '
';
- }
-}
-/**
- * Display productions in whoisonline
- * @param int $user_id User id
- * @todo use the correct api_get_path instead of $clarolineRepositoryWeb
- */
-function display_productions($user_id)
-{
- $sysdir_array = UserManager::get_user_picture_path_by_id($user_id,'system');
- $sysdir = $sysdir_array['dir'].$user_id.'/';
- $webdir_array = UserManager::get_user_picture_path_by_id($user_id,'web');
- $webdir = $webdir_array['dir'].$user_id.'/';
- if( !is_dir($sysdir)) {
- mkpath($sysdir);
- }
- $handle = opendir($sysdir);
- $productions = array();
- while ($file = readdir($handle)) {
- if ($file == '.' || $file == '..' || $file == '.htaccess') {
- continue; // Skip current and parent directories
- }
- $productions[] = $file;
- }
- if(count($productions) > 0) {
- echo ''.get_lang('Productions').' ';
- echo '';
- foreach($productions as $index => $file) {
- // Only display direct file links to avoid browsing an empty directory
- if(is_file($sysdir.$file) && $file != $webdir_array['file']){
- echo ''.$file.' ';
- }
- // Real productions are under a subdirectory by the User's id
- if(is_dir($sysdir.$file)) {
- $subs = scandir($sysdir.$file);
- foreach($subs as $my => $sub) {
- if(substr($sub,0,1) != '.' && is_file($sysdir.$file.'/'.$sub))
- {
- echo ''.$sub.' ';
- }
- }
- }
- }
- echo ' ';
- }
-}
-
-// This if statement prevents users accessing the who's online feature when it has been disabled.
-if ((api_get_setting('showonline','world') == 'true' AND !$_user['user_id']) OR ((api_get_setting('showonline','users') == 'true' OR api_get_setting('showonline','course') == 'true') AND $_user['user_id'])) {
- if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
- $user_list = Who_is_online_in_this_course($_user['user_id'],api_get_setting('time_limit_whosonline'),$_GET['cidReq']);
- } else {
- $user_list = WhoIsOnline($_user['user_id'],$_configuration['statistics_database'],api_get_setting('time_limit_whosonline'));
- }
-
-
- $total=count($user_list);
- if (!isset($_GET['id']))
- {
- Display::display_header(get_lang('UsersOnLineList'));
- echo '';
- echo get_lang('UsersOnLineList');
- echo '
';
- echo ''.get_lang('TotalOnLine').' : '.$total.'
';
- if ($_GET['id']=='') {
- echo ''.get_lang('Refresh').'
';
- } else {
- if(0) // if ($_user['user_id'] && $_GET["id"] != $_user['user_id'])
- {
- echo ''.get_lang('SendChatRequest').' ';
- }
- }
- }
-
- if ($user_list!=false)
- {
- if (!isset($_GET['id']))
- {
- display_user_list($user_list, $_plugins);
- }
- else //individual user information - also displays header info
- {
- display_individual_user(Security::remove_XSS($_GET['id']));
- }
- }
- elseif(isset($_GET['id']))
- {
- Display::display_header(get_lang('UsersOnLineList'));
- echo '';
- echo get_lang('UsersOnLineList');
- echo '
';
- }
-}
-else
-{
- Display::display_header(get_lang('UsersOnLineList'));
- Display::display_error_message(get_lang('AccessNotAllowed'));
-}
-$referer = empty($_GET['referer'])?'index.php':api_htmlentities(strip_tags($_GET['referer']),ENT_QUOTES,$charset);
-
-if (isset($_GET['id'])) {
- echo ''.get_lang('Back').' ';
-} else {
- echo ''.get_lang('BackHome').' ';
-}
-
-/*
-==============================================================================
- FOOTER
-==============================================================================
-*/
-/*echo '';*/
-Display::display_footer();
-?>
+
+ function show_image(image,width,height) {
+ width = parseInt(width) + 20;
+ height = parseInt(height) + 20;
+ window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
+ }
+
+';
+$htmlHeadXtra[] = '';
+$htmlHeadXtra[] = '';
+$htmlHeadXtra[] = ' ';
+$htmlHeadXtra[] = '';
+if ($_GET['chatid'] != '') {
+ //send out call request
+ $time = time();
+ $time = date("Y-m-d H:i:s", $time);
+ $chatid = addslashes($_GET['chatid']);
+ if ($_GET['chatid']==strval(intval($_GET['chatid']))) {
+ $sql="update $track_user_table set chatcall_user_id = '".Database::escape_string($_user['user_id'])."', chatcall_date = '".Database::escape_string($time)."', chatcall_text = '' where (user_id = ".(int)Database::escape_string($chatid).")";
+ $result=api_sql_query($sql,__FILE__,__LINE__);
+ //redirect caller to chat
+ header("Location: ".$_configuration['code_append']."chat/chat.php?".api_get_cidreq()."&origin=whoisonline&target=".Security::remove_XSS($chatid));
+ exit;
+ }
+}
+
+
+/**
+ * Displays a sortable table with the list of online users.
+ * @param array $user_list
+ */
+function display_user_list($user_list, $_plugins)
+{
+ global $charset;
+ if ($_GET["id"]=='') {
+ $extra_params = array();
+ $course_url = '';
+ if(strlen($_GET['cidReq']) > 0) {
+ $extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
+ $course_url = '&cidReq='.Security::remove_XSS($_GET['cidReq']);
+ }
+ foreach ($user_list as $user) {
+ $uid=$user[0];
+ $user_info = api_get_user_info($uid);
+ $table_row = array();
+ $url = '?id='.$uid.$course_url;
+ $image_array=UserManager::get_user_picture_path_by_id($uid,'system',false,true);
+
+ $friends_profile = UserFriend::get_picture_user($uid, $image_array['file'], 92, 'medium_', ' width="90" height="90" ');
+ //reduce image
+ $table_row[] = ' ';
+ $table_row[] = ''.$user_info['firstName'].' '.$user_info['lastName'].' ';
+
+ //$table_row[] = ''.$user_info['lastName'].' ';
+
+ if (api_get_setting('show_email_addresses') == 'true') {
+ $table_row[] = Display::encrypted_mailto_link($user_info['mail']);
+ }
+ $user_anonymous=api_get_anonymous_id();
+ if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>$user_anonymous && api_get_user_id()<>0) {
+ if ($user_info['user_id'] != api_get_user_id() && !api_is_anonymous($user_info['user_id'])) {
+ $user_relation=UserFriend::get_relation_between_contacts(api_get_user_id(),$user_info['user_id']);
+ if ($user_relation==0 || $user_relation==6) {
+ $table_row[] = ''.Display :: return_icon('add_multiple_users.gif', get_lang('SocialInvitationToFriends')).' '.get_lang('SendInvitation').'
+ '.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).' '.get_lang('SendAMessage').' ';
+ } else {
+ $table_row[] = ''.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).' '.get_lang('SendAMessage').' ';
+ }
+ }
+ }
+ $table_data[] = $table_row;
+ }
+ $table_header[] = array(get_lang('UserPicture'),false,'width="90"');
+ $table_header[] = array(get_lang('Name'),true);
+ //$table_header[] = array(get_lang('LastName'),true);
+
+ if (api_get_setting('show_email_addresses') == 'true') {
+ $table_header[] = array(get_lang('Email'),true);
+ }
+ $user_anonymous=api_get_anonymous_id();
+ if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>$user_anonymous && api_get_user_id()<>0) {
+ $table_header[] = array(get_lang('Friends'),false,'width="200"');
+ }
+ /*this feature is deprecated
+ if ( api_get_setting('allow_message_tool')=='true' && isset($_SESSION['_user'])) {
+ $table_header[] = array(get_lang('SendMessage'),true);
+ }
+ */
+ $sorting_options['column'] = (isset ($_GET['column']) ? (int)$_GET['column'] : 2);
+ /*if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true' ) {
+ //send_invitation_friend_user();
+ echo '
';
+ echo '';
+ }*/
+ }
+}
+/**
+ * Displays the information of an individual user
+ * @param int $user_id
+ */
+function display_individual_user($user_id)
+{
+ global $interbreadcrumb;
+ $safe_user_id = Database::escape_string($user_id);
+
+ // to prevent a hacking attempt: http://www.dokeos.com/forum/viewtopic.php?t=5363
+ $user_table=Database::get_main_table(TABLE_MAIN_USER);
+ $sql = "SELECT * FROM $user_table WHERE user_id='".$safe_user_id."'";
+ $result=api_sql_query($sql,__FILE__,__LINE__);
+ if (Database::num_rows($result)==1) {
+ $user_object = Database::fetch_object($result);
+ $name = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? ' ('.get_lang('Me').') ' : '' );
+ $alt = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? ' ('.get_lang('Me').')' : '');
+ $status = ($user_object->status == COURSEMANAGER ? get_lang('Teacher') : get_lang('Student'));
+ $interbreadcrumb[]=array("url" => "whoisonline.php","name" => get_lang('UsersOnLineList'));
+ Display::display_header($alt);
+ echo '';
+ echo $alt;
+ echo '
';
+ echo '';
+ if (strlen(trim($user_object->picture_uri)) > 0) {
+ $sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id,'system');
+ $sysdir = $sysdir_array['dir'];
+ $webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id,'web');
+ $webdir = $webdir_array['dir'];
+ $fullurl=$webdir.$user_object->picture_uri;
+ $system_image_path=$sysdir.$user_object->picture_uri;
+ list($width, $height, $type, $attr) = getimagesize($system_image_path);
+ $resizing = (($height > 200) ? 'height="200"' : '');
+ $height += 30;
+ $width += 30;
+ $window_name = 'window'.uniqid('');
+ // get the path,width and height from original picture
+ $big_image = $webdir.'big_'.$user_object->picture_uri;
+ $big_image_size = @getimagesize(api_url_to_local_path($big_image));
+ $big_image_width= $big_image_size[0];
+ $big_image_height= $big_image_size[1];
+ $url_big_image = $big_image.'?rnd='.time();
+ echo '
';
+ global $user_anonymous;
+ if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>$user_anonymous && api_get_user_id()<>0) {
+ echo '
';
+ echo '
'.get_lang('ViewSharedProfile').' ';
+ echo '
';
+ }
+ } else {
+ echo Display::return_icon('unknown.jpg',get_lang('Unknown'));
+ echo '
';
+ }
+
+ if (api_get_setting("show_email_addresses") == "true")
+ {
+ echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'
';
+ }
+ echo $status.'
';
+ echo '
';
+ if ($user_object->competences) {
+ echo ''.get_lang('MyCompetences').'
';
+ echo ''.$user_object->competences.' ';
+ }
+ if ($user_object->diplomas) {
+ echo ''.get_lang('MyDiplomas').'
';
+ echo ''.$user_object->diplomas.' ';
+ }
+ if ($user_object->teach) {
+ echo ''.get_lang('MyTeach').'
';
+ echo ''.$user_object->teach.' ';;
+ }
+ display_productions($user_object->user_id);
+ if ($user_object->openarea) {
+ echo ''.get_lang('MyPersonalOpenArea').'
';
+ echo ''.$user_object->openarea.' ';
+ }
+ }
+ else
+ {
+ Display::display_header(get_lang('UsersOnLineList'));
+ echo '';
+ echo get_lang('UsersOnLineList');
+ echo '
';
+ }
+}
+/**
+ * Display productions in whoisonline
+ * @param int $user_id User id
+ * @todo use the correct api_get_path instead of $clarolineRepositoryWeb
+ */
+function display_productions($user_id)
+{
+ $sysdir_array = UserManager::get_user_picture_path_by_id($user_id,'system');
+ $sysdir = $sysdir_array['dir'].$user_id.'/';
+ $webdir_array = UserManager::get_user_picture_path_by_id($user_id,'web');
+ $webdir = $webdir_array['dir'].$user_id.'/';
+ if( !is_dir($sysdir)) {
+ mkpath($sysdir);
+ }
+ $handle = opendir($sysdir);
+ $productions = array();
+ while ($file = readdir($handle)) {
+ if ($file == '.' || $file == '..' || $file == '.htaccess') {
+ continue; // Skip current and parent directories
+ }
+ $productions[] = $file;
+ }
+ if(count($productions) > 0) {
+ echo ''.get_lang('Productions').' ';
+ echo '';
+ foreach($productions as $index => $file) {
+ // Only display direct file links to avoid browsing an empty directory
+ if(is_file($sysdir.$file) && $file != $webdir_array['file']){
+ echo ''.$file.' ';
+ }
+ // Real productions are under a subdirectory by the User's id
+ if(is_dir($sysdir.$file)) {
+ $subs = scandir($sysdir.$file);
+ foreach($subs as $my => $sub) {
+ if(substr($sub,0,1) != '.' && is_file($sysdir.$file.'/'.$sub))
+ {
+ echo ''.$sub.' ';
+ }
+ }
+ }
+ }
+ echo ' ';
+ }
+}
+
+// This if statement prevents users accessing the who's online feature when it has been disabled.
+if ((api_get_setting('showonline','world') == 'true' AND !$_user['user_id']) OR ((api_get_setting('showonline','users') == 'true' OR api_get_setting('showonline','course') == 'true') AND $_user['user_id'])) {
+ if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
+ $user_list = Who_is_online_in_this_course($_user['user_id'],api_get_setting('time_limit_whosonline'),$_GET['cidReq']);
+ } else {
+ $user_list = WhoIsOnline($_user['user_id'],$_configuration['statistics_database'],api_get_setting('time_limit_whosonline'));
+ }
+
+
+ $total=count($user_list);
+ if (!isset($_GET['id']))
+ {
+ Display::display_header(get_lang('UsersOnLineList'));
+ echo '';
+ echo get_lang('UsersOnLineList');
+ echo '
';
+ echo ''.get_lang('TotalOnLine').' : '.$total.'
';
+ if ($_GET['id']=='') {
+ echo ''.get_lang('Refresh').'
';
+ } else {
+ if(0) // if ($_user['user_id'] && $_GET["id"] != $_user['user_id'])
+ {
+ echo ''.get_lang('SendChatRequest').' ';
+ }
+ }
+ }
+
+ if ($user_list!=false)
+ {
+ if (!isset($_GET['id']))
+ {
+ display_user_list($user_list, $_plugins);
+ }
+ else //individual user information - also displays header info
+ {
+ display_individual_user(Security::remove_XSS($_GET['id']));
+ }
+ }
+ elseif(isset($_GET['id']))
+ {
+ Display::display_header(get_lang('UsersOnLineList'));
+ echo '';
+ echo get_lang('UsersOnLineList');
+ echo '
';
+ }
+}
+else
+{
+ Display::display_header(get_lang('UsersOnLineList'));
+ Display::display_error_message(get_lang('AccessNotAllowed'));
+}
+$referer = empty($_GET['referer'])?'index.php':api_htmlentities(strip_tags($_GET['referer']),ENT_QUOTES,$charset);
+
+if (isset($_GET['id'])) {
+ echo ''.get_lang('Back').' ';
+} else {
+ echo ''.get_lang('BackHome').' ';
+}
+
+/*
+==============================================================================
+ FOOTER
+==============================================================================
+*/
+/*echo '';*/
+Display::display_footer();
+?>