芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/message/classes/output/messagearea/contacts.php
. /** * Contains class used to prepare the contacts for display. * * TODO: This file should be removed once the related web services go through final deprecation. * Followup: MDL-63261 * * @package core_message * @copyright 2016 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace core_message\output\messagearea; defined('MOODLE_INTERNAL') || die(); use renderable; use templatable; /** * Class to prepare the contacts for display. * * @package core_message * @copyright 2016 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class contacts implements templatable, renderable { /** * @var int The id of the user that has been selected. */ public $contactuserid; /** * @var array The contacts. */ public $contacts; /** * Constructor. * * @param int|null $contactuserid The id of the user that has been selected * @param array $contacts */ public function __construct($contactuserid, $contacts) { $this->contactuserid = $contactuserid; $this->contacts = $contacts; } public function export_for_template(\renderer_base $output) { $data = new \stdClass(); $data->contacts = array(); $userids = array(); foreach ($this->contacts as $contact) { $contact = new contact($contact); $contactdata = $contact->export_for_template($output); $userids[$contactdata->userid] = $contactdata->userid; // Check if the contact was selected. if ($this->contactuserid == $contactdata->userid) { $contactdata->selected = true; } $data->contacts[] = $contactdata; } // Check if the other user is not part of the contacts. We may be sending a message to someone // we have not had a conversation with, so we want to add a new item to the contacts array. if ($this->contactuserid && !isset($userids[$this->contactuserid])) { $user = \core_user::get_user($this->contactuserid); // Set an empty message so that we know we are messaging the user, and not viewing their profile. $user->smallmessage = ''; $user->useridfrom = $user->id; $contact = \core_message\helper::create_contact($user); $contact = new contact($contact); $contactdata = $contact->export_for_template($output); $contactdata->selected = true; // Put the contact at the front. array_unshift($data->contacts, $contactdata); } return $data; } }