2004-09-12 15:06:29 +00:00
< ? php // $Id$
2003-07-07 06:44:16 +00:00
/// Library of functions and constants for module chat
2005-02-28 04:23:52 +00:00
require_once ( $CFG -> libdir . '/pagelib.php' );
2003-08-23 14:03:14 +00:00
if ( ! isset ( $CFG -> chat_refresh_room )) {
set_config ( " chat_refresh_room " , 5 );
2004-08-10 13:50:58 +00:00
}
2003-08-23 14:03:14 +00:00
if ( ! isset ( $CFG -> chat_refresh_userlist )) {
set_config ( " chat_refresh_userlist " , 10 );
2004-08-10 13:50:58 +00:00
}
2003-08-23 14:03:14 +00:00
if ( ! isset ( $CFG -> chat_old_ping )) {
2004-08-23 08:48:57 +00:00
set_config ( " chat_old_ping " , 35 );
2004-08-10 13:50:58 +00:00
}
2004-07-30 15:36:39 +00:00
if ( ! isset ( $CFG -> chat_method )) {
set_config ( " chat_method " , " header_js " );
2004-08-10 13:50:58 +00:00
}
2004-07-30 15:36:39 +00:00
if ( ! isset ( $CFG -> chat_serverhost )) {
set_config ( " chat_serverhost " , $_SERVER [ 'HTTP_HOST' ]);
2004-08-10 13:50:58 +00:00
}
2004-07-30 15:36:39 +00:00
if ( ! isset ( $CFG -> chat_serverip )) {
2005-03-12 21:26:54 +00:00
set_config ( " chat_serverip " , '127.0.0.1' );
2004-08-10 13:50:58 +00:00
}
2004-07-30 15:36:39 +00:00
if ( ! isset ( $CFG -> chat_serverport )) {
set_config ( " chat_serverport " , 9111 );
2004-08-10 13:50:58 +00:00
}
2004-07-30 15:36:39 +00:00
if ( ! isset ( $CFG -> chat_servermax )) {
set_config ( " chat_servermax " , 100 );
2004-08-10 13:50:58 +00:00
}
2003-07-07 06:44:16 +00:00
// The HTML head for the message window to start with (<!-- nix --> is used to get some browsers starting with output
$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 bgcolor= \" #FFFFFF \" > \n \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n " ;
// The HTML head for the message window to start with (with js scrolling)
$CHAT_HTMLHEAD_JS = " <!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN \" \" http://www.w3.org/TR/REC-html40/loose.dtd \" ><html><head><script language= \" JavaScript \" > \n <!-- \n function move() \n { \n if (scroll_active) window.scroll(1,400000); \n window.setTimeout( \" move() \" ,100); \n } \n scroll_active = true; \n move(); \n //--> \n </script> \n </head> \n <body bgcolor= \" #FFFFFF \" onBlur= \" scroll_active = true \" onFocus= \" scroll_active = false \" > \n \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \
// The HTML code for standard empty pages (e.g. if a user was kicked out)
2005-02-10 18:22:31 +00:00
$CHAT_HTMLHEAD_OUT = " <!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN \" \" http://www.w3.org/TR/REC-html40/loose.dtd \" ><html><head><title>You are out!</title></head><body bgcolor= \" #FFFFFF \" ></body></html> " ;
2003-07-07 06:44:16 +00:00
// The HTML head for the message input page
2005-02-10 18:22:31 +00:00
$CHAT_HTMLHEAD_MSGINPUT = " <!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN \" \" http://www.w3.org/TR/REC-html40/loose.dtd \" ><html><head><title>Message Input</title></head><body bgcolor= \" #FFFFFF \" > " ;
2003-07-07 06:44:16 +00:00
// The HTML code for the message input page, with JavaScript
2005-02-10 18:22:31 +00:00
$CHAT_HTMLHEAD_MSGINPUT_JS = " <!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN \" \" http://www.w3.org/TR/REC-html40/loose.dtd \" ><html><head><title>Message Input</title> \n <script language= \" Javascript \" > \n <!-- \n scroll_active = true; \n function empty_field_and_submit() \n { \n document.fdummy.arsc_message.value=document.f.arsc_message.value; \n document.fdummy.submit(); \n document.f.arsc_message.focus(); \n document.f.arsc_message.select(); \n return false; \n } \n // --> \n </script> \n </head><body bgcolor= \" #FFFFFF \" OnLoad= \" document.f.arsc_message.focus();document.f.arsc_message.select(); \" > " ;
2003-07-07 06:44:16 +00:00
2004-08-23 14:40:53 +00:00
// Dummy data that gets output to the browser as needed, in order to make it show output
$CHAT_DUMMY_DATA = " <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n <!-- nix --> \n " ;
2003-07-07 06:44:16 +00:00
function chat_add_instance ( $chat ) {
2004-08-10 13:50:58 +00:00
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
/// will create a new instance and return the id number
2003-07-07 06:44:16 +00:00
/// of the new instance.
$chat -> timemodified = time ();
2004-08-10 13:50:58 +00:00
$chat -> chattime = make_timestamp ( $chat -> chatyear , $chat -> chatmonth , $chat -> chatday ,
2003-07-25 06:47:06 +00:00
$chat -> chathour , $chat -> chatminute );
2004-08-10 13:50:58 +00:00
2004-04-25 03:05:58 +00:00
if ( $returnid = insert_record ( " chat " , $chat )) {
$event = NULL ;
$event -> name = $chat -> name ;
$event -> description = $chat -> intro ;
$event -> courseid = $chat -> course ;
$event -> groupid = 0 ;
$event -> userid = 0 ;
$event -> modulename = 'chat' ;
$event -> instance = $returnid ;
$event -> eventtype = $chat -> schedule ;
$event -> timestart = $chat -> chattime ;
$event -> timeduration = 0 ;
add_event ( $event );
}
return $returnid ;
2003-07-07 06:44:16 +00:00
}
function chat_update_instance ( $chat ) {
2004-08-10 13:50:58 +00:00
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
2003-07-07 06:44:16 +00:00
/// will update an existing instance with new data.
$chat -> timemodified = time ();
$chat -> id = $chat -> instance ;
2004-08-10 13:50:58 +00:00
$chat -> chattime = make_timestamp ( $chat -> chatyear , $chat -> chatmonth , $chat -> chatday ,
2003-07-25 06:47:06 +00:00
$chat -> chathour , $chat -> chatminute );
2003-07-07 06:44:16 +00:00
2004-04-25 03:05:58 +00:00
if ( $returnid = update_record ( " chat " , $chat )) {
$event = NULL ;
if ( $event -> id = get_field ( 'event' , 'id' , 'modulename' , 'chat' , 'instance' , $chat -> id )) {
$event -> name = $chat -> name ;
$event -> description = $chat -> intro ;
$event -> timestart = $chat -> chattime ;
update_event ( $event );
}
}
return $returnid ;
2003-07-07 06:44:16 +00:00
}
function chat_delete_instance ( $id ) {
2004-08-10 13:50:58 +00:00
/// Given an ID of an instance of this module,
/// this function will permanently delete the instance
/// and any data that depends on it.
2003-07-07 06:44:16 +00:00
2005-03-27 05:56:23 +00:00
if ( ! $chat = get_record ( 'chat' , 'id' , $id )) {
2003-07-07 06:44:16 +00:00
return false ;
}
$result = true ;
# Delete any dependent records here #
2005-03-27 05:56:23 +00:00
if ( ! delete_records ( 'chat' , 'id' , $chat -> id )) {
$result = false ;
}
if ( ! delete_records ( 'chat_messages' , 'chatid' , $chat -> id )) {
$result = false ;
}
if ( ! delete_records ( 'chat_users' , 'chatid' , $chat -> id )) {
2003-07-07 06:44:16 +00:00
$result = false ;
}
2005-02-28 04:18:13 +00:00
$pagetypes = page_import_types ( 'mod/chat/' );
foreach ( $pagetypes as $pagetype ) {
if ( ! delete_records ( 'block_instance' , 'pageid' , $chat -> id , 'pagetype' , $pagetype )) {
$result = false ;
}
}
2004-05-17 16:24:19 +00:00
if ( ! delete_records ( 'event' , 'modulename' , 'chat' , 'instance' , $chat -> id )) {
$result = false ;
}
2003-07-07 06:44:16 +00:00
return $result ;
}
function chat_user_outline ( $course , $user , $mod , $chat ) {
2004-08-10 13:50:58 +00:00
/// Return a small object with summary information about what a
2003-07-07 06:44:16 +00:00
/// user has done with a given particular instance of this module
/// Used for user activity reports.
/// $return->time = the time they did it
/// $return->info = a short text description
2004-10-23 19:21:30 +00:00
$return = NULL ;
2003-07-07 06:44:16 +00:00
return $return ;
}
function chat_user_complete ( $course , $user , $mod , $chat ) {
2004-08-10 13:50:58 +00:00
/// Print a detailed representation of what a user has done with
2003-07-07 06:44:16 +00:00
/// a given particular instance of this module, for user activity reports.
return true ;
}
2003-07-10 04:46:03 +00:00
function chat_print_recent_activity ( $course , $isteacher , $timestart ) {
/// Given a course and a date, prints a summary of all chat rooms
/// that currently have people in them.
2003-07-07 06:44:16 +00:00
/// This function is called from course/lib.php: print_recent_activity()
2003-07-10 04:46:03 +00:00
global $CFG ;
2004-01-15 08:44:08 +00:00
$timeold = time () - $CFG -> chat_old_ping ;
2005-03-10 13:30:57 +00:00
$lastpingsearch = ( $CFG -> chat_method == 'sockets' ) ? '' : 'AND cu.lastping > \'' . $timeold . '\'' ;
2004-08-26 10:44:32 +00:00
2003-07-10 06:42:44 +00:00
if ( ! $chatusers = get_records_sql ( " SELECT u.id, cu.chatid, u.firstname, u.lastname
2003-07-10 04:46:03 +00:00
FROM { $CFG -> prefix } chat_users as cu ,
2003-07-21 01:35:28 +00:00
{ $CFG -> prefix } chat as ch ,
2003-07-10 04:46:03 +00:00
{ $CFG -> prefix } user as u
2004-08-10 13:50:58 +00:00
WHERE cu . userid = u . id
2004-08-26 10:44:32 +00:00
AND cu . chatid = ch . id $lastpingsearch
2003-07-21 01:35:28 +00:00
AND ch . course = '$course->id'
2003-07-10 04:46:03 +00:00
ORDER BY cu . chatid ASC " ) ) {
return false ;
}
2003-07-07 06:44:16 +00:00
2004-05-05 08:19:03 +00:00
$isteacher = isteacher ( $course -> id );
2003-07-10 04:46:03 +00:00
2004-05-05 08:19:03 +00:00
$outputstarted = false ;
2003-07-10 04:46:03 +00:00
$current = 0 ;
foreach ( $chatusers as $chatuser ) {
if ( $current != $chatuser -> chatid ) {
if ( $current ) {
2005-03-10 13:30:57 +00:00
echo '</ul></div>' ; // room
$current = 0 ;
2003-07-10 04:46:03 +00:00
}
2005-03-10 13:30:57 +00:00
if ( $chat = get_record ( 'chat' , 'id' , $chatuser -> chatid )) {
2004-05-05 08:19:03 +00:00
if ( ! ( $isteacher or instance_is_visible ( 'chat' , $chat ))) { // Chat hidden to students
continue ;
}
if ( ! $outputstarted ) {
2005-03-10 13:30:57 +00:00
print_headline ( get_string ( 'currentchats' , 'chat' ) . ':' );
2004-05-05 08:19:03 +00:00
$outputstarted = true ;
}
2005-03-27 11:36:54 +00:00
echo '<div class="room"><p class="head"><a href="' . $CFG -> wwwroot . '/mod/chat/view.php?c=' . $chat -> id . '">' . format_string ( $chat -> name , true ) . '</a></p><ul>' ;
2003-07-10 04:46:03 +00:00
}
$current = $chatuser -> chatid ;
}
2005-03-10 13:30:57 +00:00
$fullname = fullname ( $chatuser , $isteacher );
echo '<li class="info name">' . $fullname . '</li>' ;
}
if ( $current ) {
echo '</ul></div>' ; // room
2003-07-10 04:46:03 +00:00
}
return true ;
2003-07-07 06:44:16 +00:00
}
2005-03-10 13:30:57 +00:00
2003-07-07 06:44:16 +00:00
function chat_cron () {
/// Function to be run periodically according to the moodle cron
2004-08-10 13:50:58 +00:00
/// This function searches for things that need to be done, such
/// as sending out mail, toggling flags etc ...
2003-07-07 06:44:16 +00:00
global $CFG ;
2003-07-25 06:47:06 +00:00
chat_update_chat_times ();
2003-07-09 12:53:26 +00:00
chat_delete_old_users ();
2003-07-21 03:16:19 +00:00
/// Delete old messages
if ( $chats = get_records ( " chat " )) {
foreach ( $chats as $chat ) {
if ( $chat -> keepdays ) {
$timeold = time () - ( $chat -> keepdays * 24 * 3600 );
delete_records_select ( " chat_messages " , " chatid = ' $chat->id ' AND timestamp < ' $timeold ' " );
}
}
}
2003-07-07 06:44:16 +00:00
return true ;
}
2004-02-24 06:35:57 +00:00
function chat_get_participants ( $chatid , $groupid = 0 ) {
2003-09-29 15:27:30 +00:00
//Returns the users with data in one chat
//(users with records in chat_messages, students)
global $CFG ;
2004-02-24 06:35:57 +00:00
if ( $groupid ) {
$groupselect = " AND (c.groupid=' $groupid ' OR c.groupid='0') " ;
} else {
$groupselect = " " ;
}
2003-09-29 15:27:30 +00:00
//Get students
2005-02-13 00:42:29 +00:00
$students = get_records_sql ( " SELECT DISTINCT u.id, u.id
2003-09-29 15:27:30 +00:00
FROM { $CFG -> prefix } user u ,
{ $CFG -> prefix } chat_messages c
2004-02-24 06:35:57 +00:00
WHERE c . chatid = '$chatid' $groupselect
AND u . id = c . userid " );
2003-07-07 06:44:16 +00:00
2003-09-29 15:27:30 +00:00
//Return students array (it contains an array of unique users)
return ( $students );
}
2003-07-07 06:44:16 +00:00
2004-04-25 03:05:58 +00:00
function chat_refresh_events ( $courseid = 0 ) {
// This standard function will check all instances of this module
// and make sure there are up-to-date events created for each of them.
// If courseid = 0, then every chat event in the site is checked, else
// only chat events belonging to the course specified are checked.
// This function is used, in its new format, by restore_refresh_events()
if ( $courseid ) {
if ( ! $chats = get_records ( " chat " , " course " , $courseid )) {
return true ;
}
} else {
if ( ! $chats = get_records ( " chat " )) {
return true ;
}
}
2004-05-05 07:07:56 +00:00
$moduleid = get_field ( 'modules' , 'id' , 'name' , 'chat' );
2004-04-25 03:05:58 +00:00
foreach ( $chats as $chat ) {
$event = NULL ;
$event -> name = addslashes ( $chat -> name );
$event -> description = addslashes ( $chat -> intro );
$event -> timestart = $chat -> chattime ;
if ( $event -> id = get_field ( 'event' , 'id' , 'modulename' , 'chat' , 'instance' , $chat -> id )) {
update_event ( $event );
} else {
$event -> courseid = $chat -> course ;
$event -> groupid = 0 ;
$event -> userid = 0 ;
$event -> modulename = 'chat' ;
$event -> instance = $chat -> id ;
$event -> eventtype = $chat -> schedule ;
$event -> timeduration = 0 ;
2004-05-05 07:07:56 +00:00
$event -> visible = get_field ( 'course_modules' , 'visible' , 'module' , $moduleid , 'instance' , $chat -> id );
2004-08-10 13:50:58 +00:00
2004-04-25 03:05:58 +00:00
add_event ( $event );
}
}
return true ;
}
2005-02-03 20:39:27 +00:00
function chat_force_language ( $lang ) {
/// This function prepares moodle to operate in given language
/// usable when $nomoodlecookie = true;
/// BEWARE: there must be no $course, $USER or $SESSION
2005-02-08 21:23:19 +00:00
global $CFG ;
2005-02-03 20:39:27 +00:00
if ( ! empty ( $CFG -> courselang )) {
2005-02-08 21:23:19 +00:00
unset ( $CFG -> courselang );
2005-02-03 20:39:27 +00:00
}
if ( ! empty ( $CFG -> locale )) {
2005-02-08 21:23:19 +00:00
unset ( $CFG -> locale );
2005-02-03 20:39:27 +00:00
}
2005-02-12 10:54:25 +00:00
$CFG -> lang = $lang ;
2005-02-03 20:39:27 +00:00
moodle_setlocale ();
}
2003-07-07 06:44:16 +00:00
//////////////////////////////////////////////////////////////////////
/// Functions that require some SQL
2004-02-24 06:35:57 +00:00
function chat_get_users ( $chatid , $groupid = 0 ) {
2003-07-07 06:44:16 +00:00
global $CFG ;
2004-02-24 06:35:57 +00:00
if ( $groupid ) {
$groupselect = " AND (c.groupid=' $groupid ' OR c.groupid='0') " ;
} else {
$groupselect = " " ;
}
2004-08-10 13:50:58 +00:00
2004-04-26 02:54:55 +00:00
return get_records_sql ( " SELECT DISTINCT u.id, u.firstname, u.lastname, u.picture, c.lastmessageping, c.firstping
2003-07-07 06:44:16 +00:00
FROM { $CFG -> prefix } chat_users c ,
{ $CFG -> prefix } user u
WHERE c . chatid = '$chatid'
2004-02-24 06:35:57 +00:00
AND u . id = c . userid $groupselect
2003-07-07 06:44:16 +00:00
ORDER BY c . firstping ASC " );
}
2004-02-24 06:35:57 +00:00
function chat_get_latest_message ( $chatid , $groupid = 0 ) {
2003-07-25 09:01:02 +00:00
/// Efficient way to extract just the latest message
/// Uses ADOdb directly instead of get_record_sql()
2004-08-10 13:50:58 +00:00
/// because the LIMIT command causes problems with
2003-07-25 09:01:02 +00:00
/// the developer debugging in there.
2003-07-07 06:44:16 +00:00
2003-07-25 09:01:02 +00:00
global $db , $CFG ;
2003-07-07 06:44:16 +00:00
2004-02-24 06:35:57 +00:00
if ( $groupid ) {
$groupselect = " AND (groupid=' $groupid ' OR groupid='0') " ;
} else {
$groupselect = " " ;
}
2003-07-25 09:01:02 +00:00
if ( ! $rs = $db -> Execute ( " SELECT *
2004-08-10 13:50:58 +00:00
FROM { $CFG -> prefix } chat_messages
2004-02-24 06:35:57 +00:00
WHERE chatid = '$chatid' $groupselect
2003-07-25 09:01:02 +00:00
ORDER BY timestamp DESC LIMIT 1 " )) {
return false ;
}
if ( $rs -> RecordCount () == 1 ) {
return ( object ) $rs -> fields ;
} else {
return false ; // Found no records
}
2003-07-07 06:44:16 +00:00
}
2003-07-25 09:01:02 +00:00
2003-07-07 06:44:16 +00:00
//////////////////////////////////////////////////////////////////////
2005-02-03 20:39:27 +00:00
// login if not already logged in
2003-07-07 06:44:16 +00:00
2005-02-10 19:14:53 +00:00
function chat_login_user ( $chatid , $version , $groupid , $course ) {
2003-07-07 06:44:16 +00:00
global $USER ;
2005-02-12 10:54:25 +00:00
if (( $version != 'sockets' ) and $chatuser = get_record_select ( 'chat_users' , " chatid=' $chatid ' AND userid=' $USER->id ' AND groupid=' $groupid ' " )) {
2005-02-03 20:39:27 +00:00
$chatuser -> version = $version ;
$chatuser -> ip = $USER -> lastIP ;
$chatuser -> lastping = time ();
$chatuser -> lang = current_language ();
2003-07-07 06:44:16 +00:00
2005-02-03 20:39:27 +00:00
if (( $chatuser -> course != $course -> id )
or ( $chatuser -> userid != $USER -> id )) {
return false ;
}
if ( ! update_record ( 'chat_users' , $chatuser )) {
return false ;
}
} else {
$chatuser -> chatid = $chatid ;
$chatuser -> userid = $USER -> id ;
$chatuser -> groupid = $groupid ;
$chatuser -> version = $version ;
$chatuser -> ip = $USER -> lastIP ;
$chatuser -> lastping = $chatuser -> firstping = $chatuser -> lastmessageping = time ();
$chatuser -> sid = random_string ( 32 );
2005-02-07 20:33:44 +00:00
$chatuser -> course = $course -> id ; //caching - needed for current_language too
$chatuser -> lang = current_language (); //caching - to resource intensive to find out later
2005-02-03 20:39:27 +00:00
if ( ! insert_record ( 'chat_users' , $chatuser )) {
return false ;
}
2005-02-10 19:14:53 +00:00
if ( $version == 'sockets' ) {
// do not send 'enter' message, chatd will do it
} else {
2005-02-04 21:14:19 +00:00
$message -> chatid = $chatuser -> chatid ;
$message -> userid = $chatuser -> userid ;
$message -> groupid = $groupid ;
$message -> message = 'enter' ;
$message -> system = 1 ;
$message -> timestamp = time ();
if ( ! insert_record ( 'chat_messages' , $message )) {
error ( 'Could not insert a chat message!' );
}
2005-02-03 20:39:27 +00:00
}
2003-07-07 06:44:16 +00:00
}
return $chatuser -> sid ;
}
2003-07-09 12:53:26 +00:00
function chat_delete_old_users () {
// Delete the old and in the way
2003-08-23 14:03:14 +00:00
global $CFG ;
2005-02-12 10:54:25 +00:00
$timeold = time () - $CFG -> chat_old_ping ;
2005-02-10 19:14:53 +00:00
2004-08-31 10:47:24 +00:00
$query = " lastping < ' $timeold ' " ;
2003-07-09 12:53:26 +00:00
2005-02-03 20:39:27 +00:00
if ( $oldusers = get_records_select ( 'chat_users' , $query ) ) {
delete_records_select ( 'chat_users' , $query );
2003-07-09 12:53:26 +00:00
foreach ( $oldusers as $olduser ) {
2005-02-03 20:39:27 +00:00
$message -> chatid = $olduser -> chatid ;
$message -> userid = $olduser -> userid ;
$message -> groupid = $olduser -> groupid ;
$message -> message = 'exit' ;
$message -> system = 1 ;
2003-07-09 12:53:26 +00:00
$message -> timestamp = time ();
2004-08-10 13:50:58 +00:00
2005-02-03 20:39:27 +00:00
if ( ! insert_record ( 'chat_messages' , $message )) {
error ( 'Could not insert a chat message!' );
2003-07-09 12:53:26 +00:00
}
}
}
}
2003-07-07 06:44:16 +00:00
2003-07-21 03:16:19 +00:00
2003-07-25 06:47:06 +00:00
function chat_update_chat_times ( $chatid = 0 ) {
/// Updates chat records so that the next chat time is correct
$timenow = time ();
if ( $chatid ) {
if ( ! $chats [] = get_record_select ( " chat " , " id = ' $chatid ' AND chattime <= ' $timenow ' AND schedule > '0' " )) {
return ;
}
} else {
if ( ! $chats = get_records_select ( " chat " , " chattime <= ' $timenow ' AND schedule > '0' " )) {
return ;
}
}
foreach ( $chats as $chat ) {
2004-03-29 06:02:21 +00:00
unset ( $chat -> name );
unset ( $chat -> intro );
2003-07-25 06:47:06 +00:00
switch ( $chat -> schedule ) {
case 1 : // Single event - turn off schedule and disable
$chat -> chattime = 0 ;
$chat -> schedule = 0 ;
break ;
case 2 : // Repeat daily
$chat -> chattime += 24 * 3600 ;
break ;
case 3 : // Repeat weekly
$chat -> chattime += 7 * 24 * 3600 ;
break ;
}
update_record ( " chat " , $chat );
2004-04-25 03:05:58 +00:00
$event = NULL ; // Update calendar too
if ( $event -> id = get_field ( 'event' , 'id' , 'modulename' , 'chat' , 'instance' , $chat -> id )) {
$event -> timestart = $chat -> chattime ;
update_event ( $event );
}
2003-07-25 06:47:06 +00:00
}
}
2005-02-12 10:54:25 +00:00
function chat_format_message_manually ( $message , $courseid , $sender , $currentuser ) {
2004-08-10 13:50:58 +00:00
global $CFG ;
2003-07-07 06:44:16 +00:00
2004-08-10 13:50:58 +00:00
$output = New stdClass ;
2005-02-03 20:39:27 +00:00
$output -> beep = false ; // by default
$output -> refreshusers = false ; // by default
2003-07-09 12:53:26 +00:00
2005-02-12 10:54:25 +00:00
// Get some additional info
2004-08-10 13:50:58 +00:00
2005-04-08 07:42:50 +00:00
// But before that :-) let's override get_user_timezone_offset() for this call... messy stuff...
// TODO - FIX THIS TO MANAGE NEW TIMEZONES
2004-08-11 14:45:40 +00:00
$tz = ( $currentuser -> timezone == 99 ) ? $CFG -> timezone : $currentuser -> timezone ;
2004-08-10 13:50:58 +00:00
$message -> strtime = userdate ( $message -> timestamp , get_string ( 'strftimemessage' , 'chat' ), $tz );
$message -> picture = print_user_picture ( $sender -> id , 0 , $sender -> picture , false , true , false );
2003-07-24 02:25:23 +00:00
if ( $courseid ) {
2004-09-16 17:13:57 +00:00
$message -> picture = " <a target= \" _new \" href= \" $CFG->wwwroot /user/view.php?id= $sender->id &course= $courseid\ " > $message -> picture </ a > " ;
2003-07-24 02:25:23 +00:00
}
2003-07-07 06:44:16 +00:00
2004-08-10 13:50:58 +00:00
// Start processing the message
2003-07-07 06:44:16 +00:00
2004-08-10 13:50:58 +00:00
if ( ! empty ( $message -> system )) {
// System event
$output -> text = $message -> strtime . ': ' . get_string ( 'message' . $message -> message , 'chat' , fullname ( $sender ));
$output -> html = '<table><tr><td style="vertical-align: top;">' . $message -> picture . '</td><td>' ;
2004-10-19 10:34:02 +00:00
$output -> html .= '<font size="2" color="#ccaaaa">' . $output -> text . '</font></td></tr></table>' ;
2003-07-09 12:53:26 +00:00
2005-02-03 20:39:27 +00:00
if ( $message -> message == 'exit' or $message -> message == 'enter' ) {
$output -> refreshusers = true ; //force user panel refresh ASAP
}
2003-07-07 06:44:16 +00:00
return $output ;
}
2004-08-11 14:45:40 +00:00
// It's not a system event
2004-08-10 13:50:58 +00:00
$text = $message -> message ;
2004-08-11 14:45:40 +00:00
/// Parse the text to clean and filter it
$options -> para = false ;
$text = format_text ( $text , FORMAT_MOODLE , $options , $courseid );
2003-07-09 12:53:26 +00:00
2004-08-10 13:50:58 +00:00
// And now check for special cases
if ( substr ( $text , 0 , 5 ) == 'beep ' ) {
/// It's a beep!
2003-07-09 12:53:26 +00:00
$beepwho = trim ( substr ( $text , 5 ));
2003-07-09 04:17:27 +00:00
2004-08-10 13:50:58 +00:00
if ( $beepwho == 'all' ) { // everyone
$outinfo = $message -> strtime . ': ' . get_string ( 'messagebeepseveryone' , 'chat' , fullname ( $sender ));
$outmain = '' ;
$output -> beep = true ; // (eventually this should be set to
2003-07-09 12:53:26 +00:00
// to a filename uploaded by the user)
2004-08-11 14:45:40 +00:00
} else if ( $beepwho == $currentuser -> id ) { // current user
2004-08-10 13:50:58 +00:00
$outinfo = $message -> strtime . ': ' . get_string ( 'messagebeepsyou' , 'chat' , fullname ( $sender ));
$outmain = '' ;
2003-07-09 12:53:26 +00:00
$output -> beep = true ;
} else {
return false ;
}
2004-08-10 13:50:58 +00:00
} else if ( substr ( $text , 0 , 1 ) == ':' ) { /// It's an MOO emote
$outinfo = $message -> strtime ;
$outmain = $sender -> firstname . ' ' . substr ( $text , 1 );
2003-07-09 12:53:26 +00:00
2004-08-10 13:50:58 +00:00
} else if ( substr ( $text , 0 , 1 ) == '/' ) { /// It's a user command
2003-07-07 06:44:16 +00:00
2003-07-09 12:53:26 +00:00
if ( substr ( $text , 0 , 4 ) == " /me " ) {
2004-08-10 13:50:58 +00:00
$outinfo = $message -> strtime ;
$outmain = $sender -> firstname . ' ' . substr ( $text , 4 );
2003-07-09 04:17:27 +00:00
} else {
2004-08-10 13:50:58 +00:00
$outinfo = $message -> strtime ;
2003-07-09 12:53:26 +00:00
$outmain = $text ;
2003-07-07 06:44:16 +00:00
}
2003-07-09 04:17:27 +00:00
} else { /// It's a normal message
2004-08-10 13:50:58 +00:00
$outinfo = $message -> strtime . ' ' . $sender -> firstname ;
2003-07-09 12:53:26 +00:00
$outmain = $text ;
2003-07-07 06:44:16 +00:00
}
2003-07-09 04:17:27 +00:00
/// Format the message as a small table
2003-07-07 06:44:16 +00:00
2004-08-10 13:50:58 +00:00
$output -> text = strip_tags ( $outinfo . ': ' . $outmain );
2003-07-09 12:53:26 +00:00
2004-09-12 15:06:29 +00:00
$output -> html = " <table><tr><td valign= \" top \" > $message->picture </td><td><font size= \" 2 \" > " ;
2003-07-09 12:53:26 +00:00
$output -> html .= " <font color= \" #888888 \" > $outinfo </font> " ;
if ( $outmain ) {
$output -> html .= " : $outmain " ;
}
$output -> html .= " </font></td></tr></table> " ;
2003-07-07 06:44:16 +00:00
2003-07-09 12:53:26 +00:00
return $output ;
2004-08-10 13:50:58 +00:00
}
2005-02-03 20:39:27 +00:00
function chat_format_message ( $message , $courseid , $currentuser ) {
2004-08-10 13:50:58 +00:00
/// Given a message object full of information, this function
/// formats it appropriately into text and html, then
/// returns the formatted data.
if ( ! $user = get_record ( " user " , " id " , $message -> userid )) {
return " Error finding user id = $message->userid " ;
}
2005-02-03 20:39:27 +00:00
return chat_format_message_manually ( $message , $courseid , $user , $currentuser );
2003-07-07 06:44:16 +00:00
}
?>