Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | 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_managecategories\privacy;
18
 
1441 ariadna 19
use core_privacy\local\metadata\collection;
20
use core_privacy\local\request\writer;
21
 
1 efrain 22
/**
23
 * Privacy Subsystem for qbank_managecategories implementing null_provider.
24
 *
25
 * @package   qbank_managecategories
26
 * @category  privacy
27
 * @copyright 2021 Catalyst IT Australia Pty Ltd
28
 * @author    Guillermo Gomez Arias <guillermogomez@catalyst-au.net>
29
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
1441 ariadna 31
class provider implements
32
    \core_privacy\local\metadata\provider,
33
    \core_privacy\local\request\user_preference_provider {
1 efrain 34
    /**
1441 ariadna 35
     * Returns meta data about this system.
1 efrain 36
     *
1441 ariadna 37
     * @param   collection $collection The initialised collection to add items to.
38
     * @return  collection A listing of user data stored through this system.
1 efrain 39
     */
1441 ariadna 40
    public static function get_metadata(collection $collection): collection {
41
        $collection->add_user_preference('qbank_managecategories_showdescriptions', 'privacy:preference:showdescriptions');
42
        $collection->add_user_preference('qbank_managecategories_includesubcategories_filter_default',
43
            'privacy:preference:includesubcategories_filter_default');
44
        return $collection;
1 efrain 45
    }
1441 ariadna 46
 
47
    /**
48
     * Export all user preferences for the plugin.
49
     *
50
     * @param int $userid The userid of the user whose data is to be exported.
51
     */
52
    public static function export_user_preferences(int $userid) {
53
        $showdescription = get_user_preferences('qbank_managecategories_showdescriptions', null, $userid);
54
        if ($showdescription !== null) {
55
            $displaydescription = $showdescription ? 'displaydescription' : 'descriptionnotdisplayed';
56
            writer::export_user_preference(
57
                'qbank_managecategories',
58
                'showdescr',
59
                $showdescription,
60
                get_string($displaydescription, 'qbank_managecategories')
61
            );
62
        }
63
 
64
        $includesubcategories = get_user_preferences('qbank_managecategories_includesubcategories_filter_default', null, $userid);
65
        if (isset($includesubcategories)) {
66
            $displayquestions = $includesubcategories ? 'questionsubcategoriesdisplayed' : 'questionsubcategoriesnotdisplayed';
67
            writer::export_user_preference(
68
                'qbank_managecategories',
69
                'includesubcategories',
70
                $includesubcategories,
71
                get_string($displayquestions, 'qbank_managecategories')
72
            );
73
        }
74
    }
1 efrain 75
}