See Release Notes
Long Term Support Release
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 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. 8 // 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. 13 // 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/>. 16 17 /** 18 * Contains class used to display user search results. 19 * 20 * TODO: This file should be removed once the related web services go through final deprecation. 21 * Followup: MDL-63261 22 * 23 * @package core_message 24 * @copyright 2016 Mark Nelson <markn@moodle.com> 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 28 namespace core_message\output\messagearea; 29 30 defined('MOODLE_INTERNAL') || die(); 31 32 use renderable; 33 use templatable; 34 35 /** 36 * Class used to display user search results. 37 * 38 * @package core_message 39 * @copyright 2016 Mark Nelson <markn@moodle.com> 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 */ 42 class user_search_results implements templatable, renderable { 43 44 /** 45 * @var array The list of contacts. 46 */ 47 public $contacts; 48 49 /** 50 * @var array The list of courses. 51 */ 52 public $courses; 53 54 /** 55 * @var array The list of non-contacts. 56 */ 57 public $noncontacts; 58 59 /** 60 * Constructor. 61 * 62 * @param array $contacts list of contacts. 63 * @param array $courses list of courses. 64 * @param array $noncontacts list of nonconcat users. 65 */ 66 public function __construct($contacts, $courses = array(), $noncontacts = array()) { 67 $this->contacts = $contacts; 68 $this->courses = $courses; 69 $this->noncontacts = $noncontacts; 70 } 71 72 public function export_for_template(\renderer_base $output) { 73 // Set the defaults for the data we are going to export. 74 $data = new \stdClass(); 75 $data->hascontacts = false; 76 $data->contacts = array(); 77 $data->hascourses = false; 78 $data->courses = array(); 79 $data->hasnoncontacts = false; 80 $data->noncontacts = array(); 81 82 // Check if there are any contacts. 83 if (!empty($this->contacts)) { 84 $data->hascontacts = true; 85 foreach ($this->contacts as $contact) { 86 $contact = new contact($contact); 87 $data->contacts[] = $contact->export_for_template($output); 88 } 89 } 90 91 // Check if there are any courses. 92 if (!empty($this->courses)) { 93 $data->hascourses = true; 94 $data->courses = []; 95 foreach ($this->courses as $course) { 96 $coursecontext = \context_course::instance($course->id); 97 $course->shortname = external_format_string($course->shortname, $coursecontext->id, true); 98 $course->fullname = external_format_string($course->fullname, $coursecontext->id, true); 99 $data->courses[] = $course; 100 } 101 } 102 103 // Check if there are any non-contacts. 104 if (!empty($this->noncontacts)) { 105 $data->hasnoncontacts = true; 106 foreach ($this->noncontacts as $noncontact) { 107 $noncontact = new contact($noncontact); 108 $data->noncontacts[] = $noncontact->export_for_template($output); 109 } 110 } 111 112 return $data; 113 } 114 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body