Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
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 * Contact site support. 19 * 20 * @copyright 2022 Simey Lameze <simey@moodle.com> 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 * @package core_user 23 */ 24 require_once('../config.php'); 25 require_once($CFG->dirroot . '/user/lib.php'); 26 27 if (!empty($CFG->supportpage)) { 28 redirect($CFG->supportpage); 29 } 30 31 $PAGE->set_context(context_system::instance()); 32 $PAGE->set_url('/user/contactsitesupport.php'); 33 $PAGE->set_title(get_string('contactsitesupport', 'admin')); 34 $PAGE->set_heading(get_string('contactsitesupport', 'admin')); 35 $PAGE->set_pagelayout('standard'); 36 37 $user = isloggedin() && !isguestuser() ? $USER : null; 38 $renderer = $PAGE->get_renderer('user'); 39 40 $form = new \core_user\form\contactsitesupport_form(null, $user); 41 if ($form->is_cancelled()) { 42 redirect($CFG->wwwroot); 43 } else if ($form->is_submitted() && $form->is_validated() && confirm_sesskey()) { 44 $data = $form->get_data(); 45 46 $from = $user ?? core_user::get_noreply_user(); 47 $subject = get_string('supportemailsubject', 'admin', format_string($SITE->fullname)); 48 $data->notloggedinuser = (!$user); 49 $message = $renderer->render_from_template('user/contact_site_support_email_body', $data); 50 51 if (!email_to_user(core_user::get_support_user(), $from, $subject, $message)) { 52 $supportemail = $CFG->supportemail; 53 $form->set_data($data); 54 $templatectx = [ 55 'supportemail' => $user ? html_writer::link("mailto:{$supportemail}", $supportemail) : false, 56 'supportform' => $form->render(), 57 ]; 58 59 $output = $renderer->render_from_template('user/contact_site_support_not_available', $templatectx); 60 } else { 61 $level = \core\output\notification::NOTIFY_SUCCESS; 62 redirect($CFG->wwwroot, get_string('supportmessagesent', 'user'), 3, $level); 63 } 64 } else { 65 $output = $form->render(); 66 } 67 68 echo $OUTPUT->header(); 69 70 echo $output; 71 72 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body