Skip to content

Commit

Permalink
MDL-17405 moving Data mod upgrade notification to proper place (upgra…
Browse files Browse the repository at this point in the history
…de.php) - better notification will be implemented in MDL-17427
  • Loading branch information
skodak committed Nov 27, 2008
1 parent 95f0446 commit 3c67721
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 39 deletions.
2 changes: 0 additions & 2 deletions admin/environment.xml
Expand Up @@ -277,8 +277,6 @@
<ON_CHECK message="globalswarning" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="mod/data/lib.php" function="data_check_required_entries_fields" level="optional">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>
21 changes: 21 additions & 0 deletions mod/data/db/upgrade.php
Expand Up @@ -149,6 +149,27 @@ function xmldb_data_upgrade($oldversion) {
upgrade_mod_savepoint($result, 2008091400, 'data');
}

if ($result && $oldversion < 2008112700) {
if (!get_config('data', 'requiredentriesfixflag')) {
unset_config('requiredentriesfixflag', 'data'); // remove old flag
$databases = $DB->get_records_sql("SELECT d.*, c.fullname
FROM {data} d, {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 .= $database->fullname." - " .$database->name. " (course id: ".$database->course." - database id: ".$database->id.")<br/>";
}
//TODO: MDL-17427 send this info to "upgrade log" which will be implemented in 2.0
notify(get_string('requiredentrieschanged', 'admin', $a));
}
}
upgrade_mod_savepoint($result, 2008112700, 'data');
}

return $result;
}

Expand Down
36 changes: 0 additions & 36 deletions mod/data/lib.php
Expand Up @@ -2540,42 +2540,6 @@ function data_pluginfile($course, $cminfo, $context, $filearea, $args) {
return false;
}

/**
* NOTE: this function is called into environment.xml
* Check if both of database required entries fields have been set for a version anterior to 2008112101
* This check has been required by the bug MDL-16999
* @global <type> $CFG
* @param <type> $result
* @return object status
*/
function data_check_required_entries_fields($result) {
global $CFG, $DB;
if (!empty($CFG->version) //we are not installing a new Moodle site
&& $CFG->version < 2008112101 //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");
$databases = $DB->get_records_sql("SELECT d.*, c.fullname
FROM {data} d,
{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;
}

require_once($CFG->libdir . '/portfoliolib.php');
class data_portfolio_caller extends portfolio_module_caller_base {

Expand Down
2 changes: 1 addition & 1 deletion mod/data/version.php
Expand Up @@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////

$module->version = 2008091400;
$module->version = 2008112700;
$module->requires = 2008080701; // Requires this Moodle version
$module->cron = 60;

Expand Down

0 comments on commit 3c67721

Please sign in to comment.