mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-15101 towards messaging conversion
This commit is contained in:
parent
74d7d73538
commit
d756fe69c5
@ -18,7 +18,7 @@
|
||||
$noframesjs = optional_param('noframesjs', 0, PARAM_BOOL);
|
||||
|
||||
/// Check the user we are talking to is valid
|
||||
if (! $user = get_record('user', 'id', $userid)) {
|
||||
if (! $user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
print_error("User ID was incorrect");
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
}
|
||||
|
||||
/// Check that the user is not blocking us!!
|
||||
if ($contact = get_record('message_contacts', 'userid', $user->id, 'contactid', $USER->id)) {
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$user->id, 'contactid'=>$USER->id))) {
|
||||
if ($contact->blocked and !has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
print_heading(get_string('userisblockingyou', 'message'));
|
||||
exit;
|
||||
@ -127,7 +127,7 @@
|
||||
echo print_user_picture($user, SITEID, $user->picture, 48, true, true, 'userwindow');
|
||||
echo '<div class="name"><h1>'.$userfullname.'</h1></div>';
|
||||
echo '<div class="commands"><ul>';
|
||||
if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) {
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$USER->id, 'contactid'=>$user->id))) {
|
||||
if ($contact->blocked) {
|
||||
echo '<li>';
|
||||
message_contact_link($user->id, 'add', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
|
||||
@ -191,13 +191,18 @@
|
||||
$options->para = false;
|
||||
$options->newlines = true;
|
||||
|
||||
$params = array('uid1'=>$USER->id ,'userid1'=>$userid, 'start1'=>$start, 'uid2'=>$USER->id ,'userid2'=>$userid, 'start2'=>$start);
|
||||
if ($newonly) {
|
||||
$lastsql = " AND timecreated > $last";
|
||||
$lastsql1 = " AND timecreated > :last1";
|
||||
$lastsql2 = " AND timecreated > :last2";
|
||||
$params['last1'] = $last;
|
||||
$params['last2'] = $last;
|
||||
} else {
|
||||
$lastsql = "";
|
||||
$lastsql1 = "";
|
||||
$lastsql2 = "";
|
||||
}
|
||||
|
||||
if ($messages = get_records_select('message_read', "(useridto = '$USER->id' AND useridfrom = '$userid' AND timeread > '$start' $lastsql) OR (useridto = '$userid' AND useridfrom = '$USER->id' AND timeread > '$start' $lastsql)")) {
|
||||
if ($messages = $DB->get_records_select('message_read', "(useridto = :uid1 AND useridfrom = :userid1 AND timeread > :start1 $lastsql1) OR (useridto = :userid2 AND useridfrom = :uid2 AND timeread > :start2 $lastsql2)", $params)) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
|
||||
|
||||
@ -221,7 +226,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($messages = get_records_select('message', "useridto = '$userid' AND useridfrom = '$USER->id' $lastsql")) {
|
||||
if ($messages = $DB->get_records_select('message', "useridto = :userid1 AND useridfrom = :uid1 $lastsql1", $params)) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
|
||||
|
||||
@ -239,7 +244,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($messages = get_records_select('message', "useridto = '$USER->id' AND useridfrom = '$userid' $lastsql")) {
|
||||
if ($messages = $DB->get_records_select('message', "useridto = :uid2 AND useridfrom = userid2 $lastsql2", $params)) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
|
||||
|
||||
@ -260,9 +265,8 @@
|
||||
$messageid = $message->id;
|
||||
unset($message->id);
|
||||
$message->timeread = time();
|
||||
$message = addslashes_object($message);
|
||||
if (insert_record('message_read', $message)) {
|
||||
delete_records('message', 'id', $messageid);
|
||||
if ($DB->insert_record('message_read', $message)) {
|
||||
$DB->delete_records('message', array('id'=>$messageid));
|
||||
}
|
||||
if ($message->timecreated < $start) {
|
||||
$start = $message->timecreated; // move start back so that we see all current history
|
||||
|
@ -16,13 +16,13 @@
|
||||
|
||||
/// Script parameters
|
||||
$userid1 = required_param('user1', PARAM_INT);
|
||||
if (! $user1 = get_record("user", "id", $userid1)) { // Check it's correct
|
||||
if (! $user1 = $DB->get_record("user", array("id"=>$userid1))) { // Check it's correct
|
||||
print_error("User ID 1 was incorrect");
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) { // Able to see any discussion
|
||||
$userid2 = optional_param('user2', $USER->id, PARAM_INT);
|
||||
if (! $user2 = get_record("user", "id", $userid2)) { // Check
|
||||
if (! $user2 = $DB->get_record("user", array("id"=>$userid2))) { // Check
|
||||
print_error("User ID 2 was incorrect");
|
||||
}
|
||||
} else {
|
||||
|
@ -47,8 +47,7 @@
|
||||
@ob_implicit_flush(true);
|
||||
@ob_end_flush();
|
||||
|
||||
if ($messages = get_records_select('message', "useridto = '$USER->id' AND useridfrom = '$userid'",
|
||||
'timecreated')) {
|
||||
if ($messages = $DB->get_records('message', array('useridto'=>$USER->id, 'useridfrom'=>$userid), 'timecreated')) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
|
||||
|
||||
@ -64,11 +63,10 @@
|
||||
|
||||
/// Move the entry to the other table
|
||||
$message->timeread = time();
|
||||
$message = addslashes_object($message);
|
||||
$messageid = $message->id;
|
||||
unset($message->id);
|
||||
if (insert_record('message_read', $message)) {
|
||||
delete_records('message', 'id', $messageid);
|
||||
if ($DB->insert_record('message_read', $message)) {
|
||||
$DB->delete_records('message', array('id'=>$messageid));
|
||||
}
|
||||
}
|
||||
if (get_user_preferences('message_beepnewmessage', 0)) {
|
||||
|
@ -42,12 +42,12 @@ if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTE
|
||||
$format = optional_param('format', FORMAT_MOODLE, PARAM_INT);
|
||||
|
||||
/// Check the user we are talking to is valid
|
||||
if (! $user = get_record('user', 'id', $userid)) {
|
||||
if (! $user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
print_error("User ID was incorrect");
|
||||
}
|
||||
|
||||
/// Check that the user is not blocking us!!
|
||||
if ($contact = get_record('message_contacts', 'userid', $user->id, 'contactid', $USER->id)) {
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$user->id, 'contactid'=>$USER->id))) {
|
||||
if ($contact->blocked and !has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
print_heading(get_string('userisblockingyou', 'message'));
|
||||
exit;
|
||||
|
@ -22,7 +22,7 @@
|
||||
$unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact
|
||||
|
||||
/// Check the user we are talking to is valid
|
||||
if (! $user = get_record('user', 'id', $userid)) {
|
||||
if (! $user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
print_error("User ID was incorrect");
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
//echo '</font>';
|
||||
|
||||
echo '<div class="commands">';
|
||||
if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) {
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$USER->id, 'contactid'=>$user->id))) {
|
||||
if ($contact->blocked) {
|
||||
message_contact_link($user->id, 'add', false, 'user.php?id='.$user->id, true);
|
||||
message_contact_link($user->id, 'unblock', false, 'user.php?id='.$user->id, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user