mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Some minor improvements
This commit is contained in:
parent
1515a89e2d
commit
f7e648da70
@ -3,10 +3,19 @@
|
||||
require("../../../config.php");
|
||||
require("../lib.php");
|
||||
|
||||
require_variable($chat_sid);
|
||||
|
||||
if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
|
||||
echo "Not logged in!";
|
||||
die;
|
||||
}
|
||||
|
||||
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
|
||||
error("No chat found");
|
||||
}
|
||||
|
||||
require_login($chat->course);
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
|
||||
|
@ -13,6 +13,8 @@ if (!$course = get_record("course", "id", $chat->course)) {
|
||||
error("Could not find the course this belongs to!");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!$chat_sid = chat_login_user($chat->id, "header_js")) {
|
||||
error("Could not log in to chat room!!");
|
||||
}
|
||||
|
@ -5,8 +5,16 @@ require("../lib.php");
|
||||
|
||||
if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
|
||||
echo "Not logged in!";
|
||||
die;
|
||||
}
|
||||
|
||||
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
|
||||
error("No chat found");
|
||||
}
|
||||
|
||||
require_login($chat->course);
|
||||
|
||||
|
||||
if ($message = chat_get_latest_message($chatuser->chatid)) {
|
||||
$chat_newlasttime = $message->timestamp;
|
||||
} else {
|
||||
|
@ -1,43 +1,59 @@
|
||||
<?php
|
||||
|
||||
include("../../config.php");
|
||||
include("lib.php");
|
||||
include("../../config.php");
|
||||
include("lib.php");
|
||||
|
||||
require_variable($chat_sid);
|
||||
require_variable($chat_version);
|
||||
require_variable($chat_message);
|
||||
require_variable($chat_sid);
|
||||
require_variable($chat_version);
|
||||
require_variable($chat_message);
|
||||
|
||||
if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
|
||||
echo "Not logged in!";
|
||||
die;
|
||||
}
|
||||
if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
|
||||
echo "Not logged in!";
|
||||
die;
|
||||
}
|
||||
|
||||
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
|
||||
error("No chat found");
|
||||
}
|
||||
|
||||
require_login($chat->course);
|
||||
|
||||
|
||||
/// Delete old messages here
|
||||
|
||||
|
||||
|
||||
/// Clean up the message
|
||||
|
||||
$chat_message = clean_text($chat_message, FORMAT_MOODLE); // Strip bad tags
|
||||
$chat_message = clean_text($chat_message, FORMAT_MOODLE); // Strip bad tags
|
||||
|
||||
if (!empty($chat_message)) {
|
||||
/// Add the message to the database
|
||||
|
||||
$message->chatid = $chatuser->chatid;
|
||||
$message->userid = $chatuser->userid;
|
||||
$message->message = $chat_message;
|
||||
$message->timestamp = time();
|
||||
|
||||
if (!insert_record("chat_messages", $message)) {
|
||||
error("Could not insert a chat message!");
|
||||
if (!empty($chat_message)) {
|
||||
|
||||
$message->chatid = $chatuser->chatid;
|
||||
$message->userid = $chatuser->userid;
|
||||
$message->message = $chat_message;
|
||||
$message->timestamp = time();
|
||||
|
||||
if (!insert_record("chat_messages", $message)) {
|
||||
error("Could not insert a chat message!");
|
||||
}
|
||||
|
||||
$chatuser->lastmessageping = time();
|
||||
update_record("chat_users", $chatuser);
|
||||
}
|
||||
}
|
||||
|
||||
/// Go back to the other page
|
||||
|
||||
if ($chat_version == "header" OR $chat_version == "box") {
|
||||
redirect("../gui_$chat_version/chatinput.php?chat_sid=$chat_sid");
|
||||
|
||||
} else if ($chat_version == "text") {
|
||||
redirect("../gui_$chat_version/index.php?chat_sid=$chat_sid&chat_lastid=$chat_lastid");
|
||||
|
||||
} else {
|
||||
redirect("empty.php");
|
||||
}
|
||||
if ($chat_version == "header" OR $chat_version == "box") {
|
||||
redirect("../gui_$chat_version/chatinput.php?chat_sid=$chat_sid");
|
||||
|
||||
} else if ($chat_version == "text") {
|
||||
redirect("../gui_$chat_version/index.php?chat_sid=$chat_sid&chat_lastid=$chat_lastid");
|
||||
|
||||
} else {
|
||||
redirect("empty.php");
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -130,7 +130,7 @@ function chat_get_users($chatid) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql("SELECT u.id, u.firstname, u.lastname, u.picture
|
||||
return get_records_sql("SELECT u.id, u.firstname, u.lastname, u.picture, c.lastmessageping
|
||||
FROM {$CFG->prefix}chat_users c,
|
||||
{$CFG->prefix}user u
|
||||
WHERE c.chatid = '$chatid'
|
||||
@ -158,7 +158,7 @@ function chat_login_user($chatid, $version="header_js") {
|
||||
$chatuser->userid = $USER->id;
|
||||
$chatuser->version = $version;
|
||||
$chatuser->ip = $USER->lastIP;
|
||||
$chatuser->lastping = time();
|
||||
$chatuser->lastping = $chatuser->firstping = $chatuser->lastmessageping = time();
|
||||
$chatuser->sid = random_string(32);
|
||||
|
||||
if (!insert_record("chat_users", $chatuser)) {
|
||||
|
@ -10,6 +10,13 @@ if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
|
||||
die;
|
||||
}
|
||||
|
||||
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
|
||||
error("No chat found");
|
||||
}
|
||||
|
||||
require_login($chat->course);
|
||||
|
||||
|
||||
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
|
||||
error("Could not find chat! id = $chatuser->chatid");
|
||||
}
|
||||
@ -51,12 +58,28 @@ header("Refresh: ".CHAT_REFRESH_USERLIST."; URL=users.php?chat_sid=".$chat_sid);
|
||||
|
||||
print_header();
|
||||
|
||||
$timenow = time();
|
||||
|
||||
$stridle = get_string("idle", "chat");
|
||||
$str->day = get_string("day");
|
||||
$str->days = get_string("days");
|
||||
$str->hour = get_string("hour");
|
||||
$str->hours = get_string("hours");
|
||||
$str->min = get_string("min");
|
||||
$str->mins = get_string("mins");
|
||||
$str->sec = get_string("sec");
|
||||
$str->secs = get_string("secs");
|
||||
|
||||
echo "<table width=\"100%\">";
|
||||
foreach ($chatusers as $chatuser) {
|
||||
$lastping = $timenow - $chatuser->lastmessageping;
|
||||
echo "<tr><td width=35>";
|
||||
print_user_picture($chatuser->id, 0, $chatuser->picture, false, false, false);
|
||||
echo "</td><td valign=center>";
|
||||
echo "<p><font size=1>$chatuser->firstname $chatuser->lastname</font></p>";
|
||||
echo "<p><font size=1>";
|
||||
echo "$chatuser->firstname $chatuser->lastname<br />";
|
||||
echo "<font color=\"#888888\">$stridle: ".format_time($lastping, $str)."</font>";
|
||||
echo "</font></p>";
|
||||
echo "<td></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user