Add new social report to user information page - see #1693 WIP

pull/2487/head
Yannick Warnier 9 years ago
parent 865c626a37
commit c0f6582be1
  1. 38
      main/admin/user_information.php
  2. 58
      main/inc/lib/social.lib.php

@ -178,7 +178,7 @@ $data = array(
get_lang('Email') => $user['email'],
get_lang('Phone') => $user['phone'],
get_lang('OfficialCode') => $user['official_code'],
get_lang('Online') => $user['user_is_online'] ?
get_lang('Online') => !empty($user['user_is_online']) ?
Display::return_icon('online.png') : Display::return_icon(
'offline.png'
),
@ -255,6 +255,37 @@ $tbl_session = Database:: get_main_table(TABLE_MAIN_SESSION);
$tbl_course = Database:: get_main_table(TABLE_MAIN_COURSE);
$tbl_user = Database:: get_main_table(TABLE_MAIN_USER);
/**
* Show social activity
*/
if (api_get_setting('allow_social_tool') === 'true') {
$em = Database::getManager();
$userObject = $em->find('ChamiloUserBundle:User', $user['user_id']);
$header = ['Value' => 'CurrentData'];
$data = [];
// Calculate values
if (api_get_setting('allow_message_tool') === 'true') {
$messagesSent = \SocialManager::getCountMessagesSent($user['user_id']);
$data[] = [get_lang('MessagesSent'), $messagesSent];
$messagesReceived = \SocialManager::getCountMessagesReceived($user['user_id']);
$data[] = [get_lang('MessagesReceived'), $messagesReceived];
}
$wallMessagesPosted = \SocialManager::getCountWallPostedMessages($user['user_id']);
$data[] = [get_lang('WallMessagesPosted'), $wallMessagesPosted];
$socialInformation = Display::return_sortable_table(
$header,
$data
);
}
/**
* Show the sessions in which this user is subscribed
*/
$sessions = SessionManager::get_sessions_by_user($userId, true);
$personal_course_list = array();
$courseToolInformationTotal = null;
@ -556,6 +587,11 @@ if ($studentBossList) {
echo $studentBossListToString;
}
if (api_get_setting('allow_social_tool') === 'true') {
echo Display::page_subheader(get_lang('SocialData'));
echo $socialInformation;
}
echo Display::page_subheader(get_lang('SessionList'));
echo $sessionInformation;

@ -262,6 +262,62 @@ class SocialManager extends UserManager
return $row['count_message_in_box'];
}
/**
* Get number of messages sent to other users
* @param int $sender_id
* @return int
*/
public static function getCountMessagesSent($sender_id)
{
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$sql = 'SELECT COUNT(*) FROM '.$tbl_message.'
WHERE
user_sender_id='.intval($sender_id).' AND
msg_status < 5';
$res = Database::query($sql);
$row = Database::fetch_row($res);
return $row[0];
}
/**
* Get number of messages received from other users
* @param int $receiver_id
* @return int
*/
public static function getCountMessagesReceived($receiver_id)
{
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$sql = 'SELECT COUNT(*) FROM '.$tbl_message.'
WHERE
user_receiver_id='.intval($receiver_id).' AND
msg_status < 4';
$res = Database::query($sql);
$row = Database::fetch_row($res);
return $row[0];
}
/**
* Get number of messages posted on own wall
* @param int $sender_id
* @return int
*/
public static function getCountWallPostedMessages($sender_id)
{
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$sql = 'SELECT COUNT(*) FROM '.$tbl_message.'
WHERE
user_sender_id='.intval($sender_id).' AND
(msg_status = '.MESSAGE_STATUS_WALL.' OR
msg_status = '.MESSAGE_STATUS_WALL_POST.') AND
parent_id = 0';
$res = Database::query($sql);
$row = Database::fetch_row($res);
return $row[0];
}
/**
* Get invitation list received by user
* @author isaac flores paz
@ -1809,7 +1865,7 @@ class SocialManager extends UserManager
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$user_info_friend = api_get_user_info($friend['friend_user_id'], true);
if ($user_info_friend['user_is_online']) {
if (!empty($user_info_friend['user_is_online'])) {
$statusIcon = Display::return_icon('statusonline.png',get_lang('Online'));
$status=1;
} else {

Loading…
Cancel
Save