MDL-21432 backup - file handling and other changes. Saving before changes tomorrow...
[moodle.git] / backup / util / plan / restore_task.class.php
CommitLineData
b5d45a04
EL
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
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.
9//
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.
14//
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/>.
17
18/**
19 * @package moodlecore
20 * @subpackage backup-plan
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
23 */
24
25/**
26 * Abstract class defining the needed stuf for one restore task (a collection of steps)
27 *
28 * TODO: Finish phpdocs
29 */
30abstract class restore_task extends base_task {
31
32 /**
33 * Constructor - instantiates one object of this class
34 */
35 public function __construct($name, $plan = null) {
36 if (!is_null($plan) && !($plan instanceof restore_plan)) {
37 throw new restore_task_exception('wrong_restore_plan_specified');
38 }
39 parent::__construct($name, $plan);
40 }
41
42 public function get_restoreid() {
43 return $this->plan->get_restoreid();
44 }
c9d8234a
EL
45
46 public function get_info() {
47 return $this->plan->get_info();
48 }
a4e13312
EL
49
50 public function get_target() {
51 return $this->plan->get_target();
52 }
482aac65
EL
53
54 public function get_userid() {
55 return $this->plan->get_userid();
56 }
57
58 public function is_samesite() {
59 return $this->plan->is_samesite();
60 }
61
62 public function set_preloaded_information() {
63 $this->plan->set_preloaded_information();
64 }
65
66 public function get_preloaded_information() {
67 return $this->plan->get_preloaded_information();
68 }
2df0f295
EL
69
70 public function get_old_contextid() {
71 return $this->plan->get_info()->original_course_contextid;
72 }
b5d45a04
EL
73}
74
75/*
76 * Exception class used by all the @restore_task stuff
77 */
78class restore_task_exception extends base_task_exception {
79
80 public function __construct($errorcode, $a=NULL, $debuginfo=null) {
81 parent::__construct($errorcode, $a, $debuginfo);
82 }
83}