Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
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 standard functions for message_popup. 19 * 20 * @package message_popup 21 * @copyright 2016 Ryan Wyllie <ryan@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Renders the popup. 29 * 30 * @param renderer_base $renderer 31 * @return string The HTML 32 */ 33 function message_popup_render_navbar_output(\renderer_base $renderer) { 34 global $USER, $CFG; 35 36 // Early bail out conditions. 37 if (!isloggedin() || isguestuser() || user_not_fully_set_up($USER) || 38 get_user_preferences('auth_forcepasswordchange') || 39 (!$USER->policyagreed && !is_siteadmin() && 40 ($manager = new \core_privacy\local\sitepolicy\manager()) && $manager->is_defined())) { 41 return ''; 42 } 43 44 $output = ''; 45 46 // Add the notifications popover. 47 $enabled = \core_message\api::is_processor_enabled("popup"); 48 if ($enabled) { 49 $unreadcount = \message_popup\api::count_unread_popup_notifications($USER->id); 50 $caneditownmessageprofile = has_capability('moodle/user:editownmessageprofile', context_system::instance()); 51 $preferencesurl = $caneditownmessageprofile ? new moodle_url('/message/notificationpreferences.php') : null; 52 $context = [ 53 'userid' => $USER->id, 54 'unreadcount' => $unreadcount, 55 'urls' => [ 56 'seeall' => (new moodle_url('/message/output/popup/notifications.php'))->out(), 57 'preferences' => $preferencesurl ? $preferencesurl->out() : null, 58 ], 59 ]; 60 $output .= $renderer->render_from_template('message_popup/notification_popover', $context); 61 } 62 63 // Add the messages popover. 64 if (!empty($CFG->messaging)) { 65 $unreadcount = \core_message\api::count_unread_conversations($USER); 66 $requestcount = \core_message\api::get_received_contact_requests_count($USER->id); 67 $context = [ 68 'userid' => $USER->id, 69 'unreadcount' => $unreadcount + $requestcount 70 ]; 71 $output .= $renderer->render_from_template('core_message/message_popover', $context); 72 } 73 74 return $output; 75 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body