3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
20 * @subpackage backup-moodle2
21 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 * course task that provides all the properties and common steps to be performed
27 * when one course is being restored
29 * TODO: Finish phpdocs
31 class restore_course_task extends restore_task {
33 protected $info; // info related to course gathered from backup file
36 * Constructor - instantiates one object of this class
38 public function __construct($name, $info, $plan = null) {
40 parent::__construct($name, $plan);
44 * Course tasks have their own directory to read files
46 public function get_taskbasepath() {
48 return $this->get_basepath() . '/course';
52 * Create all the steps that will be part of this task
54 public function build() {
56 // TODO: Link all the course steps here
57 // Executed conditionally if restoring to new course or deleting or if overwrite_conf setting is enabled
58 if ($this->get_target() == backup::TARGET_NEW_COURSE || $this->get_setting_value('overwrite_conf') == true) {
59 $this->add_step(new restore_course_structure_step('course_info', 'course.xml'));
62 // At the end, mark it as built
67 * Code the transformations to perform in the course in
68 * order to get encoded transformed back to working links
70 static public function decode_content_links($content) {
72 // TODO: Decode COURSEVIEWBYID
77 // Protected API starts here
80 * Define the common setting that any restore course will have
82 protected function define_settings() {
84 // Define overwrite_conf to decide if course configuration will be restored over existing one
85 $overwrite = new restore_course_overwrite_conf_setting('overwrite_conf', base_setting::IS_BOOLEAN, false);
86 $overwrite->set_ui(new backup_setting_ui_select($overwrite, $overwrite->get_name(), array(1=>get_string('yes'), 0=>get_string('no'))));
87 $this->add_setting($overwrite);