2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Contains class used to prepare a contact for display.
20 * @package core_message
21 * @copyright 2016 Mark Nelson <markn@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace core_message\output;
31 * Class to prepare a contact for display.
33 * @package core_message
34 * @copyright 2016 Mark Nelson <markn@moodle.com>
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 class contact implements templatable, renderable {
40 * Maximum length of message to show in left panel.
42 const MAX_MSG_LENGTH = 60;
52 * @param \stdClass $contact
54 public function __construct($contact) {
55 $this->contact = $contact;
58 public function export_for_template(\renderer_base $output) {
59 $contact = new \stdClass();
60 $contact->userid = $this->contact->userid;
61 $contact->fullname = $this->contact->fullname;
62 $contact->profileimageurl = $this->contact->profileimageurl;
63 $contact->profileimageurlsmall = $this->contact->profileimageurlsmall;
64 $contact->lastmessage = shorten_text($this->contact->lastmessage, self::MAX_MSG_LENGTH);
65 $contact->isonline = $this->contact->isonline;
66 $contact->isread = $this->contact->isread;