Permalink
Browse files

database: MDL-16999 move the warning message from the environment che…

…ck page to a normal upgrade page
  • Loading branch information...
1 parent 0ae4106 commit e2c9778fe7d711f02c402ba484b2a8653d5e5dec jerome committed Jan 8, 2009
Showing with 25 additions and 43 deletions.
  1. +0 −4 admin/environment.xml
  2. +0 −2 lang/en_utf8/admin.php
  3. +2 −0 lang/en_utf8/data.php
  4. +22 −0 mod/data/db/upgrade.php
  5. +0 −36 mod/data/lib.php
  6. +1 −1 mod/data/version.php
@@ -128,10 +128,6 @@
</FEEDBACK>
</PHP_EXTENSION>
</PHP_EXTENSIONS>
- <CUSTOM_CHECKS>
- <CUSTOM_CHECK file="mod/data/lib.php" function="check_required_entries_fields" level="optional">
- </CUSTOM_CHECK>
- </CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="1.9">
<UNICODE level="required">
@@ -494,8 +494,6 @@
$string['releasenoteslink'] = 'For information about this version of Moodle, please see the online <a target=\"_new\" href=\"$a\">Release Notes</a>';
$string['remotelangnotavailable'] = 'Because Moodle can not connect to download.moodle.org, we are unable to do language pack installation automatically. Please download the appropriate zip file(s) from the list below, copy them to your $a directory and unzip them manually.';
$string['renameerrors'] = 'Errors in renames';
-$string['requiredentrieschanged'] = '<strong>IMPORTANT - PLEASE READ<br/>(This warning message will only be displayed during this upgrade)</strong><br/>Due to a bug fix, the behaviour of database activities using the \'Required entries\' and \'Required entries before viewing settings\' settings will change. A more detailed explaination of the changes can be read on <a href=\"http://moodle.org/mod/forum/discuss.php?d=110928\" target=\"_blank\">the database module forum</a>. The expected behavior of these settings can also be read on <a href=\"http://docs.moodle.org/en/Adding/editing_a_database#Required_entries\" target=\"_blank\">Moodle Docs</a>.
-<br/><br/>This change affects the following databases in your system: (Please save this list now, and after the upgrade, check that these activities still work the way that the teacher intends.)<br/><strong style=\"color:red\">$a->text</strong><br/>';
$string['restrictbydefault'] = 'Restrict modules by default';
$string['restrictmodulesfor'] = 'Restrict modules for';
$string['riskconfig'] = 'Users could change site configuration and behaviour';
@@ -193,6 +193,8 @@
$string['recordssaved'] = 'entries saved';
$string['requireapproval'] = 'Require approval?';
$string['requiredentries'] = 'Required entries';
+$string['requiredentrieschanged'] = '<p><strong>IMPORTANT - PLEASE READ </strong></p><p>Due to a bug fix, the behaviour of database activities using the \'Required entries\' and \'Required entries before viewing settings\' settings will change. A more detailed explaination of the changes can be read on <a href=\"http://moodle.org/mod/forum/discuss.php?d=110928\" target=\"_blank\">the database module forum</a>. The expected behavior of these settings can also be read on <a href=\"http://docs.moodle.org/en/Adding/editing_a_database#Required_entries\" target=\"_blank\">Moodle Docs</a>.
+</p><p>This change affects the following databases in your system: (Please save this list now, and after the upgrade, check that these activities still work the way that the teacher intends.)</p><strong style=\"color:red\">$a->text</strong><br/>';
$string['requiredentriestoview'] = 'Entries required before viewing';
$string['resettemplate'] = 'Reset template';
$string['resizingimages'] = 'Resizing image thumbnails...';
@@ -44,6 +44,28 @@ function xmldb_data_upgrade($oldversion=0) {
}
+ ///Display a warning message about "Required Entries" fix from MDL-16999
+ if ($result && $oldversion < 2007022602) {
+ if (!get_config('data', 'requiredentriesfixflag')) {
+ set_config('requiredentriesfixflag', true, 'data'); // remove old flag
+
+ $databases = get_records_sql("SELECT d.*, c.fullname
+ FROM {$CFG->prefix}data d, {$CFG->prefix}course c
+ WHERE d.course = c.id
+ AND (d.requiredentries > 0 OR d.requiredentriestoview > 0)
+ ORDER BY c.fullname, d.name");
+ if (!empty($databases)) {
+ $a = new object();
+ $a->text = '';
+ foreach($databases as $database) {
+ $a->text .= "<p>".$database->fullname." - " .$database->name. " (course id: ".$database->course." - database id: ".$database->id.")</p>";
+ }
+ notify(get_string('requiredentrieschanged', 'data', $a));
+ }
+ }
+ }
+
+
return $result;
}
View
@@ -1879,40 +1879,4 @@ function data_preset_path($course, $userid, $shortname) {
return 'Does it disturb you that this code will never run?';
}
-/**
- * This function is called into environment.xml
- * Check if both of database required entries fields have been set for a version anterior to 2007021572
- * This check has been required by the bug MDL-16999
- * @global <type> $CFG
- * @param <type> $result
- * @return object status
- */
-function check_required_entries_fields($result) {
- global $CFG;
- if (!empty($CFG->version) //we are not installing a new Moodle site
- && $CFG->version < 2007021572 //the version is anterior to the one when the fix has been applied
- && !get_config("data","requiredentriesfixflag")) { //do not show message when upgrading an anterior version when the patch has already been applied
- set_config("requiredentriesfixflag",true, "data"); //set a flag into database in order to let know a Moodle 1.9 upgrade that the message has already been displayed
- $databases = get_records_sql("SELECT d.*, c.fullname
- FROM {$CFG->prefix}data d,
- {$CFG->prefix}course c
- WHERE d.course = c.id
- ORDER BY c.fullname, d.name");
- if (!empty($databases)) {
- $a = new object();
- foreach($databases as $database) {
- if ($database->requiredentries != 0 || $database->requiredentriestoview != 0) {
- $a->text .= "".$database->fullname." - " .$database->name. " (course id: ".$database->course." - database id: ".$database->id.")<br/>";
- //set the feedback string here and not in xml file since we need something
- //more complex than just a string picked from admin.php lang file
- $result->setFeedbackStr(array('requiredentrieschanged', 'admin', $a));
- $result->setStatus(false);//fail test
- }
- }
- return $result;
- }
- }
- return null;
-}
-
?>
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2007022601;
+$module->version = 2007022602;
$module->requires = 2007020200; // Requires this Moodle version
$module->cron = 60;

0 comments on commit e2c9778

Please sign in to comment.