diff --git a/backup/restorelib.php b/backup/restorelib.php index 6ecd1dfc79e..334928c495c 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -797,6 +797,11 @@ $status = false; break; } + + //Get an object for the block and tell it it's been restored so it can update dates + //etc. if necessary + $blockobj=block_instance($instance->name,$instance); + $blockobj->after_restore($restore); //Now we can increment the weight counter ++$maxweights[$instance->position]; @@ -5461,4 +5466,4 @@ } } -?> +?> \ No newline at end of file diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php index 9b07fb91224..ee35ca7b08d 100644 --- a/blocks/moodleblock.class.php +++ b/blocks/moodleblock.class.php @@ -122,6 +122,14 @@ class block_base { */ function before_delete() { } + + /** + * Function that can be overridden to do extra setup after a block instance has been + * restored from backup. For example, it may need to alter any dates that the block + * stores, if the $restore->course_startdateoffset is set. + */ + function after_restore($restore) { + } /** * Returns the block name, as present in the class name, @@ -708,4 +716,4 @@ class block_list extends block_base { } -?> +?> \ No newline at end of file