ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPrivacySettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 private static ?ilPrivacySettings $instance = null;
32
33 private bool $export_course;
34 private bool $export_group;
35 private bool $export_learning_sequence = false;
36 private bool $export_confirm_course = false;
37 private bool $export_confirm_group = false;
39
41 private bool $participants_list_prg_enabled = true;
42
43 private bool $fora_statistics;
44 private bool $anonymous_fora;
45 private bool $rbac_log;
46 private int $rbac_log_age;
50 private int $ref_id;
52 private bool $export_scorm;
53 private bool $comments_export;
54
57
63 private function __construct()
64 {
65 global $DIC;
66
67 $this->settings = $DIC->settings();
68 $this->db = $DIC->database();
69 $this->user = $DIC->user();
70 $this->access = $DIC->access();
71 $this->rbacsystem = $DIC->rbac()->system();
72
73 $this->read();
74 }
75
76 public static function getInstance(): ilPrivacySettings
77 {
78 if (!self::$instance instanceof ilPrivacySettings) {
79 self::$instance = new self();
80 }
81 return self::$instance;
82 }
83
84 public function getPrivacySettingsRefId(): int
85 {
86 return $this->ref_id;
87 }
88
89 public function enabledCourseExport(): bool
90 {
92 }
93
94 public function enabledGroupExport(): bool
95 {
97 }
98
99 public function enabledLearningSequenceExport(): bool
100 {
102 }
103
104 public function participantsListInCoursesEnabled(): bool
105 {
107 }
108
109 public function enableParticipantsListInCourses(bool $a_status): void
110 {
111 $this->participants_list_course_enabled = $a_status;
112 }
113
114 public function enablePRGUserExport(bool $status = false): void
115 {
116 $this->participants_list_prg_enabled = $status;
117 }
118
119 public function enabledPRGUserExport(): bool
120 {
122 }
123
127 public function checkExportAccess(int $a_ref_id, int $a_user_id = 0): bool
128 {
129 $user_id = $a_user_id ?: $this->user->getId();
130 $object_type = ilObject::_lookupType($a_ref_id, true);
131
132 $permission_export_member_data = $this->rbacsystem->checkAccessOfUser($user_id, 'export_member_data', $this->getPrivacySettingsRefId());
133 $permission_manage_member = $this->access->checkAccessOfUser($user_id, 'manage_members', '', $a_ref_id);
134
135 switch($object_type) {
136 case 'crs':
137 return $this->enabledCourseExport()
138 && $permission_export_member_data && $permission_manage_member;
139 case 'grp':
140 return $this->enabledGroupExport()
141 && $permission_export_member_data && $permission_manage_member;
142 case 'lso':
143 return $this->enabledLearningSequenceExport()
144 && $permission_export_member_data && $permission_manage_member;
145 case 'prg':
146 return $this->enabledPRGUserExport()
147 && $permission_manage_member;
148 }
149 return false;
150 }
151
152 public function enableCourseExport(bool $a_status): void
153 {
154 $this->export_course = $a_status;
155 }
156
157 public function enableGroupExport(bool $a_status): void
158 {
159 $this->export_group = $a_status;
160 }
161
162 public function enableLearningSequenceExport(bool $a_status): void
163 {
164 $this->export_learning_sequence = $a_status;
165 }
166
170 public function enableForaStatistics(bool $a_status): void
171 {
172 $this->fora_statistics = $a_status;
173 }
174
178 public function enabledForaStatistics(): bool
179 {
181 }
182
186 public function enableAnonymousFora(bool $a_status): void
187 {
188 $this->anonymous_fora = $a_status;
189 }
190
194 public function enabledAnonymousFora(): bool
195 {
197 }
198
202 public function enableRbacLog(bool $a_status): void
203 {
204 $this->rbac_log = $a_status;
205 }
206
210 public function enabledRbacLog(): bool
211 {
212 return $this->rbac_log;
213 }
214
218 public function setRbacLogAge(int $a_age): void
219 {
220 $this->rbac_log_age = $a_age;
221 }
222
226 public function getRbacLogAge(): int
227 {
228 return $this->rbac_log_age;
229 }
230
231 public function confirmationRequired(string $a_type): bool
232 {
233 switch ($a_type) {
234 case 'crs':
235 return $this->courseConfirmationRequired();
236
237 case 'grp':
238 return $this->groupConfirmationRequired();
239
240 case 'lso':
242 }
243 return false;
244 }
245
246 public function courseConfirmationRequired(): bool
247 {
249 }
250
251 public function groupConfirmationRequired(): bool
252 {
254 }
255
257 {
259 }
260
261 public function setCourseConfirmationRequired(bool $a_status): void
262 {
263 $this->export_confirm_course = $a_status;
264 }
265
266 public function setGroupConfirmationRequired(bool $a_status): void
267 {
268 $this->export_confirm_group = (bool) $a_status;
269 }
270
271 public function setLearningSequenceConfirmationRequired(bool $a_status): void
272 {
273 $this->export_confirm_learning_sequence = $a_status;
274 }
275
279 public function showGroupAccessTimes(bool $a_status): void
280 {
281 $this->show_grp_access_times = $a_status;
282 }
283
287 public function enabledGroupAccessTimes(): bool
288 {
290 }
291
295 public function showCourseAccessTimes(bool $a_status): void
296 {
297 $this->show_crs_access_times = $a_status;
298 }
299
304 {
306 }
307
311 public function showLearningSequenceAccessTimes(bool $a_status): void
312 {
313 $this->show_lso_access_times = $a_status;
314 }
315
319 public function enabledCourseAccessTimes(): bool
320 {
322 }
323
324 public function enabledAccessTimesByType(string $a_obj_type): bool
325 {
326 switch ($a_obj_type) {
327 case 'crs':
328 return $this->enabledCourseAccessTimes();
329
330 case 'grp':
331 return $this->enabledGroupAccessTimes();
332
333 case 'lso':
335 }
336 return false;
337 }
338
342 public function save(): void
343 {
344 $this->settings->set('ps_export_confirm', (string) $this->courseConfirmationRequired());
345 $this->settings->set('ps_export_confirm_group', (string) $this->groupConfirmationRequired());
346 $this->settings->set(
347 'ps_export_confirm_learning_sequence',
349 );
350 $this->settings->set('ps_export_course', (string) $this->enabledCourseExport());
351 $this->settings->set('ps_export_group', (string) $this->enabledGroupExport());
352 $this->settings->set('ps_export_learning_sequence', (string) $this->enabledLearningSequenceExport());
353 $this->settings->set('enable_fora_statistics', (string) $this->enabledForaStatistics());
354 $this->settings->set('enable_anonymous_fora', (string) $this->enabledAnonymousFora());
355 $this->settings->set('ps_access_times', (string) $this->enabledGroupAccessTimes());
356 $this->settings->set('ps_crs_access_times', (string) $this->enabledCourseAccessTimes());
357 $this->settings->set('ps_lso_access_times', (string) $this->enabledLearningSequenceAccessTimes());
358 $this->settings->set('rbac_log', (string) $this->enabledRbacLog());
359 $this->settings->set('rbac_log_age', (string) $this->getRbacLogAge());
360 $this->settings->set('enable_sahs_pd', (string) $this->enabledSahsProtocolData());
361 $this->settings->set('ps_export_scorm', (string) $this->enabledExportSCORM());
362 $this->settings->set('participants_list_courses', (string) $this->participantsListInCoursesEnabled());
363 $this->settings->set('comments_export', (string) $this->enabledCommentsExport());
364 $this->settings->set('ps_export_prg', (string) $this->enabledPRGUserExport());
365 }
366
370 private function read(): void
371 {
372 $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data " .
373 "WHERE tree.parent = " . $this->db->quote(SYSTEM_FOLDER_ID, 'integer') . " " .
374 "AND object_data.type = 'ps' " .
375 "AND object_reference.ref_id = tree.child " .
376 "AND object_reference.obj_id = object_data.obj_id";
377 $res = $this->db->query($query);
378 $row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
379 $this->ref_id = (int) ($row["ref_id"] ?? 0);
380
381 $this->export_course = (bool) $this->settings->get('ps_export_course', null);
382 $this->export_group = (bool) $this->settings->get('ps_export_group', null);
383 $this->export_learning_sequence = (bool) $this->settings->get('ps_export_learning_sequence', null);
384 $this->export_confirm_course = (bool) $this->settings->get('ps_export_confirm', null);
385 $this->export_confirm_group = (bool) $this->settings->get('ps_export_confirm_group', null);
386 $this->export_confirm_learning_sequence = (bool) $this->settings->get('ps_export_confirm_learning_sequence', null);
387 $this->fora_statistics = (bool) $this->settings->get('enable_fora_statistics', null);
388 $this->anonymous_fora = (bool) $this->settings->get('enable_anonymous_fora', null);
389 $this->show_grp_access_times = (bool) $this->settings->get('ps_access_times', null);
390 $this->show_crs_access_times = (bool) $this->settings->get('ps_crs_access_times', null);
391 $this->show_lso_access_times = (bool) $this->settings->get('ps_lso_access_times', null);
392 $this->rbac_log = (bool) $this->settings->get('rbac_log', null);
393 $this->rbac_log_age = (int) $this->settings->get('rbac_log_age', "6");
394 $this->sahs_protocol_data = (int) $this->settings->get('enable_sahs_pd', "0");
395 $this->export_scorm = (bool) $this->settings->get('ps_export_scorm', null);
396 $this->enableParticipantsListInCourses((bool) $this->settings->get(
397 'participants_list_courses',
398 (string) $this->participantsListInCoursesEnabled()
399 ));
400 $this->enableCommentsExport((bool) $this->settings->get('comments_export', null));
401 $this->participants_list_prg_enabled = (bool) $this->settings->get('ps_export_prg', null);
402 }
403
408 public function validate(): int
409 {
410 return 0;
411 }
412
413 public function enabledSahsProtocolData(): int
414 {
415 return (int) $this->sahs_protocol_data;
416 }
417
418 public function enableSahsProtocolData(int $status): void
419 {
420 $this->sahs_protocol_data = (int) $status;
421 }
422
423 // show and export protocol data with name
424 public function enabledExportSCORM(): bool
425 {
426 return $this->export_scorm;
427 }
428
429 public function enableExportSCORM(int $a_status): void
430 {
431 $this->export_scorm = (bool) $a_status;
432 }
433
437 public function enableCommentsExport(bool $a_status): void
438 {
439 $this->comments_export = (bool) $a_status;
440 }
441
446 public function enabledCommentsExport(): bool
447 {
449 }
450}
User class.
static _lookupType(int $id, bool $reference=false)
Singleton class that stores all privacy settings.
enableCourseExport(bool $a_status)
enabledRbacLog()
read access to property enable rbac log
setGroupConfirmationRequired(bool $a_status)
enableGroupExport(bool $a_status)
showCourseAccessTimes(bool $a_status)
show course access times
enabledGroupAccessTimes()
check if group access time are visible
__construct()
Private constructor: use _getInstance() @access private.
enableAnonymousFora(bool $a_status)
write access to property anonymous fora
showGroupAccessTimes(bool $a_status)
Show group last access times.
enableParticipantsListInCourses(bool $a_status)
validate()
validate settings
enableRbacLog(bool $a_status)
write access to property rbac_log
setCourseConfirmationRequired(bool $a_status)
enablePRGUserExport(bool $status=false)
enableCommentsExport(bool $a_status)
Enable comments export.
enableExportSCORM(int $a_status)
showLearningSequenceAccessTimes(bool $a_status)
show lso access times
enableLearningSequenceExport(bool $a_status)
enabledCourseAccessTimes()
check if access time are enabled in courses
enabledForaStatistics()
read access to property enable fora statistics
enabledCommentsExport()
Enable comments export.
confirmationRequired(string $a_type)
enabledAnonymousFora()
read access to property enable anonymous fora
setLearningSequenceConfirmationRequired(bool $a_status)
static ilPrivacySettings $instance
checkExportAccess(int $a_ref_id, int $a_user_id=0)
Check if a user has the permission to access approved user profile fields, course related user data a...
enabledLearningSequenceAccessTimes()
check if access time are enabled in lso
setRbacLogAge(int $a_age)
write access to property rbac log age
enabledAccessTimesByType(string $a_obj_type)
enableForaStatistics(bool $a_status)
write access to property fora statitics
getRbacLogAge()
read access to property rbac log age
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
ILIAS Setting Class.
const SYSTEM_FOLDER_ID
Definition: constants.php:35
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26