From 5c2f6a7fb140328692b715bf7f866c8ec19ed2d6 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Sun, 15 Jun 2008 12:24:36 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- lang/en_utf8/chat.php | 1 + mod/chat/gui_header_js/chatinput.php | 2 +- mod/chat/gui_header_js/index.php | 4 ++-- mod/chat/gui_header_js/insert.php | 12 ++++++------ mod/chat/gui_sockets/chatinput.php | 2 +- mod/chat/gui_sockets/index.php | 12 ++++++------ mod/chat/lib.php | 10 +++++++++- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/lang/en_utf8/chat.php b/lang/en_utf8/chat.php index 368fb462b9..34e59df5c8 100644 --- a/lang/en_utf8/chat.php +++ b/lang/en_utf8/chat.php @@ -47,6 +47,7 @@ $string['modulename'] = 'Chat'; $string['modulenameplural'] = 'Chats'; $string['neverdeletemessages'] = 'Never delete messages'; $string['nextsession'] = 'Next scheduled session'; +$string['nochat'] = 'No chat found'; $string['noguests'] = 'The chat is not open to guests'; $string['nomessages'] = 'No messages yet'; $string['normalkeepalive'] = 'KeepAlive'; diff --git a/mod/chat/gui_header_js/chatinput.php b/mod/chat/gui_header_js/chatinput.php index ea61d3f042..d859c5dbcc 100644 --- a/mod/chat/gui_header_js/chatinput.php +++ b/mod/chat/gui_header_js/chatinput.php @@ -8,7 +8,7 @@ $chat_sid = required_param('chat_sid', PARAM_ALPHANUM); if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) { - print_error('Not logged in!'); + print_error('notlogged', 'chat'); } //Get the user theme diff --git a/mod/chat/gui_header_js/index.php b/mod/chat/gui_header_js/index.php index 41fddcc60c..f90af0777e 100644 --- a/mod/chat/gui_header_js/index.php +++ b/mod/chat/gui_header_js/index.php @@ -33,7 +33,7 @@ if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if ($groupid = groups_get_activity_group($cm)) { if (!$group = groups_get_group($groupid, false)) { - print_error("That group (id $groupid) doesn't exist!"); + print_error('invalidgroupid'); } $groupname = ': '.$group->name; } else { @@ -47,7 +47,7 @@ $strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!! if (!$chat_sid = chat_login_user($chat->id, 'header_js', $groupid, $course)) { - print_error('Could not log in to chat room!!'); + print_error('cantlogin', 'chat'); } $params = "chat_sid=$chat_sid"; diff --git a/mod/chat/gui_header_js/insert.php b/mod/chat/gui_header_js/insert.php index 484b6afa0c..406e7345a4 100644 --- a/mod/chat/gui_header_js/insert.php +++ b/mod/chat/gui_header_js/insert.php @@ -7,25 +7,25 @@ $chat_message = required_param('chat_message', PARAM_RAW); if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) { - print_error('Not logged in!'); + print_error('notlogged', 'chat'); } if (!$chat = $DB->get_record('chat', array('id'=>$chatuser->chatid))) { - print_error('No chat found'); + print_error('nochat', 'chat'); } if (!$course = $DB->get_record('course', array('id'=>$chat->course))) { - print_error('Could not find the course this belongs to!'); + print_error('invalidcourseid'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { - print_error('Course Module ID was incorrect'); + print_error('invalidcoursemodule'); } require_login($course->id, false, $cm); if (isguest()) { - print_error('Guest does not have access to chat rooms'); + print_error('noguests'); } session_write_close(); @@ -50,7 +50,7 @@ $message->timestamp = time(); if (!$DB->insert_record('chat_messages', $message)) { - print_error('Could not insert a chat message!'); + print_error('cantinsert', 'chat'); } $chatuser->lastmessageping = time() - 2; diff --git a/mod/chat/gui_sockets/chatinput.php b/mod/chat/gui_sockets/chatinput.php index f66b03d249..f873cf0bd5 100644 --- a/mod/chat/gui_sockets/chatinput.php +++ b/mod/chat/gui_sockets/chatinput.php @@ -8,7 +8,7 @@ $chat_sid = required_param('chat_sid', PARAM_ALPHANUM); if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) { - print_error('Not logged in!'); + print_error('notlogged', 'chat'); } //Get the user theme diff --git a/mod/chat/gui_sockets/index.php b/mod/chat/gui_sockets/index.php index cad32ada67..33d06cd37d 100644 --- a/mod/chat/gui_sockets/index.php +++ b/mod/chat/gui_sockets/index.php @@ -7,21 +7,21 @@ $groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers if (!$chat = $DB->get_record('chat', array('id'=>$id))) { - print_error('Could not find that chat room!'); + print_error('invalidid', 'chat'); } if (!$course = $DB->get_record('course', array('id'=>$chat->course))) { - print_error('Could not find the course this belongs to!'); + print_error('invalidcourseid'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { - print_error('Course Module ID was incorrect'); + print_error('invalidcoursemodule'); } require_login($course->id, false, $cm); if (isguest()) { - print_error('Guest does not have access to chat rooms'); + print_error('noguests', 'chat'); } if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) { @@ -33,7 +33,7 @@ if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if ($groupid = groups_get_activity_group($cm)) { if (!$group = groups_get_group($groupid, false)) { - print_error("That group (id $groupid) doesn't exist!"); + print_error('invalidgroupid'); } $groupname = ': '.$group->name; } else { @@ -47,7 +47,7 @@ $strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!! if (!$chat_sid = chat_login_user($chat->id, 'sockets', $groupid, $course)) { - print_error('Could not log in to chat room!!'); + print_error('cantlogin'); } $params = "chat_sid=$chat_sid"; diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 81417fda26..d3c6c1ea19 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -20,7 +20,15 @@ $CHAT_HTMLHEAD_MSGINPUT = "Message Input\n\n"; // Dummy data that gets output to the browser as needed, in order to make it show output -$CHAT_DUMMY_DATA = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; +$CHAT_DUMMY_DATA = produce_data(200); + +function produce_data($n){ + $str = ''; + for($i; $i<$n; $i++){ + $str.='\n'; + } + return $str; +} function chat_add_instance($chat) { global $DB; -- 2.39.5