From: sam_marshall Date: Thu, 21 Sep 2006 12:07:15 +0000 (+0000) Subject: Added feature to blocks (and restorelib) so that blocks get a method call (default... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a82e9bc3bbd6bf2f93cb6a060ef2406cd010d9fb;p=moodle.git Added feature to blocks (and restorelib) so that blocks get a method call (default does nothing) after they are restored. This allows blocks to change their settings if necessary in respect of the new course roll-forward 'restore and change start date' feature that Al implemented recently. The core blocks happen not to store dates anyway so don't need this, but contributed blocks may well do. --- diff --git a/backup/restorelib.php b/backup/restorelib.php index 6ecd1dfc79..334928c495 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 9b07fb9122..ee35ca7b08 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