| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php //$Id: import.php,v 1.3 2007/10/10 06:34:21 nicolasconnault Exp $ 2 3 /////////////////////////////////////////////////////////////////////////// 4 // // 5 // NOTICE OF COPYRIGHT // 6 // // 7 // Moodle - Modular Object-Oriented Dynamic Learning Environment // 8 // http://moodle.com // 9 // // 10 // Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com // 11 // // 12 // This program is free software; you can redistribute it and/or modify // 13 // it under the terms of the GNU General Public License as published by // 14 // the Free Software Foundation; either version 2 of the License, or // 15 // (at your option) any later version. // 16 // // 17 // This program is distributed in the hope that it will be useful, // 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 20 // GNU General Public License for more details: // 21 // // 22 // http://www.gnu.org/copyleft/gpl.html // 23 // // 24 /////////////////////////////////////////////////////////////////////////// 25 26 require_once '../../../config.php'; 27 require_once 'lib.php'; 28 require_once $CFG->libdir.'/filelib.php'; 29 30 $url = required_param('url', PARAM_URL); // only real urls here 31 $id = required_param('id', PARAM_INT); // course id 32 $feedback = optional_param('feedback', 0, PARAM_BOOL); 33 34 if (!$course = get_record('course', 'id', $id)) { 35 print_error('nocourseid'); 36 } 37 38 require_login($course); 39 $context = get_context_instance(CONTEXT_COURSE, $id); 40 41 require_capability('moodle/grade:import', $context); 42 require_capability('gradeimport/xml:view', $context); 43 44 45 // Large files are likely to take their time and memory. Let PHP know 46 // that we'll take longer, and that the process should be recycled soon 47 // to free up memory. 48 @set_time_limit(0); 49 @raise_memory_limit("256M"); 50 if (function_exists('apache_child_terminate')) { 51 @apache_child_terminate(); 52 } 53 54 $text = download_file_content($url); 55 if ($text === false) { 56 error('Can not read file'); 57 } 58 59 $error = ''; 60 $importcode = import_xml_grades($text, $course, $error); 61 62 if ($importcode !== false) { 63 /// comit the code if we are up this far 64 65 if (defined('USER_KEY_LOGIN')) { 66 if (grade_import_commit($id, $importcode, $feedback, false)) { 67 echo 'ok'; 68 die; 69 } else { 70 error('Grade import error'); //TODO: localize 71 } 72 73 } else { 74 $strgrades = get_string('grades', 'grades'); 75 $actionstr = get_string('xml', 'grades'); 76 $navigation = grade_build_nav(__FILE__, $actionstr, array('courseid' => $course->id)); 77 78 print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation); 79 print_grade_plugin_selector($id, 'import', 'xml'); 80 81 grade_import_commit($id, $importcode, $feedback, true); 82 83 print_footer(); 84 die; 85 } 86 87 } else { 88 error($error); 89 } 90 91 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |