mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-61484 mod_chat: Add CHAT_SESSION_GAP constant
This commit is contained in:
parent
d7b236fa5e
commit
64818f403d
@ -29,6 +29,9 @@ require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
// Event types.
|
||||
define('CHAT_EVENT_TYPE_CHATTIME', 'chattime');
|
||||
|
||||
// Gap between sessions. 5 minutes or more of idleness between messages in a chat means the messages belong in different sessions.
|
||||
define('CHAT_SESSION_GAP', 300);
|
||||
|
||||
// The HTML head for the message window to start with (<!-- nix --> is used to get some browsers starting with output.
|
||||
global $CHAT_HTMLHEAD;
|
||||
$CHAT_HTMLHEAD = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head></head>\n<body>\n\n".padding(200);
|
||||
@ -1493,7 +1496,6 @@ function mod_chat_core_calendar_provide_event_action(calendar_event $event,
|
||||
*/
|
||||
function chat_get_sessions($messages, $showall = false) {
|
||||
$sessions = [];
|
||||
$sessiongap = 5 * 60; // 5 minutes silence means a new session.
|
||||
$start = 0;
|
||||
$end = 0;
|
||||
$sessiontimes = [];
|
||||
@ -1509,7 +1511,7 @@ function chat_get_sessions($messages, $showall = false) {
|
||||
}
|
||||
|
||||
// If this message's timestamp has been more than the gap, it means it's been idle.
|
||||
if ($start - $message->timestamp > $sessiongap) {
|
||||
if ($start - $message->timestamp > CHAT_SESSION_GAP) {
|
||||
// Mark this as the session end of the next session.
|
||||
$end = $message->timestamp;
|
||||
}
|
||||
|
@ -116,14 +116,13 @@ class chat_portfolio_caller extends portfolio_module_caller_base {
|
||||
public function prepare_package() {
|
||||
$content = '';
|
||||
$lasttime = 0;
|
||||
$sessiongap = 5 * 60; // 5 minutes silence means a new session
|
||||
foreach ($this->messages as $message) { // We are walking FORWARDS through messages
|
||||
$m = clone $message; // grrrrrr - this causes the sha1 to change as chat_format_message changes what it's passed.
|
||||
$formatmessage = chat_format_message($m, $this->cm->course, $this->user);
|
||||
if (!isset($formatmessage->html)) {
|
||||
continue;
|
||||
}
|
||||
if (empty($lasttime) || (($message->timestamp - $lasttime) > $sessiongap)) {
|
||||
if (empty($lasttime) || (($message->timestamp - $lasttime) > CHAT_SESSION_GAP)) {
|
||||
$content .= '<hr />';
|
||||
$content .= userdate($message->timestamp);
|
||||
}
|
||||
|
@ -214,7 +214,6 @@ class mod_chat_lib_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_chat_get_sessions_multiple() {
|
||||
$messages = [];
|
||||
$widegap = 5 * 60; // 5 mins.
|
||||
$gap = 5; // 5 secs.
|
||||
|
||||
$now = time();
|
||||
@ -282,7 +281,7 @@ class mod_chat_lib_testcase extends advanced_testcase {
|
||||
if ($i == 10 || $i == 25) {
|
||||
// New session.
|
||||
$session++;
|
||||
$timestamp += $widegap + 1;
|
||||
$timestamp += CHAT_SESSION_GAP + 1;
|
||||
} else {
|
||||
$timestamp += $gap;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user