Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
// This file is part of Moodle - https://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <https://www.gnu.org/licenses/>.
16
 
17
/**
18
 * All the steps to restore mod_subsection are defined here.
19
 *
20
 * @package     mod_subsection
21
 * @category    backup
22
 * @copyright   2023 Amaia Anabitarte <amaia@moodle.com>
23
 * @license     https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
use mod_subsection\manager;
27
 
28
// More information about the restore process: {@link https://docs.moodle.org/dev/Restore_API}.
29
 
30
/**
31
 * Defines the structure step to restore one mod_subsection activity.
32
 */
33
class restore_subsection_activity_structure_step extends restore_activity_structure_step {
34
 
35
    /**
36
     * Defines the structure to be restored.
37
     *
38
     * @return restore_path_element[].
39
     */
40
    protected function define_structure() {
41
        $paths = [];
42
        $paths[] = new restore_path_element('subsection', '/activity/subsection');
43
 
44
        // Return the paths wrapped into standard activity structure.
45
        return $this->prepare_activity_structure($paths);
46
    }
47
 
48
    /**
49
     * Process the subsection element.
50
     *
51
     * @param \stdClass $data the data to be processed.
52
     */
53
    protected function process_subsection($data) {
54
        global $DB;
55
 
56
        $data = (object)$data;
57
        $oldid = $data->id;
58
        $data->course = $this->get_courseid();
59
 
60
        // Insert the subsection record.
61
        $newitemid = $DB->insert_record('subsection', $data);
62
        // Immediately after inserting "activity" record, call this.
63
        $this->apply_activity_instance($newitemid);
64
        $this->set_delegated_section_mapping(manager::PLUGINNAME, $oldid, $newitemid);
65
    }
66
 
67
    /**
68
     * Defines post-execution actions.
69
     */
70
    protected function after_execute() {
71
        return;
72
    }
73
}