1 |
efrain |
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 |
namespace core\moodlenet;
|
|
|
18 |
|
|
|
19 |
use backup;
|
|
|
20 |
use backup_controller;
|
|
|
21 |
use cm_info;
|
|
|
22 |
|
|
|
23 |
defined('MOODLE_INTERNAL') || die();
|
|
|
24 |
|
|
|
25 |
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Packager to prepare appropriate backup of an activity to share to MoodleNet.
|
|
|
29 |
*
|
|
|
30 |
* @package core
|
|
|
31 |
* @copyright 2023 Raquel Ortega <raquel.ortega@moodle.com>
|
|
|
32 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
33 |
*/
|
|
|
34 |
class activity_packager extends resource_packager {
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Constructor.
|
|
|
38 |
*
|
|
|
39 |
* @param cm_info $cminfo context module information about the resource being packaged.
|
|
|
40 |
* @param int $userid The ID of the user performing the packaging.
|
|
|
41 |
*/
|
|
|
42 |
public function __construct(
|
|
|
43 |
cm_info $cminfo,
|
|
|
44 |
int $userid,
|
|
|
45 |
) {
|
|
|
46 |
// Check backup/restore support.
|
|
|
47 |
if (!plugin_supports('mod', $cminfo->modname , FEATURE_BACKUP_MOODLE2)) {
|
|
|
48 |
throw new \coding_exception("Cannot backup module $cminfo->modname. This module doesn't support the backup feature.");
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
parent::__construct($cminfo, $userid, $cminfo->modname);
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* Get the backup controller for the activity.
|
|
|
56 |
*
|
|
|
57 |
* @return backup_controller the backup controller for the activity.
|
|
|
58 |
*/
|
|
|
59 |
protected function get_backup_controller(): backup_controller {
|
|
|
60 |
return new backup_controller(
|
|
|
61 |
backup::TYPE_1ACTIVITY,
|
|
|
62 |
$this->cminfo->id,
|
|
|
63 |
backup::FORMAT_MOODLE,
|
|
|
64 |
backup::INTERACTIVE_NO,
|
|
|
65 |
backup::MODE_GENERAL,
|
|
|
66 |
$this->userid
|
|
|
67 |
);
|
|
|
68 |
}
|
|
|
69 |
}
|