mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-17444: Backup hooks for local plugin
This commit is contained in:
parent
6109f2112c
commit
a66e8bb3aa
30
backup/moodle2/backup_local_plugin.class.php
Normal file
30
backup/moodle2/backup_local_plugin.class.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?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 core
|
||||
* @subpackage backup-moodle2
|
||||
* @copyright 2011 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Base class for local plugins
|
||||
*/
|
||||
abstract class backup_local_plugin extends backup_plugin {}
|
@ -39,6 +39,7 @@ require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_gradingform_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_local_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_report_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
|
||||
|
@ -341,6 +341,9 @@ class backup_module_structure_step extends backup_structure_step {
|
||||
// many plagiarism plugins storing information about this course
|
||||
$this->add_plugin_structure('plagiarism', $module, true);
|
||||
|
||||
// attach local plugin structure to $module, multiple allowed
|
||||
$this->add_plugin_structure('local', $module, true);
|
||||
|
||||
// Define the tree
|
||||
$module->add_child($availinfo);
|
||||
$availinfo->add_child($availability);
|
||||
@ -386,6 +389,9 @@ class backup_section_structure_step extends backup_structure_step {
|
||||
// attach format plugin structure to $section element, only one allowed
|
||||
$this->add_plugin_structure('format', $section, false);
|
||||
|
||||
// attach local plugin structure to $section element, multiple allowed
|
||||
$this->add_plugin_structure('local', $section, true);
|
||||
|
||||
// Add nested elements for _availability table
|
||||
$avail = new backup_nested_element('availability', array('id'), array(
|
||||
'sourcecmid', 'requiredcompletion', 'gradeitemid', 'grademin', 'grademax'));
|
||||
@ -464,6 +470,10 @@ class backup_course_structure_step extends backup_structure_step {
|
||||
// many plagiarism plugins storing information about this course
|
||||
$this->add_plugin_structure('plagiarism', $course, true);
|
||||
|
||||
// attach local plugin structure to $course element; multiple local plugins
|
||||
// can save course data if required
|
||||
$this->add_plugin_structure('local', $course, true);
|
||||
|
||||
// Build the tree
|
||||
|
||||
$course->add_child($category);
|
||||
@ -1785,6 +1795,9 @@ class backup_questions_structure_step extends backup_structure_step {
|
||||
// attach qtype plugin structure to $question element, only one allowed
|
||||
$this->add_plugin_structure('qtype', $question, false);
|
||||
|
||||
// attach local plugin stucture to $question element, multiple allowed
|
||||
$this->add_plugin_structure('local', $question, true);
|
||||
|
||||
$qhints = new backup_nested_element('question_hints');
|
||||
|
||||
$qhint = new backup_nested_element('question_hint', array('id'), array(
|
||||
@ -1904,12 +1917,18 @@ class backup_activity_grading_structure_step extends backup_structure_step {
|
||||
// Build the tree including the method specific structures
|
||||
// (beware - the order of how gradingform plugins structures are attached is important)
|
||||
$areas->add_child($area);
|
||||
// attach local plugin stucture to $area element, multiple allowed
|
||||
$this->add_plugin_structure('local', $area, true);
|
||||
$area->add_child($definitions);
|
||||
$definitions->add_child($definition);
|
||||
$this->add_plugin_structure('gradingform', $definition, true);
|
||||
// attach local plugin stucture to $definition element, multiple allowed
|
||||
$this->add_plugin_structure('local', $definition, true);
|
||||
$definition->add_child($instances);
|
||||
$instances->add_child($instance);
|
||||
$this->add_plugin_structure('gradingform', $instance, false);
|
||||
// attach local plugin stucture to $instance element, multiple allowed
|
||||
$this->add_plugin_structure('local', $instance, true);
|
||||
|
||||
// Define data sources
|
||||
|
||||
|
30
backup/moodle2/restore_local_plugin.class.php
Normal file
30
backup/moodle2/restore_local_plugin.class.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?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 moodlecore
|
||||
* @subpackage backup-moodle2
|
||||
* @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class extending standard restore_plugin in order to implement some
|
||||
* helper methods related with local plugins
|
||||
*
|
||||
*/
|
||||
abstract class restore_local_plugin extends restore_plugin {}
|
@ -44,7 +44,7 @@ abstract class restore_plagiarism_plugin extends restore_plugin {
|
||||
require_once($CFG->libdir . '/plagiarismlib.php');
|
||||
$enabledplugins = plagiarism_load_available_plugins();
|
||||
if (!array_key_exists($this->pluginname, $enabledplugins)) {
|
||||
return;
|
||||
return array();
|
||||
}
|
||||
return parent::define_plugin_structure($connectionpoint);
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ require_once($CFG->dirroot . '/backup/moodle2/restore_default_block_task.class.p
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_qtype_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_format_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_local_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_theme_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_report_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_coursereport_plugin.class.php');
|
||||
@ -45,6 +46,7 @@ require_once($CFG->dirroot . '/backup/moodle2/restore_gradingform_plugin.class.p
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_local_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_report_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
|
||||
|
@ -1104,6 +1104,9 @@ class restore_section_structure_step extends restore_structure_step {
|
||||
// Apply for 'format' plugins optional paths at section level
|
||||
$this->add_plugin_structure('format', $section);
|
||||
|
||||
// Apply for 'local' plugins optional paths at section level
|
||||
$this->add_plugin_structure('local', $section);
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
@ -1317,6 +1320,9 @@ class restore_course_structure_step extends restore_structure_step {
|
||||
// Apply for plagiarism plugins optional paths at course level
|
||||
$this->add_plugin_structure('plagiarism', $course);
|
||||
|
||||
// Apply for local plugins optional paths at course level
|
||||
$this->add_plugin_structure('local', $course);
|
||||
|
||||
return array($course, $category, $tag, $allowed_module);
|
||||
}
|
||||
|
||||
@ -2305,17 +2311,25 @@ class restore_activity_grading_structure_step extends restore_structure_step {
|
||||
$paths = array();
|
||||
$userinfo = $this->get_setting_value('userinfo');
|
||||
|
||||
$paths[] = new restore_path_element('grading_area', '/areas/area');
|
||||
$area = new restore_path_element('grading_area', '/areas/area');
|
||||
$paths[] = $area;
|
||||
// attach local plugin stucture to $area element
|
||||
$this->add_plugin_structure('local', $area);
|
||||
|
||||
$definition = new restore_path_element('grading_definition', '/areas/area/definitions/definition');
|
||||
$paths[] = $definition;
|
||||
$this->add_plugin_structure('gradingform', $definition);
|
||||
// attach local plugin stucture to $definition element
|
||||
$this->add_plugin_structure('local', $definition);
|
||||
|
||||
|
||||
if ($userinfo) {
|
||||
$instance = new restore_path_element('grading_instance',
|
||||
'/areas/area/definitions/definition/instances/instance');
|
||||
$paths[] = $instance;
|
||||
$this->add_plugin_structure('gradingform', $instance);
|
||||
// attach local plugin stucture to $intance element
|
||||
$this->add_plugin_structure('local', $instance);
|
||||
}
|
||||
|
||||
return $paths;
|
||||
@ -2678,6 +2692,9 @@ class restore_module_structure_step extends restore_structure_step {
|
||||
// Apply for 'plagiarism' plugins optional paths at module level
|
||||
$this->add_plugin_structure('plagiarism', $module);
|
||||
|
||||
// Apply for 'local' plugins optional paths at module level
|
||||
$this->add_plugin_structure('local', $module);
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
@ -2974,6 +2991,9 @@ class restore_create_categories_and_questions extends restore_structure_step {
|
||||
// Apply for 'qtype' plugins optional paths at question level
|
||||
$this->add_plugin_structure('qtype', $question);
|
||||
|
||||
// Apply for 'local' plugins optional paths at question level
|
||||
$this->add_plugin_structure('local', $question);
|
||||
|
||||
return array($category, $question, $hint);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user