Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]
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 * A page displaying the user's contacts and messages 19 * 20 * @package core_message 21 * @copyright 2010 Andrew Davis 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require_once('../config.php'); 26 27 require_login(null, false); 28 29 if (isguestuser()) { 30 redirect($CFG->wwwroot); 31 } 32 33 if (empty($CFG->messaging)) { 34 throw new \moodle_exception('disabled', 'message'); 35 } 36 37 // The id of the user we want to view messages from. 38 $id = optional_param('id', 0, PARAM_INT); 39 $view = optional_param('view', null, PARAM_ALPHANUM); 40 // It's possible a user may come from a link where these parameters are specified. 41 // We no longer support viewing another user's messaging area (that can be achieved 42 // via the 'Log-in as' feature). The 'user2' value takes preference over 'id'. 43 $userid = optional_param('user2', $id, PARAM_INT); 44 $conversationid = optional_param('convid', null, PARAM_INT); 45 46 if (!core_user::is_real_user($userid)) { 47 $userid = null; 48 } 49 // You can specify either a user, or a conversation, not both. 50 if ($userid) { 51 $conversationid = \core_message\api::get_conversation_between_users([$USER->id, $userid]); 52 } else if ($conversationid) { 53 // Check that the user belongs to the conversation. 54 if (!\core_message\api::is_user_in_conversation($USER->id, $conversationid)) { 55 $conversationid = null; 56 } 57 } 58 59 if ($userid) { 60 if (!\core_message\api::can_send_message($userid, $USER->id)) { 61 throw new moodle_exception('Can not contact user'); 62 } 63 } 64 65 $url = new moodle_url('/message/index.php'); 66 if ($userid) { 67 $url->param('id', $userid); 68 } 69 $PAGE->set_url($url); 70 $PAGE->set_context(context_user::instance($USER->id)); 71 $PAGE->set_pagelayout('mydashboard'); 72 73 $strmessages = get_string('messages', 'message'); 74 75 $PAGE->set_title("$strmessages"); 76 $PAGE->set_heading("$strmessages"); 77 78 // Remove the user node from the main navigation for this page. 79 $usernode = $PAGE->navigation->find('users', null); 80 $usernode->remove(); 81 82 $settings = $PAGE->settingsnav->find('messages', null); 83 $settings->make_active(); 84 85 echo $OUTPUT->header(); 86 // Display a message if the messages have not been migrated yet. 87 if (!get_user_preferences('core_message_migrate_data', false)) { 88 $notify = new \core\output\notification(get_string('messagingdatahasnotbeenmigrated', 'message'), 89 \core\output\notification::NOTIFY_WARNING); 90 echo $OUTPUT->render($notify); 91 } 92 echo \core_message\helper::render_messaging_widget(false, $userid, $conversationid, $view); 93 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body