core MDL-19799 Updated print_header and build_navigation to OUTPUT and PAGE equivalents
[moodle.git] / error / index.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2
70e728fb 3 require('../config.php');
3b120e46 4 require_once($CFG->libdir.'/eventslib.php');
f9903ed0 5
294ce987 6 if ($form = data_submitted()) { // form submitted, do not check referer (original page unknown)!
6e27c7c6 7
8 /// Only deal with real users
9 if (!isloggedin()) {
10 redirect($CFG->wwwroot);
f9903ed0 11 }
12
6e27c7c6 13 /// Work out who to send the message to
14 if (!$admin = get_admin() ) {
f945d59b 15 print_error('cannotfindadmin', 'debug');
4ca5b473 16 }
6e27c7c6 17
18 $supportuser = new object;
19 $supportuser->email = $CFG->supportemail ? $CFG->supportemail : $admin->email;
20 $supportuser->firstname = $CFG->supportname ? $CFG->supportname : $admin->firstname;
21 $supportuser->lastname = $CFG->supportname ? '' : $admin->lastname;
22 $supportuser->maildisplay = true;
23
3b120e46 24 /// Send the message and redirect
25 $eventdata = new object();
26 $eventdata->modulename = 'moodle';
27 $eventdata->userfrom = $USER;
28 $eventdata->userto = $supportuser;
29 $eventdata->subject = 'Error: '. $form->referer .' -> '. $form->requested;
30 $eventdata->fullmessage = $form->text;
31 $eventdata->fullmessageformat = FORMAT_PLAIN;
32 $eventdata->fullmessagehtml = '';
2044a2b2 33 $eventdata->smallmessage = '';
3b120e46 34 events_trigger('message_send', $eventdata);
2044a2b2 35
70e728fb 36 redirect($CFG->wwwroot .'/course/', 'Message sent, thanks', 3);
6e27c7c6 37 exit;
f9903ed0 38 }
e80e60a6 39
40 $site = get_site();
6cbaa56a 41 $redirecturl = empty($_SERVER['REDIRECT_URL']) ? '' : $_SERVER['REDIRECT_URL'];
42 $httpreferer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
43 $requesturi = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
f9903ed0 44
6e27c7c6 45 header("HTTP/1.0 404 Not Found");
46 header("Status: 404 Not Found");
47
70f25518 48 $PAGE->set_title($site->fullname .':Error');
49 $PAGE->set_heading($site->fullname .': Error 404');
50 $PAGE->navbar->add('Error 404 - File not Found');
51 echo $OUTPUT->header();
aa9a6867 52 echo $OUTPUT->box(get_string('pagenotexist', 'error'). '<br />'.s($requesturi), 'generalbox boxaligncenter');
6e27c7c6 53
54 if (isloggedin()) {
f9903ed0 55?>
6e27c7c6 56 <center>
57 <p><?php echo get_string('pleasereport', 'error'); ?>
58 <p><form action="<?php echo $CFG->wwwroot ?>/error/index.php" method="post">
59 <textarea rows="3" cols="50" name="text" id="text"></textarea><br />
60 <input type="hidden" name="referer" value="<?php p($httpreferer) ?>">
61 <input type="hidden" name="requested" value="<?php p($requesturi) ?>">
62 <input type="submit" value="<?php echo get_string('sendmessage', 'error'); ?>">
63 </form>
c8848161 64<?php
6e27c7c6 65 } else {
aa9a6867 66 echo $OUTPUT->continue_button($CFG->wwwroot);
6e27c7c6 67 }
7e0d6675 68 echo $OUTPUT->footer();
6573940c 69?>