2010-06-21 07:55:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manage files in folder module instance
|
|
|
|
*
|
2010-07-25 11:12:16 +00:00
|
|
|
* @package mod
|
|
|
|
* @subpackage folder
|
|
|
|
* @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
2010-06-21 07:55:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
require('../../config.php');
|
|
|
|
require_once("$CFG->dirroot/mod/folder/locallib.php");
|
|
|
|
require_once("$CFG->dirroot/mod/folder/edit_form.php");
|
|
|
|
require_once("$CFG->dirroot/repository/lib.php");
|
|
|
|
|
2010-06-21 08:20:34 +00:00
|
|
|
$id = required_param('id', PARAM_INT); // Course module ID
|
2010-06-21 07:55:18 +00:00
|
|
|
|
|
|
|
$cm = get_coursemodule_from_id('folder', $id, 0, false, MUST_EXIST);
|
2010-07-03 13:37:13 +00:00
|
|
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id, MUST_EXIST);
|
2010-06-21 07:55:18 +00:00
|
|
|
$folder = $DB->get_record('folder', array('id'=>$cm->instance), '*', MUST_EXIST);
|
|
|
|
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
|
|
|
|
|
2010-07-03 13:37:13 +00:00
|
|
|
require_login($course, false, $cm);
|
2010-07-22 09:04:06 +00:00
|
|
|
require_capability('mod/folder:managefiles', $context);
|
2010-06-21 07:55:18 +00:00
|
|
|
|
|
|
|
add_to_log($course->id, 'folder', 'edit', 'edit.php?id='.$cm->id, $folder->id, $cm->id);
|
|
|
|
|
|
|
|
$PAGE->set_url('/mod/folder/edit.php', array('id' => $cm->id));
|
|
|
|
$PAGE->set_title($course->shortname.': '.$folder->name);
|
|
|
|
$PAGE->set_heading($course->fullname);
|
|
|
|
$PAGE->set_activity_record($folder);
|
|
|
|
|
2010-09-21 08:37:36 +00:00
|
|
|
$data = new stdClass();
|
2010-07-03 13:37:13 +00:00
|
|
|
$data->id = $cm->id;
|
2010-10-21 04:41:38 +00:00
|
|
|
$options = array('mainfile'=>true, 'subdirs'=>1, 'maxbytes'=>$CFG->maxbytes, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
|
2010-07-03 13:37:13 +00:00
|
|
|
file_prepare_standard_filemanager($data, 'files', $options, $context, 'mod_folder', 'content', 0);
|
2010-06-21 07:55:18 +00:00
|
|
|
|
2010-07-03 13:37:13 +00:00
|
|
|
$mform = new mod_folder_edit_form(null, array('data'=>$data, 'options'=>$options));
|
2010-06-21 07:55:18 +00:00
|
|
|
|
2010-07-03 13:37:13 +00:00
|
|
|
if ($mform->is_cancelled()) {
|
|
|
|
redirect(new moodle_url('/mod/folder/view.php', array('id'=>$cm->id)));
|
|
|
|
|
|
|
|
} else if ($formdata = $mform->get_data()) {
|
|
|
|
$formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_folder', 'content', 0);
|
2010-06-21 07:55:18 +00:00
|
|
|
redirect(new moodle_url('/mod/folder/view.php', array('id'=>$cm->id)));
|
|
|
|
}
|
2010-07-03 13:37:13 +00:00
|
|
|
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $OUTPUT->box_start('generalbox foldertree');
|
|
|
|
$mform->display();
|
|
|
|
echo $OUTPUT->box_end();
|
|
|
|
echo $OUTPUT->footer();
|