Permalink
Browse files

MDL-21432 backup - add plagiarism plugin hooks for course and module

  • Loading branch information...
1 parent f786f01 commit 571ae25286d6fe332f656f5fefa1b58c5c45a3d2 @danmarsden danmarsden committed with stronk7 Mar 14, 2011
@@ -0,0 +1,44 @@
+<?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 backup_plugin in order to implement some
+ * helper methods related with the plagiarism plugins (plagiarism plugin)
+ *
+ * TODO: Finish phpdocs
+ */
+abstract class backup_plagiarism_plugin extends backup_plugin {
+
+ public function define_plugin_structure($connectionpoint) {
+ global $CFG;
+ require_once($CFG->libdir . '/plagiarismlib.php');
+ //check if enabled at site level and plugin is enabled.
+ $enabledplugins = plagiarism_load_available_plugins();
+ if (!array_key_exists($this->pluginname, $enabledplugins)) {
+ return;
+ }
+
+ parent::define_plugin_structure($connectionpoint);
+ }
+}
@@ -36,6 +36,7 @@
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_theme_plugin.class.php');
+require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_subplugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_settingslib.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_stepslib.php');
@@ -321,6 +321,9 @@ protected function define_structure() {
// attach format plugin structure to $module element, only one allowed
$this->add_plugin_structure('format', $module, false);
+ // attach plagiarism plugin structure to $module element, only one allowed
+ $this->add_plugin_structure('plagiarism', $module, false);
+
// Define the tree
$module->add_child($availinfo);
$availinfo->add_child($availability);
@@ -416,6 +419,9 @@ protected function define_structure() {
// save course data (in case of user theme, legacy theme, etc)
$this->add_plugin_structure('theme', $course, true);
+ // attach plagiarism plugin structure to $course element, only one allowed
+ $this->add_plugin_structure('plagiarism', $course, false);
+
// Build the tree
$course->add_child($category);
@@ -0,0 +1,46 @@
+<?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 the plagiarism plugins
+ *
+ * TODO: Finish phpdocs
+ */
+abstract class restore_plagiarism_plugin extends restore_plugin {
+ public function define_plugin_structure($connectionpoint) {
+ global $CFG;
+ if (!$connectionpoint instanceof restore_path_element) {
+ throw new restore_step_exception('restore_path_element_required', $connectionpoint);
+ }
+
+ //check if enabled at site level and plugin is enabled.
+ require_once($CFG->libdir . '/plagiarismlib.php');
+ $enabledplugins = plagiarism_load_available_plugins();
+ if (!array_key_exists($this->pluginname, $enabledplugins)) {
+ return;
+ }
+ parent::define_plugin_structure($connectionpoint);
+ }
+}
@@ -35,10 +35,12 @@
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_theme_plugin.class.php');
+require_once($CFG->dirroot . '/backup/moodle2/restore_plagiarism_plugin.class.php');
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_theme_plugin.class.php');
+require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_subplugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_settingslib.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_stepslib.php');
@@ -1010,6 +1010,9 @@ protected function define_structure() {
// Apply for 'theme' plugins optional paths at course level
$this->add_plugin_structure('theme', $course);
+ // Apply for plagiarism plugins optional paths at course level
+ $this->add_plugin_structure('plagiarism', $course);
+
return array($course, $category, $tag, $allowed_module);
}
@@ -2007,6 +2010,9 @@ protected function define_structure() {
// Apply for 'format' plugins optional paths at module level
$this->add_plugin_structure('format', $module);
+ // Apply for 'plagiarism' plugins optional paths at module level
+ $this->add_plugin_structure('plagiarism', $module);
+
return $paths;
}

0 comments on commit 571ae25

Please sign in to comment.