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
|
|
|
|
*
|
2014-02-14 17:04:59 +13:00
|
|
|
* @package mod_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
|
|
|
|
2013-01-23 15:53:29 +11:00
|
|
|
$cm = get_coursemodule_from_id('folder', $id, 0, true, MUST_EXIST);
|
2012-07-26 14:53:42 +08:00
|
|
|
$context = context_module::instance($cm->id, MUST_EXIST);
|
2010-06-21 07:55:18 +00:00
|
|
|
$folder = $DB->get_record('folder', array('id'=>$cm->instance), '*', MUST_EXIST);
|
2013-08-21 13:42:30 +08:00
|
|
|
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
|
2010-06-21 07:55:18 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
$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);
|
2021-07-14 23:11:36 +08:00
|
|
|
$PAGE->set_secondary_active_tab('modulepage');
|
2021-09-21 16:16:47 +08:00
|
|
|
$PAGE->activityheader->set_attrs([
|
|
|
|
'hidecompletion' => true,
|
|
|
|
'description' => ''
|
|
|
|
]);
|
2021-10-04 16:57:04 +02:00
|
|
|
$PAGE->add_body_class('limitedwidth');
|
2010-06-21 07:55:18 +00:00
|
|
|
|
2010-09-21 08:37:36 +00:00
|
|
|
$data = new stdClass();
|
2010-07-03 13:37:13 +00:00
|
|
|
$data->id = $cm->id;
|
2014-12-29 12:11:52 +00:00
|
|
|
$maxbytes = get_user_max_upload_file_size($context, $CFG->maxbytes);
|
|
|
|
$options = array('subdirs' => 1, 'maxbytes' => $maxbytes, 'maxfiles' => -1, 'accepted_types' => '*');
|
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));
|
2013-02-15 20:12:31 +11:00
|
|
|
if ($folder->display == FOLDER_DISPLAY_INLINE) {
|
2013-01-23 15:53:29 +11:00
|
|
|
$redirecturl = course_get_url($cm->course, $cm->sectionnum);
|
|
|
|
} else {
|
|
|
|
$redirecturl = new moodle_url('/mod/folder/view.php', array('id' => $cm->id));
|
|
|
|
}
|
2010-06-21 07:55:18 +00:00
|
|
|
|
2010-07-03 13:37:13 +00:00
|
|
|
if ($mform->is_cancelled()) {
|
2013-01-23 15:53:29 +11:00
|
|
|
redirect($redirecturl);
|
2010-07-03 13:37:13 +00:00
|
|
|
|
|
|
|
} else if ($formdata = $mform->get_data()) {
|
|
|
|
$formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_folder', 'content', 0);
|
2017-09-13 12:40:53 +12:00
|
|
|
$folder->timemodified = time();
|
2013-11-18 18:37:03 -08:00
|
|
|
$folder->revision = $folder->revision + 1;
|
|
|
|
|
2017-09-13 12:40:53 +12:00
|
|
|
$DB->update_record('folder', $folder);
|
|
|
|
|
2013-11-18 18:37:03 -08:00
|
|
|
$params = array(
|
|
|
|
'context' => $context,
|
|
|
|
'objectid' => $folder->id
|
|
|
|
);
|
|
|
|
$event = \mod_folder\event\folder_updated::create($params);
|
|
|
|
$event->add_record_snapshot('folder', $folder);
|
|
|
|
$event->trigger();
|
2013-04-28 09:30:29 +02:00
|
|
|
|
2013-01-23 15:53:29 +11:00
|
|
|
redirect($redirecturl);
|
2010-06-21 07:55:18 +00:00
|
|
|
}
|
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();
|