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 |
* This file defines the core_privacy\local\metadata\collection class object.
|
|
|
19 |
*
|
|
|
20 |
* The collection class is used to organize a collection of types
|
|
|
21 |
* objects, which contains the privacy field details of a component.
|
|
|
22 |
*
|
|
|
23 |
* @package core_privacy
|
|
|
24 |
* @copyright 2018 Jake Dallimore <jrhdallimore@gmail.com>
|
|
|
25 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
26 |
*/
|
|
|
27 |
namespace core_privacy\local\metadata;
|
|
|
28 |
|
|
|
29 |
use core_privacy\local\metadata\types\type;
|
|
|
30 |
|
|
|
31 |
defined('MOODLE_INTERNAL') || die();
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
* A collection of metadata items.
|
|
|
35 |
*
|
|
|
36 |
* @copyright 2018 Jake Dallimore <jrhdallimore@gmail.com>
|
|
|
37 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
38 |
*/
|
|
|
39 |
class collection {
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* @var string The component that the items in the collection belong to.
|
|
|
43 |
*/
|
|
|
44 |
protected $component;
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* @var type[] The collection of metadata items.
|
|
|
48 |
*/
|
|
|
49 |
protected $collection = [];
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Constructor for a component's privacy collection class.
|
|
|
53 |
*
|
|
|
54 |
* @param string $component component name.
|
|
|
55 |
*/
|
|
|
56 |
public function __construct($component) {
|
|
|
57 |
$this->component = $component;
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
* Function to add an object that implements type interface to the current collection.
|
|
|
62 |
*
|
|
|
63 |
* @param type $type to add to collection.
|
|
|
64 |
* @return $this
|
|
|
65 |
*/
|
|
|
66 |
public function add_type(type $type) {
|
|
|
67 |
$this->collection[] = $type;
|
|
|
68 |
|
|
|
69 |
return $this;
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
/**
|
|
|
73 |
* Function to add a database table which contains user data to this collection.
|
|
|
74 |
*
|
|
|
75 |
* @param string $name the name of the database table.
|
|
|
76 |
* @param array $privacyfields An associative array of fieldname to description.
|
|
|
77 |
* @param string $summary A description of what the table is used for.
|
|
|
78 |
* @return $this
|
|
|
79 |
*/
|
|
|
80 |
public function add_database_table($name, array $privacyfields, $summary = '') {
|
|
|
81 |
$this->add_type(new types\database_table($name, $privacyfields, $summary));
|
|
|
82 |
|
|
|
83 |
return $this;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* Function to link a subsystem to the component.
|
|
|
88 |
*
|
|
|
89 |
* @param string $name the name of the subsystem to link.
|
|
|
90 |
* @param array $privacyfields An optional associative array of fieldname to description.
|
|
|
91 |
* @param string $summary A description of what is stored within this subsystem.
|
|
|
92 |
* @return $this
|
|
|
93 |
*/
|
|
|
94 |
public function add_subsystem_link($name, array $privacyfields = [], $summary = '') {
|
|
|
95 |
$this->add_type(new types\subsystem_link($name, $privacyfields, $summary));
|
|
|
96 |
|
|
|
97 |
return $this;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
/**
|
|
|
101 |
* Old function to link a subsystem to the component.
|
|
|
102 |
*
|
|
|
103 |
* This function is legacy and is not recommended. Please use add_subsystem_link() instead.
|
|
|
104 |
*
|
|
|
105 |
* @param string $name the name of the subsystem to link.
|
|
|
106 |
* @param string $summary A description of what is stored within this subsystem.
|
|
|
107 |
* @return $this
|
|
|
108 |
*/
|
|
|
109 |
public function link_subsystem($name, $summary = '') {
|
|
|
110 |
$this->add_type(new types\subsystem_link($name, [], $summary));
|
|
|
111 |
|
|
|
112 |
return $this;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
/**
|
|
|
116 |
* Function to link a plugin to the component.
|
|
|
117 |
*
|
|
|
118 |
* @param string $name the name of the plugin to link.
|
|
|
119 |
* @param array $privacyfields An optional associative array of fieldname to description.
|
|
|
120 |
* @param string $summary A description of what is stored within this plugin.
|
|
|
121 |
* @return $this
|
|
|
122 |
*/
|
|
|
123 |
public function add_plugintype_link($name, array $privacyfields = [], $summary = '') {
|
|
|
124 |
$this->add_type(new types\plugintype_link($name, $privacyfields, $summary));
|
|
|
125 |
|
|
|
126 |
return $this;
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
/**
|
|
|
130 |
* Old function to link a plugin to the component.
|
|
|
131 |
*
|
|
|
132 |
* This function is legacy and is not recommended. Please use add_plugintype_link() instead.
|
|
|
133 |
*
|
|
|
134 |
* @param string $name the name of the plugin to link.
|
|
|
135 |
* @param string $summary A description of what is stored within this plugin.
|
|
|
136 |
* @return $this
|
|
|
137 |
*/
|
|
|
138 |
public function link_plugintype($name, $summary = '') {
|
|
|
139 |
$this->add_type(new types\plugintype_link($name, [], $summary));
|
|
|
140 |
|
|
|
141 |
return $this;
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
/**
|
|
|
145 |
* Function to indicate that data may be exported to an external location.
|
|
|
146 |
*
|
|
|
147 |
* @param string $name A name for the type of data exported.
|
|
|
148 |
* @param array $privacyfields A list of fields with their description.
|
|
|
149 |
* @param string $summary A description of what the table is used for. This is a language string identifier
|
|
|
150 |
* within the component.
|
|
|
151 |
* @return $this
|
|
|
152 |
*/
|
|
|
153 |
public function add_external_location_link($name, array $privacyfields, $summary = '') {
|
|
|
154 |
$this->add_type(new types\external_location($name, $privacyfields, $summary));
|
|
|
155 |
|
|
|
156 |
return $this;
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
/**
|
|
|
160 |
* Old function to indicate that data may be exported to an external location.
|
|
|
161 |
*
|
|
|
162 |
* This function is legacy and is not recommended. Please use add_external_location_link() instead.
|
|
|
163 |
*
|
|
|
164 |
* @param string $name A name for the type of data exported.
|
|
|
165 |
* @param array $privacyfields A list of fields with their description.
|
|
|
166 |
* @param string $summary A description of what the table is used for. This is a language string identifier
|
|
|
167 |
* within the component.
|
|
|
168 |
* @return $this
|
|
|
169 |
*/
|
|
|
170 |
public function link_external_location($name, array $privacyfields, $summary = '') {
|
|
|
171 |
$this->add_type(new types\external_location($name, $privacyfields, $summary));
|
|
|
172 |
|
|
|
173 |
return $this;
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
/**
|
|
|
177 |
* Add a type of user preference to the collection.
|
|
|
178 |
*
|
|
|
179 |
* Typically this is a single user preference, but in some cases the
|
|
|
180 |
* name of a user preference fits a particular format.
|
|
|
181 |
*
|
|
|
182 |
* @param string $name The name of the user preference.
|
|
|
183 |
* @param string $summary A description of what the preference is used for.
|
|
|
184 |
* @return $this
|
|
|
185 |
*/
|
|
|
186 |
public function add_user_preference($name, $summary = '') {
|
|
|
187 |
$this->add_type(new types\user_preference($name, $summary));
|
|
|
188 |
|
|
|
189 |
return $this;
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
/**
|
|
|
193 |
* Function to return the current component name.
|
|
|
194 |
*
|
|
|
195 |
* @return string
|
|
|
196 |
*/
|
|
|
197 |
public function get_component() {
|
|
|
198 |
return $this->component;
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
/**
|
|
|
202 |
* The content of this collection.
|
|
|
203 |
*
|
|
|
204 |
* @return type[]
|
|
|
205 |
*/
|
|
|
206 |
public function get_collection() {
|
|
|
207 |
return $this->collection;
|
|
|
208 |
}
|
|
|
209 |
}
|