Commit | Line | Data |
---|---|---|
8580535b | 1 | <?php |
2 | ||
3 | // This file is part of Moodle - http://moodle.org/ | |
4 | // | |
5 | // Moodle is free software: you can redistribute it and/or modify | |
6 | // it under the terms of the GNU General Public License as published by | |
7 | // the Free Software Foundation, either version 3 of the License, or | |
8 | // (at your option) any later version. | |
9 | // | |
10 | // Moodle is distributed in the hope that it will be useful, | |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | // GNU General Public License for more details. | |
14 | // | |
15 | // You should have received a copy of the GNU General Public License | |
16 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | /** | |
19 | * Main administration script. | |
20 | * | |
d078f6d3 | 21 | * @package core |
8580535b | 22 | * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) |
23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
24 | */ | |
f9903ed0 | 25 | |
00be1916 | 26 | // Check that config.php exists, if not then call the install script |
27 | if (!file_exists('../config.php')) { | |
28 | header('Location: ../install.php'); | |
29 | die; | |
30 | } | |
31 | ||
32 | // Check that PHP is of a sufficient version as soon as possible | |
eab044a0 | 33 | if (version_compare(phpversion(), '5.3.2') < 0) { |
00be1916 | 34 | $phpversion = phpversion(); |
35 | // do NOT localise - lang strings would not work here and we CAN NOT move it to later place | |
eab044a0 PS |
36 | echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />"; |
37 | echo "Please upgrade your server software or install older Moodle version."; | |
00be1916 | 38 | die; |
39 | } | |
40 | ||
695940df PS |
41 | // make sure iconv is available and actually works |
42 | if (!function_exists('iconv')) { | |
43 | // this should not happen, this must be very borked install | |
7d85a4e2 | 44 | echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.'; |
695940df PS |
45 | die(); |
46 | } | |
47 | if (iconv('UTF-8', 'UTF-8//IGNORE', 'abc') !== 'abc') { | |
48 | // known to be broken in mid-2011 MAMP installations | |
49 | echo 'Broken iconv PHP extension detected, installation/upgrade can not continue.'; | |
50 | die; | |
51 | } | |
52 | ||
cbad562e | 53 | define('NO_OUTPUT_BUFFERING', true); |
00be1916 | 54 | |
55 | require('../config.php'); | |
bc76b3c0 | 56 | require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions |
57 | require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions | |
00be1916 | 58 | |
59 | $id = optional_param('id', '', PARAM_TEXT); | |
60 | $confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL); | |
61 | $confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL); | |
62 | $confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL); | |
b9934a17 | 63 | $showallplugins = optional_param('showallplugins', 0, PARAM_BOOL); |
00be1916 | 64 | $agreelicense = optional_param('agreelicense', 0, PARAM_BOOL); |
65 | ||
66 | // Check some PHP server settings | |
67 | ||
a6855934 | 68 | $PAGE->set_url('/admin/index.php'); |
6d80fad4 | 69 | $PAGE->set_pagelayout('admin'); // Set a default pagelayout |
ee73b1ff | 70 | |
00be1916 | 71 | $documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>'; |
72 | ||
73 | if (ini_get_bool('session.auto_start')) { | |
74 | print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink)); | |
75 | } | |
76 | ||
77 | if (ini_get_bool('magic_quotes_runtime')) { | |
78 | print_error('phpvaroff', 'debug', '', (object)array('name'=>'magic_quotes_runtime', 'link'=>$documentationlink)); | |
79 | } | |
80 | ||
81 | if (!ini_get_bool('file_uploads')) { | |
82 | print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink)); | |
83 | } | |
84 | ||
85 | if (is_float_problem()) { | |
86 | print_error('phpfloatproblem', 'admin', '', $documentationlink); | |
87 | } | |
88 | ||
00be1916 | 89 | // Set some necessary variables during set-up to avoid PHP warnings later on this page |
00be1916 | 90 | if (!isset($CFG->release)) { |
bc76b3c0 | 91 | $CFG->release = ''; |
00be1916 | 92 | } |
93 | if (!isset($CFG->version)) { | |
bc76b3c0 | 94 | $CFG->version = ''; |
00be1916 | 95 | } |
96 | ||
97 | $version = null; | |
98 | $release = null; | |
3d673fc4 | 99 | require("$CFG->dirroot/version.php"); // defines $version, $release and $maturity |
00be1916 | 100 | $CFG->target_release = $release; // used during installation and upgrades |
101 | ||
102 | if (!$version or !$release) { | |
103 | print_error('withoutversion', 'debug'); // without version, stop | |
104 | } | |
105 | ||
00be1916 | 106 | // Turn off xmlstrictheaders during upgrade. |
107 | $origxmlstrictheaders = !empty($CFG->xmlstrictheaders); | |
108 | $CFG->xmlstrictheaders = false; | |
109 | ||
3316fe24 | 110 | if (!core_tables_exist()) { |
78946b9b | 111 | $PAGE->set_pagelayout('maintenance'); |
d3875524 | 112 | $PAGE->set_popup_notification_allowed(false); |
00be1916 | 113 | |
114 | // fake some settings | |
115 | $CFG->docroot = 'http://docs.moodle.org'; | |
116 | ||
117 | $strinstallation = get_string('installation', 'install'); | |
118 | ||
119 | // remove current session content completely | |
120 | session_get_instance()->terminate_current(); | |
121 | ||
122 | if (empty($agreelicense)) { | |
123 | $strlicense = get_string('license'); | |
69d77c23 | 124 | $PAGE->navbar->add($strlicense); |
125 | $PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release); | |
126 | $PAGE->set_heading($strinstallation); | |
127 | $PAGE->set_cacheable(false); | |
da2fdc3f TH |
128 | $output = $PAGE->get_renderer('core', 'admin'); |
129 | echo $output->header(); | |
130 | echo $output->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment'); | |
131 | echo $output->heading(get_string('copyrightnotice')); | |
852a1f66 | 132 | $copyrightnotice = text_to_html(get_string('gpl3')); |
00be1916 | 133 | $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack |
da2fdc3f | 134 | echo $output->box($copyrightnotice, 'copyrightnotice'); |
bc76b3c0 | 135 | echo '<br />'; |
66f3df17 | 136 | $continue = new single_button(new moodle_url('/admin/index.php', array('lang'=>$CFG->lang, 'agreelicense'=>1)), get_string('continue'), 'get'); |
da2fdc3f TH |
137 | echo $output->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/dev/License"); |
138 | echo $output->footer(); | |
249ab745 | 139 | die; |
140 | } | |
00be1916 | 141 | if (empty($confirmrelease)) { |
bc76b3c0 | 142 | $strcurrentrelease = get_string('currentrelease'); |
69d77c23 | 143 | $PAGE->navbar->add($strcurrentrelease); |
1a4d6a5b DM |
144 | $PAGE->set_title($strinstallation); |
145 | $PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release); | |
69d77c23 | 146 | $PAGE->set_cacheable(false); |
da2fdc3f TH |
147 | $output = $PAGE->get_renderer('core', 'admin'); |
148 | echo $output->header(); | |
149 | echo $output->heading("Moodle $release"); | |
3d673fc4 DM |
150 | |
151 | if (isset($maturity)) { | |
152 | // main version.php declares moodle code maturity | |
153 | if ($maturity < MATURITY_STABLE) { | |
154 | $maturitylevel = get_string('maturity'.$maturity, 'admin'); | |
da2fdc3f TH |
155 | echo $output->box( |
156 | $output->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) . | |
157 | $output->container($output->doc_link('admin/versions', get_string('morehelp'))), | |
dc41abd8 | 158 | 'generalbox maturitywarning'); |
3d673fc4 DM |
159 | } |
160 | } | |
161 | ||
43d26e6d | 162 | $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases'); |
00be1916 | 163 | $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack |
da2fdc3f | 164 | echo $output->box($releasenoteslink, 'generalbox releasenoteslink'); |
00be1916 | 165 | |
166 | require_once($CFG->libdir.'/environmentlib.php'); | |
1c71748d | 167 | if (!check_moodle_environment(normalize_version($release), $environment_results, true, ENV_SELECT_RELEASE)) { |
da2fdc3f | 168 | echo $output->upgrade_reload(new moodle_url('/admin/index.php', array('agreelicense' => 1, 'lang' => $CFG->lang))); |
00be1916 | 169 | } else { |
da2fdc3f TH |
170 | echo $output->notification(get_string('environmentok', 'admin'), 'notifysuccess'); |
171 | echo $output->continue_button(new moodle_url('/admin/index.php', array('agreelicense'=>1, 'confirmrelease'=>1, 'lang'=>$CFG->lang))); | |
00be1916 | 172 | } |
249ab745 | 173 | |
da2fdc3f | 174 | echo $output->footer(); |
00be1916 | 175 | die; |
1dd24519 | 176 | } |
177 | ||
bc76b3c0 | 178 | $strdatabasesetup = get_string('databasesetup'); |
543f54d3 | 179 | upgrade_init_javascript(); |
69d77c23 | 180 | $PAGE->navbar->add($strdatabasesetup); |
181 | $PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release); | |
2ea05146 | 182 | $PAGE->set_heading($strinstallation); |
69d77c23 | 183 | $PAGE->set_cacheable(false); |
da2fdc3f TH |
184 | $output = $PAGE->get_renderer('core', 'admin'); |
185 | echo $output->header(); | |
d02bc6ce | 186 | |
00be1916 | 187 | if (!$DB->setup_is_unicodedb()) { |
188 | if (!$DB->change_db_encoding()) { | |
189 | // If could not convert successfully, throw error, and prevent installation | |
190 | print_error('unicoderequired', 'admin'); | |
db5af934 | 191 | } |
db5af934 | 192 | } |
90509582 | 193 | |
00be1916 | 194 | install_core($version, true); |
195 | } | |
db5af934 | 196 | |
db5af934 | 197 | |
00be1916 | 198 | // Check version of Moodle code on disk compared with database |
199 | // and upgrade if possible. | |
db5af934 | 200 | |
00be1916 | 201 | $stradministration = get_string('administration'); |
202 | $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); | |
db5af934 | 203 | |
00be1916 | 204 | if (empty($CFG->version)) { |
205 | print_error('missingconfigversion', 'debug'); | |
206 | } | |
db5af934 | 207 | |
00be1916 | 208 | if ($version > $CFG->version) { // upgrade |
a95682b2 | 209 | purge_all_caches(); |
78946b9b | 210 | $PAGE->set_pagelayout('maintenance'); |
d3875524 | 211 | $PAGE->set_popup_notification_allowed(false); |
d4a03c00 | 212 | |
00be1916 | 213 | $a->oldversion = "$CFG->release ($CFG->version)"; |
214 | $a->newversion = "$release ($version)"; | |
bc76b3c0 | 215 | $strdatabasechecking = get_string('databasechecking', '', $a); |
db5af934 | 216 | |
00be1916 | 217 | if (empty($confirmupgrade)) { |
1a4d6a5b DM |
218 | $PAGE->set_title($stradministration); |
219 | $PAGE->set_heading($strdatabasechecking); | |
69d77c23 | 220 | $PAGE->set_cacheable(false); |
da2fdc3f TH |
221 | $output = $PAGE->get_renderer('core', 'admin'); |
222 | echo $output->header(); | |
3d673fc4 DM |
223 | if (isset($maturity)) { |
224 | // main version.php declares moodle code maturity | |
225 | if ($maturity < MATURITY_STABLE) { | |
226 | $maturitylevel = get_string('maturity'.$maturity, 'admin'); | |
da2fdc3f TH |
227 | echo $output->box( |
228 | $output->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) . | |
229 | $output->container($output->doc_link('admin/versions', get_string('morehelp'))), | |
dc41abd8 DM |
230 | 'generalbox maturitywarning'); |
231 | } | |
3d673fc4 | 232 | } |
8a138093 PS |
233 | $continueurl = new moodle_url('index.php', array('confirmupgrade' => 1)); |
234 | $cancelurl = new moodle_url('index.php'); | |
da2fdc3f TH |
235 | echo $output->confirm(get_string('upgradesure', 'admin', $a->newversion), $continueurl, $cancelurl); |
236 | echo $output->footer(); | |
00be1916 | 237 | exit; |
db5af934 | 238 | |
00be1916 | 239 | } else if (empty($confirmrelease)){ |
bc76b3c0 | 240 | $strcurrentrelease = get_string('currentrelease'); |
69d77c23 | 241 | $PAGE->navbar->add($strcurrentrelease); |
242 | $PAGE->set_title($strcurrentrelease); | |
52273536 | 243 | $PAGE->set_heading($strcurrentrelease); |
69d77c23 | 244 | $PAGE->set_cacheable(false); |
da2fdc3f TH |
245 | $output = $PAGE->get_renderer('core', 'admin'); |
246 | echo $output->header(); | |
247 | echo $output->heading("Moodle $release"); | |
43d26e6d | 248 | $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases'); |
00be1916 | 249 | $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack |
da2fdc3f | 250 | echo $output->box($releasenoteslink); |
db5af934 | 251 | |
00be1916 | 252 | require_once($CFG->libdir.'/environmentlib.php'); |
253 | if (!check_moodle_environment($release, $environment_results, true, ENV_SELECT_RELEASE)) { | |
da2fdc3f | 254 | echo $output->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1)); |
db5af934 | 255 | } else { |
da2fdc3f | 256 | echo $output->notification(get_string('environmentok', 'admin'), 'notifysuccess'); |
bd41bdd9 | 257 | if (empty($CFG->skiplangupgrade) and current_language() !== 'en') { |
da2fdc3f | 258 | echo $output->box_start('generalbox', 'notice'); |
00be1916 | 259 | print_string('langpackwillbeupdated', 'admin'); |
da2fdc3f | 260 | echo $output->box_end(); |
00be1916 | 261 | } |
da2fdc3f | 262 | echo $output->continue_button('index.php?confirmupgrade=1&confirmrelease=1'); |
db5af934 | 263 | } |
db5af934 | 264 | |
da2fdc3f | 265 | echo $output->footer(); |
00be1916 | 266 | die; |
db5af934 | 267 | |
00be1916 | 268 | } elseif (empty($confirmplugins)) { |
269 | $strplugincheck = get_string('plugincheck'); | |
69d77c23 | 270 | $PAGE->navbar->add($strplugincheck); |
271 | $PAGE->set_title($strplugincheck); | |
52273536 | 272 | $PAGE->set_heading($strplugincheck); |
69d77c23 | 273 | $PAGE->set_cacheable(false); |
b9934a17 | 274 | $output = $PAGE->get_renderer('core', 'admin'); |
b9934a17 DM |
275 | |
276 | echo $output->header(); | |
277 | echo $output->box_start('generalbox'); | |
278 | echo $output->container(get_string('pluginchecknotice', 'core_plugin'), 'generalbox', 'notice'); | |
36ca62ca | 279 | echo $output->plugins_check(plugin_manager::instance(), array('full' => $showallplugins)); |
b9934a17 | 280 | echo $output->box_end(); |
da2fdc3f | 281 | echo $output->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1, 'confirmrelease' => 1)); |
575f245f PS |
282 | $button = new single_button(new moodle_url('index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)), get_string('upgradestart', 'admin'), 'get'); |
283 | $button->class = 'continuebutton'; | |
b9934a17 DM |
284 | echo $output->render($button); |
285 | echo $output->footer(); | |
00be1916 | 286 | die(); |
db5af934 | 287 | |
00be1916 | 288 | } else { |
289 | // Launch main upgrade | |
290 | upgrade_core($version, true); | |
88582df4 | 291 | } |
00be1916 | 292 | } else if ($version < $CFG->version) { |
80380bd7 PS |
293 | // better stop here, we can not continue with plugin upgrades or anything else |
294 | throw new moodle_exception('downgradedcore', 'error', new moodle_url('/admin/')); | |
00be1916 | 295 | } |
296 | ||
297 | // Updated human-readable release version if necessary | |
298 | if ($release <> $CFG->release) { // Update the release version | |
bc76b3c0 | 299 | set_config('release', $release); |
00be1916 | 300 | } |
301 | ||
575f245f PS |
302 | if (moodle_needs_upgrading()) { |
303 | if (!$PAGE->headerprinted) { | |
2361b7dd | 304 | // means core upgrade or installation was not already done |
575f245f | 305 | if (!$confirmplugins) { |
2361b7dd | 306 | $PAGE->set_pagelayout('maintenance'); |
d3875524 | 307 | $PAGE->set_popup_notification_allowed(false); |
575f245f PS |
308 | $strplugincheck = get_string('plugincheck'); |
309 | $PAGE->navbar->add($strplugincheck); | |
310 | $PAGE->set_title($strplugincheck); | |
311 | $PAGE->set_heading($strplugincheck); | |
312 | $PAGE->set_cacheable(false); | |
b9934a17 | 313 | $output = $PAGE->get_renderer('core', 'admin'); |
b9934a17 DM |
314 | |
315 | echo $output->header(); | |
316 | echo $output->box_start('generalbox'); | |
317 | echo $output->container(get_string('pluginchecknotice', 'core_plugin'), 'generalbox', 'notice'); | |
36ca62ca | 318 | echo $output->plugins_check(plugin_manager::instance(), array('full' => $showallplugins)); |
b9934a17 | 319 | echo $output->box_end(); |
da2fdc3f | 320 | echo $output->upgrade_reload(new moodle_url('/admin/index.php')); |
575f245f PS |
321 | $button = new single_button(new moodle_url('index.php', array('confirmplugincheck'=>1)), get_string('upgradestart', 'admin'), 'get'); |
322 | $button->class = 'continuebutton'; | |
b9934a17 DM |
323 | echo $output->render($button); |
324 | echo $output->footer(); | |
575f245f PS |
325 | die(); |
326 | } | |
327 | } | |
328 | // install/upgrade all plugins and other parts | |
329 | upgrade_noncore(true); | |
330 | } | |
00be1916 | 331 | |
31a99877 | 332 | // If this is the first install, indicate that this site is fully configured |
333 | // except the admin password | |
334 | if (during_initial_install()) { | |
335 | set_config('rolesactive', 1); // after this, during_initial_install will return false. | |
00be1916 | 336 | set_config('adminsetuppending', 1); |
c8ae55e9 | 337 | // we need this redirect to setup proper session |
00be1916 | 338 | upgrade_finished("index.php?sessionstarted=1&lang=$CFG->lang"); |
339 | } | |
340 | ||
341 | // make sure admin user is created - this is the last step because we need | |
342 | // session to be working properly in order to edit admin account | |
343 | if (!empty($CFG->adminsetuppending)) { | |
344 | $sessionstarted = optional_param('sessionstarted', 0, PARAM_BOOL); | |
345 | if (!$sessionstarted) { | |
346 | redirect("index.php?sessionstarted=1&lang=$CFG->lang"); | |
347 | } else { | |
348 | $sessionverify = optional_param('sessionverify', 0, PARAM_BOOL); | |
349 | if (!$sessionverify) { | |
350 | $SESSION->sessionverify = 1; | |
351 | redirect("index.php?sessionstarted=1&sessionverify=1&lang=$CFG->lang"); | |
88582df4 | 352 | } else { |
00be1916 | 353 | if (empty($SESSION->sessionverify)) { |
354 | print_error('installsessionerror', 'admin', "index.php?sessionstarted=1&lang=$CFG->lang"); | |
88582df4 | 355 | } |
00be1916 | 356 | unset($SESSION->sessionverify); |
88582df4 | 357 | } |
00be1916 | 358 | } |
88582df4 | 359 | |
c8ae55e9 PS |
360 | // at this stage there can be only one admin - users may change username, so do not rely on that |
361 | $adminuser = get_complete_user_data('id', $CFG->siteadmins); | |
88582df4 | 362 | |
00be1916 | 363 | if ($adminuser->password === 'adminsetuppending') { |
364 | // prevent installation hijacking | |
365 | if ($adminuser->lastip !== getremoteaddr()) { | |
366 | print_error('installhijacked', 'admin'); | |
35d6a2a4 | 367 | } |
00be1916 | 368 | // login user and let him set password and admin details |
369 | $adminuser->newadminuser = 1; | |
0342fc36 | 370 | complete_user_login($adminuser); |
00be1916 | 371 | redirect("$CFG->wwwroot/user/editadvanced.php?id=$adminuser->id"); // Edit thyself |
db5af934 | 372 | |
5c144d60 | 373 | } else { |
00be1916 | 374 | unset_config('adminsetuppending'); |
4da1a0a1 | 375 | } |
376 | ||
00be1916 | 377 | } else { |
378 | // just make sure upgrade logging is properly terminated | |
379 | upgrade_finished('upgradesettings.php'); | |
380 | } | |
b3732604 | 381 | |
00be1916 | 382 | // Turn xmlstrictheaders back on now. |
383 | $CFG->xmlstrictheaders = $origxmlstrictheaders; | |
384 | unset($origxmlstrictheaders); | |
385 | ||
386 | // Check for valid admin user - no guest autologin | |
387 | require_login(0, false); | |
388 | $context = get_context_instance(CONTEXT_SYSTEM); | |
389 | require_capability('moodle/site:config', $context); | |
390 | ||
391 | // check that site is properly customized | |
392 | $site = get_site(); | |
393 | if (empty($site->shortname)) { | |
394 | // probably new installation - lets return to frontpage after this step | |
395 | // remove settings that we want uninitialised | |
396 | unset_config('registerauth'); | |
397 | redirect('upgradesettings.php?return=site'); | |
398 | } | |
399 | ||
400 | // Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders | |
401 | if (!empty($id) and $id == $CFG->siteidentifier) { | |
402 | set_config('registered', time()); | |
403 | } | |
404 | ||
405 | // setup critical warnings before printing admin tree block | |
bc76b3c0 | 406 | $insecuredataroot = is_dataroot_insecure(true); |
00be1916 | 407 | $SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR); |
408 | ||
409 | $adminroot = admin_get_root(); | |
410 | ||
411 | // Check if there are any new admin settings which have still yet to be set | |
412 | if (any_new_admin_settings($adminroot)){ | |
413 | redirect('upgradesettings.php'); | |
414 | } | |
415 | ||
416 | // Everything should now be set up, and the user is an admin | |
417 | ||
418 | // Print default admin page with notifications. | |
00be1916 | 419 | admin_externalpage_setup('adminnotifications'); |
61ef8f9f | 420 | echo $OUTPUT->header(); |
00be1916 | 421 | |
a95682b2 DM |
422 | // Unstable code warning |
423 | if (isset($maturity)) { | |
424 | if ($maturity < MATURITY_STABLE) { | |
425 | $maturitylevel = get_string('maturity'.$maturity, 'admin'); | |
426 | echo $OUTPUT->box( | |
427 | get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' . | |
428 | $OUTPUT->doc_link('admin/versions', get_string('morehelp')), | |
429 | 'generalbox adminwarning maturityinfo'); | |
430 | } | |
431 | } | |
432 | ||
00be1916 | 433 | if ($insecuredataroot == INSECURE_DATAROOT_WARNING) { |
20486a5a | 434 | echo $OUTPUT->box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning'); |
00be1916 | 435 | } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) { |
20486a5a | 436 | echo $OUTPUT->box(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'generalbox adminerror'); |
00be1916 | 437 | |
438 | } | |
439 | ||
440 | if (defined('WARN_DISPLAY_ERRORS_ENABLED')) { | |
20486a5a | 441 | echo $OUTPUT->box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning'); |
00be1916 | 442 | } |
443 | ||
444 | // If no recently cron run | |
445 | $lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}'); | |
446 | if (time() - $lastcron > 3600 * 24) { | |
9047d80e | 447 | $helpbutton = $OUTPUT->help_icon('cron', 'admin'); |
20486a5a | 448 | echo $OUTPUT->box(get_string('cronwarning', 'admin').' '.$helpbutton, 'generalbox adminwarning'); |
00be1916 | 449 | } |
450 | ||
d35ece6c PS |
451 | // diagnose DB, especially the sloppy MyISAM tables |
452 | $diagnose = $DB->diagnose(); | |
453 | if ($diagnose !== NULL) { | |
454 | echo $OUTPUT->box($diagnose, 'generalbox adminwarning'); | |
455 | } | |
456 | ||
00be1916 | 457 | // Alert if we are currently in maintenance mode |
4fe2250a | 458 | if (!empty($CFG->maintenance_enabled)) { |
20486a5a | 459 | echo $OUTPUT->box(get_string('sitemaintenancewarning2', 'admin', "$CFG->wwwroot/$CFG->admin/settings.php?section=maintenancemode"), 'generalbox adminwarning'); |
00be1916 | 460 | } |
461 | ||
00be1916 | 462 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
463 | //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE /// | |
464 | $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '. | |
19b4d9d8 | 465 | '<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'. |
00be1916 | 466 | 'Copyright © 1999 onwards, Martin Dougiamas<br />'. |
9fdab2fe AB |
467 | 'and <a href="http://docs.moodle.org/dev/Credits">many other contributors</a>.<br />'. |
468 | '<a href="http://docs.moodle.org/dev/License">GNU Public License</a>'; | |
20486a5a | 469 | echo $OUTPUT->box($copyrighttext, 'copyright'); |
00be1916 | 470 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
471 | ||
73d6f52f | 472 | echo $OUTPUT->footer(); |
74944b73 | 473 |