. /** * The main screen of the tool. * * @package tool_installaddon * @copyright 2013 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require(dirname(__FILE__) . '/../../../config.php'); require_once($CFG->libdir.'/adminlib.php'); admin_externalpage_setup('tool_installaddon_index'); if (!empty($CFG->disableonclickaddoninstall)) { notice(get_string('featuredisabled', 'tool_installaddon')); } $installer = tool_installaddon_installer::instance(); $output = $PAGE->get_renderer('tool_installaddon'); $output->set_installer_instance($installer); // Handle the eventual request for installing from remote repository. $remoterequest = optional_param('installaddonrequest', null, PARAM_RAW); $confirmed = optional_param('confirm', false, PARAM_BOOL); $installer->handle_remote_request($output, $remoterequest, $confirmed); $form = $installer->get_installfromzip_form(); if ($form->is_cancelled()) { redirect($PAGE->url); } else if ($data = $form->get_data()) { // Save the ZIP file into a temporary location. $jobid = md5(rand().uniqid('', true)); $sourcedir = make_temp_directory('tool_installaddon/'.$jobid.'/source'); $zipfilename = $installer->save_installfromzip_file($form, $sourcedir); // Redirect to the validation page. $nexturl = new moodle_url('/admin/tool/installaddon/validate.php', array( 'sesskey' => sesskey(), 'jobid' => $jobid, 'zip' => $zipfilename, 'type' => $data->plugintype, 'rootdir' => $data->rootdir)); redirect($nexturl); } // Output starts here. echo $output->index_page();