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
namespace qbank_columnsortorder\privacy;
18
 
19
use core_privacy\local\metadata\collection;
20
use core_privacy\local\request\writer;
21
 
22
/**
23
 * Privacy provider for columnsortorder.
24
 *
25
 * @package    qbank_columnsortorder
26
 * @copyright  2021 Catalyst IT Australia Pty Ltd
27
 * @author     Ghaly Marc-Alexandre <marc-alexandreghaly@catalyst-ca.net>
28
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 */
30
class provider implements
31
    // The forms subsystem does not store any data itself, it has no database tables.
32
    \core_privacy\local\metadata\provider,
33
 
34
    // The forms subsystem has user preferences.
35
    \core_privacy\local\request\user_preference_provider {
36
 
37
    public static function get_metadata(collection $collection): collection {
38
        $collection->add_user_preference('enabledcol', 'privacy:metadata:preference:enabledcol');
39
        $collection->add_user_preference('hiddencols', 'privacy:metadata:preference:hiddencols');
40
        $collection->add_user_preference('colsize', 'privacy:metadata:preference:colsize');
41
 
42
        return $collection;
43
    }
44
 
45
    public static function export_user_preferences(int $userid) {
46
        $components = ['core_question', "qbank_history"];
47
        foreach ($components as $component) {
48
            $prefnames = ['enabledcol', 'hiddencols', 'colsize'];
49
            foreach ($prefnames as $name) {
50
                $preference = get_user_preferences("{$component}_{$name}", null, $userid);
51
                if ($preference !== null) {
52
                    $desc = get_string('enabledcol', 'privacy:metadata:preference:enabledcol');
53
                    writer::export_user_preference('qbank_columnsortorder', "{$component}_{$name}", $preference, $desc);
54
                }
55
            }
56
        }
57
    }
58
}