Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
ad5c3230
Commit
ad5c3230
authored
Jan 30, 2015
by
Nathan Lewis
Committed by
Dave Cooper
Apr 08, 2015
Browse files
MDL-49306 blocks: Copy instance data when copying block instances
parent
d8727a4d
Changes
3
Show whitespace changes
Inline
Side-by-side
blocks/moodleblock.class.php
View file @
ad5c3230
...
...
@@ -501,6 +501,15 @@ class block_base {
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
)
{
return
true
;
}
/**
* Delete everything related to this instance if you have been using persistent storage other than the configdata field.
* @return boolean
...
...
blocks/upgrade.txt
View file @
ad5c3230
...
...
@@ -5,6 +5,8 @@ information provided here is intended especially for developers.
* The obsolete method preferred_width() was removed (it was not doing anything)
* Deprecated block_base::config_save as is not called anywhere and should not be used.
* Added instance_copy() function to the block_base class. This function allows for block
specific data to be copied when a block is copied.
=== 2.8 ===
...
...
my/lib.php
View file @
ad5c3230
...
...
@@ -81,11 +81,17 @@ function my_copy_page($userid, $private=MY_PAGE_PRIVATE, $pagetype='my-index') {
'pagetypepattern'
=>
$pagetype
,
'subpagepattern'
=>
$systempage
->
id
));
foreach
(
$blockinstances
as
$instance
)
{
$originalid
=
$instance
->
id
;
unset
(
$instance
->
id
);
$instance
->
parentcontextid
=
$usercontext
->
id
;
$instance
->
subpagepattern
=
$page
->
id
;
$instance
->
id
=
$DB
->
insert_record
(
'block_instances'
,
$instance
);
$blockcontext
=
context_block
::
instance
(
$instance
->
id
);
// Just creates the context record
$block
=
block_instance
(
$instance
->
blockname
,
$instance
);
if
(
!
$block
->
instance_copy
(
$originalid
))
{
debugging
(
"Unable to copy block-specific data for original block instance:
$originalid
to new block instance:
$instance->id
"
,
DEBUG_DEVELOPER
);
}
}
// FIXME: block position overrides should be merged in with block instance
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment