MDL-63538 repository_merlot: Add support for removal of context users
[moodle.git] / user / files_form.php
blob709b3c9a86d1e1caad5df5ade06d8a5a32443823
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 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);
60 /**
61 * Validate incoming data.
63 * @param array $data
64 * @param array $files
65 * @return array
67 public function validation($data, $files) {
68 $errors = array();
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');
74 return $errors;