source: moodle/trunk/fuentes/admin/tool/log/store/database/backup/moodle2/backup_logstore_database_subplugin.class.php

Last change on this file was 1331, checked in by jrpelegrina, 3 years ago

Updated to moodle 3.0.3

File size: 2.5 KB
RevLine 
[1331]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 * Backup implementation for the (tool_log) logstore_database subplugin.
19 *
20 * @package    logstore_database
21 * @category   backup
22 * @copyright  2015 Mark Nelson <markn@moodle.com>
23 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26defined('MOODLE_INTERNAL') || die();
27require_once('backup_logstore_database_nested_element.php');
28
29class backup_logstore_database_subplugin extends backup_tool_log_logstore_subplugin {
30
31    /**
32     * Returns the subplugin structure to attach to the 'logstore' XML element.
33     *
34     * @return backup_subplugin_element the subplugin structure to be attached.
35     */
36    protected function define_logstore_subplugin_structure() {
37        $subplugin = $this->get_subplugin_element();
38        $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
39
40        // Create the custom (base64 encoded, xml safe) 'other' final element.
41        $otherelement = new base64_encode_final_element('other');
42
43        $subpluginlog = new backup_logstore_database_nested_element('logstore_database_log', array('id'), array(
44            'eventname', 'component', 'action', 'target', 'objecttable',
45            'objectid', 'crud', 'edulevel', 'contextid', 'userid', 'relateduserid',
46            'anonymous', $otherelement, 'timecreated', 'ip', 'realuserid'));
47
48        $subplugin->add_child($subpluginwrapper);
49        $subpluginwrapper->add_child($subpluginlog);
50
51        // Get the details for the external database.
52        $manager = new \tool_log\log\manager();
53        $store = new \logstore_database\log\store($manager);
54        $extdb = $store->get_extdb();
55
56        if (!$extdb) {
57            return false;
58        }
59
60        $subpluginlog->set_source_db($extdb);
61        $subpluginlog->set_source_table($store->get_config_value('dbtable'), array('contextid' => backup::VAR_CONTEXTID));
62
63        return $subplugin;
64    }
65}
Note: See TracBrowser for help on using the repository browser.