MDL-33173 files: correct @package name
[moodle.git] / user / files.php
CommitLineData
82af55d7
MD
1<?php
2
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.
14//
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/>.
17
18/**
4c886459 19 * Manage files in folder in private area.
82af55d7 20 *
f5a68663 21 * @package core_files
82af55d7
MD
22 * @copyright 2010 Petr Skoda (http://skodak.org)
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26require('../config.php');
4c886459
FM
27require_once("$CFG->dirroot/user/files_form.php");
28require_once("$CFG->dirroot/repository/lib.php");
82af55d7
MD
29
30require_login();
31if (isguestuser()) {
32 die();
33}
82af55d7 34
4c886459
FM
35$returnurl = optional_param('returnurl', '', PARAM_URL);
36$returnbutton = true;
37
38if (empty($returnurl)) {
39 $returnbutton = false;
40 $returnurl = new moodle_url('/user/files.php');
41}
42
82af55d7 43$context = get_context_instance(CONTEXT_USER, $USER->id);
37a81e19 44require_capability('moodle/user:manageownfiles', $context);
4c886459 45
82af55d7
MD
46$title = get_string('myfiles');
47$struser = get_string('user');
48
49$PAGE->set_url('/user/files.php');
50$PAGE->set_context($context);
51$PAGE->set_title($title);
52$PAGE->set_heading($title);
53$PAGE->set_pagelayout('mydashboard');
54$PAGE->set_pagetype('user-files');
55
4c886459
FM
56$data = new stdClass();
57$data->returnurl = $returnurl;
58$options = array('subdirs'=>1, 'maxbytes'=>$CFG->userquota, 'maxfiles'=>-1, 'accepted_types'=>'*');
59file_prepare_standard_filemanager($data, 'files', $options, $context, 'user', 'private', 0);
82af55d7 60
4c886459 61$mform = new user_files_form(null, array('data'=>$data, 'options'=>$options, 'cancelbutton'=>$returnbutton));
82af55d7 62
4c886459
FM
63if ($mform->is_cancelled()) {
64 redirect($returnurl);
65} else if ($formdata = $mform->get_data()) {
66 $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'user', 'private', 0);
67 redirect($returnurl);
68}
82af55d7 69
4c886459
FM
70echo $OUTPUT->header();
71echo $OUTPUT->box_start('generalbox');
72$mform->display();
82af55d7
MD
73echo $OUTPUT->box_end();
74echo $OUTPUT->footer();