Skip to content

Commit

Permalink
MDL-63915 core_message: remove use of renderable so we can nuke it
Browse files Browse the repository at this point in the history
The other renderables in the same namespace are still used by
deprecated web services. Once we do the final deprecation of
those web services they will be removed - see MDL-63261.
  • Loading branch information
mdjnelson committed Feb 27, 2019
1 parent b1bba55 commit ee45ecc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 69 deletions.
65 changes: 0 additions & 65 deletions message/classes/output/messagearea/message_search_results.php

This file was deleted.

36 changes: 32 additions & 4 deletions message/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ public static function data_for_messagearea_search_messages_parameters() {
* @since 3.2
*/
public static function data_for_messagearea_search_messages($userid, $search, $limitfrom = 0, $limitnum = 0) {
global $CFG, $PAGE, $USER;
global $CFG, $USER;

// Check if messaging is enabled.
if (empty($CFG->messaging)) {
Expand Down Expand Up @@ -1567,10 +1567,38 @@ public static function data_for_messagearea_search_messages($userid, $search, $l
$params['limitfrom'],
$params['limitnum']
);
$results = new \core_message\output\messagearea\message_search_results($messages);

$renderer = $PAGE->get_renderer('core_message');
return $results->export_for_template($renderer);
$data = new \stdClass();
$data->contacts = [];
foreach ($messages as $message) {
$contact = new \stdClass();
$contact->userid = $message->userid;
$contact->fullname = $message->fullname;
$contact->profileimageurl = $message->profileimageurl;
$contact->profileimageurlsmall = $message->profileimageurlsmall;
$contact->messageid = $message->messageid;
$contact->ismessaging = $message->ismessaging;
$contact->sentfromcurrentuser = false;
if ($message->lastmessage) {
if ($message->userid !== $message->useridfrom) {
$contact->sentfromcurrentuser = true;
}
$contact->lastmessage = shorten_text($message->lastmessage, 60);
} else {
$contact->lastmessage = null;
}
$contact->lastmessagedate = $message->lastmessagedate;
$contact->showonlinestatus = is_null($message->isonline) ? false : true;
$contact->isonline = $message->isonline;
$contact->isblocked = $message->isblocked;
$contact->isread = $message->isread;
$contact->unreadcount = $message->unreadcount;
$contact->conversationid = $message->conversationid;

$data->contacts[] = $contact;
}

return $data;
}

/**
Expand Down

0 comments on commit ee45ecc

Please sign in to comment.