[ 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 * Deploy the validated contents of the ZIP package to the $CFG->dirroot 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.'/filelib.php'); 28 29 require_login(); 30 require_capability('moodle/site:config', context_system::instance()); 31 32 if (!empty($CFG->disableonclickaddoninstall)) { 33 notice(get_string('featuredisabled', 'tool_installaddon')); 34 } 35 36 require_sesskey(); 37 38 $jobid = required_param('jobid', PARAM_ALPHANUM); 39 $plugintype = required_param('type', PARAM_ALPHANUMEXT); 40 $pluginname = required_param('name', PARAM_PLUGIN); 41 42 $zipcontentpath = $CFG->tempdir.'/tool_installaddon/'.$jobid.'/contents'; 43 44 if (!is_dir($zipcontentpath)) { 45 debugging('Invalid location of the extracted ZIP package: '.s($zipcontentpath), DEBUG_DEVELOPER); 46 redirect(new moodle_url('/admin/tool/installaddon/index.php'), 47 get_string('invaliddata', 'core_error')); 48 } 49 50 if (!is_dir($zipcontentpath.'/'.$pluginname)) { 51 debugging('Invalid location of the plugin root directory: '.$zipcontentpath.'/'.$pluginname, DEBUG_DEVELOPER); 52 redirect(new moodle_url('/admin/tool/installaddon/index.php'), 53 get_string('invaliddata', 'core_error')); 54 } 55 56 $installer = tool_installaddon_installer::instance(); 57 58 if (!$installer->is_plugintype_writable($plugintype)) { 59 debugging('Plugin type location not writable', DEBUG_DEVELOPER); 60 redirect(new moodle_url('/admin/tool/installaddon/index.php'), 61 get_string('invaliddata', 'core_error')); 62 } 63 64 $plugintypepath = $installer->get_plugintype_root($plugintype); 65 66 if (file_exists($plugintypepath.'/'.$pluginname)) { 67 debugging('Target location already exists', DEBUG_DEVELOPER); 68 redirect(new moodle_url('/admin/tool/installaddon/index.php'), 69 get_string('invaliddata', 'core_error')); 70 } 71 72 // Copy permissions form the plugin type directory. 73 $dirpermissions = fileperms($plugintypepath); 74 $filepermissions = ($dirpermissions & 0666); // Strip execute flags. 75 76 $installer->move_directory($zipcontentpath.'/'.$pluginname, $plugintypepath.'/'.$pluginname, $dirpermissions, $filepermissions); 77 fulldelete($CFG->tempdir.'/tool_installaddon/'.$jobid); 78 redirect(new moodle_url('/admin'));
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 |