Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://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 <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Define all the restore steps that will be used by the restore_reengagement_activity_task
19
 *
20
 * @package    mod_reengagement
21
 * @author     Peter Bulmer <peter.bulmer@catlayst.net.nz>
22
 * @copyright  2016 Catalyst IT {@link http://www.catalyst.net.nz}
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
/**
27
 * Structure step to restore one reengagement activity
28
 *
29
 * @package    mod_reengagement
30
 * @author     Peter Bulmer <peter.bulmer@catlayst.net.nz>
31
 * @copyright  2016 Catalyst IT {@link http://www.catalyst.net.nz}
32
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 */
34
class restore_reengagement_activity_structure_step extends restore_activity_structure_step {
35
    /**
36
     * Define the structure for the reengagement activity
37
     * @return void
38
     */
39
    protected function define_structure() {
40
 
41
        $paths = array();
42
        $userinfo = $this->get_setting_value('userinfo');
43
 
44
        $paths[] = new restore_path_element('reengagement', '/activity/reengagement');
45
        if ($userinfo) {
46
            $paths[] = new restore_path_element('reengagement_inprogress', '/activity/reengagement/inprogresses/inprogress');
47
        }
48
 
49
        // Return the paths wrapped into standard activity structure.
50
        return $this->prepare_activity_structure($paths);
51
    }
52
 
53
    /**
54
     * Process a reengagement restore.
55
     *
56
     * @param object $data The data in object form
57
     * @return void
58
     */
59
    protected function process_reengagement($data) {
60
        global $DB;
61
 
62
        $data = (object)$data;
63
        $data->course = $this->get_courseid();
64
 
65
        $data->timecreated = $this->apply_date_offset($data->timecreated);
66
        $data->timemodified = $this->apply_date_offset($data->timemodified);
67
        // Insert the reengagement record.
68
        $newitemid = $DB->insert_record('reengagement', $data);
69
        // Immediately after inserting "activity" record, call this.
70
        $this->apply_activity_instance($newitemid);
71
    }
72
 
73
    /**
74
     * Process reengagement inprogress records.
75
     *
76
     * @param object $data The data in object form
77
     * @return void
78
     */
79
    protected function process_reengagement_inprogress($data) {
80
        global $DB;
81
 
82
        $data = (object)$data;
83
 
84
        $data->reengagement = $this->get_new_parentid('reengagement');
85
        $data->userid = $this->get_mappingid('user', $data->userid);
86
 
87
        $DB->insert_record('reengagement_inprogress', $data);
88
        // No need to save this mapping as far as nothing depend on it
89
        // (child paths, file areas nor links decoder).
90
    }
91
 
92
    /**
93
     * Once the database tables have been fully restored, restore any files
94
     * @return void
95
     */
96
    protected function after_execute() {
97
        // Add reengagement related files, no need to match by itemname (just internally handled context).
98
    }
99
}