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
 * Provides {@see restore_subcourse_activity_task} class.
19
 *
20
 * @package     mod_subcourse
21
 * @category    backup
22
 * @copyright   2013 David Mudrak <david@moodle.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/subcourse/backup/moodle2/restore_subcourse_stepslib.php');
29
 
30
/**
31
 * Defines all settings and step to perform the activity restore.
32
 *
33
 * @copyright 2013 David Mudrak <david@moodle.com>
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
36
class restore_subcourse_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
        // Choice only has one structure step.
50
        $this->add_step(new restore_subcourse_activity_structure_step('subcourse_structure', 'subcourse.xml'));
51
    }
52
 
53
    /**
54
     * Define the contents in the activity that must be
55
     * processed by the link decoder
56
     */
57
    public static function define_decode_contents() {
58
        $contents = [];
59
 
60
        $contents[] = new restore_decode_content('subcourse', ['intro'], 'subcourse');
61
 
62
        return $contents;
63
    }
64
 
65
    /**
66
     * Define the decoding rules for links belonging
67
     * to the activity to be executed by the link decoder
68
     */
69
    public static function define_decode_rules() {
70
        $rules = [];
71
 
72
        $rules[] = new restore_decode_rule('SUBCOURSEVIEWBYID', '/mod/subcourse/view.php?id=$1', 'course_module');
73
        $rules[] = new restore_decode_rule('SUBCOURSEINDEX', '/mod/subcourse/index.php?id=$1', 'course');
74
 
75
        return $rules;
76
 
77
    }
78
 
79
    /**
80
     * Define the restore log rules that will be applied
81
     * by the {@see restore_logs_processor} when restoring
82
     * subcourse logs. It must return one array
83
     * of {@see restore_log_rule} objects
84
     */
85
    public static function define_restore_log_rules() {
86
        $rules = [];
87
 
88
        $rules[] = new restore_log_rule('subcourse', 'add', 'view.php?id={course_module}', '{subcourse}');
89
        $rules[] = new restore_log_rule('subcourse', 'update', 'view.php?id={course_module}', '{subcourse}');
90
        $rules[] = new restore_log_rule('subcourse', 'view', 'view.php?id={course_module}', '{subcourse}');
91
        $rules[] = new restore_log_rule('subcourse', 'fetch', 'view.php?id={course_module}', '{subcourse}');
92
 
93
        return $rules;
94
    }
95
 
96
    /**
97
     * Define the restore log rules that will be applied
98
     * by the {@see restore_logs_processor} when restoring
99
     * course logs. It must return one array
100
     * of {@see restore_log_rule} objects
101
     *
102
     * Note this rules are applied when restoring course logs
103
     * by the restore final task, but are defined here at
104
     * activity level. All them are rules not linked to any module instance (cmid = 0)
105
     */
106
    public static function define_restore_log_rules_for_course() {
107
        $rules = [];
108
 
109
        // Fix old wrong uses (missing extension).
110
        $rules[] = new restore_log_rule('subcourse', 'view all', 'index?id={course}', null,
111
                                        null, null, 'index.php?id={course}');
112
        $rules[] = new restore_log_rule('subcourse', 'view all', 'index.php?id={course}', null);
113
 
114
        return $rules;
115
    }
116
}