Merge branch 'MDL-35644-MOODLE_22_STABLE' of git://github.com/mouneyrac/moodle into...
[moodle.git] / user / filesedit.php
blobafc4d16a48da007a520e141a559ee15f235ef2f0
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 moodle
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");
30 require_login();
31 if (isguestuser()) {
32 die();
35 $returnurl = optional_param('returnurl', '', PARAM_URL);
37 if (empty($returnurl)) {
38 $returnurl = new moodle_url('/user/filesedit.php');
41 $context = get_context_instance(CONTEXT_USER, $USER->id);
42 require_capability('moodle/user:manageownfiles', $context);
44 $title = get_string('myfiles');
45 $struser = get_string('user');
47 $PAGE->set_url('/user/filesedit.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 $data = new stdClass();
55 $data->returnurl = $returnurl;
56 $options = array('subdirs'=>1, 'maxbytes'=>$CFG->userquota, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
57 file_prepare_standard_filemanager($data, 'files', $options, $context, 'user', 'private', 0);
59 $mform = new user_filesedit_form(null, array('data'=>$data, 'options'=>$options));
61 if ($mform->is_cancelled()) {
62 redirect($returnurl);
63 } else if ($formdata = $mform->get_data()) {
64 $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'user', 'private', 0);
65 redirect($returnurl);
68 echo $OUTPUT->header();
69 echo $OUTPUT->box_start('generalbox');
70 $mform->display();
71 echo $OUTPUT->box_end();
72 echo $OUTPUT->footer();