"MDL-14129, fix print_error"
This commit is contained in:
@@ -10,16 +10,16 @@
|
||||
$last = optional_param('last', 0, PARAM_INT); // last time refresh or sending
|
||||
$newonly = optional_param('newonly', 0, PARAM_BOOL); // show only new messages
|
||||
|
||||
if (!$chat = get_record('chat', 'id', $id)) {
|
||||
print_error('Could not find that chat room!');
|
||||
if (!$chat = $DB->get_record('chat', array('id'=>$id))) {
|
||||
print_error('invalidid', 'chat');
|
||||
}
|
||||
|
||||
if (!$course = get_record('course', 'id', $chat->course)) {
|
||||
print_error('Could not find the course this belongs to!');
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
||||
print_error('Course Module ID was incorrect');
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
@@ -30,7 +30,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 {
|
||||
@@ -45,7 +45,7 @@
|
||||
$strchats = get_string('modulenameplural', 'chat');
|
||||
$stridle = get_String('idle', 'chat');
|
||||
if (!$chat_sid = chat_login_user($chat->id, 'basic', $groupid, $course)) {
|
||||
print_error('Could not log in to chat room!!');
|
||||
print_error('cantlogin', 'chat');
|
||||
}
|
||||
|
||||
if (!$chatusers = chat_get_users($chat->id, $groupid, $cm->groupingid)) {
|
||||
@@ -81,7 +81,7 @@
|
||||
$newmessage->message = $message;
|
||||
$newmessage->timestamp = time();
|
||||
if (!insert_record('chat_messages', $newmessage)) {
|
||||
print_error('Could not insert a chat message!');
|
||||
print_error('cantinsert', 'chat');
|
||||
}
|
||||
|
||||
set_field('chat_users', 'lastmessageping', time(), 'sid', $chat_sid);
|
||||
@@ -148,8 +148,8 @@
|
||||
}
|
||||
|
||||
$groupselect = $groupid ? "AND (groupid='$groupid' OR groupid='0')" : "";
|
||||
$messages = get_records_select("chat_messages",
|
||||
"chatid = '$chat->id' AND timestamp > $chatentered $lastsql $groupselect",
|
||||
$messages = $DB->get_records_select("chat_messages",
|
||||
"chatid = '$chat->id' AND timestamp > $chatentered $lastsql $groupselect", null,
|
||||
"timestamp DESC");
|
||||
|
||||
if ($messages) {
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
|
||||
|
||||
if (!$chat = get_record('chat', 'id', $id)) {
|
||||
print_error('Could not find that chat room!');
|
||||
print_error('invalidid', 'chat');
|
||||
}
|
||||
|
||||
if (!$course = get_record('course', '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');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
$chat_lasttime = optional_param('chat_lasttime', 0, PARAM_INT);
|
||||
$chat_lastrow = optional_param('chat_lastrow', 1, PARAM_INT);
|
||||
|
||||
if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
|
||||
print_error('Not logged in!');
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
|
||||
print_error('notlogged', 'chat');
|
||||
}
|
||||
|
||||
//Get the minimal course
|
||||
if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) {
|
||||
print_error('incorrect course id');
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chatuser->course), 'id,theme,lang')) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
//Get the user theme and enough info to be used in chat_format_message() which passes it along to
|
||||
if (!$USER = get_record('user','id',$chatuser->userid)) { // no optimisation here, it would break again in future!
|
||||
print_error('User does not exist!');
|
||||
if (!$USER = $DB->get_record('user', array('id'=>$chatuser->userid))) { // no optimisation here, it would break again in future!
|
||||
print_error('invaliduser');
|
||||
}
|
||||
$USER->description = '';
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
|
||||
$groupselect = $chatuser->groupid ? " AND (groupid='".$chatuser->groupid."' OR groupid='0') " : "";
|
||||
|
||||
$messages = get_records_select("chat_messages",
|
||||
"chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect",
|
||||
$messages = $DB->get_records_select("chat_messages",
|
||||
"chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect", null,
|
||||
"timestamp ASC");
|
||||
|
||||
if ($messages) {
|
||||
|
||||
@@ -31,19 +31,19 @@
|
||||
$chat_lastrow = optional_param('chat_lastrow', 1, PARAM_INT);
|
||||
$chat_lastid = optional_param('chat_lastid', 0, PARAM_INT);
|
||||
|
||||
if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
|
||||
print_error('Not logged in!');
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
|
||||
print_error('notlogged', 'chat');
|
||||
}
|
||||
|
||||
//Get the minimal course
|
||||
if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) {
|
||||
print_error('incorrect course id');
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chatuser->course), 'id,theme,lang')) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
//Get the user theme and enough info to be used in chat_format_message() which passes it along to
|
||||
// chat_format_message_manually() -- and only id and timezone are used.
|
||||
if (!$USER = get_record('user','id',$chatuser->userid)) { // no optimisation here, it would break again in future!
|
||||
print_error('User does not exist!');
|
||||
if (!$USER = $DB->get_record('user', array('id'=>$chatuser->userid))) { // no optimisation here, it would break again in future!
|
||||
print_error('invaliduser');
|
||||
}
|
||||
$USER->description = '';
|
||||
|
||||
@@ -133,8 +133,8 @@
|
||||
$newcriteria = "timestamp > $chat_lasttime";
|
||||
}
|
||||
|
||||
$messages = get_records_select("chat_messages",
|
||||
"chatid = '$chatuser->chatid' AND $newcriteria $groupselect",
|
||||
$messages = $DB->get_records_select("chat_messages",
|
||||
"chatid = '$chatuser->chatid' AND $newcriteria $groupselect", null,
|
||||
"timestamp ASC");
|
||||
|
||||
if ($messages) {
|
||||
|
||||
@@ -9,17 +9,17 @@
|
||||
$beep = optional_param('beep', 0, PARAM_INT); // beep target
|
||||
|
||||
if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
|
||||
print_error('Not logged in!');
|
||||
print_error('notlogged', 'chat');
|
||||
}
|
||||
|
||||
//Get the minimal course
|
||||
if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) {
|
||||
print_error('incorrect course id');
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
//Get the user theme and enough info to be used in chat_format_message() which passes it along to
|
||||
if (!$USER = get_record('user','id',$chatuser->userid)) { // no optimisation here, it would break again in future!
|
||||
print_error('User does not exist!');
|
||||
print_error('invaliduser');
|
||||
}
|
||||
$USER->description = '';
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
$courseid = $chatuser->course;
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('chat', $chatuser->chatid, $courseid)) {
|
||||
print_error('Course Module ID was incorrect');
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if ($beep) {
|
||||
@@ -41,7 +41,7 @@
|
||||
$message->timestamp = time();
|
||||
|
||||
if (!insert_record('chat_messages', $message)) {
|
||||
print_error('Could not insert a chat message!');
|
||||
print_error('cantinsert', 'chat');
|
||||
}
|
||||
|
||||
$chatuser->lastmessageping = time(); // A beep is a ping ;-)
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
$id = required_param('id', PARAM_INT); // course
|
||||
|
||||
if (! $course = get_record('course', 'id', $id)) {
|
||||
print_error('Course ID is incorrect');
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
require_course_login($course);
|
||||
|
||||
+2
-2
@@ -493,7 +493,7 @@ function chat_login_user($chatid, $version, $groupid, $course) {
|
||||
$message->timestamp = time();
|
||||
|
||||
if (!insert_record('chat_messages', $message)) {
|
||||
print_error('Could not insert a chat message!');
|
||||
print_error('cantinsert', 'chat');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,7 +523,7 @@ function chat_delete_old_users() {
|
||||
$message->timestamp = time();
|
||||
|
||||
if (!insert_record('chat_messages', $message)) {
|
||||
print_error('Could not insert a chat message!');
|
||||
print_error('cantinsert', 'chat');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class page_chat extends page_generic_activity {
|
||||
|
||||
function init_quick($data) {
|
||||
if(empty($data->pageid)) {
|
||||
print_error('Cannot quickly initialize page: empty course id');
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
$this->activityname = 'chat';
|
||||
parent::init_quick($data);
|
||||
|
||||
+3
-3
@@ -12,13 +12,13 @@
|
||||
$confirmdelete = optional_param('confirmdelete', 0, PARAM_BOOL);
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('chat', $id)) {
|
||||
print_error('Course Module ID was incorrect');
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $chat = get_record('chat', 'id', $cm->instance)) {
|
||||
print_error('Course module is incorrect');
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $course = get_record('course', 'id', $chat->course)) {
|
||||
print_error('Course is misconfigured');
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
+10
-10
@@ -13,30 +13,30 @@
|
||||
|
||||
if ($id) {
|
||||
if (! $cm = get_coursemodule_from_id('chat', $id)) {
|
||||
print_error('Course Module ID was incorrect');
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = get_record('course', 'id', $cm->course)) {
|
||||
print_error('Course is misconfigured');
|
||||
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
chat_update_chat_times($cm->instance);
|
||||
|
||||
if (! $chat = get_record('chat', 'id', $cm->instance)) {
|
||||
print_error('Course module is incorrect');
|
||||
if (! $chat = $DB->get_record('chat', array('id'=>$cm->instance))) {
|
||||
print_error('invalidid', 'chat');
|
||||
}
|
||||
|
||||
} else {
|
||||
chat_update_chat_times($c);
|
||||
|
||||
if (! $chat = get_record('chat', 'id', $c)) {
|
||||
print_error('Course module is incorrect');
|
||||
if (! $chat = $DB->get_record('chat', array('id'=>$c))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (! $course = get_record('course', 'id', $chat->course)) {
|
||||
print_error('Course is misconfigured');
|
||||
if (! $course = get_record('course', array('id'=>$chat->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
||||
print_error('Course Module ID was incorrect');
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user