diff --git a/admin/tool/dataprivacy/classes/privacy/provider.php b/admin/tool/dataprivacy/classes/privacy/provider.php index d415002fed5..0668704bed5 100644 --- a/admin/tool/dataprivacy/classes/privacy/provider.php +++ b/admin/tool/dataprivacy/classes/privacy/provider.php @@ -79,6 +79,16 @@ class provider implements 'privacy:metadata:request' ); + // Regarding this block, we are unable to export or purge this data, as + // it would damage the privacy data across the whole site. + $collection->add_database_table( + 'tool_dataprivacy_purposerole', + [ + 'usermodified' => 'privacy:metadata:purpose:usermodified', + ], + 'privacy:metadata:purpose' + ); + $collection->add_user_preference(tool_helper::PREF_REQUEST_FILTERS, 'privacy:metadata:preference:tool_dataprivacy_request-filters'); $collection->add_user_preference(tool_helper::PREF_REQUEST_PERPAGE, diff --git a/admin/tool/dataprivacy/db/install.xml b/admin/tool/dataprivacy/db/install.xml index f2e2bf0d5e1..1db738eaf03 100644 --- a/admin/tool/dataprivacy/db/install.xml +++ b/admin/tool/dataprivacy/db/install.xml @@ -1,5 +1,5 @@ - @@ -130,6 +130,7 @@ + diff --git a/admin/tool/dataprivacy/db/upgrade.php b/admin/tool/dataprivacy/db/upgrade.php index 3cfa09b9129..e562f68b44a 100644 --- a/admin/tool/dataprivacy/db/upgrade.php +++ b/admin/tool/dataprivacy/db/upgrade.php @@ -71,6 +71,18 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) { // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2022053000) { + + // Define key usermodified (foreign) to be added to tool_dataprivacy_purposerole. + $table = new xmldb_table('tool_dataprivacy_purposerole'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Dataprivacy savepoint reached. + upgrade_plugin_savepoint(true, 2022053000, 'tool', 'dataprivacy'); + } return true; } diff --git a/admin/tool/dataprivacy/lang/en/tool_dataprivacy.php b/admin/tool/dataprivacy/lang/en/tool_dataprivacy.php index 4a8e3ff279f..04f7659cb75 100644 --- a/admin/tool/dataprivacy/lang/en/tool_dataprivacy.php +++ b/admin/tool/dataprivacy/lang/en/tool_dataprivacy.php @@ -232,6 +232,8 @@ $string['privacy'] = 'Privacy'; $string['privacyofficeronly'] = 'Only users who are assigned a privacy officer role ({$a}) have access to this content'; $string['privacy:metadata:preference:tool_dataprivacy_request-filters'] = 'The filters currently applied to the data requests page.'; $string['privacy:metadata:preference:tool_dataprivacy_request-perpage'] = 'The number of data requests the user prefers to see on one page'; +$string['privacy:metadata:purpose'] = 'Information from data purposes made for this site.'; +$string['privacy:metadata:purpose:usermodified'] = 'The ID of the user to who modified the purpose'; $string['privacy:metadata:request'] = 'Information from personal data requests (subject access and deletion requests) made for this site.'; $string['privacy:metadata:request:comments'] = 'Any user comments accompanying the request.'; $string['privacy:metadata:request:userid'] = 'The ID of the user to whom the request belongs'; diff --git a/admin/tool/dataprivacy/version.php b/admin/tool/dataprivacy/version.php index baca9cd6fc0..6ffcf4375fb 100644 --- a/admin/tool/dataprivacy/version.php +++ b/admin/tool/dataprivacy/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2022041900; +$plugin->version = 2022053000; $plugin->requires = 2022041200; $plugin->component = 'tool_dataprivacy'; diff --git a/admin/tool/log/store/standard/db/install.xml b/admin/tool/log/store/standard/db/install.xml index e3b8c40b7e2..67b9abae7bf 100644 --- a/admin/tool/log/store/standard/db/install.xml +++ b/admin/tool/log/store/standard/db/install.xml @@ -1,5 +1,5 @@ - @@ -31,6 +31,10 @@ + + + + diff --git a/admin/tool/log/store/standard/db/upgrade.php b/admin/tool/log/store/standard/db/upgrade.php index 6496e66b446..4d35052f39c 100644 --- a/admin/tool/log/store/standard/db/upgrade.php +++ b/admin/tool/log/store/standard/db/upgrade.php @@ -25,13 +25,40 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_logstore_standard_upgrade($oldversion) { - global $CFG; + global $CFG, $DB; + + require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions. + + $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. // Automatically generated Moodle v3.9.0 release upgrade line. // Put any upgrade step following this. // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2022053000) { + // Define index relateduserid (not unique) to be added to logstore_standard_log. + $table = new xmldb_table('logstore_standard_log'); + + // Launch add key userid. + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + $dbman->add_key($table, $key); + + // Launch add key courseid. + $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']); + $dbman->add_key($table, $key); + + // Launch add key realuserid. + $key = new xmldb_key('realuserid', XMLDB_KEY_FOREIGN, ['realuserid'], 'user', ['id']); + $dbman->add_key($table, $key); + + // Launch add key relateduserid. + $key = new xmldb_key('relateduserid', XMLDB_KEY_FOREIGN, ['relateduserid'], 'user', ['id']); + $dbman->add_key($table, $key); + + // Standard savepoint reached. + upgrade_plugin_savepoint(true, 2022053000, 'logstore', 'standard'); + } return true; } diff --git a/admin/tool/log/store/standard/version.php b/admin/tool/log/store/standard/version.php index eb1e891e4c3..a4e9d286927 100644 --- a/admin/tool/log/store/standard/version.php +++ b/admin/tool/log/store/standard/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022041900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2022053000; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'logstore_standard'; // Full name of the plugin (used for diagnostics). diff --git a/admin/tool/monitor/db/install.xml b/admin/tool/monitor/db/install.xml index 1774e5895d1..da64419f0f8 100644 --- a/admin/tool/monitor/db/install.xml +++ b/admin/tool/monitor/db/install.xml @@ -1,5 +1,5 @@ - @@ -76,6 +76,9 @@ + + + diff --git a/admin/tool/monitor/db/upgrade.php b/admin/tool/monitor/db/upgrade.php index 248aea174bd..86781854f70 100644 --- a/admin/tool/monitor/db/upgrade.php +++ b/admin/tool/monitor/db/upgrade.php @@ -33,11 +33,41 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_tool_monitor_upgrade($oldversion) { global $CFG, $DB; + require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions. + + $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. + // Automatically generated Moodle v3.9.0 release upgrade line. // Put any upgrade step following this. // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2022053000) { + + // Define key courseid (foreign) to be added to tool_monitor_events. + $table = new xmldb_table('tool_monitor_events'); + $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']); + + // Launch add key courseid. + $dbman->add_key($table, $key); + + // Define key contextid (foreign) to be added to tool_monitor_events. + $table = new xmldb_table('tool_monitor_events'); + $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']); + + // Launch add key contextid. + $dbman->add_key($table, $key); + + // Define key contextinstanceid (foreign) to be added to tool_monitor_events. + $table = new xmldb_table('tool_monitor_events'); + $key = new xmldb_key('contextinstanceid', XMLDB_KEY_FOREIGN, ['contextinstanceid'], 'context', ['instanceid']); + + // Launch add key contextinstanceid. + $dbman->add_key($table, $key); + + // Monitor savepoint reached. + upgrade_plugin_savepoint(true, 2022053000, 'tool', 'monitor'); + } return true; } diff --git a/admin/tool/monitor/version.php b/admin/tool/monitor/version.php index 7c0e0c6c33b..3397cbfcda5 100644 --- a/admin/tool/monitor/version.php +++ b/admin/tool/monitor/version.php @@ -26,6 +26,6 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2022041900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2022053000; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'tool_monitor'; // Full name of the plugin (used for diagnostics). diff --git a/analytics/classes/privacy/provider.php b/analytics/classes/privacy/provider.php index c147bdfd974..68e306db83c 100644 --- a/analytics/classes/privacy/provider.php +++ b/analytics/classes/privacy/provider.php @@ -96,6 +96,26 @@ class provider implements 'privacy:metadata:analytics:predictionactions' ); + // Regarding this block, we are unable to export or purge this data, as + // it would damage the analytics data across the whole site. + $collection->add_database_table( + 'analytics_models', + [ + 'usermodified' => 'privacy:metadata:analytics:analyticsmodels:usermodified', + ], + 'privacy:metadata:analytics:analyticsmodels' + ); + + // Regarding this block, we are unable to export or purge this data, as + // it would damage the analytics log data across the whole site. + $collection->add_database_table( + 'analytics_models_log', + [ + 'usermodified' => 'privacy:metadata:analytics:analyticsmodelslog:usermodified', + ], + 'privacy:metadata:analytics:analyticsmodelslog' + ); + return $collection; } diff --git a/auth/oauth2/classes/privacy/provider.php b/auth/oauth2/classes/privacy/provider.php index f5130ae4794..c60abc69ab4 100644 --- a/auth/oauth2/classes/privacy/provider.php +++ b/auth/oauth2/classes/privacy/provider.php @@ -64,6 +64,20 @@ class provider implements ]; $collection->add_database_table('auth_oauth2_linked_login', $authfields, 'privacy:metadata:auth_oauth2:tableexplanation'); + + // Regarding this block, we are unable to export or purge this data, as + // it would damage the oauth2 data across the whole site. + foreach ([ + 'oauth2_endpoint', + 'oauth2_user_field_mapping', + 'oauth2_access_token', + 'oauth2_system_account', + ] as $tablename) { + $collection->add_database_table($tablename, [ + 'usermodified' => 'privacy:metadata:auth_oauth2:usermodified', + ], 'privacy:metadata:auth_oauth2:tableexplanation'); + } + $collection->link_subsystem('core_auth', 'privacy:metadata:auth_oauth2:authsubsystem'); return $collection; diff --git a/files/classes/privacy/provider.php b/files/classes/privacy/provider.php index efae2a97fd7..44c8694da89 100644 --- a/files/classes/privacy/provider.php +++ b/files/classes/privacy/provider.php @@ -73,6 +73,12 @@ class provider implements 'timemodified' => 'privacy:metadata:files:timemodified', ], 'privacy:metadata:files'); + // Regarding this block, we are unable to export or purge this data, as + // it would damage the file conversion data across the whole site. + $collection->add_database_table('file_conversion', [ + 'usermodified' => 'privacy:metadata:file_conversion:usermodified', + ], 'privacy:metadata:file_conversions'); + $collection->add_subsystem_link('core_userkey', [], 'privacy:metadata:core_userkey'); return $collection; diff --git a/lang/en/analytics.php b/lang/en/analytics.php index f3d19e8c60e..55c29e0d228 100644 --- a/lang/en/analytics.php +++ b/lang/en/analytics.php @@ -144,6 +144,10 @@ $string['privacy:metadata:analytics:predictionactions:predictionid'] = 'The pred $string['privacy:metadata:analytics:predictionactions:userid'] = 'The user that made the action'; $string['privacy:metadata:analytics:predictionactions:actionname'] = 'The action name'; $string['privacy:metadata:analytics:predictionactions:timecreated'] = 'When the prediction action was performed'; +$string['privacy:metadata:analytics:analyticsmodels'] = 'Analytic Models'; +$string['privacy:metadata:analytics:analyticsmodels:usermodified'] = 'The user that modified the model'; +$string['privacy:metadata:analytics:analyticsmodelslog'] = 'The log used for Analytic Models'; +$string['privacy:metadata:analytics:analyticsmodelslog:usermodified'] = 'The user that modified the log'; $string['processingsitecontents'] = 'Processing site contents'; $string['successfullyanalysed'] = 'Successfully analysed'; $string['timesplittingmethod'] = 'Analysis interval'; diff --git a/lang/en/files.php b/lang/en/files.php index 8702327d026..d73ab1fc83b 100644 --- a/lang/en/files.php +++ b/lang/en/files.php @@ -25,6 +25,8 @@ defined('MOODLE_INTERNAL') || die(); +$string['privacy:metadata:file_conversions'] = 'A record of the file_conversions performed by a user'; +$string['privacy:metadata:file_conversion:usermodified'] = 'The user who started the file conversion.'; $string['privacy:metadata:files'] = 'A record of the files uploaded or shared by users'; $string['privacy:metadata:files:author'] = 'The author of the file\'s content'; $string['privacy:metadata:files:contenthash'] = 'A hash of the file\'s content'; diff --git a/lib/db/install.xml b/lib/db/install.xml index ab1e31dfc05..a070c9d7ef6 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -108,6 +108,7 @@ + @@ -257,6 +258,7 @@ + @@ -951,6 +953,7 @@ + @@ -975,6 +978,7 @@ + @@ -1126,6 +1130,8 @@ + + @@ -1622,6 +1628,7 @@ + @@ -1639,6 +1646,7 @@ +
@@ -1688,6 +1696,9 @@ + + +
@@ -1813,6 +1824,8 @@ + + @@ -2204,6 +2217,7 @@ +
@@ -2525,6 +2539,7 @@ +
@@ -2637,6 +2652,7 @@ +
@@ -2665,6 +2681,8 @@ + +
@@ -2910,6 +2928,7 @@ + @@ -3026,7 +3045,11 @@ + + + +
@@ -3100,6 +3123,8 @@ + +
@@ -3470,6 +3495,7 @@ + @@ -3540,6 +3566,8 @@ + + @@ -3558,6 +3586,7 @@ +
@@ -3578,6 +3607,9 @@ + + + @@ -3598,6 +3630,7 @@ + @@ -3622,6 +3655,7 @@ + @@ -3644,6 +3678,8 @@ + +
@@ -3660,6 +3696,7 @@ +
@@ -3673,6 +3710,7 @@ + @@ -3690,6 +3728,9 @@ + + +
@@ -3707,6 +3748,7 @@ + @@ -3726,6 +3768,7 @@ + @@ -3746,6 +3789,7 @@ + @@ -3763,6 +3807,7 @@ + @@ -3787,6 +3832,9 @@ + + + @@ -3806,6 +3854,7 @@ + @@ -3822,6 +3871,7 @@ + @@ -3843,6 +3893,7 @@ + @@ -3862,6 +3913,7 @@ +
@@ -3908,6 +3960,7 @@ +
@@ -3924,6 +3977,7 @@ +
@@ -3965,6 +4019,7 @@ + @@ -3988,6 +4043,7 @@ +
@@ -4117,6 +4173,7 @@ +
@@ -4371,6 +4428,7 @@ +
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 2a81dd07fd5..6d3f0da2c05 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2877,6 +2877,15 @@ privatefiles,moodle|/user/files.php'; // Main savepoint reached. upgrade_main_savepoint(true, 2022061500.00); + + } + + if ($oldversion < 2022072900.00) { + // Call the helper function that updates the foreign keys and indexes in MDL-49795. + upgrade_add_foreign_key_and_indexes(); + + // Main savepoint reached. + upgrade_main_savepoint(true, 2022072900.00); } return true; diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index 48fc3ce461e..820752a8485 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -1534,3 +1534,339 @@ function upgrade_fix_file_timestamps() { $recordset->close(); } + +/** + * Upgrade helper to add foreign keys and indexes for MDL-49795 + */ +function upgrade_add_foreign_key_and_indexes() { + global $DB; + + $dbman = $DB->get_manager(); + // Define key originalcourseid (foreign) to be added to course. + $table = new xmldb_table('course'); + $key = new xmldb_key('originalcourseid', XMLDB_KEY_FOREIGN, ['originalcourseid'], 'course', ['id']); + // Launch add key originalcourseid. + $dbman->add_key($table, $key); + + // Define key roleid (foreign) to be added to enrol. + $table = new xmldb_table('enrol'); + $key = new xmldb_key('roleid', XMLDB_KEY_FOREIGN, ['roleid'], 'role', ['id']); + // Launch add key roleid. + $dbman->add_key($table, $key); + + // Define key userid (foreign) to be added to scale. + $table = new xmldb_table('scale'); + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + // Launch add key userid. + $dbman->add_key($table, $key); + + // Define key userid (foreign) to be added to scale_history. + $table = new xmldb_table('scale_history'); + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + // Launch add key userid. + $dbman->add_key($table, $key); + + // Define key courseid (foreign) to be added to post. + $table = new xmldb_table('post'); + $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']); + // Launch add key courseid. + $dbman->add_key($table, $key); + + // Define key coursemoduleid (foreign) to be added to post. + $table = new xmldb_table('post'); + $key = new xmldb_key('coursemoduleid', XMLDB_KEY_FOREIGN, ['coursemoduleid'], 'course_modules', ['id']); + // Launch add key coursemoduleid. + $dbman->add_key($table, $key); + + // Define key questionid (foreign) to be added to question_statistics. + $table = new xmldb_table('question_statistics'); + $key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN, ['questionid'], 'question', ['id']); + // Launch add key questionid. + $dbman->add_key($table, $key); + + // Define key questionid (foreign) to be added to question_response_analysis. + $table = new xmldb_table('question_response_analysis'); + $key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN, ['questionid'], 'question', ['id']); + // Launch add key questionid. + $dbman->add_key($table, $key); + + // Define index last_log_id (not unique) to be added to mnet_host. + $table = new xmldb_table('mnet_host'); + $index = new xmldb_index('last_log_id', XMLDB_INDEX_NOTUNIQUE, ['last_log_id']); + // Conditionally launch add index last_log_id. + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Define key userid (foreign) to be added to mnet_session. + $table = new xmldb_table('mnet_session'); + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + // Launch add key userid. + $dbman->add_key($table, $key); + + // Define key mnethostid (foreign) to be added to mnet_session. + $table = new xmldb_table('mnet_session'); + $key = new xmldb_key('mnethostid', XMLDB_KEY_FOREIGN, ['mnethostid'], 'mnet_host', ['id']); + // Launch add key mnethostid. + $dbman->add_key($table, $key); + + // Define key userid (foreign) to be added to grade_import_values. + $table = new xmldb_table('grade_import_values'); + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + // Launch add key userid. + $dbman->add_key($table, $key); + + // Define key tempdataid (foreign) to be added to portfolio_log. + $table = new xmldb_table('portfolio_log'); + $key = new xmldb_key('tempdataid', XMLDB_KEY_FOREIGN, ['tempdataid'], 'portfolio_tempdata', ['id']); + // Launch add key tempdataid. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to file_conversion. + $table = new xmldb_table('file_conversion'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key userid (foreign) to be added to repository_instances. + $table = new xmldb_table('repository_instances'); + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + // Launch add key userid. + $dbman->add_key($table, $key); + + // Define key contextid (foreign) to be added to repository_instances. + $table = new xmldb_table('repository_instances'); + $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']); + // Launch add key contextid. + $dbman->add_key($table, $key); + + // Define key scaleid (foreign) to be added to rating. + $table = new xmldb_table('rating'); + $key = new xmldb_key('scaleid', XMLDB_KEY_FOREIGN, ['scaleid'], 'scale', ['id']); + // Launch add key scaleid. + $dbman->add_key($table, $key); + + // Define key courseid (foreign) to be added to course_published. + $table = new xmldb_table('course_published'); + $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']); + // Launch add key courseid. + $dbman->add_key($table, $key); + + // Define index hubcourseid (not unique) to be added to course_published. + $table = new xmldb_table('course_published'); + $index = new xmldb_index('hubcourseid', XMLDB_INDEX_NOTUNIQUE, ['hubcourseid']); + // Conditionally launch add index hubcourseid. + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Define key courseid (foreign) to be added to event_subscriptions. + $table = new xmldb_table('event_subscriptions'); + $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']); + // Launch add key courseid. + $dbman->add_key($table, $key); + + // Define key userid (foreign) to be added to event_subscriptions. + $table = new xmldb_table('event_subscriptions'); + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + // Launch add key userid. + $dbman->add_key($table, $key); + + // Define key userid (foreign) to be added to task_log. + $table = new xmldb_table('task_log'); + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + // Launch add key userid. + $dbman->add_key($table, $key); + + // Define key scaleid (foreign) to be added to competency. + $table = new xmldb_table('competency'); + $key = new xmldb_key('scaleid', XMLDB_KEY_FOREIGN, ['scaleid'], 'scale', ['id']); + // Launch add key scaleid. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency. + $table = new xmldb_table('competency'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_coursecompsetting. + $table = new xmldb_table('competency_coursecompsetting'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key contextid (foreign) to be added to competency_framework. + $table = new xmldb_table('competency_framework'); + $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']); + // Launch add key contextid. + $dbman->add_key($table, $key); + + // Define key scaleid (foreign) to be added to competency_framework. + $table = new xmldb_table('competency_framework'); + $key = new xmldb_key('scaleid', XMLDB_KEY_FOREIGN, ['scaleid'], 'scale', ['id']); + // Launch add key scaleid. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_framework. + $table = new xmldb_table('competency_framework'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_coursecomp. + $table = new xmldb_table('competency_coursecomp'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key actionuserid (foreign) to be added to competency_evidence. + $table = new xmldb_table('competency_evidence'); + $key = new xmldb_key('actionuserid', XMLDB_KEY_FOREIGN, ['actionuserid'], 'user', ['id']); + // Launch add key actionuserid. + $dbman->add_key($table, $key); + + // Define key contextid (foreign) to be added to competency_evidence. + $table = new xmldb_table('competency_evidence'); + $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']); + // Launch add key contextid. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_evidence. + $table = new xmldb_table('competency_evidence'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_userevidence. + $table = new xmldb_table('competency_userevidence'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_plan. + $table = new xmldb_table('competency_plan'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_template. + $table = new xmldb_table('competency_template'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key contextid (foreign) to be added to competency_template. + $table = new xmldb_table('competency_template'); + $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']); + // Launch add key contextid. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_templatecomp. + $table = new xmldb_table('competency_templatecomp'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_templatecohort. + $table = new xmldb_table('competency_templatecohort'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key relatedcompetencyid (foreign) to be added to competency_relatedcomp. + $table = new xmldb_table('competency_relatedcomp'); + $key = new xmldb_key('relatedcompetencyid', XMLDB_KEY_FOREIGN, ['relatedcompetencyid'], 'competency', ['id']); + // Launch add key relatedcompetencyid. + $dbman->add_key($table, $key); + + // Define key relatedcompetencyid (foreign) to be added to competency_relatedcomp. + $table = new xmldb_table('competency_relatedcomp'); + $key = new xmldb_key('relatedcompetencyid', XMLDB_KEY_FOREIGN, ['relatedcompetencyid'], 'competency', ['id']); + // Launch add key relatedcompetencyid. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_relatedcomp. + $table = new xmldb_table('competency_relatedcomp'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_usercomp. + $table = new xmldb_table('competency_usercomp'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_usercompcourse. + $table = new xmldb_table('competency_usercompcourse'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_usercompplan. + $table = new xmldb_table('competency_usercompplan'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_plancomp. + $table = new xmldb_table('competency_plancomp'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_userevidencecomp. + $table = new xmldb_table('competency_userevidencecomp'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to competency_modulecomp. + $table = new xmldb_table('competency_modulecomp'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to oauth2_endpoint. + $table = new xmldb_table('oauth2_endpoint'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to oauth2_system_account. + $table = new xmldb_table('oauth2_system_account'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to oauth2_user_field_mapping. + $table = new xmldb_table('oauth2_user_field_mapping'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to analytics_models. + $table = new xmldb_table('analytics_models'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to analytics_models_log. + $table = new xmldb_table('analytics_models_log'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key usermodified (foreign) to be added to oauth2_access_token. + $table = new xmldb_table('oauth2_access_token'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Define key contextid (foreign) to be added to payment_accounts. + $table = new xmldb_table('payment_accounts'); + $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']); + // Launch add key contextid. + $dbman->add_key($table, $key); +} diff --git a/mod/book/db/install.xml b/mod/book/db/install.xml index 61c38b4eb6a..b991b1b18be 100644 --- a/mod/book/db/install.xml +++ b/mod/book/db/install.xml @@ -1,5 +1,5 @@ - @@ -20,6 +20,7 @@ +
diff --git a/mod/book/db/upgrade.php b/mod/book/db/upgrade.php index db6abc23599..a4145c7c409 100644 --- a/mod/book/db/upgrade.php +++ b/mod/book/db/upgrade.php @@ -48,6 +48,16 @@ function xmldb_book_upgrade($oldversion) { // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2022053000) { + // Define key course (foreign) to be added to book. + $table = new xmldb_table('book'); + $key = new xmldb_key('course', XMLDB_KEY_FOREIGN, ['course'], 'course', ['id']); + // Launch add key course. + $dbman->add_key($table, $key); + + // Book savepoint reached. + upgrade_mod_savepoint(true, 2022053000, 'book'); + } return true; } diff --git a/mod/book/version.php b/mod/book/version.php index cf37ab93b75..83d09ef319b 100644 --- a/mod/book/version.php +++ b/mod/book/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die; $plugin->component = 'mod_book'; // Full name of the plugin (used for diagnostics) -$plugin->version = 2022041900; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2022053000; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->cron = 0; // Period for cron to check this module (secs) diff --git a/mod/chat/db/install.xml b/mod/chat/db/install.xml index 1da4bee36d5..dfc44d0257a 100644 --- a/mod/chat/db/install.xml +++ b/mod/chat/db/install.xml @@ -1,5 +1,5 @@ - @@ -82,6 +82,7 @@ + diff --git a/mod/chat/db/upgrade.php b/mod/chat/db/upgrade.php index 0a8c96abbef..f9c8c83babb 100644 --- a/mod/chat/db/upgrade.php +++ b/mod/chat/db/upgrade.php @@ -25,13 +25,27 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_chat_upgrade($oldversion) { - global $CFG; + global $CFG, $DB; + + require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions. + + $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. // Automatically generated Moodle v3.9.0 release upgrade line. // Put any upgrade step following this. // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2022053000) { + // Define key course (foreign) to be added to chat_users. + $table = new xmldb_table('chat_users'); + $key = new xmldb_key('course', XMLDB_KEY_FOREIGN, ['course'], 'course', ['id']); + // Launch add key course. + $dbman->add_key($table, $key); + + // Chat savepoint reached. + upgrade_mod_savepoint(true, 2022053000, 'chat'); + } return true; } diff --git a/mod/chat/version.php b/mod/chat/version.php index 3ed5c49c4fd..711d86d70ce 100644 --- a/mod/chat/version.php +++ b/mod/chat/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022041900; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2022053000; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'mod_chat'; // Full name of the plugin (used for diagnostics). diff --git a/mod/data/db/install.xml b/mod/data/db/install.xml index 38f427a1c80..a9c9de292d1 100644 --- a/mod/data/db/install.xml +++ b/mod/data/db/install.xml @@ -1,5 +1,5 @@ - @@ -91,6 +91,7 @@ +
diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index 1fb0b4c4ee3..c84211358a8 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -22,13 +22,25 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_data_upgrade($oldversion) { - global $CFG; + global $DB; + + $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. // Automatically generated Moodle v3.9.0 release upgrade line. // Put any upgrade step following this. // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2022081600) { + // Define key userid (foreign) to be added to data_records. + $table = new xmldb_table('data_records'); + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + // Launch add key userid. + $dbman->add_key($table, $key); + + // Data savepoint reached. + upgrade_mod_savepoint(true, 2022081600, 'data'); + } return true; } diff --git a/mod/data/version.php b/mod/data/version.php index bad3d8c0efe..42a618aa0e2 100644 --- a/mod/data/version.php +++ b/mod/data/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022071201; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2022081600; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'mod_data'; // Full name of the plugin (used for diagnostics) $plugin->cron = 0; diff --git a/mod/feedback/db/install.xml b/mod/feedback/db/install.xml index 19295e44db0..971492e6bf0 100644 --- a/mod/feedback/db/install.xml +++ b/mod/feedback/db/install.xml @@ -1,5 +1,5 @@ - @@ -80,6 +80,7 @@ + diff --git a/mod/feedback/db/upgrade.php b/mod/feedback/db/upgrade.php index 3e198a1c3b2..f20e918d60d 100644 --- a/mod/feedback/db/upgrade.php +++ b/mod/feedback/db/upgrade.php @@ -42,13 +42,26 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_feedback_upgrade($oldversion) { - global $CFG; + global $CFG, $DB; + + $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. // Automatically generated Moodle v3.9.0 release upgrade line. // Put any upgrade step following this. // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2022053000) { + // Define key courseid (foreign) to be added to feedback_completed. + $table = new xmldb_table('feedback_completed'); + $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']); + + // Launch add key courseid. + $dbman->add_key($table, $key); + + // Feedback savepoint reached. + upgrade_mod_savepoint(true, 2022053000, 'feedback'); + } return true; } diff --git a/mod/feedback/version.php b/mod/feedback/version.php index 43b064c57da..1992dd65dfe 100644 --- a/mod/feedback/version.php +++ b/mod/feedback/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022041900; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2022053000; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'mod_feedback'; // Full name of the plugin (used for diagnostics) $plugin->cron = 0; diff --git a/mod/forum/db/install.xml b/mod/forum/db/install.xml index 0edb6ab22c4..ed437491d83 100644 --- a/mod/forum/db/install.xml +++ b/mod/forum/db/install.xml @@ -1,5 +1,5 @@ - @@ -63,6 +63,7 @@ + diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php index 8236d25a597..cf0d1ab03bc 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -162,5 +162,16 @@ function xmldb_forum_upgrade($oldversion) { upgrade_mod_savepoint(true, 2022062700, 'forum'); } + if ($oldversion < 2022072900) { + // Define key usermodified (foreign) to be added to forum_discussions. + $table = new xmldb_table('forum_discussions'); + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + // Launch add key usermodified. + $dbman->add_key($table, $key); + + // Forum savepoint reached. + upgrade_mod_savepoint(true, 2022072900, 'forum'); + } + return true; } diff --git a/mod/forum/version.php b/mod/forum/version.php index 4c4d8b261af..f8c383b188d 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022062700; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2022072900; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics)