[ 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 * The ZIP package validation. 20 * 21 * @package tool_installaddon 22 * @copyright 2013 David Mudrak <[email protected]> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require(dirname(__FILE__) . '/../../../config.php'); 27 require_once($CFG->libdir.'/adminlib.php'); 28 require_once($CFG->libdir.'/filelib.php'); 29 30 navigation_node::override_active_url(new moodle_url('/admin/tool/installaddon/index.php')); 31 admin_externalpage_setup('tool_installaddon_validate'); 32 33 if (!empty($CFG->disableonclickaddoninstall)) { 34 notice(get_string('featuredisabled', 'tool_installaddon')); 35 } 36 37 require_sesskey(); 38 39 $jobid = required_param('jobid', PARAM_ALPHANUM); 40 $zipfilename = required_param('zip', PARAM_FILE); 41 $plugintype = required_param('type', PARAM_ALPHANUMEXT); 42 $rootdir = optional_param('rootdir', '', PARAM_PLUGIN); 43 44 $zipfilepath = $CFG->tempdir.'/tool_installaddon/'.$jobid.'/source/'.$zipfilename; 45 if (!file_exists($zipfilepath)) { 46 redirect(new moodle_url('/admin/tool/installaddon/index.php'), 47 get_string('invaliddata', 'core_error')); 48 } 49 50 $installer = tool_installaddon_installer::instance(); 51 52 // Extract the ZIP contents. 53 fulldelete($CFG->tempdir.'/tool_installaddon/'.$jobid.'/contents'); 54 $zipcontentpath = make_temp_directory('tool_installaddon/'.$jobid.'/contents'); 55 $zipcontentfiles = $installer->extract_installfromzip_file($zipfilepath, $zipcontentpath, $rootdir); 56 57 // Validate the contents of the plugin ZIP file. 58 $validator = tool_installaddon_validator::instance($zipcontentpath, $zipcontentfiles); 59 $validator->assert_plugin_type($plugintype); 60 $validator->assert_moodle_version($CFG->version); 61 $result = $validator->execute(); 62 63 if ($result) { 64 $validator->set_continue_url(new moodle_url('/admin/tool/installaddon/deploy.php', array( 65 'sesskey' => sesskey(), 66 'jobid' => $jobid, 67 'type' => $plugintype, 68 'name' => $validator->get_rootdir()))); 69 70 } else { 71 fulldelete($CFG->tempdir.'/tool_installaddon/'.$jobid); 72 } 73 74 // Display the validation results. 75 $output = $PAGE->get_renderer('tool_installaddon'); 76 $output->set_installer_instance($installer); 77 $output->set_validator_instance($validator); 78 echo $output->validation_page();
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 |