mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'MDL-58906-master' of git://github.com/ankitagarwal/moodle
This commit is contained in:
commit
53565d4cf5
@ -878,13 +878,22 @@ class backup_calendarevents_structure_step extends backup_structure_step {
|
||||
$calendar_items_params = array('courseid'=>backup::VAR_COURSEID);
|
||||
$event->set_source_sql($calendar_items_sql, $calendar_items_params);
|
||||
} else if ($this->name == 'activity_calendar') {
|
||||
$params = array('instance' => backup::VAR_ACTIVITYID, 'modulename' => backup::VAR_MODNAME);
|
||||
// We don't backup action events.
|
||||
$params = array('instance' => backup::VAR_ACTIVITYID, 'modulename' => backup::VAR_MODNAME,
|
||||
'type' => array('sqlparam' => CALENDAR_EVENT_TYPE_ACTION));
|
||||
// If we don't want to include the userinfo in the backup then setting the courseid
|
||||
// will filter out all of the user override events (which have a course id of zero).
|
||||
$coursewhere = "";
|
||||
if (!$this->get_setting_value('userinfo')) {
|
||||
$params['courseid'] = backup::VAR_COURSEID;
|
||||
$coursewhere = " AND courseid = :courseid";
|
||||
}
|
||||
$event->set_source_table('event', $params);
|
||||
$calendarsql = "SELECT * FROM {event}
|
||||
WHERE instance = :instance
|
||||
AND type <> :type
|
||||
AND modulename = :modulename";
|
||||
$calendarsql = $calendarsql . $coursewhere;
|
||||
$event->set_source_sql($calendarsql, $params);
|
||||
} else {
|
||||
$event->set_source_table('event', array('courseid' => backup::VAR_COURSEID, 'instance' => backup::VAR_ACTIVITYID, 'modulename' => backup::VAR_MODNAME));
|
||||
}
|
||||
|
@ -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'));
|
||||
|
||||
|
@ -2659,6 +2659,13 @@ class restore_calendarevents_structure_step extends restore_structure_step {
|
||||
$data = (object)$data;
|
||||
$oldid = $data->id;
|
||||
$restorefiles = true; // We'll restore the files
|
||||
|
||||
// If this is a new action event, it will automatically be populated by the adhoc task.
|
||||
// Nothing to do here.
|
||||
if (isset($data->type) && $data->type == CALENDAR_EVENT_TYPE_ACTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
// User overrides for activities are identified by having a courseid of zero with
|
||||
// both a modulename and instance value set.
|
||||
$isuseroverride = !$data->courseid && $data->modulename && $data->instance;
|
||||
@ -5553,3 +5560,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);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class api {
|
||||
*
|
||||
* @param int $cmid The course module id
|
||||
* @param string $modulename The name of the module (eg. assign, quiz)
|
||||
* @param stdClass|int $instanceorid The instance object or ID.
|
||||
* @param \stdClass|int $instanceorid The instance object or ID.
|
||||
* @param int|null $completionexpectedtime The time completion is expected, null if not set
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -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