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 |
* Contains interface datafield_provider
|
|
|
19 |
*
|
|
|
20 |
* @package mod_data
|
|
|
21 |
* @copyright 2018 Marina Glancy
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace mod_data\privacy;
|
|
|
26 |
|
|
|
27 |
defined('MOODLE_INTERNAL') || die();
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* Interface datafield_provider, all datafield plugins need to implement it
|
|
|
31 |
*
|
|
|
32 |
* @package mod_data
|
|
|
33 |
* @copyright 2018 Marina Glancy
|
|
|
34 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
35 |
*/
|
|
|
36 |
interface datafield_provider extends
|
|
|
37 |
\core_privacy\local\request\plugin\subplugin_provider,
|
|
|
38 |
|
|
|
39 |
// The data subplugins do not need to do anything themselves for the shared_userlist.
|
|
|
40 |
// This is all handled by the parent plugin.
|
|
|
41 |
\core_privacy\local\request\shared_userlist_provider
|
|
|
42 |
{
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
* Exports data about one record in {data_content} table.
|
|
|
46 |
*
|
|
|
47 |
* Datafield plugins providers should implement this method to:
|
|
|
48 |
* - preprocess references to files in the response (examples - textarea, picture, file)
|
|
|
49 |
* - make content more human-readable (example - replace values separators in multimenu, format date in date)
|
|
|
50 |
* - add more information about the field itself (example - list all options for menu, multimenu, radio)
|
|
|
51 |
*
|
|
|
52 |
* Sample implementation (from datafield_textarea):
|
|
|
53 |
*
|
|
|
54 |
* $defaultvalue->content = writer::with_context($context)
|
|
|
55 |
* ->rewrite_pluginfile_urls([$recordobj->id, $contentobj->id], 'mod_data', 'content', $contentobj->id,
|
|
|
56 |
* $defaultvalue->content);
|
|
|
57 |
* writer::with_context($context)->export_data([$recordobj->id, $contentobj->id], $defaultvalue);
|
|
|
58 |
*
|
|
|
59 |
* @param \context_module $context
|
|
|
60 |
* @param \stdClass $recordobj record from DB table {data_records}
|
|
|
61 |
* @param \stdClass $fieldobj record from DB table {data_fields}
|
|
|
62 |
* @param \stdClass $contentobj record from DB table {data_content}
|
|
|
63 |
* @param \stdClass $defaultvalue pre-populated default value that most of plugins will use
|
|
|
64 |
*/
|
|
|
65 |
public static function export_data_content($context, $recordobj, $fieldobj, $contentobj, $defaultvalue);
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* Allows plugins to delete locally stored data.
|
|
|
69 |
*
|
|
|
70 |
* Usually datafield plugins do not store anything and this method will be empty.
|
|
|
71 |
*
|
|
|
72 |
* @param \context_module $context
|
|
|
73 |
* @param \stdClass $recordobj record from DB table {data_records}
|
|
|
74 |
* @param \stdClass $fieldobj record from DB table {data_fields}
|
|
|
75 |
* @param \stdClass $contentobj record from DB table {data_content}
|
|
|
76 |
*/
|
|
|
77 |
public static function delete_data_content($context, $recordobj, $fieldobj, $contentobj);
|
|
|
78 |
}
|