2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * minimalistic edit form
22 * @copyright 2010 Petr Skoda (http://skodak.org)
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') ||
die();
28 require_once("$CFG->libdir/formslib.php");
31 * Class user_files_form
32 * @copyright 2010 Petr Skoda (http://skodak.org)
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 class user_files_form
extends moodleform
{
38 * Add elements to this form.
40 public function definition() {
41 $mform = $this->_form
;
43 $data = $this->_customdata
['data'];
44 $options = $this->_customdata
['options'];
46 $mform->addElement('filemanager', 'files_filemanager', get_string('files'), null, $options);
47 $mform->addElement('hidden', 'returnurl', $data->returnurl
);
48 if (isset($data->emaillink
)) {
49 $emaillink = html_writer
::link(new moodle_url('mailto:' . $data->emaillink
), $data->emaillink
);
50 $mform->addElement('static', 'emailaddress', '',
51 get_string('emailtoprivatefiles', 'moodle', $emaillink));
53 $mform->setType('returnurl', PARAM_LOCALURL
);
55 $this->add_action_buttons(true, get_string('savechanges'));
57 $this->set_data($data);
61 * Validate incoming data.
67 public function validation($data, $files) {
69 $draftitemid = $data['files_filemanager'];
70 if (file_is_draft_area_limit_reached($draftitemid, $this->_customdata
['options']['areamaxbytes'])) {
71 $errors['files_filemanager'] = get_string('userquotalimit', 'error');