Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 
18
/**
19
 * Manage files in folder module instance
20
 *
21
 * @package   mod_folder
22
 * @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
23
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
require('../../config.php');
27
require_once("$CFG->dirroot/mod/folder/locallib.php");
28
require_once("$CFG->dirroot/mod/folder/edit_form.php");
29
require_once("$CFG->dirroot/repository/lib.php");
30
 
31
$id = required_param('id', PARAM_INT);  // Course module ID
32
 
33
$cm = get_coursemodule_from_id('folder', $id, 0, true, MUST_EXIST);
34
$context = context_module::instance($cm->id, MUST_EXIST);
35
$folder = $DB->get_record('folder', array('id'=>$cm->instance), '*', MUST_EXIST);
36
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
37
 
38
require_login($course, false, $cm);
39
require_capability('mod/folder:managefiles', $context);
40
 
41
$PAGE->set_url('/mod/folder/edit.php', array('id' => $cm->id));
42
$PAGE->set_title($course->shortname.': '.$folder->name);
43
$PAGE->set_heading($course->fullname);
44
$PAGE->set_activity_record($folder);
45
$PAGE->set_secondary_active_tab('modulepage');
46
$PAGE->activityheader->set_attrs([
47
    'hidecompletion' => true,
48
    'description' => ''
49
]);
50
$PAGE->add_body_class('limitedwidth');
51
 
52
$data = new stdClass();
53
$data->id = $cm->id;
54
$maxbytes = get_user_max_upload_file_size($context, $CFG->maxbytes);
55
$options = array('subdirs' => 1, 'maxbytes' => $maxbytes, 'maxfiles' => -1, 'accepted_types' => '*');
56
file_prepare_standard_filemanager($data, 'files', $options, $context, 'mod_folder', 'content', 0);
57
 
58
$mform = new mod_folder_edit_form(null, array('data'=>$data, 'options'=>$options));
59
if ($folder->display == FOLDER_DISPLAY_INLINE) {
60
    $redirecturl = course_get_url($cm->course, $cm->sectionnum);
61
} else {
62
    $redirecturl = new moodle_url('/mod/folder/view.php', array('id' => $cm->id));
63
}
64
 
65
if ($mform->is_cancelled()) {
66
    redirect($redirecturl);
67
 
68
} else if ($formdata = $mform->get_data()) {
69
    $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_folder', 'content', 0);
70
    $folder->timemodified = time();
71
    $folder->revision = $folder->revision + 1;
72
 
73
    $DB->update_record('folder', $folder);
74
 
75
    $params = array(
76
        'context' => $context,
77
        'objectid' => $folder->id
78
    );
79
    $event = \mod_folder\event\folder_updated::create($params);
80
    $event->add_record_snapshot('folder', $folder);
81
    $event->trigger();
82
 
83
    redirect($redirecturl);
84
}
85
 
86
echo $OUTPUT->header();
87
echo $OUTPUT->box_start('generalbox foldertree');
88
$mform->display();
89
echo $OUTPUT->box_end();
90
echo $OUTPUT->footer();