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
 * Provides the class {@link workshopallocation_manual\privacy\provider}
19
 *
20
 * @package     workshopallocation_manual
21
 * @category    privacy
22
 * @copyright   2018 David Mudrák <david@moodle.com>
23
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
namespace workshopallocation_manual\privacy;
27
 
28
use core_privacy\local\metadata\collection;
29
use core_privacy\local\request\writer;
30
 
31
defined('MOODLE_INTERNAL') || die();
32
 
33
/**
34
 * Privacy API implementation for the Manual allocation method.
35
 *
36
 * @copyright 2018 David Mudrák <david@moodle.com>
37
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 */
39
class provider implements \core_privacy\local\metadata\provider, \core_privacy\local\request\user_preference_provider {
40
 
41
    /**
42
     * Describe all the places where this plugin stores some personal data.
43
     *
44
     * @param collection $collection Collection of items to add metadata to.
45
     * @return collection Collection with our added items.
46
     */
47
    public static function get_metadata(collection $collection): collection {
48
 
49
        $collection->add_user_preference('workshopallocation_manual_perpage', 'privacy:metadata:preference:perpage');
50
 
51
        return $collection;
52
    }
53
 
54
    /**
55
     * Export user preferences controlled by this plugin.
56
     *
57
     * @param int $userid ID of the user we are exporting data form.
58
     */
59
    public static function export_user_preferences(int $userid) {
60
 
61
        $perpage = get_user_preferences('workshopallocation_manual_perpage', null, $userid);
62
 
63
        if ($perpage !== null) {
64
            writer::export_user_preference('workshopallocation_manual', 'workshopallocation_manual_perpage', $perpage,
65
                get_string('privacy:metadata:preference:perpage', 'workshopallocation_manual'));
66
        }
67
    }
68
}