Permalink
Browse files

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.
  • Loading branch information...
sam_marshall
sam_marshall committed Sep 21, 2006
1 parent db33348 commit a82e9bc3bbd6bf2f93cb6a060ef2406cd010d9fb
Showing with 15 additions and 2 deletions.
  1. +6 −1 backup/restorelib.php
  2. +9 −1 blocks/moodleblock.class.php
View
@@ -797,6 +797,11 @@ function restore_create_block_instances($restore,$xml_file) {
$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 @@ function restore_close_html($restore) {
}
}
-?>
+?>
@@ -122,6 +122,14 @@ function after_install() {
*/
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 @@ function _print_block() {
}
-?>
+?>

0 comments on commit a82e9bc

Please sign in to comment.