See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Import a framework. 19 * 20 * @package tool_lpimportcsv 21 * @copyright 2016 Damyon Wiese 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 define('NO_OUTPUT_BUFFERING', true); 25 require_once(__DIR__ . '/../../../config.php'); 26 require_once($CFG->libdir.'/adminlib.php'); 27 28 admin_externalpage_setup('toollpimportcsv'); 29 30 $pagetitle = get_string('pluginname', 'tool_lpimportcsv'); 31 32 $context = context_system::instance(); 33 34 $url = new moodle_url("/admin/tool/lpimportcsv/index.php"); 35 $PAGE->set_context($context); 36 $PAGE->set_url($url); 37 $PAGE->set_title($pagetitle); 38 $PAGE->set_pagelayout('admin'); 39 $PAGE->set_heading($pagetitle); 40 41 $form = null; 42 echo $OUTPUT->header(); 43 if (optional_param('needsconfirm', 0, PARAM_BOOL)) { 44 $form = new \tool_lpimportcsv\form\import($url->out(false)); 45 } else if (optional_param('confirm', 0, PARAM_BOOL)) { 46 $importer = new \tool_lpimportcsv\framework_importer(); 47 $form = new \tool_lpimportcsv\form\import_confirm(null, $importer); 48 } else { 49 $form = new \tool_lpimportcsv\form\import($url->out(false)); 50 } 51 52 if ($form->is_cancelled()) { 53 $form = new \tool_lpimportcsv\form\import($url->out(false)); 54 } else if ($data = $form->get_data()) { 55 require_sesskey(); 56 57 if ($data->confirm) { 58 $importid = $data->importid; 59 $importer = new \tool_lpimportcsv\framework_importer(null, null, null, $importid, $data, true); 60 61 $error = $importer->get_error(); 62 if ($error) { 63 $form = new \tool_lpimportcsv\form\import($url->out(false)); 64 $form->set_import_error($error); 65 } else { 66 $framework = $importer->import(); 67 $urlparams = ['competencyframeworkid' => $framework->get('id'), 'pagecontextid' => $context->id]; 68 $frameworksurl = new moodle_url('/admin/tool/lp/competencies.php', $urlparams); 69 echo $OUTPUT->notification(get_string('competencyframeworkcreated', 'tool_lp'), 'notifysuccess'); 70 echo $OUTPUT->continue_button($frameworksurl); 71 die(); 72 } 73 } else { 74 $text = $form->get_file_content('importfile'); 75 $encoding = $data->encoding; 76 $delimiter = $data->delimiter_name; 77 $importer = new \tool_lpimportcsv\framework_importer($text, $encoding, $delimiter, 0, null, true); 78 $confirmform = new \tool_lpimportcsv\form\import_confirm(null, $importer); 79 $form = $confirmform; 80 $pagetitle = get_string('confirmcolumnmappings', 'tool_lpimportcsv'); 81 } 82 } 83 84 echo $OUTPUT->heading($pagetitle); 85 86 $form->display(); 87 88 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body