MDL-22245 backup - keep subplugin branches connected all the time. Thanks for spotting it David!
This commit is contained in:
@@ -106,6 +106,7 @@ abstract class backup_activity_structure_step extends backup_structure_step {
|
||||
// Arrived here, subplugin is correct, let's create the optigroup
|
||||
$optigroupname = $subplugintype . '_' . $element->get_name() . '_subplugin';
|
||||
$optigroup = new backup_optigroup($optigroupname, null, $multiple);
|
||||
$element->add_child($optigroup); // Add optigroup to stay connected since beginning
|
||||
|
||||
// Get all the optigroup_elements, looking across al the subplugin dirs
|
||||
$elements = array();
|
||||
@@ -115,15 +116,11 @@ abstract class backup_activity_structure_step extends backup_structure_step {
|
||||
$backupfile = $subpluginsdir . '/backup/moodle2/' . $classname . '.class.php';
|
||||
if (file_exists($backupfile)) {
|
||||
require_once($backupfile);
|
||||
$backupsubplugin = new $classname($subplugintype, $name);
|
||||
// Add subplugin returned structure to optigroup (must be optigroup_element instance)
|
||||
if ($subpluginstructure = $backupsubplugin->define_subplugin_structure($element->get_name())) {
|
||||
$optigroup->add_child($subpluginstructure);
|
||||
}
|
||||
$backupsubplugin = new $classname($subplugintype, $name, $optigroup);
|
||||
// Add subplugin returned structure to optigroup
|
||||
$backupsubplugin->define_subplugin_structure($element->get_name());
|
||||
}
|
||||
}
|
||||
// Finished, add optigroup to element
|
||||
$element->add_child($optigroup);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,10 +32,12 @@ abstract class backup_subplugin {
|
||||
protected $subplugintype;
|
||||
protected $subpluginname;
|
||||
protected $connectionpoint;
|
||||
protected $optigroup; // Optigroup, parent of all optigroup elements
|
||||
|
||||
public function __construct($subplugintype, $subpluginname) {
|
||||
public function __construct($subplugintype, $subpluginname, $optigroup) {
|
||||
$this->subplugintype = $subplugintype;
|
||||
$this->subpluginname = $subpluginname;
|
||||
$this->optigroup = $optigroup;
|
||||
$this->connectionpoint = '';
|
||||
}
|
||||
|
||||
@@ -46,10 +48,8 @@ abstract class backup_subplugin {
|
||||
$methodname = 'define_' . $connectionpoint . '_subplugin_structure';
|
||||
|
||||
if (method_exists($this, $methodname)) {
|
||||
return $this->$methodname();
|
||||
$this->$methodname();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,9 @@ abstract class backup_subplugin {
|
||||
// Something exclusive for this backup_subplugin_element (backup_optigroup_element)
|
||||
// because it hasn't XML representation
|
||||
$name = 'optigroup_' . $this->subplugintype . '_' . $this->subpluginname . '_' . $this->connectionpoint;
|
||||
return new backup_subplugin_element($name, $final_elements, $conditionparam, $conditionvalue);
|
||||
$optigroup_element = new backup_subplugin_element($name, $final_elements, $conditionparam, $conditionvalue);
|
||||
$this->optigroup->add_child($optigroup_element); // Add optigroup_element to stay connected since beginning
|
||||
return $optigroup_element;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ class backup_assignment_offline_subplugin extends backup_subplugin {
|
||||
$subplugin->add_child($assassoff);
|
||||
$assassoff->add_child($config);
|
||||
|
||||
$config->set_source_table('config', array());
|
||||
$config->set_source_table('config', array('id' => '/assignment/id'));
|
||||
|
||||
return $subplugin; // And we return the root subplugin element
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class backup_assignment_offline_subplugin extends backup_subplugin {
|
||||
$subplugin->add_child($asssuboff);
|
||||
$asssuboff->add_child($config);
|
||||
|
||||
$config->set_source_table('config', array());
|
||||
$config->set_source_table('config', array('id' => backup::VAR_PARENTID));
|
||||
|
||||
return $subplugin; // And we return the root subplugin element
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user