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']);
$sql="update $track_user_table set chatcall_user_id = '".mysql_real_escape_string($_user['user_id'])."', chatcall_date = '".mysql_real_escape_string($time)."', chatcall_text = '' where (user_id = ".mysql_real_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'] = Database::escape_string($_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,'web',false,true);
$table_row[] = ' ';
$table_row[] = ''.$user_info['firstName'].' ';
$table_row[] = ''.$user_info['lastName'].' ';
if (api_get_setting('show_email_addresses') == 'true') {
$table_row[] = Display::encrypted_mailto_link($user_info['mail']);
}
if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>2 && api_get_user_id()<>0) {
if ($user_info['user_id'] != api_get_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[] = ' ';
} else {
$table_row[] = ' ';
}
}
}
//this feature is deprecated
/*
if ( api_get_setting('allow_message_tool')=='true' && isset($_SESSION['_user']) ) {
$table_row[] = ' ';
}
*/
$table_data[] = $table_row;
}
$table_header[] = array(get_lang('UserPicture'),true,'width="50"');
$table_header[] = array(get_lang('FirstName'),true);
$table_header[] = array(get_lang('LastName'),true);
if (api_get_setting('show_email_addresses') == 'true') {
$table_header[] = array(get_lang('Email'),true);
}
if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>2 && api_get_user_id()<>0) {
$table_header[] = array(get_lang('Friends'),true,'width="100"');
}
/*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);
api_display_tool_title($alt);
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($big_image);
$big_image_width= $big_image_size[0];
$big_image_height= $big_image_size[1];
$url_big_image = $big_image.'?rnd='.time();
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'));
api_display_tool_title(get_lang('UsersOnLineList'));
}
}
/**
* 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)
{
global $clarolineRepositoryWeb, $disabled_output;
$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'));
api_display_tool_title(get_lang('UsersOnLineList'));
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($_GET['id']);
}
}
elseif(isset($_GET['id']))
{
Display::display_header(get_lang('UsersOnLineList'));
api_display_tool_title(get_lang('UsersOnLineList'));
}
}
else
{
Display::display_header(get_lang('UsersOnLineList'));
Display::display_error_message(get_lang('AccessNotAllowed'));
}
$referer = empty($_GET['referer'])?'index.php':htmlentities(strip_tags($_GET['referer']),ENT_QUOTES,$charset);
if (isset($_GET['id'])) {
echo '< '.get_lang('Back').' ';
} else {
echo '< '.get_lang('Back').' ';
}
/*
==============================================================================
FOOTER
==============================================================================
*/
/*echo '';*/
Display::display_footer();
?>