Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
/**
18
 * This file manages the public functions of this module
19
 *
20
 * @package    mod_custommailing
21
 * @author     jeanfrancois@cblue.be,olivier@cblue.be
22
 * @copyright  2021 CBlue SPRL
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
/**
27
 * Define the complete custommailing structure for backup, with file and id annotations
28
 */
29
class backup_custommailing_activity_structure_step extends backup_activity_structure_step {
30
 
31
    protected function define_structure() {
32
 
33
        // To know if we are including userinfo
34
        $userinfo = $this->get_setting_value('userinfo');
35
 
36
        // Define each element separated
37
        $custommailing= new backup_nested_element('custommailing', array('id'), array(
38
            'course', 'name', 'intro', 'introformat', 'timecreated', 'timemodified'));
39
 
40
        $custommailing_mailings = new backup_nested_element('custommailing_mailings');
41
 
42
        $custommailing_mailing = new backup_nested_element('custommailing_mailing', array('id'), array(
43
            'custommailingid', 'mailingname', 'mailinglang', 'mailingsubject',
44
            'mailingcontent', 'mailingcontentformat', 'mailingmode', 'mailingdelay',
45
            'mailingstatus', 'retroactive', 'targetmoduleid','targetmodulestatus', 'customcertmoduleid','starttime',
46
            'timecreated', 'timemodified'));
47
 
48
        $custommailing_logs = new backup_nested_element('custommailing_logs');
49
 
50
        $custommailing_log = new backup_nested_element('custommailing_log', array('id'), array(
51
            'custommailingmailingid', 'emailtouserid', 'emailstatus','timecreated', 'timemodified'));
52
 
53
        // Build the tree
54
        $custommailing->add_child($custommailing_mailings);
55
        $custommailing_mailings->add_child($custommailing_mailing);
56
 
57
        $custommailing->add_child($custommailing_logs);
58
        $custommailing_logs->add_child($custommailing_log);
59
        // Define sources
60
        $custommailing->set_source_table('custommailing', array('id' => backup::VAR_ACTIVITYID));
61
 
62
        $custommailing_mailing->set_source_sql('
63
            SELECT *
64
            FROM {custommailing_mailing}
65
            WHERE custommailingid = ?',
66
            array(backup::VAR_PARENTID));
67
 
68
        // All the rest of elements only happen if we are including user info
69
        if ($userinfo) {
70
            $custommailing_log->set_source_table('custommailing_logs', array('custommailingmailingid' => '../../id'));
71
        }
72
        // Define id annotations
73
        $custommailing_log->annotate_ids('user','emailtouserid');
74
 
75
        // Define file annotations
76
 
77
        // Return the root element (choice), wrapped into standard activity structure
78
        return $this->prepare_activity_structure($custommailing);
79
    }
80
}