Minor fixing who is online list

skala
Julio Montoya 13 years ago
parent 1ff58eaaf4
commit 61940c31e1
  1. 21
      main/inc/ajax/online.ajax.php
  2. 31
      main/inc/lib/online.inc.php
  3. 60
      main/inc/lib/social.lib.php
  4. 9
      main/inc/lib/usermanager.lib.php
  5. 37
      main/social/home.php
  6. 7
      main/social/profile.php
  7. 5
      main/template/default/layout/social_layout.tpl
  8. 39
      whoisonline.php

@ -10,26 +10,33 @@ $action = $_GET['a'];
switch($action) {
case 'load_online_user':
$page = intval($_REQUEST['online_page_nr']);
if (isset($_SESSION['who_is_online_counter'])) {
$_SESSION['who_is_online_counter']++;
} else {
$_SESSION['who_is_online_counter'] = 2;
}
$page = intval($_REQUEST['online_page_nr']);
$max_page = round(who_is_online_count()/10);
if (!isset($_SESSION['online_user_items']) || (isset($_SESSION['online_user_items']) && !in_array($page, $_SESSION['online_user_items']) && $page <= $max_page)) {
if (!empty($max_page) && $page <= $max_page) {
if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
$user_list = who_is_online_in_this_course($page_rows, $page_rows + 10, api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
} else {
} else {
$page_rows = $page*10;
$user_list = who_is_online($page_rows, $page_rows + 10);
}
}
/*
if ($page == 1) {
$_SESSION['online_user_items'] = array();
}
}*/
$_SESSION['online_user_items'][] = $page;
//$_SESSION['online_user_items'][] = $page;
if (!empty($user_list)) {
echo SocialManager::display_user_list($user_list);
exit;
}
}
echo 'end';
break;
default:
break;

@ -182,9 +182,7 @@ function who_is_online($from, $number_of_items, $column = null, $direction = nul
WHERE DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."' AND friend_user_id <> '".api_get_user_id()."' AND relation_type='".USER_RELATION_TYPE_FRIEND."' AND user_id = '".api_get_user_id()."'
ORDER BY $column $direction
LIMIT $from, $number_of_items";
} else {
// all users online
//$query = "SELECT login_user_id,login_date FROM ".$track_online_table ." WHERE DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."' "; //WHERE DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."'
} else {
$query = "SELECT login_user_id, login_date FROM ".$track_online_table ." e INNER JOIN ".$table_user ." u ON (u.user_id=e.login_user_id)
WHERE DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."'
ORDER BY $column $direction
@ -212,15 +210,13 @@ function who_is_online($from, $number_of_items, $column = null, $direction = nul
}
//This query will show all registered users. Only for dev purposes.
/*$query = "SELECT DISTINCT u.user_id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u
$query = "SELECT DISTINCT u.user_id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u
GROUP by u.user_id
ORDER BY $column $direction
LIMIT $from, $number_of_items";
*/
$result = Database::query($query);
if ($result) {
$rtime = time();
$rdate = date("Y-m-d H:i:s",$rtime);
if ($result) {
$validtime = mktime(date("H"),date("i")-$time_limit,date("s"),date("m"),date("d"),date("Y"));
$rarray = array();
@ -257,8 +253,7 @@ function who_is_online_count($valid = null, $friends = false) {
}
$current_date = date('Y-m-d H:i:s',time());
$track_online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
$query = '';
if ($friends) {
// who friends from social network is online
@ -287,8 +282,9 @@ function who_is_online_count($valid = null, $friends = false) {
}
}
//dev purposes
//$query = "SELECT count(u.user_id) as count FROM ".$track_online_table ." e , $table_user u ";
//dev purposes show all users online
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$query = "SELECT count(*) as count FROM ".$table_user ." ";
$result = Database::query($query);
if (Database::num_rows($result) > 0) {
@ -327,7 +323,6 @@ function GetFullUserName($uid) {
* @return string An HTML-formatted message
*/
function chatcall() {
global $_user, $_cid;
if (!$_user['user_id']) {
@ -366,10 +361,8 @@ function chatcall() {
."</p>";
return($message);
}
else
{
return(false);
} else {
return false;
}
}
@ -395,9 +388,7 @@ function who_is_online_in_this_course($from, $number_of_items, $uid, $valid, $co
LIMIT $from, $number_of_items
";
$result = Database::query($query);
if (count($result)>0) {
$rtime = time();
$rdate = date("Y-m-d H:i:s",$rtime);
if (count($result)>0) {
$validtime = mktime(date("H"),date("i")-$valid,date("s"),date("m"),date("d"),date("Y"));
$rarray = array();

@ -745,18 +745,19 @@ class SocialManager extends UserManager {
* Displays a sortable table with the list of online users.
* @param array $user_list
*/
public static function display_user_list($user_list, $query_vars = array()) {
public static function display_user_list($user_list) {
if ($_GET['id'] == '') {
$extra_params = array();
$course_url = '';
if (strlen($_GET['cidReq']) > 0) {
$extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
$course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']);
}
}
$html .= '<div class="span9">';
$html .= '<ul id="online_grid_container" class="thumbnails">';
foreach ($user_list as $user) {
$uid = $user[0];
$user_info = api_get_user_info($uid);
$table_row = array();
$user_info = api_get_user_info($uid);
//Anonymous users can't have access to the profile
if (!api_is_anonymous()) {
if (api_get_setting('allow_social_tool')=='true') {
@ -775,40 +776,21 @@ class SocialManager extends UserManager {
if ($image_array['file'] == 'unknown.jpg' || !file_exists($image_array['dir'].$image_array['file'])) {
$friends_profile['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
$table_row[] = '<a href="'.$url.'"><img title = "'.$name.'" class="social-home-anonymous-online" alt="'.$name.'" src="'.$friends_profile['file'].'"></a>';
} else {
$friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
$clip = 'clip_vertical';
if ($friends_profile['original_height'] > $friends_profile['original_width']) {
$clip = 'clip_horizontal';
}
//A really tiny image
if ($friends_profile['original_height'] < 50 || $friends_profile['original_height']< 50) {
$clip = '';
}
$table_row[] = Display::url(Display::div(Display::div($img, array('class'=>$clip)), array('class'=>'clip-wrapper')) , $url);
}
$table_row[] = Display::div($status_icon).'<a href="'.$url.'">'.$name.'</a><br>';
$table_data[] = $table_row;
}
$table_header[] = array(get_lang('UserPicture'), false, 'width="90"');
if (api_get_setting('show_email_addresses') == 'true') {
//$table_header[] = array(get_lang('Email'), true);
}
$params = array();
if (!isset($params['per_page'])) {
$params['per_page'] = 10;
}
$params['hide_navigation'] = true;
return Display::return_sortable_grid('online', $table_header, $table_data, $params, $query_vars);
} else {
$friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
}
$name = Display::div($status_icon).'<a href="'.$url.'">'.$name.'</a><br>';
$html .= '<li class="span9"><div class="thumbnail">'.$img.'<div class="caption">'.$name.'</div</div></li>';
}
$counter = $_SESSION['who_is_online_counter'];
$html .= '</ul></div>';
$html .= '<div class="span9"><a class="btn btn-large" id="link_load_more_items" data_link="'.$counter.'" >'.get_lang('More').'</a></div>';
}
}
return $html;
}
/**
* Displays the information of an individual user
* @param int $user_id
@ -840,11 +822,9 @@ class SocialManager extends UserManager {
$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"' : '');
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$height += 30;
$width += 30;
$window_name = 'window'.uniqid('');
$width += 30;
// get the path,width and height from original picture
$big_image = $webdir.'big_'.$user_object->picture_uri;
$big_image_size = api_getimagesize($big_image);

@ -795,8 +795,6 @@ class UserManager {
if (api_get_setting('split_users_upload_directory') === 'true') {
if (!empty($picture_filename) or $preview) {
// $dir = $base.'upload/users/'.substr($picture_filename, 0, 1).'/'.$user_id.'/';
// } elseif ($preview) {
$dir = $base.'upload/users/'.substr((string)$user_id, 0, 1).'/'.$user_id.'/';
} else {
$dir = $base.'upload/users/'.$user_id.'/';
@ -807,7 +805,6 @@ class UserManager {
if (empty($picture_filename) && $anonymous) {
return array('dir' => $base.'img/', 'file' => 'unknown.jpg');
}
return array('dir' => $dir, 'file' => $picture_filename);
}
@ -2318,15 +2315,12 @@ class UserManager {
* @return array with the file and the style of an image i.e $array['file'] $array['style']
*/
public static function get_picture_user($user_id, $picture_file, $height, $size_picture = USER_IMAGE_SIZE_MEDIUM , $style = '') {
$patch_profile = 'upload/users/';
$picture = array();
$picture['style'] = $style;
if ($picture_file == 'unknown.jpg') {
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
return $picture;
}
switch ($size_picture) {
case USER_IMAGE_SIZE_ORIGINAL :
$size_picture = '';
@ -2359,8 +2353,7 @@ class UserManager {
$picture['original_height'] = $dimension['width'];
$picture['original_width'] = $dimension['height'];
}
} else {
//$file = api_get_path(SYS_CODE_PATH).$patch_profile.$user_id.'/'.$picture_file;
} else {
$file = $image_array_sys['dir'].$picture_file;
if (file_exists($file) && !is_dir($file)) {
$picture['file'] = $image_array['dir'].$picture_file;

@ -67,25 +67,23 @@ if (api_get_setting('profile', 'picture') == 'true') {
$user_info = UserManager :: get_user_info_by_id(api_get_user_id());
$social_left_content = SocialManager::show_social_menu('home');
$social_right_content .= '<div class="row"><div class="social_user_information span4">';
$social_right_content .= '<div class="social-groups-home-title">'.get_lang('ContactInformation').'</div>';
$social_left_content = SocialManager::show_social_menu('home');
$social_right_content .= '<div class="social_user_information span4">';
$social_right_content .= '<div class="social-groups-home-title">'.get_lang('ContactInformation').'</div>';
// information current user
$social_right_content .= '<div>
<p><strong>'.get_lang('Name').'</strong><br />
<span class="social-groups-text4">'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</span></p>
</div>
<div>
<p><strong>'.get_lang('Email').'</strong><br /><span class="social-groups-text4">'.($user_info['email']?$user_info['email']:'').'</span></p>
</div>
<div class="box_description_group_actions">
<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">
'.Display::return_icon('profile_edit.png', null, array('hspace'=>'6')).get_lang('EditProfile').'
</a>
</div>';
// information current user
$social_right_content .= '<div>
<p><strong>'.get_lang('Name').'</strong><br />
<span class="social-groups-text4">'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</span></p>
</div>
<div>
<p><strong>'.get_lang('Email').'</strong><br /><span class="social-groups-text4">'.($user_info['email']?$user_info['email']:'').'</span></p>
</div>
<div class="box_description_group_actions">
<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">
'.Display::return_icon('profile_edit.png', null, array('hspace'=>'6')).get_lang('EditProfile').'
</a>
</div>';
$skill = new Skill();
$skills = $skill->get_user_skills(api_get_user_id(), true);
@ -162,8 +160,7 @@ $social_left_content = SocialManager::show_social_menu('home');
$social_right_content .= '<div class="social-groups-home-title">'.get_lang('Popular').'</div>';
$social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,true,true));
}
$social_right_content .= '</div>';
$social_right_content .= '</div>';
$social_right_content .= '</div>';
$tpl = new Template(get_lang('Social'));
$tpl->assign('social_left_content', $social_left_content);

@ -226,7 +226,7 @@ if (is_array($personal_course_list)) {
}
$social_left_content = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
$social_right_content = '<div class="row"><div class="rounded_div span4">';
$social_right_content = '<div class="rounded_div span4">';
if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
$social_right_content .= '<div><h3>'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</h3></div>';
@ -625,11 +625,8 @@ if ($show_full_profile) {
}
$social_right_content .= '</div>'; //rounded
}
$social_right_content .= '</div>'; //
$social_right_content .= '</div>';
}
$social_right_content .= '</div>'; //
$tpl = new Template(get_lang('Social'));
$tpl->assign('social_left_content', $social_left_content);

@ -1,10 +1,13 @@
<div class="row-fluid">
<div class="row-fluid">
<div class="span3">
{$social_left_content}
{$social_left_menu}
</div>
<div class="span9">
<div class="row">
{$social_right_content}
<div id="display_response_id"></div>
</div>
</div>
</div>

@ -16,8 +16,9 @@ if (!isset($_GET['cidReq'])) {
require_once './main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
$htmlHeadXtra[] = api_get_js('jquery.endless-scroll.js');
$_SESSION['who_is_online_counter'] = 2;
$htmlHeadXtra[] = api_get_js('jquery.endless-scroll.js');
//social tab
$this_section = SECTION_SOCIAL;
// table definitions
@ -105,17 +106,11 @@ function hide_icon_edit(element_html) {
$(ident).hide();
}
$(document).ready(function() {
$(document).ready(function() {
$(document).endlessScroll({
fireOnce: false,
fireDelay: false,
loader: "<div class=\'loading\'>Loading<div>",
callback: function(page) {
page = page;
$.ajax({
$("#link_load_more_items").live("click", function() {
page = $("#link_load_more_items").attr("data_link");
$.ajax({
beforeSend: function(objeto) {
$("#display_response_id").html("Loading");
},
@ -123,15 +118,19 @@ $(document).ready(function() {
url: "main/inc/ajax/online.ajax.php?a=load_online_user",
data: "online_page_nr="+page,
success: function(data) {
$("#display_response_id").html("");
if (data != "end") {
var last = $(".online_grid_container .online_grid_item:last");
$("#link_load_more_items").remove();
var last = $("#online_grid_container li:last");
last.after(data);
} else {
$("#link_load_more_items").remove();
}
}
});
}
});
});
});
</script>';
@ -139,7 +138,7 @@ if ($_GET['chatid'] != '') {
//send out call request
$time = time();
$time = date("Y-m-d H:i:s", $time);
$chatid = addslashes($_GET['chatid']);
$chatid = intval($_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 = Database::query($sql);
@ -149,7 +148,6 @@ if ($_GET['chatid'] != '') {
}
}
// This if statement prevents users accessing the who's online feature when it has been disabled.
if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) || ((api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id'])) {
@ -173,15 +171,14 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
if (api_get_setting('allow_social_tool') == 'true') {
if (!api_is_anonymous()) {
$query = isset($_GET['q']) ? $_GET['q']: null;
$social_right_content .= UserManager::get_search_form($query);
$social_right_content .= '<div class="span9">'.UserManager::get_search_form($query).'</div>';
}
}
$social_right_content .= SocialManager::display_user_list($user_list);
}
}
if (isset($_GET['id'])) {
if (isset($_GET['id'])) {
if (api_get_setting('allow_social_tool') == 'true') {
header("Location: ".api_get_path(WEB_CODE_PATH)."social/profile.php?u=?".$_GET['id']);
exit;
@ -210,4 +207,4 @@ $tpl->assign('actions', $actions);
$tpl->assign('message', $show_message);
$tpl->assign('header', get_lang('UsersOnLineList'));
$tpl->assign('content', $content);
$tpl->display_one_col_template();
$tpl->display_one_col_template();
Loading…
Cancel
Save