3 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
19 * Folder configuration form
23 * @copyright 2009 Petr Skoda {@link http://skodak.org}
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') ||
die();
29 require_once ($CFG->dirroot
.'/course/moodleform_mod.php');
31 class mod_folder_mod_form
extends moodleform_mod
{
32 function definition() {
34 $mform = $this->_form
;
36 $config = get_config('folder');
38 //-------------------------------------------------------
39 $mform->addElement('header', 'general', get_string('general', 'form'));
40 $mform->addElement('text', 'name', get_string('name'), array('size'=>'48'));
41 if (!empty($CFG->formatstringstriptags
)) {
42 $mform->setType('name', PARAM_TEXT
);
44 $mform->setType('name', PARAM_CLEANHTML
);
46 $mform->addRule('name', null, 'required', null, 'client');
47 $this->add_intro_editor($config->requiremodintro
);
49 //-------------------------------------------------------
50 $mform->addElement('header', 'content', get_string('contentheader', 'folder'));
51 $mform->addElement('filemanager', 'files', get_string('files'), null, array('subdirs'=>1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL
));
53 //-------------------------------------------------------
54 $this->standard_coursemodule_elements();
56 //-------------------------------------------------------
57 $this->add_action_buttons();
59 //-------------------------------------------------------
60 $mform->addElement('hidden', 'revision');
61 $mform->setType('revision', PARAM_INT
);
62 $mform->setDefault('revision', 1);
65 function data_preprocessing(&$default_values) {
66 if ($this->current
->instance
) {
67 // editing existing instance - copy existing files into draft area
68 $draftitemid = file_get_submitted_draft_itemid('files');
69 file_prepare_draft_area($draftitemid, $this->context
->id
, 'mod_folder', 'content', 0, array('subdirs'=>true));
70 $default_values['files'] = $draftitemid;