mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-58906 restore: Call action event refresh task during restore
This commit is contained in:
parent
229ae617c5
commit
a4af31ded4
@ -78,6 +78,11 @@ class restore_final_task extends restore_task {
|
||||
// during backup/restore.
|
||||
$this->add_step(new restore_update_availability('update_availability'));
|
||||
|
||||
// Refresh action events conditionally.
|
||||
if ($this->get_setting_value('activities')) {
|
||||
$this->add_step(new restore_calendar_action_events('restoring_action_events'));
|
||||
}
|
||||
|
||||
// Decode all the interlinks
|
||||
$this->add_step(new restore_decode_interlinks('decode_interlinks'));
|
||||
|
||||
|
@ -5553,3 +5553,22 @@ class restore_completion_defaults_structure_step extends restore_structure_step
|
||||
$this->set_mapping('course_completion_defaults', $oldid, $newid);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Restore action events.
|
||||
*
|
||||
* @package core_backup
|
||||
* @copyright 2017 onwards Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class restore_calendar_action_events extends restore_execution_step {
|
||||
/**
|
||||
* What to do when this step is executed.
|
||||
*/
|
||||
protected function define_execution() {
|
||||
// We just queue the task here rather trying to recreate everything manually.
|
||||
// The task will automatically populate all data.
|
||||
$task = new \core\task\refresh_mod_calendar_events_task();
|
||||
$task->set_custom_data(array('courseid' => $this->get_courseid()));
|
||||
\core\task\manager::queue_adhoc_task($task);
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,13 @@ class refresh_mod_calendar_events_task extends adhoc_task {
|
||||
$pluginstorefresh = $this->get_custom_data()->plugins;
|
||||
}
|
||||
|
||||
// Is course id set?
|
||||
if (isset($this->get_custom_data()->courseid)) {
|
||||
$courseid = $this->get_custom_data()->courseid;
|
||||
} else {
|
||||
$courseid = 0;
|
||||
}
|
||||
|
||||
$pluginmanager = core_plugin_manager::instance();
|
||||
$modplugins = $pluginmanager->get_plugins_of_type('mod');
|
||||
foreach ($modplugins as $plugin) {
|
||||
@ -61,7 +68,7 @@ class refresh_mod_calendar_events_task extends adhoc_task {
|
||||
// Check if the plugin implements *_refresh_events() and call it when it does.
|
||||
if (component_callback_exists('mod_' . $plugin->name, 'refresh_events')) {
|
||||
mtrace('Refreshing events for ' . $plugin->name);
|
||||
component_callback('mod_' . $plugin->name, 'refresh_events');
|
||||
course_module_bulk_update_calendar_events($plugin->name, $courseid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user