See Release Notes
Long Term Support Release
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 main screen of the tool. 20 * 21 * @package tool_installaddon 22 * @copyright 2013 David Mudrak <david@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require(__DIR__ . '/../../../config.php'); 27 require_once($CFG->libdir.'/adminlib.php'); 28 29 admin_externalpage_setup('tool_installaddon_index'); 30 31 if (!empty($CFG->disableupdateautodeploy)) { 32 notice(get_string('featuredisabled', 'tool_installaddon')); 33 } 34 35 $pluginman = core_plugin_manager::instance(); 36 $installer = tool_installaddon_installer::instance(); 37 38 $output = $PAGE->get_renderer('tool_installaddon'); 39 $output->set_installer_instance($installer); 40 41 // Handle the eventual request for installing from remote repository. 42 $remoterequest = optional_param('installaddonrequest', null, PARAM_RAW); 43 $installer->handle_remote_request($output, $remoterequest); 44 45 // Handle the confirmed installation request. 46 $installremote = optional_param('installremote', null, PARAM_COMPONENT); 47 $installremoteversion = optional_param('installremoteversion', null, PARAM_INT); 48 $installremoteconfirm = optional_param('installremoteconfirm', false, PARAM_BOOL); 49 50 if ($installremote and $installremoteversion) { 51 require_sesskey(); 52 require_once($CFG->libdir.'/upgradelib.php'); 53 54 $PAGE->set_pagelayout('maintenance'); 55 $PAGE->set_popup_notification_allowed(false); 56 57 if ($pluginman->is_remote_plugin_installable($installremote, $installremoteversion)) { 58 $installable = array($pluginman->get_remote_plugin_info($installremote, $installremoteversion, true)); 59 upgrade_install_plugins($installable, $installremoteconfirm, 60 get_string('installfromrepo', 'tool_installaddon'), 61 new moodle_url($PAGE->url, array('installremote' => $installremote, 62 'installremoteversion' => $installremoteversion, 'installremoteconfirm' => 1) 63 ) 64 ); 65 } 66 // We should never get here. 67 throw new moodle_exception('installing_non_installable_component', 'tool_installaddon'); 68 } 69 70 // Handle installation of a plugin from the ZIP file. 71 $installzipcomponent = optional_param('installzipcomponent', null, PARAM_COMPONENT); 72 $installzipstorage = optional_param('installzipstorage', null, PARAM_FILE); 73 $installzipconfirm = optional_param('installzipconfirm', false, PARAM_BOOL); 74 75 if ($installzipcomponent and $installzipstorage) { 76 require_sesskey(); 77 require_once($CFG->libdir.'/upgradelib.php'); 78 79 $PAGE->set_pagelayout('maintenance'); 80 $PAGE->set_popup_notification_allowed(false); 81 82 $installable = array((object)array( 83 'component' => $installzipcomponent, 84 'zipfilepath' => make_temp_directory('tool_installaddon').'/'.$installzipstorage.'/plugin.zip', 85 )); 86 upgrade_install_plugins($installable, $installzipconfirm, get_string('installfromzip', 'tool_installaddon'), 87 new moodle_url($installer->index_url(), array('installzipcomponent' => $installzipcomponent, 88 'installzipstorage' => $installzipstorage, 'installzipconfirm' => 1) 89 ) 90 ); 91 } 92 93 $form = $installer->get_installfromzip_form(); 94 95 if ($form->is_cancelled()) { 96 redirect($PAGE->url); 97 98 } else if ($data = $form->get_data()) { 99 $storage = $installer->make_installfromzip_storage(); 100 $form->save_file('zipfile', $storage.'/plugin.zip'); 101 102 $ziprootdir = $pluginman->get_plugin_zip_root_dir($storage.'/plugin.zip'); 103 if (empty($ziprootdir)) { 104 echo $output->zip_not_valid_plugin_package_page($installer->index_url()); 105 die(); 106 } 107 108 $component = $installer->detect_plugin_component($storage.'/plugin.zip'); 109 if (!empty($component) and !empty($data->plugintype)) { 110 // If the plugin type was explicitly set, make sure it matches the detected one. 111 list($detectedtype, $detectedname) = core_component::normalize_component($component); 112 if ($detectedtype !== $data->plugintype) { 113 $form->selected_plugintype_mismatch($detectedtype); 114 echo $output->index_page(); 115 die(); 116 } 117 } 118 if (empty($component)) { 119 // This should not happen as all plugins are supposed to declare their 120 // component. Still, let admins upload legacy packages if they want/need. 121 if (empty($data->plugintype)) { 122 $form->require_explicit_plugintype(); 123 echo $output->index_page(); 124 die(); 125 } 126 if (!empty($data->rootdir)) { 127 $usepluginname = $data->rootdir; 128 } else { 129 $usepluginname = $ziprootdir; 130 } 131 $component = $data->plugintype.'_'.$usepluginname; 132 } 133 134 redirect($installer->index_url(array( 135 'installzipcomponent' => $component, 136 'installzipstorage' => basename($storage), 137 'sesskey' => sesskey(), 138 ))); 139 } 140 141 // Display the tool main page. 142 echo $output->index_page();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body