|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00025 require_once('../config.php'); 00026 require_once(dirname(__FILE__) . '/backupfilesedit_form.php'); 00027 require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); 00028 require_once($CFG->dirroot . '/repository/lib.php'); 00029 00030 // current context 00031 $contextid = required_param('contextid', PARAM_INT); 00032 $currentcontext = required_param('currentcontext', PARAM_INT); 00033 // file parameters 00034 $component = optional_param('component', null, PARAM_COMPONENT); 00035 $filearea = optional_param('filearea', null, PARAM_AREA); 00036 $returnurl = optional_param('returnurl', null, PARAM_URL); 00037 00038 list($context, $course, $cm) = get_context_info_array($currentcontext); 00039 $filecontext = get_context_instance_by_id($contextid); 00040 00041 $url = new moodle_url('/backup/backupfilesedit.php', array('currentcontext'=>$currentcontext, 'contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea)); 00042 00043 require_login($course, false, $cm); 00044 require_capability('moodle/restore:uploadfile', $context); 00045 00046 $PAGE->set_url($url); 00047 $PAGE->set_context($context); 00048 $PAGE->set_title(get_string('managefiles', 'backup')); 00049 $PAGE->set_heading(get_string('managefiles', 'backup')); 00050 $PAGE->set_pagelayout('admin'); 00051 $browser = get_file_browser(); 00052 00053 $data = new stdClass(); 00054 $options = array('subdirs'=>0, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL); 00055 file_prepare_standard_filemanager($data, 'files', $options, $filecontext, $component, $filearea, 0); 00056 $form = new backup_files_edit_form(null, array('data'=>$data, 'contextid'=>$contextid, 'currentcontext'=>$currentcontext, 'filearea'=>$filearea, 'component'=>$component, 'returnurl'=>$returnurl)); 00057 00058 if ($form->is_cancelled()) { 00059 redirect($returnurl); 00060 } 00061 00062 $data = $form->get_data(); 00063 if ($data) { 00064 $formdata = file_postupdate_standard_filemanager($data, 'files', $options, $filecontext, $component, $filearea, 0); 00065 redirect($returnurl); 00066 } 00067 00068 echo $OUTPUT->header(); 00069 00070 echo $OUTPUT->container_start(); 00071 $form->display(); 00072 echo $OUTPUT->container_end(); 00073 00074 echo $OUTPUT->footer();