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/>.
18 require_once('../config.php');
19 require_once(dirname(__FILE__
) . '/coursefilesedit_form.php');
20 require_once($CFG->dirroot
. '/repository/lib.php');
23 $contextid = required_param('contextid', PARAM_INT
);
24 $component = 'course';
28 list($context, $course, $cm) = get_context_info_array($contextid);
30 $url = new moodle_url('/files/coursefilesedit.php', array('contextid'=>$contextid));
32 require_login($course);
33 require_capability('moodle/course:managefiles', $context);
36 $heading = get_string('coursefiles') . ': ' . format_string($course->fullname
, true, array('context' => $context));
37 $strfiles = get_string("files");
38 if ($node = $PAGE->settingsnav
->find('coursefiles', navigation_node
::TYPE_SETTING
)) {
41 $PAGE->navbar
->add($strfiles);
43 $PAGE->set_context($context);
44 $PAGE->set_title($heading);
45 $PAGE->set_heading($heading);
46 $PAGE->set_pagelayout('course');
48 $data = new stdClass();
49 $options = array('subdirs'=>1, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL
);
50 file_prepare_standard_filemanager($data, 'files', $options, $context, $component, $filearea, $itemid);
51 $form = new coursefiles_edit_form(null, array('data'=>$data, 'contextid'=>$contextid));
53 $returnurl = new moodle_url('/files/index.php', array('contextid'=>$contextid));
55 if ($form->is_cancelled()) {
59 if ($data = $form->get_data()) {
60 $data = file_postupdate_standard_filemanager($data, 'files', $options, $context, $component, $filearea, $itemid);
64 echo $OUTPUT->header();
66 echo $OUTPUT->container_start();
68 echo $OUTPUT->container_end();
70 echo $OUTPUT->footer();