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
 * Test provider using a fake plugin name.
19
 *
20
 * @package core_privacy
21
 * @copyright 2018 Jake Dallimore <jrhdallimore@gmail.com>
22
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace mod_testcomponent\privacy;
26
 
27
use core_privacy\local\metadata\collection;
28
use core_privacy\local\request\approved_contextlist;
29
use core_privacy\local\request\contextlist;
30
 
31
/**
32
 * Mock core_user_data_provider for unit tests.
33
 * @copyright 2018 Jake Dallimore <jrhdallimore@gmail.com>
34
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
36
class provider implements \core_privacy\local\metadata\provider, \core_privacy\local\request\plugin\provider {
37
    /**
38
     * @return array The array of metadata.
39
     */
40
    public static function get_metadata(collection $collection): collection {
41
        $collection = new collection('testcomponent');
42
        $collection->add_database_table('testtable', ['testfield1', 'testfield2'], 'testsummary');
43
        return $collection;
44
    }
45
 
46
    /**
47
     * Get the list of contexts that contain user information for the specified user.
48
     *
49
     * @param   int $userid The user to search.
50
     * @return  contextlist   $contextlist  The contextlist containing the list of contexts used in this plugin.
51
     */
52
    public static function get_contexts_for_userid(int $userid): contextlist {
53
        $cl = new contextlist();
54
        $cl->add_from_sql("SELECT c.id FROM {context} c WHERE c.id = :id", ['id' => \context_system::instance()->id]);
55
 
56
        return $cl;
57
    }
58
 
59
    /**
60
     * Export all user data for the specified user, in the specified contexts.
61
     *
62
     * @param   approved_contextlist $contextlist The approved contexts to export information for.
63
     */
64
    public static function export_user_data(approved_contextlist $contextlist) {
65
        // This does nothing. We only want to confirm this can be called via the \core_privacy\manager.
66
    }
67
 
68
    /**
69
     * Delete all use data which matches the specified deletion criteria.
70
     *
71
     * @param   context         $context   The specific context to delete data for.
72
     */
73
    public static function delete_data_for_all_users_in_context(\context $context) {
74
        // This does nothing. We only want to confirm this can be called via the \core_privacy\manager.
75
    }
76
 
77
    /**
78
     * Delete all user data for the specified user, in the specified contexts.
79
     *
80
     * @param   approved_contextlist $contextlist The approved contexts and user information to delete information for.
81
     */
82
    public static function delete_data_for_user(approved_contextlist $contextlist) {
83
        // This does nothing. We only want to confirm this can be called via the \core_privacy\manager.
84
    }
85
}