Merge branch 'MDL-50611-master' of git://github.com/LukeCarrier/moodle
[moodle.git] / backup / backupfilesedit.php
blobac5584cd38043f1d8834355e087af23f295767ae
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 backup files
20 * @package moodlecore
21 * @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 require_once('../config.php');
26 require_once(dirname(__FILE__) . '/backupfilesedit_form.php');
27 require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
28 require_once($CFG->dirroot . '/repository/lib.php');
30 // current context
31 $contextid = required_param('contextid', PARAM_INT);
32 $currentcontext = required_param('currentcontext', PARAM_INT);
33 // file parameters
34 $component = optional_param('component', null, PARAM_COMPONENT);
35 $filearea = optional_param('filearea', null, PARAM_AREA);
36 $returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
38 list($context, $course, $cm) = get_context_info_array($currentcontext);
39 $filecontext = context::instance_by_id($contextid, IGNORE_MISSING);
41 $url = new moodle_url('/backup/backupfilesedit.php', array('currentcontext'=>$currentcontext, 'contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea));
43 require_login($course, false, $cm);
44 require_capability('moodle/restore:uploadfile', $context);
46 $PAGE->set_url($url);
47 $PAGE->set_context($context);
48 $PAGE->set_title(get_string('managefiles', 'backup'));
49 $PAGE->set_heading(get_string('managefiles', 'backup'));
50 $PAGE->set_pagelayout('admin');
51 $browser = get_file_browser();
53 $data = new stdClass();
54 $options = array('subdirs'=>0, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
55 file_prepare_standard_filemanager($data, 'files', $options, $filecontext, $component, $filearea, 0);
56 $form = new backup_files_edit_form(null, array('data'=>$data, 'contextid'=>$contextid, 'currentcontext'=>$currentcontext, 'filearea'=>$filearea, 'component'=>$component, 'returnurl'=>$returnurl));
58 if ($form->is_cancelled()) {
59 redirect($returnurl);
62 $data = $form->get_data();
63 if ($data) {
64 $formdata = file_postupdate_standard_filemanager($data, 'files', $options, $filecontext, $component, $filearea, 0);
65 redirect($returnurl);
68 echo $OUTPUT->header();
70 echo $OUTPUT->container_start();
71 $form->display();
72 echo $OUTPUT->container_end();
74 echo $OUTPUT->footer();