MDL-41342 admin: Adding warning when upgrading a test site

This commit is contained in:
David Monllao 2013-09-06 14:46:15 +08:00
parent 83f26f6407
commit 6e09cf98fa
6 changed files with 36 additions and 5 deletions

View File

@ -249,6 +249,13 @@ if ($CFG->version != $DB->get_field('config', 'value', array('name'=>'version'))
}
if (!$cache and $version > $CFG->version) { // upgrade
// Warning about upgrading a test site.
$testsite = false;
if (defined('BEHAT_SITE_RUNNING')) {
$testsite = 'behat';
}
// We purge all of MUC's caches here.
// Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
// This ensures a real config object is loaded and the stores will be purged.
@ -283,7 +290,7 @@ if (!$cache and $version > $CFG->version) { // upgrade
/** @var core_admin_renderer $output */
$output = $PAGE->get_renderer('core', 'admin');
echo $output->upgrade_confirm_page($a->newversion, $maturity);
echo $output->upgrade_confirm_page($a->newversion, $maturity, $testsite);
die();
} else if (empty($confirmrelease)){

View File

@ -135,9 +135,10 @@ class core_admin_renderer extends plugin_renderer_base {
* during upgrade.
* @param string $strnewversion
* @param int $maturity
* @param string $testsite
* @return string HTML to output.
*/
public function upgrade_confirm_page($strnewversion, $maturity) {
public function upgrade_confirm_page($strnewversion, $maturity, $testsite) {
$output = '';
$continueurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1));
@ -146,6 +147,7 @@ class core_admin_renderer extends plugin_renderer_base {
$output .= $this->header();
$output .= $this->maturity_warning($maturity);
$output .= $this->test_site_warning($testsite);
$output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl);
$output .= $this->footer();
@ -614,6 +616,24 @@ class core_admin_renderer extends plugin_renderer_base {
'generalbox maturitywarning');
}
/*
* If necessary, displays a warning about upgrading a test site.
*
* @param string $testsite
* @return string HTML
*/
protected function test_site_warning($testsite) {
if (!$testsite) {
return '';
}
return $this->box(
$this->container(get_string('testsiteupgradewarning', 'admin', $testsite)),
'generalbox testsitewarning'
);
}
/**
* Output the copyright notice.
* @return string HTML to output.

View File

@ -1016,6 +1016,7 @@ $string['tablenosave'] = 'Changes in table above are saved automatically.';
$string['tablesnosave'] = 'Changes in tables above are saved automatically.';
$string['tabselectedtofront'] = 'On tables with tabs, should the row with the currently selected tab be placed at the front';
$string['tabselectedtofronttext'] = 'Bring selected tab row to front';
$string['testsiteupgradewarning'] = 'You are currently using the {$a} test site, to upgrade it properly use the command line interface tool';
$string['themedesignermode'] = 'Theme designer mode';
$string['themelist'] = 'Theme list';
$string['themenoselected'] = 'No theme selected';

View File

@ -208,6 +208,7 @@ img.iconsmall {
#page-admin-index .releasenoteslink,
#page-admin-index .adminwarning,
#page-admin-index .maturitywarning,
#page-admin-index .testsitewarning,
#page-admin-index .maturityinfo {
.alert;
width: 60%;
@ -215,6 +216,7 @@ img.iconsmall {
margin: auto;
}
#page-admin-index .maturitywarning,
#page-admin-index .testsitewarning,
#page-admin-index .adminwarning.maturityinfo.maturity50 {
.alert-error;
}

File diff suppressed because one or more lines are too long

View File

@ -19,7 +19,8 @@
#page-admin-index .adminerror,
#page-admin-index .adminwarning {margin:20px;}
#page-admin-index .maturitywarning {margin-left:auto;margin-right:auto;text-align:center;width:60%;background-color:#ffd3d9;}
#page-admin-index .maturitywarning,
#page-admin-index .testsitewarning {margin-left:auto;margin-right:auto;text-align:center;width:60%;background-color:#ffd3d9;}
#page-admin-index .releasenoteslink {margin-left:auto;margin-right:auto;text-align:center;width:60%;}
#page-admin-enrol .enrolplugintable {width:700px;margin:1em auto;}
@ -149,4 +150,4 @@ table.flexible .r1 {background-color: #FAFAFA;}
#page-admin-modules.dir-rtl .generaltable th.c0,
#page-admin-modules.dir-rtl .generaltable td.c0,
#page-admin-auth.dir-rtl .generaltable th.c0,
#page-admin-auth.dir-rtl .generaltable td.c0 {text-align: right;}
#page-admin-auth.dir-rtl .generaltable td.c0 {text-align: right;}