Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]
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 $pagetitle = get_string('pluginname', 'tool_lpimportcsv'); 29 30 $context = context_system::instance(); 31 32 $url = new moodle_url("/admin/tool/lpimportcsv/index.php"); 33 $PAGE->set_context($context); 34 $PAGE->set_url($url); 35 $PAGE->set_title($pagetitle); 36 $PAGE->set_pagelayout('admin'); 37 $PAGE->set_heading($pagetitle); 38 39 $form = null; 40 echo $OUTPUT->header(); 41 if (optional_param('needsconfirm', 0, PARAM_BOOL)) { 42 $form = new \tool_lpimportcsv\form\import($url->out(false)); 43 } else if (optional_param('confirm', 0, PARAM_BOOL)) { 44 $importer = new \tool_lpimportcsv\framework_importer(); 45 $form = new \tool_lpimportcsv\form\import_confirm(null, $importer); 46 } else { 47 $form = new \tool_lpimportcsv\form\import($url->out(false)); 48 } 49 50 if ($form->is_cancelled()) { 51 $form = new \tool_lpimportcsv\form\import($url->out(false)); 52 } else if ($data = $form->get_data()) { 53 require_sesskey(); 54 55 if ($data->confirm) { 56 $importid = $data->importid; 57 $importer = new \tool_lpimportcsv\framework_importer(null, null, null, $importid, $data, true); 58 59 $error = $importer->get_error(); 60 if ($error) { 61 $form = new \tool_lpimportcsv\form\import($url->out(false)); 62 $form->set_import_error($error); 63 } else { 64 $framework = $importer->import(); 65 $urlparams = ['competencyframeworkid' => $framework->get('id'), 'pagecontextid' => $context->id]; 66 $frameworksurl = new moodle_url('/admin/tool/lp/competencies.php', $urlparams); 67 echo $OUTPUT->notification(get_string('competencyframeworkcreated', 'tool_lp'), 'notifysuccess'); 68 echo $OUTPUT->continue_button($frameworksurl); 69 die(); 70 } 71 } else { 72 $text = $form->get_file_content('importfile'); 73 $encoding = $data->encoding; 74 $delimiter = $data->delimiter_name; 75 $importer = new \tool_lpimportcsv\framework_importer($text, $encoding, $delimiter, 0, null, true); 76 $confirmform = new \tool_lpimportcsv\form\import_confirm(null, $importer); 77 $form = $confirmform; 78 $pagetitle = get_string('confirmcolumnmappings', 'tool_lpimportcsv'); 79 } 80 } 81 82 echo $OUTPUT->heading($pagetitle); 83 84 $form->display(); 85 86 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body