MDL-23308, move legacyfilesinnewcourse setting from developement settings to reposito...
[moodle.git] / files / coursefilesedit.php
CommitLineData
e921afa8
DC
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
18require_once('../config.php');
19require_once(dirname(__FILE__) . '/coursefilesedit_form.php');
20require_once($CFG->dirroot . '/repository/lib.php');
21
22// current context
23$contextid = required_param('contextid', PARAM_INT);
24$component = 'course';
25$filearea = 'legacy';
26$itemid = 0;
27
28list($context, $course, $cm) = get_context_info_array($contextid);
29
30$url = new moodle_url('/files/coursefilesedit.php', array('contextid'=>$contextid));
31
32require_login($course);
33require_capability('moodle/course:managefiles', $context);
34
35$heading = get_string('coursefiles') . ': ' . $course->fullname;
36$PAGE->set_url($url);
37$PAGE->set_context($context);
38$PAGE->set_title($heading);
39$PAGE->set_heading($heading);
40$PAGE->set_pagelayout('admin');
41
42$data = new object();
43$options = array('subdirs'=>1, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
44file_prepare_standard_filemanager($data, 'files', $options, $context, $component, $filearea, $itemid);
45$form = new coursefiles_edit_form(null, array('data'=>$data, 'contextid'=>$contextid));
46
47$returnurl = new moodle_url('/files/index.php', array('contextid'=>$contextid));
48
49if ($form->is_cancelled()) {
50 redirect($returnurl);
51}
52
53if ($data = $form->get_data()) {
54 $data = file_postupdate_standard_filemanager($data, 'files', $options, $context, $component, $filearea, $itemid);
55 redirect($returnurl);
56}
57
58echo $OUTPUT->header();
59
60echo $OUTPUT->container_start();
61$form->display();
62echo $OUTPUT->container_end();
63
64echo $OUTPUT->footer();