MDL-22388 Added some checks to kill these scripts dead with an unequivocal notice...
[moodle.git] / mod / folder / mod_form.php
CommitLineData
0e16b939 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 * Folder configuration form
20 *
21 * @package mod-folder
22 * @copyright 2009 Petr Skoda (http://skodak.org)
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
bfebaf64
MD
26if (!defined('MOODLE_INTERNAL')) {
27 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
28}
29
0e16b939 30require_once ($CFG->dirroot.'/course/moodleform_mod.php');
31
32class mod_folder_mod_form extends moodleform_mod {
33 function definition() {
34 global $CFG;
35 $mform = $this->_form;
36
37 $config = get_config('folder');
38
39 //-------------------------------------------------------
40 $mform->addElement('header', 'general', get_string('general', 'form'));
41 $mform->addElement('text', 'name', get_string('name'), array('size'=>'48'));
42 if (!empty($CFG->formatstringstriptags)) {
43 $mform->setType('name', PARAM_TEXT);
44 } else {
45 $mform->setType('name', PARAM_CLEAN);
46 }
47 $mform->addRule('name', null, 'required', null, 'client');
48 $this->add_intro_editor($config->requiremodintro);
49
50 //-------------------------------------------------------
51 $mform->addElement('header', 'content', get_string('contentheader', 'folder'));
6b3c4d65 52 $mform->addElement('filemanager', 'files', get_string('files'), null, array('subdirs'=>1, 'filetypes'=>'*', 'returnvalue'=>'ref_id'));
0e16b939 53
54 //-------------------------------------------------------
55 $this->standard_coursemodule_elements();
56
57 //-------------------------------------------------------
58 $this->add_action_buttons();
59
60 //-------------------------------------------------------
61 $mform->addElement('hidden', 'revision');
62 $mform->setType('revision', PARAM_INT);
63 $mform->setDefault('revision', 1);
64 }
65
66 function data_preprocessing(&$default_values) {
67 if ($this->current->instance) {
68 // editing existing instance - copy existing files into draft area
69 $draftitemid = file_get_submitted_draft_itemid('files');
70 file_prepare_draft_area($draftitemid, $this->context->id, 'folder_content', 0, array('subdirs'=>true));
71 $default_values['files'] = $draftitemid;
72 }
73 }
74}