3 // This file is part of Moodle - http://moodle.org/
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.
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/>.
19 * Manage files in folder in private area.
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/filesedit_form.php");
28 require_once("$CFG->dirroot/repository/lib.php");
35 $returnurl = optional_param('returnurl', '', PARAM_URL
);
37 if (empty($returnurl)) {
38 if (!empty($_SERVER["HTTP_REFERER"])) {
39 $returnurl = $_SERVER["HTTP_REFERER"];
41 $returnurl = new moodle_url('/user/files.php');
45 $context = get_context_instance(CONTEXT_USER
, $USER->id
);
46 require_capability('moodle/user:manageownfiles', $context);
48 $title = get_string('myfiles');
49 $struser = get_string('user');
51 $PAGE->set_url('/user/files.php');
52 $PAGE->set_context($context);
53 $PAGE->set_title($title);
54 $PAGE->set_heading($title);
55 $PAGE->set_pagelayout('mydashboard');
56 $PAGE->set_pagetype('user-files');
58 $data = new stdClass();
59 $data->returnurl
= $returnurl;
60 $options = array('subdirs'=>1, 'maxbytes'=>$CFG->userquota
, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL
);
61 file_prepare_standard_filemanager($data, 'files', $options, $context, 'user', 'private', 0);
63 $mform = new user_filesedit_form(null, array('data'=>$data, 'options'=>$options));
65 if ($mform->is_cancelled()) {
67 } else if ($formdata = $mform->get_data()) {
68 $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'user', 'private', 0);
72 echo $OUTPUT->header();
73 echo $OUTPUT->box_start('generalbox');
75 echo $OUTPUT->box_end();
76 echo $OUTPUT->footer();