This commit is contained in:
Damyon Wiese
2013-11-11 10:41:40 +08:00
3 changed files with 28 additions and 8 deletions
+1
View File
@@ -128,6 +128,7 @@ class core_user {
if (empty(self::$noreplyuser)) {
self::$noreplyuser = self::get_dummy_user_record();
self::$noreplyuser->maildisplay = '1'; // Show to all.
}
self::$noreplyuser->emailstop = 1; // Force msg stop for this user.
return self::$noreplyuser;
+5 -5
View File
@@ -136,7 +136,7 @@ if (substr($viewing, 0, 7) == MESSAGE_VIEW_COURSE) {
if (!empty($user1->id) && $user1->id != $USER->id) {
$PAGE->navigation->extend_for_user($user1);
}
if (!empty($user2->id) && $user2->id != $USER->id) {
if (!empty($user2->id) && $user2realuser && ($user2->id != $USER->id)) {
$PAGE->navigation->extend_for_user($user2);
}
@@ -161,7 +161,7 @@ if ($unblockcontact and confirm_sesskey()) {
//was a message sent? Do NOT allow someone looking at someone else's messages to send them.
$messageerror = null;
if ($currentuser && $user2realuser && has_capability('moodle/site:sendmessage', $systemcontext)) {
if ($currentuser && !empty($user2) && has_capability('moodle/site:sendmessage', $systemcontext)) {
// Check that the user is not blocking us!!
if ($contact = $DB->get_record('message_contacts', array('userid' => $user2->id, 'contactid' => $user1->id))) {
if ($contact->blocked and !has_capability('moodle/site:readallmessages', $systemcontext)) {
@@ -221,7 +221,7 @@ $countunreadtotal = 0; //count of unread messages from all users
//we're dealing with unread messages early so the contact list will accurately reflect what is read/unread
$viewingnewmessages = false;
if ($user2realuser) {
if (!empty($user2)) {
//are there any unread messages from $user2
$countunread = message_count_unread_messages($user1, $user2);
if ($countunread>0) {
@@ -249,7 +249,7 @@ list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts($user
message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showactionlinks, $page);
echo html_writer::start_tag('div', array('class' => 'messagearea mdl-align'));
if ($user2realuser) {
if (!empty($user2)) {
echo html_writer::start_tag('div', array('class' => 'mdl-left messagehistory'));
@@ -306,7 +306,7 @@ echo html_writer::start_tag('div', array('class' => 'messagearea mdl-align'));
echo html_writer::end_tag('div');
//send message form
if ($currentuser && has_capability('moodle/site:sendmessage', $systemcontext)) {
if ($currentuser && has_capability('moodle/site:sendmessage', $systemcontext) && $user2realuser) {
echo html_writer::start_tag('div', array('class' => 'mdl-align messagesend'));
if (!empty($messageerror)) {
echo html_writer::tag('span', $messageerror, array('id' => 'messagewarning'));
+22 -3
View File
@@ -378,6 +378,17 @@ function message_get_contacts($user1=null, $user2=null) {
}
$rs->close();
// Add noreply user and support user to the list.
$supportuser = core_user::get_support_user();
$supportuser->messagecount = message_count_unread_messages($USER, $supportuser);
if ($supportuser->messagecount > 0) {
$strangers[] = $supportuser;
}
$noreplyuser = core_user::get_noreply_user();
$noreplyuser->messagecount = message_count_unread_messages($USER, $noreplyuser);
if ($supportuser->messagecount > 0) {
$strangers[] = $noreplyuser;
}
return array($onlinecontacts, $offlinecontacts, $strangers);
}
@@ -1941,7 +1952,12 @@ function message_print_message_history($user1, $user2 ,$search = '', $messagelim
echo html_writer::end_tag('td');
echo html_writer::start_tag('td', array('align' => 'center', 'id' => 'user2'));
echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID));
// Show user picture with link is real user else without link.
if (core_user::is_real_user($user2->id)) {
echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID));
} else {
echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID, 'link' => false));
}
echo html_writer::tag('div', fullname($user2), array('class' => 'heading'));
if ($showactionlinks && isset($user2->iscontact) && isset($user2->isblocked)) {
@@ -2156,8 +2172,11 @@ function message_print_contactlist_user($contact, $incontactlist = true, $isbloc
$strcontact = $strblock = $strhistory = null;
if ($showactionlinks) {
$strcontact = message_get_contact_add_remove_link($incontactlist, $isblocked, $contact);
$strblock = message_get_contact_block_link($incontactlist, $isblocked, $contact);
// Show block and delete links if user is real user.
if (core_user::is_real_user($contact->id)) {
$strcontact = message_get_contact_add_remove_link($incontactlist, $isblocked, $contact);
$strblock = message_get_contact_block_link($incontactlist, $isblocked, $contact);
}
$strhistory = message_history_link($USER->id, $contact->id, true, '', '', 'icon');
}