restore_bigbluebuttonbn_activity_structure_step   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A define_structure() 0 7 1
A process_bigbluebuttonbn() 0 10 1
A process_bigbluebuttonbn_logs() 0 13 1
A after_execute() 0 4 1
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
 * Class for the structure used for restore BigBlueButtonBN.
19
 *
20
 * @package   mod_bigbluebuttonbn
21
 * @copyright 2010 onwards, Blindside Networks Inc
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 * @author    Fred Dixon  (ffdixon [at] blindsidenetworks [dt] com)
24
 * @author    Jesus Federico  (jesus [at] blindsidenetworks [dt] com)
25
 */
26
27
defined('MOODLE_INTERNAL') || die();
28
29
/**
30
 * Define all the restore steps that will be used by the restore_url_activity_task.
31
 *
32
 * @package   mod_bigbluebuttonbn
33
 * @copyright 2010 onwards, Blindside Networks Inc
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
36
class restore_bigbluebuttonbn_activity_structure_step extends restore_activity_structure_step
37
{
38
    /**
39
     * Structure step to restore one bigbluebuttonbn activity.
40
     *
41
     * @return array
42
     */
43
    protected function define_structure() {
44
        $paths = array();
45
        $paths[] = new restore_path_element('bigbluebuttonbn', '/activity/bigbluebuttonbn');
46
        $paths[] = new restore_path_element('bigbluebuttonbn_logs', '/activity/bigbluebuttonbn/logs/log');
47
        // Return the paths wrapped into standard activity structure.
48
        return $this->prepare_activity_structure($paths);
49
    }
50
51
    /**
52
     * Process a bigbluebuttonbn restore.
53
     *
54
     * @param object $data The data in object form
55
     * @return void
56
     */
57
    protected function process_bigbluebuttonbn($data) {
58
        global $DB;
59
        $data = (object) $data;
60
        $data->course = $this->get_courseid();
61
        $data->timemodified = $this->apply_date_offset($data->timemodified);
62
        // Insert the bigbluebuttonbn record.
63
        $newitemid = $DB->insert_record('bigbluebuttonbn', $data);
64
        // Immediately after inserting "activity" record, call this.
65
        $this->apply_activity_instance($newitemid);
66
    }
67
68
    /**
69
     * Process a bigbluebuttonbn_logs restore (additional table).
70
     *
71
     * @param object $data The data in object form
72
     * @return void
73
     */
74
    protected function process_bigbluebuttonbn_logs($data) {
75
        global $DB;
76
        $data = (object) $data;
77
        // Apply modifications.
78
        $data->courseid = $this->get_mappingid('course', $data->courseid);
79
        $data->bigbluebuttonbnid = $this->get_new_parentid('bigbluebuttonbn');
80
        $data->userid = $this->get_mappingid('user', $data->userid);
81
        $data->timecreated = $this->apply_date_offset($data->timecreated);
82
        // Insert the bigbluebuttonbn_logs record.
83
        $newitemid = $DB->insert_record('bigbluebuttonbn_logs', $data);
84
        // Immediately after inserting associated record, call this.
85
        $this->set_mapping('bigbluebuttonbn_logs', $data->id, $newitemid);
86
    }
87
88
    /**
89
     * Actions to be executed after the restore is completed
90
     *
91
     * @return array
92
     */
93
    protected function after_execute() {
94
        // Add bigbluebuttonbn related files, no need to match by itemname (just internally handled context).
95
        $this->add_related_files('mod_bigbluebuttonbn', 'intro', null);
96
    }
97
}
98