mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 14:40:06 +01:00
MDL-54687 message: show most recent conversation by default
This commit is contained in:
parent
c1fec732c6
commit
8c250260e6
@ -55,6 +55,13 @@ class contact implements templatable, renderable {
|
||||
$this->contact = $contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user id for this contact.
|
||||
*/
|
||||
public function get_contact() {
|
||||
return $this->contact;
|
||||
}
|
||||
|
||||
public function export_for_template(\renderer_base $output) {
|
||||
$contact = new \stdClass();
|
||||
$contact->userid = $this->contact->userid;
|
||||
|
@ -64,6 +64,22 @@ class contacts implements templatable, renderable {
|
||||
$this->contacts = $contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of contacts.
|
||||
*/
|
||||
public function get_contacts() {
|
||||
return $this->contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other user id.
|
||||
*
|
||||
* @param {int} $otheruserid The id of the other user
|
||||
*/
|
||||
public function set_otheruserid($otheruserid) {
|
||||
$this->otheruserid = $otheruserid;
|
||||
}
|
||||
|
||||
public function export_for_template(\renderer_base $output) {
|
||||
$data = new \stdClass();
|
||||
$data->userid = $this->userid;
|
||||
|
@ -245,7 +245,17 @@ $settings->make_active();
|
||||
$renderer = $PAGE->get_renderer('core_message');
|
||||
if (!$user2realuser) {
|
||||
$conversations = \core_message\api::get_conversations($user1->id, 0, 0, 20);
|
||||
$messages = null;
|
||||
$contacts = $conversations->get_contacts();
|
||||
|
||||
if (!empty($contacts)) {
|
||||
// If there are conversations then render the most recent one by default.
|
||||
$contact = reset($contacts);
|
||||
$otheruserid = $contact->get_contact()->userid;
|
||||
$conversations->set_otheruserid($otheruserid);
|
||||
$messages = \core_message\api::get_messages($user1->id, $otheruserid);
|
||||
} else {
|
||||
$messages = null;
|
||||
}
|
||||
} else {
|
||||
$conversations = \core_message\api::get_conversations($user1->id, $user2->id, 0, 20);
|
||||
$messages = \core_message\api::get_messages($user1->id, $user2->id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user