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
 * Describe how H5P activites are to be restored from backup
19
 *
20
 * @package     mod_hvp
21
 * @category    backup
22
 * @copyright   2016 Joubel AS <contact@joubel.com>
23
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
require_once($CFG->dirroot . '/mod/hvp/backup/moodle2/restore_hvp_stepslib.php'); // Because it exists (must).
29
 
30
/**
31
 * Hvp restore task that provides all the settings and steps to perform one complete restore of the activity.
32
 *
33
 * @copyright   2018 Joubel AS <contact@joubel.com>
34
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
36
class restore_hvp_activity_task extends restore_activity_task {
37
 
38
    /**
39
     * Define (add) particular settings this activity can have
40
     */
41
    protected function define_my_settings() {
42
        // No particular settings for this activity.
43
    }
44
 
45
    /**
46
     * Define (add) particular steps this activity can have
47
     */
48
    protected function define_my_steps() {
49
        // Add H5P libraries.
50
        $this->add_step(new restore_hvp_libraries_structure_step('hvp_structure', 'hvp_libraries.xml'));
51
 
52
        // Add H5P content.
53
        $this->add_step(new restore_hvp_activity_structure_step('hvp_structure', 'hvp.xml'));
54
    }
55
 
56
    /**
57
     * Define the contents in the activity that must be
58
     * processed by the link decoder
59
     */
60
    static public function define_decode_contents() {
61
        $contents = array();
62
 
63
        $contents[] = new restore_decode_content('hvp', array('intro'), 'hvp');
64
 
65
        return $contents;
66
    }
67
 
68
    /**
69
     * Define the decoding rules for links belonging
70
     * to the activity to be executed by the link decoder
71
     */
72
    static public function define_decode_rules() {
73
        $rules = array();
74
 
75
        $rules[] = new restore_decode_rule('HVPVIEWBYID', '/mod/hvp/view.php?id=$1', 'course_module');
76
        $rules[] = new restore_decode_rule('HVPINDEX', '/mod/hvp/index.php?id=$1', 'course');
77
        $rules[] = new restore_decode_rule('HVPEMBEDBYID', '/mod/hvp/embed.php?id=$1', 'course_module');
78
 
79
        return $rules;
80
    }
81
 
82
    /**
83
     * Define the restore log rules that will be applied
84
     * by the {@link restore_logs_processor} when restoring
85
     * hvp logs. It must return one array
86
     * of {@link restore_log_rule} objects
87
     */
88
    static public function define_restore_log_rules() {
89
        $rules = array();
90
 
91
        $rules[] = new restore_log_rule('hvp', 'add', 'view.php?id={course_module}', '{hvp}');
92
        $rules[] = new restore_log_rule('hvp', 'update', 'view.php?id={course_module}', '{hvp}');
93
        $rules[] = new restore_log_rule('hvp', 'view', 'view.php?id={course_module}', '{hvp}');
94
 
95
        return $rules;
96
    }
97
 
98
    /**
99
     * Define the restore log rules that will be applied
100
     * by the {@link restore_logs_processor} when restoring
101
     * course logs. It must return one array
102
     * of {@link restore_log_rule} objects
103
     *
104
     * Note this rules are applied when restoring course logs
105
     * by the restore final task, but are defined here at
106
     * activity level. All them are rules not linked to any module instance (cmid = 0)
107
     */
108
    static public function define_restore_log_rules_for_course() {
109
        $rules = array();
110
 
111
        $rules[] = new restore_log_rule('hvp', 'view all', 'index.php?id={course}', null);
112
 
113
        return $rules;
114
    }
115
}