Advertisement
Guest User

Untitled

a guest
Jan 10th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. diff --git a/course/lib.php b/course/lib.php
  2. index d0ad4f0660..a475fbd30b 100644
  3. --- a/course/lib.php
  4. +++ b/course/lib.php
  5. @@ -3452,6 +3452,14 @@ function duplicate_module($course, $cm) {
  6.  
  7.      $bc->destroy();
  8.  
  9. +    // Hack the backup, we want a different name here.
  10. +    $filetohack = $backupbasepath . '/activities/' . $cm->modname . '_' . $cm->id . '/' . $cm->modname . '.xml';
  11. +    // Activity xml files are small enough to be read as a whole.
  12. +    $filecontents = file_get_contents($filetohack);
  13. +    // Of course we must support here lang strings and copy 2, 3, 4...
  14. +    $filecontents = preg_replace('#(<name>)(.*)(</name>)#', '${1}I hacked ${2}!!${3}', $filecontents);
  15. +    file_put_contents($filetohack, $filecontents);
  16. +
  17.      // Restore the backup immediately.
  18.  
  19.      $rc = new restore_controller($backupid, $course->id,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement