Skip to content
GitLab
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
e7e0a570
Commit
e7e0a570
authored
Jan 13, 2016
by
Dan Poltawski
Browse files
Merge branch 'wip-MDL-50851-backupfix' of
https://github.com/marinaglancy/moodle
parents
67f68027
8f5d6695
Changes
1
Hide whitespace changes
Inline
Side-by-side
blocks/tags/backup/moodle2/restore_tags_block_task.class.php
0 → 100644
View file @
e7e0a570
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package block_tags
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Specialised restore task for the tags block
* (using execute_after_tasks for recoding of tag collection id)
*
* @package block_tags
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
restore_tags_block_task
extends
restore_block_task
{
protected
function
define_my_settings
()
{
}
protected
function
define_my_steps
()
{
}
public
function
get_fileareas
()
{
return
array
();
// No associated fileareas.
}
public
function
get_configdata_encoded_attributes
()
{
return
array
();
// No special handling of configdata.
}
/**
* This function, executed after all the tasks in the plan
* have been executed, will remove tag collection reference in case block was restored into another site.
* Also get mapping of contextid.
*/
public
function
after_restore
()
{
global
$DB
;
// Get the blockid.
$blockid
=
$this
->
get_blockid
();
// Extract block configdata and remove tag collection reference if this is another site. Also map contextid.
if
(
$configdata
=
$DB
->
get_field
(
'block_instances'
,
'configdata'
,
array
(
'id'
=>
$blockid
)))
{
$config
=
unserialize
(
base64_decode
(
$configdata
));
$changed
=
false
;
if
(
!
empty
(
$config
->
tagcoll
)
&&
$config
->
tagcoll
>
1
&&
!
$this
->
is_samesite
())
{
$config
->
tagcoll
=
0
;
$changed
=
true
;
}
if
(
!
empty
(
$config
->
ctx
))
{
if
(
$ctxmap
=
restore_dbops
::
get_backup_ids_record
(
$this
->
get_restoreid
(),
'context'
,
$config
->
ctx
))
{
$config
->
ctx
=
$ctxmap
->
newitemid
;
}
else
{
$config
->
ctx
=
0
;
}
$changed
=
true
;
}
if
(
$changed
)
{
$configdata
=
base64_encode
(
serialize
(
$config
));
$DB
->
set_field
(
'block_instances'
,
'configdata'
,
$configdata
,
array
(
'id'
=>
$blockid
));
}
}
}
static
public
function
define_decode_contents
()
{
return
array
();
}
static
public
function
define_decode_rules
()
{
return
array
();
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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