MDL-45219 add \mod\chat\course_module_viewed event
[moodle.git] / user / files_form.php
blob9c0947ef3d27dbc5e8224dcbaaa54e17f79d829d
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.
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/>.
17 /**
18 * minimalistic edit form
20 * @package core_user
21 * @category files
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");
30 /**
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 {
37 /**
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 $mform->setType('returnurl', PARAM_LOCALURL);
50 $this->add_action_buttons(true, get_string('savechanges'));
52 $this->set_data($data);
55 /**
56 * Validate incoming data.
58 * @param array $data
59 * @param array $files
60 * @return array
62 public function validation($data, $files) {
63 $errors = array();
64 $draftitemid = $data['files_filemanager'];
65 if (file_is_draft_area_limit_reached($draftitemid, $this->_customdata['options']['areamaxbytes'])) {
66 $errors['files_filemanager'] = get_string('userquotalimit', 'error');
69 return $errors;