Commit 1c11c660 authored by Richard Mansfield's avatar Richard Mansfield

When a db upgrade is waiting, redirect admins to upgrade page & disable non-admin logins

parent 684ddc35
......@@ -355,6 +355,10 @@ function auth_setup () {
return;
}
// Lock the site until core upgrades are done
require_once(get_config('libroot') . 'version.php');
set_config('siteclosed', $config->version > get_config('version'));
// Check the time that the session is set to log out. If the user does
// not have a session, this time will be 0.
$sessionlogouttime = $USER->get('logout_time');
......
......@@ -27,6 +27,7 @@
define('INTERNAL', 1);
define('PUBLIC', 1);
define('MENUITEM', '');
define('HOME', 1);
require('init.php');
define('TITLE', get_string('home'));
......
......@@ -206,6 +206,20 @@ if (!defined('INSTALLER')) {
auth_setup();
}
if (get_config('siteclosed')) {
if ($USER->admin && !defined('INSTALLER')) {
redirect('/admin/upgrade.php');
}
if (!$USER->admin) {
if ($USER->is_logged_in()) {
$USER->logout();
}
if (!defined('HOME')) {
redirect();
}
}
}
// check to see if we're installed...
if (!get_config('installed')
&& false === strpos($_SERVER['SCRIPT_FILENAME'], 'admin/index.php')
......
......@@ -400,6 +400,8 @@ $string['useradministration'] = 'User Administration';
$string['unreadmessages'] = 'unread messages';
$string['unreadmessage'] = 'unread message';
$string['siteclosed'] = 'The site is temporarily closed for a database upgrade. Site administrators may log in.';
// footer
$string['termsandconditions'] = 'Terms and Conditions';
$string['privacystatement'] = 'Privacy Statement';
......
......@@ -367,6 +367,7 @@ EOF;
$smarty->assign('SESSKEY', $USER->get('sesskey'));
$smarty->assign_by_ref('JAVASCRIPT', $javascript_array);
$smarty->assign_by_ref('HEADERS', $headers);
$smarty->assign('SITECLOSED', get_config('siteclosed'));
if ((!isset($extraconfig['pagehelp']) || $extraconfig['pagehelp'] !== false)
and $help = has_page_help()) {
......
......@@ -566,6 +566,10 @@ tr.required th,
#logo {
padding: 0;
}
.sitemessage {
text-align: center;
color: #cc0000;
}
/* search box in header */
.searchbox {
font-size: 11px;
......
......@@ -59,6 +59,7 @@
{/if}
</table>
<div id="logo"><a href="{$WWWROOT}"><img src="{theme_path location='images/logo.gif'}" border="0" alt=""></a></div>
{if $SITECLOSED}<div class="sitemessage">{str tag=siteclosed}</div>{/if}
<h1 class="hidden"><a href="{$WWWROOT}">{$hiddenheading|default:"Mahara"|escape}</a></h1>
{if $MAINNAV}
<div id="mainnav">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment