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
 * Class for exporting partial database data.
19
 *
20
 * @package    mod_data
21
 * @copyright  2017 Juan Leyva <juan@moodle.com>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
namespace mod_data\external;
25
defined('MOODLE_INTERNAL') || die();
26
 
27
use core\external\exporter;
28
use renderer_base;
29
use core_external\external_files;
30
use core_external\util as external_util;
31
 
32
/**
33
 * Class for exporting partial database data (some fields are only viewable by admins).
34
 *
35
 * @copyright  2017 Juan Leyva <juan@moodle.com>
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 */
38
class database_summary_exporter extends exporter {
39
 
40
    protected static function define_properties() {
41
 
42
        return array(
43
            'id' => array(
44
                'type' => PARAM_INT,
45
                'description' => 'Database id'),
46
            'course' => array(
47
                'type' => PARAM_INT,
48
                'description' => 'Course id'),
49
            'name' => array(
50
                'type' => PARAM_RAW,
51
                'description' => 'Database name'),
52
            'intro' => array(
53
                'type' => PARAM_RAW,
54
                'description' => 'The Database intro',
55
            ),
56
            'introformat' => array(
57
                'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN),
58
                'type' => PARAM_INT,
59
                'default' => FORMAT_MOODLE
60
            ),
61
            'lang' => array(
62
                'type' => PARAM_LANG,
63
                'description' => 'Forced activity language',
64
                'null' => NULL_ALLOWED,
65
            ),
66
            'comments' => array(
67
                'type' => PARAM_BOOL,
68
                'description' => 'comments enabled',
69
            ),
70
            'timeavailablefrom' => array(
71
                'type' => PARAM_INT,
72
                'description' => 'timeavailablefrom field',
73
            ),
74
            'timeavailableto' => array(
75
                'type' => PARAM_INT,
76
                'description' => 'timeavailableto field',
77
            ),
78
            'timeviewfrom' => array(
79
                'type' => PARAM_INT,
80
                'description' => 'timeviewfrom field',
81
            ),
82
            'timeviewto' => array(
83
                'type' => PARAM_INT,
84
                'description' => 'timeviewto field',
85
            ),
86
            'requiredentries' => array(
87
                'type' => PARAM_INT,
88
                'description' => 'requiredentries field',
89
            ),
90
            'requiredentriestoview' => array(
91
                'type' => PARAM_INT,
92
                'description' => 'requiredentriestoview field',
93
            ),
94
            'maxentries' => array(
95
                'type' => PARAM_INT,
96
                'description' => 'maxentries field',
97
            ),
98
            'rssarticles' => array(
99
                'type' => PARAM_INT,
100
                'description' => 'rssarticles field',
101
            ),
102
            'singletemplate' => array(
103
                'type' => PARAM_RAW,
104
                'description' => 'singletemplate field',
105
                'null' => NULL_ALLOWED,
106
            ),
107
            'listtemplate' => array(
108
                'type' => PARAM_RAW,
109
                'description' => 'listtemplate field',
110
                'null' => NULL_ALLOWED,
111
            ),
112
            'listtemplateheader' => array(
113
                'type' => PARAM_RAW,
114
                'description' => 'listtemplateheader field',
115
                'null' => NULL_ALLOWED,
116
            ),
117
            'listtemplatefooter' => array(
118
                'type' => PARAM_RAW,
119
                'description' => 'listtemplatefooter field',
120
                'null' => NULL_ALLOWED,
121
            ),
122
            'addtemplate' => array(
123
                'type' => PARAM_RAW,
124
                'description' => 'addtemplate field',
125
                'null' => NULL_ALLOWED,
126
            ),
127
            'rsstemplate' => array(
128
                'type' => PARAM_RAW,
129
                'description' => 'rsstemplate field',
130
                'null' => NULL_ALLOWED,
131
            ),
132
            'rsstitletemplate' => array(
133
                'type' => PARAM_RAW,
134
                'description' => 'rsstitletemplate field',
135
                'null' => NULL_ALLOWED,
136
            ),
137
            'csstemplate' => array(
138
                'type' => PARAM_RAW,
139
                'description' => 'csstemplate field',
140
                'null' => NULL_ALLOWED,
141
            ),
142
            'jstemplate' => array(
143
                'type' => PARAM_RAW,
144
                'description' => 'jstemplate field',
145
                'null' => NULL_ALLOWED,
146
            ),
147
            'asearchtemplate' => array(
148
                'type' => PARAM_RAW,
149
                'description' => 'asearchtemplate field',
150
                'null' => NULL_ALLOWED,
151
            ),
152
            'approval' => array(
153
                'type' => PARAM_BOOL,
154
                'description' => 'approval field',
155
            ),
156
            'manageapproved' => array(
157
                'type' => PARAM_BOOL,
158
                'description' => 'manageapproved field',
159
            ),
160
            'scale' => array(
161
                'type' => PARAM_INT,
162
                'description' => 'scale field',
163
                'optional' => true,
164
            ),
165
            'assessed' => array(
166
                'type' => PARAM_INT,
167
                'description' => 'assessed field',
168
                'optional' => true,
169
            ),
170
            'assesstimestart' => array(
171
                'type' => PARAM_INT,
172
                'description' => 'assesstimestart field',
173
                'optional' => true,
174
            ),
175
            'assesstimefinish' => array(
176
                'type' => PARAM_INT,
177
                'description' => 'assesstimefinish field',
178
                'optional' => true,
179
            ),
180
            'defaultsort' => array(
181
                'type' => PARAM_INT,
182
                'description' => 'defaultsort field',
183
            ),
184
            'defaultsortdir' => array(
185
                'type' => PARAM_INT,
186
                'description' => 'defaultsortdir field',
187
            ),
188
            'editany' => array(
189
                'type' => PARAM_BOOL,
190
                'description' => 'editany field (not used any more)',
191
                'optional' => true,
192
            ),
193
            'notification' => array(
194
                'type' => PARAM_INT,
195
                'description' => 'notification field (not used any more)',
196
                'optional' => true,
197
            ),
198
            'timemodified' => array(
199
                'type' => PARAM_INT,
200
                'description' => 'Time modified',
201
                'optional' => true,
202
            ),
203
        );
204
    }
205
 
206
    protected static function define_related() {
207
        return array(
208
            'context' => 'context'
209
        );
210
    }
211
 
212
    protected static function define_other_properties() {
213
        return array(
214
            'coursemodule' => array(
215
                'type' => PARAM_INT
216
            ),
217
            'introfiles' => array(
218
                'type' => external_files::get_properties_for_exporter(),
219
                'multiple' => true,
220
                'optional' => true,
221
            ),
222
        );
223
    }
224
 
225
    protected function get_other_values(renderer_base $output) {
226
        $context = $this->related['context'];
227
 
228
        $values = array(
229
            'coursemodule' => $context->instanceid,
230
            'introfiles' => external_util::get_area_files($context->id, 'mod_data', 'intro', false, false),
231
        );
232
 
233
        return $values;
234
    }
235
 
236
    /**
237
     * Get the formatting parameters for the intro.
238
     *
239
     * @return array
240
     */
241
    protected function get_format_parameters_for_intro() {
242
        return [
243
            'component' => 'mod_data',
244
            'filearea' => 'intro',
245
            'options' => array('noclean' => true),
246
        ];
247
    }
248
}