Skip to content

Commit

Permalink
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ywarnier committed Oct 18, 2024
2 parents 5393257 + 20ec8e7 commit 0654537
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 15 deletions.
27 changes: 15 additions & 12 deletions main/inc/lib/banner.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,22 @@ function get_tabs($courseId = null)
$navigation['session_my_space']['key'] = 'my-space';
$navigation['session_my_space']['icon'] = 'my-space.png';
} else {
$navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH);
// Link to my progress
switch (api_get_setting('gamification_mode')) {
case 1:
$navigation['session_my_progress']['url'] .= 'gamification/my_progress.php';
break;
default:
$navigation['session_my_progress']['url'] .= 'auth/my_progress.php';
}
$hideMyProgressTab = api_get_configuration_value('hide_my_progress_tab');
if (true !== $hideMyProgressTab) {
$navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH);
// Link to my progress
switch (api_get_setting('gamification_mode')) {
case 1:
$navigation['session_my_progress']['url'] .= 'gamification/my_progress.php';
break;
default:
$navigation['session_my_progress']['url'] .= 'auth/my_progress.php';
}

$navigation['session_my_progress']['title'] = get_lang('MyProgress');
$navigation['session_my_progress']['key'] = 'my-progress';
$navigation['session_my_progress']['icon'] = 'my-progress.png';
$navigation['session_my_progress']['title'] = get_lang('MyProgress');
$navigation['session_my_progress']['key'] = 'my-progress';
$navigation['session_my_progress']['icon'] = 'my-progress.png';
}
}
}

Expand Down
51 changes: 51 additions & 0 deletions main/inc/lib/message.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3049,6 +3049,57 @@ public static function getUsersThatHadConversationWithUser($userId, $startDate =
return $userList;
}

/**
* Retrieves a list of users with whom the specified user has exchanged messages within an optional date range.
*
* @param int $userId The user ID for whom to retrieve message exchange.
* @param string|null $startDate Start date to filter the messages (optional).
* @param string|null $endDate End date to filter the messages (optional).
*
* @return array Array of user information for each user with whom the specified user has exchanged messages.
*/
public static function getMessageExchangeWithUser($userId, $startDate = null, $endDate = null)
{
$messagesTable = Database::get_main_table(TABLE_MESSAGE);
$userId = (int) $userId;

if ($startDate !== null) {
$startDate = Database::escape_string($startDate);
}
if ($endDate !== null) {
$endDate = Database::escape_string($endDate);
}

$sql = "SELECT DISTINCT user_sender_id AS user_id
FROM $messagesTable
WHERE user_receiver_id = $userId" .
($startDate ? " AND send_date >= '$startDate'" : "") .
($endDate ? " AND send_date <= '$endDate'" : "") .
" UNION
SELECT DISTINCT user_receiver_id
FROM $messagesTable
WHERE user_sender_id = $userId" .
($startDate ? " AND send_date >= '$startDate'" : "") .
($endDate ? " AND send_date <= '$endDate'" : "");

$result = Database::query($sql);
$users = Database::store_result($result);

$userList = [];
foreach ($users as $userData) {
$userId = $userData['user_id'];
if (empty($userId)) {
continue;
}
$userInfo = api_get_user_info($userId);
if ($userInfo) {
$userList[$userId] = $userInfo;
}
}

return $userList;
}

/**
* @param int $userId
* @param int $otherUserId
Expand Down
3 changes: 3 additions & 0 deletions main/install/configuration.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,9 @@
// Block access to any user to "my progress" page
//$_configuration['block_my_progress_page'] = false;

// Hides the "my progress" tab from the navigation menu
//$_configuration['hide_my_progress_tab'] = false;

// Add user extra fields in report: main/mySpace/exercise_category_report.php
//$_configuration['exercise_category_report_user_extra_fields'] = ['fields' => ['skype', 'rssfeeds']];

Expand Down
6 changes: 3 additions & 3 deletions main/mySpace/myStudents.php
Original file line number Diff line number Diff line change
Expand Up @@ -2405,11 +2405,11 @@ function ($hookHeader) {
$allow = api_get_configuration_value('allow_user_message_tracking');
if ($allow && (api_is_drh() || api_is_platform_admin())) {
if ($filterMessages) {
$users = MessageManager::getUsersThatHadConversationWithUser($student_id, $coachAccessStartDate, $coachAccessEndDate);
$users = MessageManager::getMessageExchangeWithUser($student_id, $coachAccessStartDate, $coachAccessEndDate);
} else {
$users = MessageManager::getUsersThatHadConversationWithUser($student_id);
$users = MessageManager::getMessageExchangeWithUser($student_id);
}
$users = MessageManager::getUsersThatHadConversationWithUser($student_id);

echo Display::page_subheader2(get_lang('MessageTracking'));

$table = new HTML_Table(['class' => 'table']);
Expand Down

0 comments on commit 0654537

Please sign in to comment.