Skip to content

Commit

Permalink
MDL-44707 block_html: copy files when copying instance
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Aug 28, 2015
1 parent 6d392b3 commit f5b9384
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions blocks/html/block_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ function instance_delete() {
return true;
}

/**
* Copy any block-specific data when copying to a new block instance.
* @param int $fromid the id number of the block instance to copy from
* @return boolean
*/
public function instance_copy($fromid) {
$fromcontext = context_block::instance($fromid);
$fs = get_file_storage();
// This extra check if file area is empty adds one query if it is not empty but saves several if it is.
if (!$fs->is_area_empty($fromcontext->id, 'block_html', 'content', 0, false)) {
$draftitemid = 0;
file_prepare_draft_area($draftitemid, $fromcontext->id, 'block_html', 'content', 0, array('subdirs' => true));
file_save_draft_area_files($draftitemid, $this->context->id, 'block_html', 'content', 0, array('subdirs' => true));
}
return true;
}

function content_is_trusted() {
global $SCRIPT;

Expand Down

0 comments on commit f5b9384

Please sign in to comment.