Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 21... Línea 21...
21
 * to Moodle to be rendered using the site theme.
21
 * to Moodle to be rendered using the site theme.
22
 *
22
 *
23
 * ErrorDocument 404 /error/index.php
23
 * ErrorDocument 404 /error/index.php
24
 *
24
 *
25
 * @package    core
25
 * @package    core
26
 * @copyright  2020 Brendan Heywood <brendan@catalyst-au.net>
26
 * @copyright  Brendan Heywood <brendan@catalyst-au.net>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
28
 */
29
 
-
 
30
require('../config.php'); // phpcs:ignore
-
 
31
 
-
 
32
// Until we have a more robust routing api in place this is a very simple
-
 
33
// and clean way to handle arbitrary urls without a php extension.
-
 
34
if ($ME === '/.well-known/change-password') {
-
 
35
    redirect(new moodle_url('/login/change_password.php'));
-
 
36
}
-
 
37
 
-
 
38
$context = context_system::instance();
-
 
39
$title = get_string('pagenotexisttitle', 'error');
-
 
40
$PAGE->set_url('/error/index.php');
-
 
41
$PAGE->set_context($context);
29
require_once("../r.php");
42
$PAGE->set_title($title);
-
 
43
$PAGE->set_heading($title);
-
 
44
$PAGE->navbar->add($title);
-
 
45
 
-
 
46
// This allows the webserver to dictate wether the http status should remain
-
 
47
// what it would have been, or force it to be a 404. Under other conditions
-
 
48
// it could most often be a 403, 405 or a 50x error.
-
 
49
$code = optional_param('code', 0, PARAM_INT);
-
 
50
if ($code == 404) {
-
 
51
    header("HTTP/1.0 404 Not Found");
-
 
52
}
-
 
53
 
-
 
54
$canmessage = has_capability('moodle/site:senderrormessage', $context);
-
 
55
 
-
 
56
$supportuser = core_user::get_support_user();
-
 
57
 
-
 
58
// We can only message support if both the user has the capability
-
 
59
// and the support user is a real user.
-
 
60
if ($canmessage) {
-
 
61
    $canmessage = core_user::is_real_user($supportuser->id);
-
 
62
}
-
 
63
 
-
 
64
$mform = new \core\form\error_feedback($CFG->wwwroot . '/error/index.php');
-
 
65
 
-
 
66
if ($data = $mform->get_data()) {
-
 
67
 
-
 
68
    if (!$canmessage) {
-
 
69
        redirect($CFG->wwwroot);
-
 
70
    }
-
 
71
 
-
 
72
    // Send the message and redirect.
-
 
73
    $message = new \core\message\message();
-
 
74
    $message->courseid         = SITEID;
-
 
75
    $message->component        = 'moodle';
-
 
76
    $message->name             = 'errors';
-
 
77
    $message->userfrom          = $USER;
-
 
78
    $message->userto            = core_user::get_support_user();
-
 
79
    $message->subject           = 'Error: '. $data->referer .' -> '. $data->requested;
-
 
80
    $message->fullmessage       = $data->text;
-
 
81
    $message->fullmessageformat = FORMAT_PLAIN;
-
 
82
    $message->fullmessagehtml   = '';
-
 
83
    $message->smallmessage      = '';
-
 
84
    $message->contexturl = $data->requested;
-
 
85
    message_send($message);
-
 
86
 
-
 
87
    redirect($CFG->wwwroot, get_string('sendmessagesent', 'error', $data->requested), 5);
-
 
88
    exit;
-
 
89
}
-
 
90
 
-
 
91
echo $OUTPUT->header();
-
 
92
echo $OUTPUT->notification(get_string('pagenotexist', 'error', s($ME)), 'error');
-
 
93
echo $OUTPUT->supportemail(['class' => 'text-center d-block mb-3 font-weight-bold']);
-
 
94
 
-
 
95
if ($canmessage) {
-
 
96
    echo \html_writer::tag('h4', get_string('sendmessage', 'error'));
-
 
97
    $mform->display();
-
 
98
} else {
-
 
99
    echo $OUTPUT->continue_button($CFG->wwwroot);
-
 
100
}
-
 
101
 
-
 
102
echo $OUTPUT->footer();
-