MDL-44151 Amend subplugin packages.
[moodle.git] / mod / assignment / type / offline / backup / moodle2 / restore_assignment_offline_subplugin.class.php
CommitLineData
51ea278b
EL
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
993414fd 19 * @package assignment_offline
51ea278b
EL
20 * @subpackage backup-moodle2
21 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25/**
26 * restore subplugin class that provides the necessary information
27 * needed to restore one assignment->offline subplugin.
28 *
29 * Note: Offline assignments really haven't any special subplugin
30 * information to backup/restore, hence code below is skipped (return false)
91421f3e 31 * but it's a good example of subplugins supported at different
51ea278b
EL
32 * elements (assignment and submission)
33 */
34class restore_assignment_offline_subplugin extends restore_subplugin {
35
36 /**
37 * Returns the paths to be handled by the subplugin at assignment level
38 */
39 protected function define_assignment_subplugin_structure() {
40
41 return false; // This subplugin restore is only one example. Skip it.
42
43 $paths = array();
44
45 $elename = $this->get_namefor('config');
46 $elepath = $this->get_pathfor('/config'); // because we used get_recommended_name() in backup this works
47 $paths[] = new restore_path_element($elename, $elepath);
48
49 return $paths; // And we return the interesting paths
50 }
51
52 /**
53 * Returns the paths to be handled by the subplugin at submission level
54 */
55 protected function define_submission_subplugin_structure() {
56
57 return false; // This subplugin restore is only one example. Skip it.
58
59 $paths = array();
60
61 $elename = $this->get_namefor('submission_config');
62 $elepath = $this->get_pathfor('/submission_config'); // because we used get_recommended_name() in backup this works
63 $paths[] = new restore_path_element($elename, $elepath);
64
65 return $paths; // And we return the interesting paths
66 }
67
68 /**
91421f3e 69 * This method processes the config element inside one offline assignment (see offline subplugin backup)
51ea278b
EL
70 */
71 public function process_assignment_offline_config($data) {
72 $data = (object)$data;
73 print_object($data); // Nothing to do, just print the data
74
75 // Just to check that the whole API is available here
76 $this->set_mapping('assignment_offline_config', 1, 1, true);
77 $this->add_related_files('mod_assignment', 'intro', 'assignment_offline_config');
78 print_object($this->get_mappingid('assignment_offline_config', 1));
79 print_object($this->get_old_parentid('assignment'));
80 print_object($this->get_new_parentid('assignment'));
81 print_object($this->get_mapping('assignment', $this->get_old_parentid('assignment')));
82 print_object($this->apply_date_offset(1));
83 print_object($this->task->get_courseid());
84 print_object($this->task->get_contextid());
85 print_object($this->get_restoreid());
86 }
87
88 /**
91421f3e 89 * This method processes the submission_config element inside one offline assignment (see offline subplugin backup)
51ea278b
EL
90 */
91 public function process_assignment_offline_submission_config($data) {
92 $data = (object)$data;
93 print_object($data); // Nothing to do, just print the data
94 }
95}