ILIAS  release_8 Revision v8.24
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
42 private bool $fora_statistics;
43 private bool $anonymous_fora;
44 private bool $rbac_log;
45 private int $rbac_log_age;
49 private int $ref_id;
51 private bool $export_scorm;
52 private bool $comments_export;
53
59 private function __construct()
60 {
61 global $DIC;
62
63 $this->settings = $DIC->settings();
64 $this->db = $DIC->database();
65 $this->user = $DIC->user();
66
67 $this->read();
68 }
69
70 public static function getInstance(): ilPrivacySettings
71 {
72 if (!self::$instance instanceof ilPrivacySettings) {
73 self::$instance = new self();
74 }
75 return self::$instance;
76 }
77
78 public function getPrivacySettingsRefId(): int
79 {
80 return $this->ref_id;
81 }
82
83 public function enabledCourseExport(): bool
84 {
86 }
87
88 public function enabledGroupExport(): bool
89 {
91 }
92
93 public function enabledLearningSequenceExport(): bool
94 {
96 }
97
98 public function participantsListInCoursesEnabled(): bool
99 {
101 }
102
103 public function enableParticipantsListInCourses(bool $a_status): void
104 {
105 $this->participants_list_course_enabled = $a_status;
106 }
107
111 public function checkExportAccess(int $a_ref_id, int $a_user_id = 0): bool
112 {
113 global $DIC;
114
115 $ilAccess = $DIC->access();
116 $rbacsystem = $DIC->rbac()->system();
117
118 $user_id = $a_user_id ?: $this->user->getId();
119 if (ilObject::_lookupType($a_ref_id, true) == 'crs') {
120 return $this->enabledCourseExport() and $ilAccess->checkAccessOfUser(
121 $user_id,
122 'manage_members',
123 '',
124 $a_ref_id
125 ) and $rbacsystem->checkAccessOfUser(
126 $user_id,
127 'export_member_data',
129 );
130 } elseif (ilObject::_lookupType($a_ref_id, true) == 'grp') {
131 return $this->enabledGroupExport() and $ilAccess->checkAccessOfUser(
132 $user_id,
133 'manage_members',
134 '',
135 $a_ref_id
136 ) and $rbacsystem->checkAccessOfUser(
137 $user_id,
138 'export_member_data',
140 );
141 } elseif (ilObject::_lookupType($a_ref_id, true) == 'lso') {
142 return $this->enabledLearningSequenceExport() and $ilAccess->checkAccessOfUser(
143 $user_id,
144 'manage_members',
145 '',
146 $a_ref_id
147 ) and $rbacsystem->checkAccessOfUser(
148 $user_id,
149 'export_member_data',
151 );
152 }
153 return false;
154 }
155
156 public function enableCourseExport(bool $a_status): void
157 {
158 $this->export_course = $a_status;
159 }
160
161 public function enableGroupExport(bool $a_status): void
162 {
163 $this->export_group = $a_status;
164 }
165
166 public function enableLearningSequenceExport(bool $a_status): void
167 {
168 $this->export_learning_sequence = $a_status;
169 }
170
174 public function enableForaStatistics(bool $a_status): void
175 {
176 $this->fora_statistics = $a_status;
177 }
178
182 public function enabledForaStatistics(): bool
183 {
185 }
186
190 public function enableAnonymousFora(bool $a_status): void
191 {
192 $this->anonymous_fora = $a_status;
193 }
194
198 public function enabledAnonymousFora(): bool
199 {
201 }
202
206 public function enableRbacLog(bool $a_status): void
207 {
208 $this->rbac_log = $a_status;
209 }
210
214 public function enabledRbacLog(): bool
215 {
216 return $this->rbac_log;
217 }
218
222 public function setRbacLogAge(int $a_age): void
223 {
224 $this->rbac_log_age = $a_age;
225 }
226
230 public function getRbacLogAge(): int
231 {
232 return $this->rbac_log_age;
233 }
234
235 public function confirmationRequired(string $a_type): bool
236 {
237 switch ($a_type) {
238 case 'crs':
239 return $this->courseConfirmationRequired();
240
241 case 'grp':
242 return $this->groupConfirmationRequired();
243
244 case 'lso':
246 }
247 return false;
248 }
249
250 public function courseConfirmationRequired(): bool
251 {
253 }
254
255 public function groupConfirmationRequired(): bool
256 {
258 }
259
261 {
263 }
264
265 public function setCourseConfirmationRequired(bool $a_status): void
266 {
267 $this->export_confirm_course = $a_status;
268 }
269
270 public function setGroupConfirmationRequired(bool $a_status): void
271 {
272 $this->export_confirm_group = (bool) $a_status;
273 }
274
275 public function setLearningSequenceConfirmationRequired(bool $a_status): void
276 {
277 $this->export_confirm_learning_sequence = $a_status;
278 }
279
283 public function showGroupAccessTimes(bool $a_status): void
284 {
285 $this->show_grp_access_times = $a_status;
286 }
287
291 public function enabledGroupAccessTimes(): bool
292 {
294 }
295
299 public function showCourseAccessTimes(bool $a_status): void
300 {
301 $this->show_crs_access_times = $a_status;
302 }
303
308 {
310 }
311
315 public function showLearningSequenceAccessTimes(bool $a_status): void
316 {
317 $this->show_lso_access_times = $a_status;
318 }
319
323 public function enabledCourseAccessTimes(): bool
324 {
326 }
327
328 public function enabledAccessTimesByType(string $a_obj_type): bool
329 {
330 switch ($a_obj_type) {
331 case 'crs':
332 return $this->enabledCourseAccessTimes();
333
334 case 'grp':
335 return $this->enabledGroupAccessTimes();
336
337 case 'lso':
339 }
340 return false;
341 }
342
346 public function save(): void
347 {
348 $this->settings->set('ps_export_confirm', (string) $this->courseConfirmationRequired());
349 $this->settings->set('ps_export_confirm_group', (string) $this->groupConfirmationRequired());
350 $this->settings->set(
351 'ps_export_confirm_learning_sequence',
353 );
354 $this->settings->set('ps_export_course', (string) $this->enabledCourseExport());
355 $this->settings->set('ps_export_group', (string) $this->enabledGroupExport());
356 $this->settings->set('ps_export_learning_sequence', (string) $this->enabledLearningSequenceExport());
357 $this->settings->set('enable_fora_statistics', (string) $this->enabledForaStatistics());
358 $this->settings->set('enable_anonymous_fora', (string) $this->enabledAnonymousFora());
359 $this->settings->set('ps_access_times', (string) $this->enabledGroupAccessTimes());
360 $this->settings->set('ps_crs_access_times', (string) $this->enabledCourseAccessTimes());
361 $this->settings->set('ps_lso_access_times', (string) $this->enabledLearningSequenceAccessTimes());
362 $this->settings->set('rbac_log', (string) $this->enabledRbacLog());
363 $this->settings->set('rbac_log_age', (string) $this->getRbacLogAge());
364 $this->settings->set('enable_sahs_pd', (string) $this->enabledSahsProtocolData());
365 $this->settings->set('ps_export_scorm', (string) $this->enabledExportSCORM());
366
367 $this->settings->set('participants_list_courses', (string) $this->participantsListInCoursesEnabled());
368 $this->settings->set('comments_export', (string) $this->enabledCommentsExport());
369 }
370
374 private function read(): void
375 {
376 $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data " .
377 "WHERE tree.parent = " . $this->db->quote(SYSTEM_FOLDER_ID, 'integer') . " " .
378 "AND object_data.type = 'ps' " .
379 "AND object_reference.ref_id = tree.child " .
380 "AND object_reference.obj_id = object_data.obj_id";
381 $res = $this->db->query($query);
382 $row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
383 $this->ref_id = (int) ($row["ref_id"] ?? 0);
384
385 $this->export_course = (bool) $this->settings->get('ps_export_course', null);
386 $this->export_group = (bool) $this->settings->get('ps_export_group', null);
387 $this->export_learning_sequence = (bool) $this->settings->get('ps_export_learning_sequence', null);
388 $this->export_confirm_course = (bool) $this->settings->get('ps_export_confirm', null);
389 $this->export_confirm_group = (bool) $this->settings->get('ps_export_confirm_group', null);
390 $this->export_confirm_learning_sequence = (bool) $this->settings->get('ps_export_confirm_learning_sequence', null);
391 $this->fora_statistics = (bool) $this->settings->get('enable_fora_statistics', null);
392 $this->anonymous_fora = (bool) $this->settings->get('enable_anonymous_fora', null);
393 $this->show_grp_access_times = (bool) $this->settings->get('ps_access_times', null);
394 $this->show_crs_access_times = (bool) $this->settings->get('ps_crs_access_times', null);
395 $this->show_lso_access_times = (bool) $this->settings->get('ps_lso_access_times', null);
396 $this->rbac_log = (bool) $this->settings->get('rbac_log', null);
397 $this->rbac_log_age = (int) $this->settings->get('rbac_log_age', "6");
398 $this->sahs_protocol_data = (int) $this->settings->get('enable_sahs_pd', "0");
399 $this->export_scorm = (bool) $this->settings->get('ps_export_scorm', null);
400 $this->enableParticipantsListInCourses((bool) $this->settings->get(
401 'participants_list_courses',
402 (string) $this->participantsListInCoursesEnabled()
403 ));
404 $this->enableCommentsExport((bool) $this->settings->get('comments_export', null));
405 }
406
411 public function validate(): int
412 {
413 return 0;
414 }
415
416 public function enabledSahsProtocolData(): int
417 {
418 return (int) $this->sahs_protocol_data;
419 }
420
421 public function enableSahsProtocolData(int $status): void
422 {
423 $this->sahs_protocol_data = (int) $status;
424 }
425
426 // show and export protocol data with name
427 public function enabledExportSCORM(): bool
428 {
429 return $this->export_scorm;
430 }
431
432 public function enableExportSCORM(int $a_status): void
433 {
434 $this->export_scorm = (bool) $a_status;
435 }
436
440 public function enableCommentsExport(bool $a_status): void
441 {
442 $this->comments_export = (bool) $a_status;
443 }
444
449 public function enabledCommentsExport(): bool
450 {
452 }
453}
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)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
$query