[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 <[email protected]> 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 46 $data = new stdClass(); 47 $data->id = $cm->id; 48 $options = array('subdirs'=>1, 'maxbytes'=>$CFG->maxbytes, 'maxfiles'=>-1, 'accepted_types'=>'*'); 49 file_prepare_standard_filemanager($data, 'files', $options, $context, 'mod_folder', 'content', 0); 50 51 $mform = new mod_folder_edit_form(null, array('data'=>$data, 'options'=>$options)); 52 if ($folder->display == FOLDER_DISPLAY_INLINE) { 53 $redirecturl = course_get_url($cm->course, $cm->sectionnum); 54 } else { 55 $redirecturl = new moodle_url('/mod/folder/view.php', array('id' => $cm->id)); 56 } 57 58 if ($mform->is_cancelled()) { 59 redirect($redirecturl); 60 61 } else if ($formdata = $mform->get_data()) { 62 $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_folder', 'content', 0); 63 $DB->set_field('folder', 'revision', $folder->revision+1, array('id'=>$folder->id)); 64 65 // Update the variable of the folder revision so we can pass it as an accurate snapshot later. 66 $folder->revision = $folder->revision + 1; 67 68 $params = array( 69 'context' => $context, 70 'objectid' => $folder->id 71 ); 72 $event = \mod_folder\event\folder_updated::create($params); 73 $event->add_record_snapshot('folder', $folder); 74 $event->trigger(); 75 76 redirect($redirecturl); 77 } 78 79 echo $OUTPUT->header(); 80 echo $OUTPUT->heading(format_string($folder->name)); 81 echo $OUTPUT->box_start('generalbox foldertree'); 82 $mform->display(); 83 echo $OUTPUT->box_end(); 84 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |