MDL-39702 generators: Adding MOODLE_INTERNAL
[moodle.git] / user / files.php
blobd7043c588c8a11fc13e1b3ed5dff7aad5ac68ec5
1 <?php
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.
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/>.
18 /**
19 * Manage files in folder in private area.
21 * @package core_files
22 * @copyright 2010 Petr Skoda (http://skodak.org)
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 require('../config.php');
27 require_once("$CFG->dirroot/user/files_form.php");
28 require_once("$CFG->dirroot/repository/lib.php");
30 require_login();
31 if (isguestuser()) {
32 die();
35 $returnurl = optional_param('returnurl', '', PARAM_LOCALURL);
37 if (empty($returnurl)) {
38 $returnurl = new moodle_url('/user/files.php');
41 $context = context_user::instance($USER->id);
42 require_capability('moodle/user:manageownfiles', $context);
44 $title = get_string('myfiles');
45 $struser = get_string('user');
47 $PAGE->set_url('/user/files.php');
48 $PAGE->set_context($context);
49 $PAGE->set_title($title);
50 $PAGE->set_heading($title);
51 $PAGE->set_pagelayout('mydashboard');
52 $PAGE->set_pagetype('user-files');
54 $maxareabytes = $CFG->userquota;
55 if (has_capability('moodle/user:ignoreuserquota', $context)) {
56 $maxareabytes = FILE_AREA_MAX_BYTES_UNLIMITED;
59 $data = new stdClass();
60 $data->returnurl = $returnurl;
61 $options = array('subdirs' => 1, 'maxbytes' => $CFG->userquota, 'maxfiles' => -1, 'accepted_types' => '*',
62 'areamaxbytes' => $maxareabytes);
63 file_prepare_standard_filemanager($data, 'files', $options, $context, 'user', 'private', 0);
65 $mform = new user_files_form(null, array('data'=>$data, 'options'=>$options));
67 if ($mform->is_cancelled()) {
68 redirect($returnurl);
69 } else if ($formdata = $mform->get_data()) {
70 $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'user', 'private', 0);
71 redirect($returnurl);
74 echo $OUTPUT->header();
75 echo $OUTPUT->box_start('generalbox');
76 $mform->display();
77 echo $OUTPUT->box_end();
78 echo $OUTPUT->footer();