Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
// This file is part of Moodle - http://moodle.org/
4
//
5
// Moodle is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// Moodle is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17
 
18
/**
19
 * @package mod_glossary
20
 * @subpackage backup-moodle2
21
 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
require_once($CFG->dirroot . '/mod/glossary/backup/moodle2/restore_glossary_stepslib.php'); // Because it exists (must)
28
 
29
/**
30
 * glossary restore task that provides all the settings and steps to perform one
31
 * complete restore of the activity
32
 */
33
class restore_glossary_activity_task extends restore_activity_task {
34
 
35
    /**
36
     * Define (add) particular settings this activity can have
37
     */
38
    protected function define_my_settings() {
39
        // No particular settings for this activity
40
    }
41
 
42
    /**
43
     * Define (add) particular steps this activity can have
44
     */
45
    protected function define_my_steps() {
46
        // Choice only has one structure step
47
        $this->add_step(new restore_glossary_activity_structure_step('glossary_structure', 'glossary.xml'));
48
    }
49
 
50
    /**
51
     * Define the contents in the activity that must be
52
     * processed by the link decoder
53
     */
54
    public static function define_decode_contents() {
55
        $contents = array();
56
 
57
        $contents[] = new restore_decode_content('glossary', array('intro'), 'glossary');
58
        $contents[] = new restore_decode_content('glossary_entries', array('definition'), 'glossary_entry');
59
 
60
        return $contents;
61
    }
62
 
63
    /**
64
     * Define the decoding rules for links belonging
65
     * to the activity to be executed by the link decoder
66
     */
67
    public static function define_decode_rules() {
68
        $rules = array();
69
 
70
        $rules[] = new restore_decode_rule('GLOSSARYVIEWBYID', '/mod/glossary/view.php?id=$1', 'course_module');
71
        $rules[] = new restore_decode_rule('GLOSSARYINDEX', '/mod/glossary/index.php?id=$1', 'course');
72
        $rules[] = new restore_decode_rule('GLOSSARYSHOWENTRY', '/mod/glossary/showentry.php?courseid=$1&eid=$2',
73
                                           array('course', 'glossary_entry'));
74
 
75
        return $rules;
76
 
77
    }
78
 
79
    /**
80
     * Define the restore log rules that will be applied
81
     * by the {@link restore_logs_processor} when restoring
82
     * glossary logs. It must return one array
83
     * of {@link restore_log_rule} objects
84
     */
85
    public static function define_restore_log_rules() {
86
        $rules = array();
87
 
88
        $rules[] = new restore_log_rule('glossary', 'add', 'view.php?id={course_module}', '{glossary}');
89
        $rules[] = new restore_log_rule('glossary', 'update', 'view.php?id={course_module}', '{glossary}');
90
        $rules[] = new restore_log_rule('glossary', 'view', 'view.php?id={course_module}', '{glossary}');
91
        $rules[] = new restore_log_rule('glossary', 'add category', 'editcategories.php?id={course_module}', '{glossary_category}');
92
        $rules[] = new restore_log_rule('glossary', 'edit category', 'editcategories.php?id={course_module}', '{glossary_category}');
93
        $rules[] = new restore_log_rule('glossary', 'delete category', 'editcategories.php?id={course_module}', '{glossary_category}');
94
        $rules[] = new restore_log_rule('glossary', 'add entry', 'view.php?id={course_module}&mode=entry&hook={glossary_entry}', '{glossary_entry}');
95
        $rules[] = new restore_log_rule('glossary', 'update entry', 'view.php?id={course_module}&mode=entry&hook={glossary_entry}', '{glossary_entry}');
96
        $rules[] = new restore_log_rule('glossary', 'delete entry', 'view.php?id={course_module}&mode=entry&hook={glossary_entry}', '{glossary_entry}');
97
        $rules[] = new restore_log_rule('glossary', 'approve entry', 'showentry.php?id={course_module}&eid={glossary_entry}', '{glossary_entry}');
98
        $rules[] = new restore_log_rule('glossary', 'disapprove entry', 'showentry.php?id={course_module}&eid={glossary_entry}', '{glossary_entry}');
99
        $rules[] = new restore_log_rule('glossary', 'view entry', 'showentry.php?eid={glossary_entry}', '{glossary_entry}');
100
 
101
        return $rules;
102
    }
103
 
104
    /**
105
     * Define the restore log rules that will be applied
106
     * by the {@link restore_logs_processor} when restoring
107
     * course logs. It must return one array
108
     * of {@link restore_log_rule} objects
109
     *
110
     * Note this rules are applied when restoring course logs
111
     * by the restore final task, but are defined here at
112
     * activity level. All them are rules not linked to any module instance (cmid = 0)
113
     */
114
    public static function define_restore_log_rules_for_course() {
115
        $rules = array();
116
 
117
        $rules[] = new restore_log_rule('glossary', 'view all', 'index.php?id={course}', null);
118
 
119
        return $rules;
120
    }
121
}