MDL-18177 availability: Excluding group members availability info
If setting was not enabled when backing up, exclude the availability information of group members.
This commit is contained in:
@@ -311,17 +311,25 @@ abstract class info {
|
||||
* @param int $courseid Target course id
|
||||
* @param \base_logger $logger Logger for any warnings
|
||||
* @param int $dateoffset Date offset to be added to any dates (0 = none)
|
||||
* @param \base_task $task Restore task
|
||||
*/
|
||||
public function update_after_restore($restoreid, $courseid, \base_logger $logger, $dateoffset) {
|
||||
public function update_after_restore($restoreid, $courseid, \base_logger $logger,
|
||||
$dateoffset, \base_task $task) {
|
||||
$tree = $this->get_availability_tree();
|
||||
// Set static data for use by get_restore_date_offset function.
|
||||
self::$restoreinfo = array('restoreid' => $restoreid, 'dateoffset' => $dateoffset);
|
||||
self::$restoreinfo = array('restoreid' => $restoreid, 'dateoffset' => $dateoffset,
|
||||
'task' => $task);
|
||||
$changed = $tree->update_after_restore($restoreid, $courseid, $logger,
|
||||
$this->get_thing_name());
|
||||
if ($changed) {
|
||||
// Save modified data.
|
||||
$structure = $tree->save();
|
||||
$this->set_in_database(json_encode($structure));
|
||||
if ($tree->is_empty()) {
|
||||
// If the tree is empty, but the tree has changed, remove this condition.
|
||||
$this->set_in_database(null);
|
||||
} else {
|
||||
$structure = $tree->save();
|
||||
$this->set_in_database(json_encode($structure));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,6 +351,24 @@ abstract class info {
|
||||
return self::$restoreinfo['dateoffset'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the restore task (specifically, the task that calls the
|
||||
* update_after_restore method) for the current restore.
|
||||
*
|
||||
* @param string $restoreid Restore identifier
|
||||
* @return \base_task Restore task
|
||||
* @throws coding_exception If not in a restore (or not in that restore)
|
||||
*/
|
||||
public static function get_restore_task($restoreid) {
|
||||
if (!self::$restoreinfo) {
|
||||
throw new coding_exception('Only valid during restore');
|
||||
}
|
||||
if (self::$restoreinfo['restoreid'] !== $restoreid) {
|
||||
throw new coding_exception('Data not available for that restore id');
|
||||
}
|
||||
return self::$restoreinfo['task'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the name of the item (cm_info or section_info, at present) that
|
||||
* this is controlling availability of. Name should be formatted ready
|
||||
|
||||
Reference in New Issue
Block a user