fixed coding conventions

pull/3908/head
Juan Cortizas Ponte 4 years ago
parent 09d8152c9c
commit ab409a8bf9
  1. 24
      main/inc/lib/message.lib.php
  2. 23
      main/mySpace/myStudents.php
  3. 10
      main/tracking/messages.php

@ -2886,10 +2886,12 @@ class MessageManager
*
* @return array
*/
public static function getUsersThatHadConversationWithUser($userId, $dateStart = null, $dateFinish = null)
public static function getUsersThatHadConversationWithUser($userId, $startDate = null, $endDate = null)
{
$messagesTable = Database::get_main_table(TABLE_MESSAGE);
$userId = (int) $userId;
$startDate = Database::escape_string($startDate);
$endDate = Database::escape_string($endDate);
$sql = "SELECT DISTINCT
user_sender_id
@ -2897,12 +2899,12 @@ class MessageManager
WHERE
user_receiver_id = ".$userId;
if ($dateStart != null) {
$sql .= " AND send_date >= '".$dateStart."'";
if ($startDate != null) {
$sql .= " AND send_date >= '".$startDate."'";
}
if ($dateFinish != null) {
$sql .= " AND send_date <= '".$dateFinish."'";
if ($endDate != null) {
$sql .= " AND send_date <= '".$endDate."'";
}
$result = Database::query($sql);
@ -2930,11 +2932,13 @@ class MessageManager
*
* @return array
*/
public static function getAllMessagesBetweenStudents($userId, $otherUserId, $dateStart = null, $dateFinish = null)
public static function getAllMessagesBetweenStudents($userId, $otherUserId, $startDate = null, $endDate = null)
{
$messagesTable = Database::get_main_table(TABLE_MESSAGE);
$userId = (int) $userId;
$otherUserId = (int) $otherUserId;
$startDate = Database::escape_string($startDate);
$endDate = Database::escape_string($endDate);
if (empty($otherUserId) || empty($userId)) {
return [];
@ -2946,12 +2950,12 @@ class MessageManager
((user_receiver_id = $userId AND user_sender_id = $otherUserId) OR
(user_receiver_id = $otherUserId AND user_sender_id = $userId))
";
if ($dateStart != null) {
$dateStart = Database::escape_string($dateStart);
if ($startDate != null) {
$dateStart = Database::escape_string($startDate);
$sql .= " AND send_date >= '".$dateStart."'";
}
if ($dateFinish != null) {
$dateFinish = Database::escape_string($dateFinish);
if ($endDate != null) {
$dateFinish = Database::escape_string($endDate);
$sql .= " AND send_date <= '".$dateFinish."'";
}
$sql .= " ORDER BY send_date DESC";

@ -2057,18 +2057,23 @@ if ($allowMessages === true) {
$form->display();
}
$filter_messages = api_get_configuration_value('filter_interactivity_messages') && !empty($sessionId);
$coachAccessStartDate = null;
$coachAccessEndDate = null;
if ($filter_messages) {
$session_info = api_get_session_info($sessionId);
$coach_access_start_date = $session_info['coach_access_start_date'];
$coach_access_end_date = $session_info['coach_access_end_date'];
if (!empty($sessionId)) {
$filterMessages = api_get_configuration_value('filter_interactivity_messages');
if ($filterMessages) {
$sessionInfo = api_get_session_info($sessionId);
$coachAccessStartDate = $sessionInfo['coach_access_start_date'];
$coachAccessEndDate = $sessionInfo['coach_access_end_date'];
}
}
$allow = api_get_configuration_value('allow_user_message_tracking');
if ($allow && (api_is_drh() || api_is_platform_admin())) {
if ($filter_messages) {
$users = MessageManager::getUsersThatHadConversationWithUser($student_id, $coach_access_start_date, $coach_access_end_date);
if ($filterMessages) {
$users = MessageManager::getUsersThatHadConversationWithUser($student_id, $coachAccessStartDate, $coachAccessEndDate);
} else {
$users = MessageManager::getUsersThatHadConversationWithUser($student_id);
}
@ -2090,8 +2095,8 @@ if ($allow && (api_is_drh() || api_is_platform_admin())) {
foreach ($users as $userFollowed) {
$followedUserId = $userFollowed['user_id'];
if ($filter_messages) {
$url = api_get_path(WEB_CODE_PATH).'tracking/messages.php?from_user='.$student_id.'&to_user='.$followedUserId.'&date_from='.$coach_access_start_date.'&date_to='.$coach_access_end_date;
if ($filterMessages) {
$url = api_get_path(WEB_CODE_PATH).'tracking/messages.php?from_user='.$student_id.'&to_user='.$followedUserId.'&start_date='.$coachAccessStartDate.'&end_date='.$coachAccessEndDate;
} else {
$url = api_get_path(WEB_CODE_PATH).'tracking/messages.php?from_user='.$student_id.'&to_user='.$followedUserId;
}

@ -18,8 +18,8 @@ if (!$allowUser) {
$fromUserId = isset($_GET['from_user']) ? (int) $_GET['from_user'] : 0;
$toUserId = isset($_GET['to_user']) ? (int) $_GET['to_user'] : 0;
$coach_access_start_date = isset($_GET['date_from']) ? $_GET['date_from'] : null;
$coach_access_end_date = isset($_GET['date_to']) ? $_GET['date_to'] : null;
$coachAccessStartDate = isset($_GET['start_date']) ? $_GET['start_date'] : null;
$coachAccessEndDate = isset($_GET['end_date']) ? $_GET['end_date'] : null;
if (empty($fromUserId) || empty($toUserId)) {
api_not_allowed(true);
@ -65,9 +65,9 @@ if (api_is_drh()) {
$usersData[$toUserId] = api_get_user_info($toUserId);
$usersData[$fromUserId] = api_get_user_info($fromUserId);
$filter_messages = api_get_configuration_value('filter_interactivity_messages');
if ($filter_messages) {
$messages = MessageManager::getAllMessagesBetweenStudents($toUserId, $fromUserId, $coach_access_start_date, $coach_access_end_date);
$filterMessages = api_get_configuration_value('filter_interactivity_messages');
if ($filterMessages) {
$messages = MessageManager::getAllMessagesBetweenStudents($toUserId, $fromUserId, $coachAccessStartDate, $coachAccessEndDate);
} else {
$messages = MessageManager::getAllMessagesBetweenStudents($toUserId, $fromUserId);
}

Loading…
Cancel
Save