Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
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 * This script is used to configure and execute the course copy proccess. 19 * 20 * @package core_backup 21 * @copyright 2020 onward The Moodle Users Association <https://moodleassociation.org/> 22 * @author Matt Porritt <mattp@catalyst-au.net> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require_once('../config.php'); 27 require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); 28 29 defined('MOODLE_INTERNAL') || die(); 30 31 $courseid = required_param('id', PARAM_INT); 32 $returnto = optional_param('returnto', 'course', PARAM_ALPHANUM); // Generic navigation return page switch. 33 $returnurl = optional_param('returnurl', '', PARAM_LOCALURL); // A return URL. returnto must also be set to 'url'. 34 35 $url = new moodle_url('/backup/copy.php', array('id' => $courseid)); 36 $course = get_course($courseid); 37 $coursecontext = context_course::instance($course->id); 38 39 // Security and access checks. 40 require_login($course, false); 41 $copycaps = \core_course\management\helper::get_course_copy_capabilities(); 42 require_all_capabilities($copycaps, $coursecontext); 43 44 if ($returnurl != '') { 45 $returnurl = new moodle_url($returnurl); 46 } else if ($returnto == 'catmanage') { 47 // Redirect to category management page. 48 $returnurl = new moodle_url('/course/management.php', array('categoryid' => $course->category)); 49 } else { 50 // Redirect back to course page if we came from there. 51 $returnurl = new moodle_url('/course/view.php', array('id' => $courseid)); 52 } 53 54 // Setup the page. 55 $title = get_string('copycoursetitle', 'backup', $course->shortname); 56 $heading = get_string('copycourseheading', 'backup'); 57 $PAGE->set_url($url); 58 $PAGE->set_pagelayout('admin'); 59 $PAGE->set_title($title); 60 $PAGE->set_heading($heading); 61 62 // Get data ready for mform. 63 $mform = new \core_backup\output\copy_form( 64 $url, 65 array('course' => $course, 'returnto' => $returnto, 'returnurl' => $returnurl)); 66 67 if ($mform->is_cancelled()) { 68 // The form has been cancelled, take them back to what ever the return to is. 69 redirect($returnurl); 70 71 } else if ($mdata = $mform->get_data()) { 72 73 // Process the form and create the copy task. 74 $copydata = \copy_helper::process_formdata($mdata); 75 \copy_helper::create_copy($copydata); 76 77 if (!empty($mdata->submitdisplay)) { 78 // Redirect to the copy progress overview. 79 $progressurl = new moodle_url('/backup/copyprogress.php', array('id' => $courseid)); 80 redirect($progressurl); 81 } else { 82 // Redirect to the course view page. 83 $coursesurl = new moodle_url('/course/view.php', array('id' => $courseid)); 84 redirect($coursesurl); 85 } 86 87 } else { 88 // This branch is executed if the form is submitted but the data doesn't validate, 89 // or on the first display of the form. 90 91 // Build the page output. 92 echo $OUTPUT->header(); 93 echo $OUTPUT->heading($title); 94 $mform->display(); 95 echo $OUTPUT->footer(); 96 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body