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/>.
17 defined('MOODLE_INTERNAL') || die();
20 * Contains standard functions for message_popup.
22 * @package message_popup
23 * @copyright 2016 Ryan Wyllie <ryan@moodle.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 * @param renderer_base $renderer
31 * @return string The HTML
33 function message_popup_render_navbar_output(\renderer_base $renderer) {
34 global $USER, $DB, $CFG;
36 // Early bail out conditions.
37 if (!isloggedin() || isguestuser() || user_not_fully_set_up($USER) ||
38 get_user_preferences('auth_forcepasswordchange') ||
39 (!$USER->policyagreed && $CFG->sitepolicy)) {
45 // Add the messages popover.
46 if (!empty($CFG->messaging)) {
48 'userid' => $USER->id,
50 'seeall' => (new moodle_url('/message/index.php'))->out(),
51 'writeamessage' => (new moodle_url('/message/index.php', ['contactsfirst' => 1]))->out(),
52 'preferences' => (new moodle_url('/message/edit.php', ['id' => $USER->id]))->out(),
55 $output .= $renderer->render_from_template('message_popup/message_popover', $context);
58 // Add the notifications popover.
59 $enabled = \core_message\api::is_processor_enabled("popup");
62 'userid' => $USER->id,
64 'preferences' => (new moodle_url('/message/notificationpreferences.php', ['userid' => $USER->id]))->out(),
67 $output .= $renderer->render_from_template('message_popup/notification_popover', $context);