ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPrivacySettings.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
35{
36 private static $instance = null;
37 private $db;
38 private $settings;
39
46
51
54 private $rbac_log;
59 private $ref_id;
62
67
75 private function __construct()
76 {
77 global $DIC;
78
79 $ilSetting = $DIC['ilSetting'];
80 $ilDB = $DIC['ilDB'];
81
82 $this->db = $ilDB;
83 $this->settings = $ilSetting;
84
85 $this->read();
86 }
87
94 public static function _getInstance()
95 {
96 if (is_object(self::$instance)) {
97 return self::$instance;
98 }
99 return self::$instance = new ilPrivacySettings();
100 }
101
102 public function getPrivacySettingsRefId()
103 {
104 return $this->ref_id;
105 }
106
107 public function enabledCourseExport()
108 {
110 }
111
112 public function enabledGroupExport()
113 {
114 return $this->export_group;
115 }
116
118 {
120 }
121
126 {
128 }
129
133 public function enableParticipantsListInCourses($a_status)
134 {
135 $this->participants_list_course_enabled = $a_status;
136 }
137
144 public function checkExportAccess($a_ref_id, $a_user_id = 0)
145 {
146 global $DIC;
147
148 $ilUser = $DIC['ilUser'];
149 $ilAccess = $DIC['ilAccess'];
150 $rbacsystem = $DIC['rbacsystem'];
151
152 $user_id = $a_user_id ? $a_user_id : $ilUser->getId();
153
154 if (ilObject::_lookupType($a_ref_id, true) == 'crs') {
155 return $this->enabledCourseExport() and $ilAccess->checkAccessOfUser($user_id, 'manage_members', '', $a_ref_id) and $rbacsystem->checkAccessOfUser($user_id, 'export_member_data', $this->getPrivacySettingsRefId());
156 } elseif (ilObject::_lookupType($a_ref_id, true) == 'grp') {
157 return $this->enabledGroupExport() and $ilAccess->checkAccessOfUser($user_id, 'manage_members', '', $a_ref_id) and $rbacsystem->checkAccessOfUser($user_id, 'export_member_data', $this->getPrivacySettingsRefId());
158 } elseif (ilObject::_lookupType($a_ref_id, true) == 'lso') {
159 return $this->enabledLearningSequenceExport() and $ilAccess->checkAccessOfUser($user_id, 'manage_members', '', $a_ref_id) and $rbacsystem->checkAccessOfUser($user_id, 'export_member_data', $this->getPrivacySettingsRefId());
160 }
161 }
162
163 public function enableCourseExport($a_status)
164 {
165 $this->export_course = (bool) $a_status;
166 }
167
168 public function enableGroupExport($a_status)
169 {
170 $this->export_group = (bool) $a_status;
171 }
172
173 public function enableLearningSequenceExport($a_status)
174 {
175 $this->export_learning_sequence = (bool) $a_status;
176 }
177
182 public function enableForaStatistics($a_status)
183 {
184 $this->fora_statistics = (bool) $a_status;
185 }
186
191 public function enabledForaStatistics()
192 {
194 }
195
200 public function enableAnonymousFora($a_status)
201 {
202 $this->anonymous_fora = (bool) $a_status;
203 }
204
209 public function enabledAnonymousFora()
210 {
212 }
213
218 public function enableRbacLog($a_status)
219 {
220 $this->rbac_log = (bool) $a_status;
221 }
222
227 public function enabledRbacLog()
228 {
229 return $this->rbac_log;
230 }
231
236 public function setRbacLogAge($a_age)
237 {
238 $this->rbac_log_age = (int) $a_age;
239 }
240
245 public function getRbacLogAge()
246 {
247 return $this->rbac_log_age;
248 }
249
250 public function confirmationRequired($a_type)
251 {
252 switch ($a_type) {
253 case 'crs':
254 return $this->courseConfirmationRequired();
255
256 case 'grp':
257 return $this->groupConfirmationRequired();
258
259 case 'lso':
261 }
262 return false;
263 }
264
266 {
268 }
269
271 {
273 }
274
276 {
278 }
279
280 public function setCourseConfirmationRequired($a_status)
281 {
282 $this->export_confirm_course = (bool) $a_status;
283 }
284
285 public function setGroupConfirmationRequired($a_status)
286 {
287 $this->export_confirm_group = (bool) $a_status;
288 }
289
291 {
292 $this->export_confirm_learning_sequence = (bool) $a_status;
293 }
294
302 public function showGroupAccessTimes($a_status)
303 {
304 $this->show_grp_access_times = $a_status;
305 }
306
313 public function enabledGroupAccessTimes()
314 {
315 return (bool) $this->show_grp_access_times;
316 }
317
325 public function showCourseAccessTimes($a_status)
326 {
327 $this->show_crs_access_times = $a_status;
328 }
329
337 {
338 return (bool) $this->show_lso_access_times;
339 }
340
348 public function showLearningSequenceAccessTimes($a_status)
349 {
350 $this->show_lso_access_times = $a_status;
351 }
352
359 public function enabledCourseAccessTimes()
360 {
361 return (bool) $this->show_crs_access_times;
362 }
363
369 public function enabledAccessTimesByType($a_obj_type)
370 {
371 switch ($a_obj_type) {
372 case 'crs':
373 return $this->enabledCourseAccessTimes();
374
375 case 'grp':
376 return $this->enabledGroupAccessTimes();
377 }
378 }
379
385 public function save()
386 {
387 $this->settings->set('ps_export_confirm', (bool) $this->courseConfirmationRequired());
388 $this->settings->set('ps_export_confirm_group', (bool) $this->groupConfirmationRequired());
389 $this->settings->set('ps_export_confirm_learning_sequence', (bool) $this->learningSequenceConfirmationRequired());
390 $this->settings->set('ps_export_course', (bool) $this->enabledCourseExport());
391 $this->settings->set('ps_export_group', (bool) $this->enabledGroupExport());
392 $this->settings->set('ps_export_learning_sequence', (bool) $this->enabledLearningSequenceExport());
393 $this->settings->set('enable_fora_statistics', (bool) $this->enabledForaStatistics());
394 $this->settings->set('enable_anonymous_fora', (bool) $this->enabledAnonymousFora());
395 $this->settings->set('ps_access_times', (bool) $this->enabledGroupAccessTimes());
396 $this->settings->set('ps_crs_access_times', (bool) $this->enabledCourseAccessTimes());
397 $this->settings->set('rbac_log', (bool) $this->enabledRbacLog());
398 $this->settings->set('rbac_log_age', (int) $this->getRbacLogAge());
399 $this->settings->set('enable_sahs_pd', (int) $this->enabledSahsProtocolData());
400 $this->settings->set('ps_export_scorm', (bool) $this->enabledExportSCORM());
401
402 $this->settings->set('participants_list_courses', (bool) $this->participantsListInCoursesEnabled());
403 $this->settings->set('comments_export', (bool) $this->enabledCommentsExport());
404 }
412 private function read()
413 {
414 global $DIC;
415
416 $ilDB = $DIC['ilDB'];
417
418 $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data " .
419 "WHERE tree.parent = " . $ilDB->quote(SYSTEM_FOLDER_ID, 'integer') . " " .
420 "AND object_data.type = 'ps' " .
421 "AND object_reference.ref_id = tree.child " .
422 "AND object_reference.obj_id = object_data.obj_id";
423 $res = $this->db->query($query);
424 $row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
425 $this->ref_id = $row["ref_id"];
426
427 $this->export_course = (bool) $this->settings->get('ps_export_course', false);
428 $this->export_group = (bool) $this->settings->get('ps_export_group', false);
429 $this->export_confirm_course = (bool) $this->settings->get('ps_export_confirm', false);
430 $this->export_confirm_group = (bool) $this->settings->get('ps_export_confirm_group', false);
431 $this->fora_statistics = (bool) $this->settings->get('enable_fora_statistics', false);
432 $this->anonymous_fora = (bool) $this->settings->get('enable_anonymous_fora', false);
433 $this->show_grp_access_times = (bool) $this->settings->get('ps_access_times', false);
434 $this->show_crs_access_times = (bool) $this->settings->get('ps_crs_access_times', false);
435 $this->rbac_log = (bool) $this->settings->get('rbac_log', false);
436 $this->rbac_log_age = (int) $this->settings->get('rbac_log_age', 6);
437 $this->sahs_protocol_data = (int) $this->settings->get('enable_sahs_pd', 0);
438 $this->export_scorm = (bool) $this->settings->get('ps_export_scorm', false);
439 $this->enableParticipantsListInCourses((bool) $this->settings->get('participants_list_courses', $this->participantsListInCoursesEnabled()));
440 $this->enableCommentsExport((bool) $this->settings->get('comments_export', false));
441 }
442
448 public function validate()
449 {
450 return 0;
451 }
452
453 public function enabledSahsProtocolData()
454 {
455 return (int) $this->sahs_protocol_data;
456 }
457 public function enableSahsProtocolData($status)
458 {
459 $this->sahs_protocol_data = (int) $status;
460 }
461
462 // show and export protocol data with name
463 public function enabledExportSCORM()
464 {
465 return $this->export_scorm;
466 }
467 public function enableExportSCORM($a_status)
468 {
469 $this->export_scorm = (bool) $a_status;
470 }
471
476 public function enableCommentsExport($a_status)
477 {
478 $this->comments_export = (bool) $a_status;
479 }
480
485 public function enabledCommentsExport(): bool
486 {
488 }
489
490}
An exception for terminatinating execution or to throw for unit testing.
static _lookupType($a_id, $a_reference=false)
lookup object type
Singleton class that stores all privacy settings.
enabledRbacLog()
read access to property enable rbac log
setRbacLogAge($a_age)
write access to property rbac log age
enabledGroupAccessTimes()
check if group access time are visible
__construct()
Private constructor: use _getInstance()
enableCommentsExport($a_status)
Enable comments export.
enableForaStatistics($a_status)
write access to property fora statitics
validate()
validate settings
showGroupAccessTimes($a_status)
Show group last access times.
enableRbacLog($a_status)
write access to property rbac_log
checkExportAccess($a_ref_id, $a_user_id=0)
Check if a user has the permission to access approved user profile fields, course related user data a...
showCourseAccessTimes($a_status)
show course access times
enabledCourseAccessTimes()
check if access time are enabled in courses
enabledForaStatistics()
read access to property enable fora statistics
enabledCommentsExport()
Enable comments export.
enabledAccessTimesByType($a_obj_type)
Check if access time are enabled for a specific type.
enableParticipantsListInCourses($a_status)
static _getInstance()
Get instance of ilPrivacySettings.
enabledAnonymousFora()
read access to property enable anonymous fora
showLearningSequenceAccessTimes($a_status)
show lso access times
setLearningSequenceConfirmationRequired($a_status)
enabledLearningSequenceAccessTimes()
check if access time are enabled in lso
setCourseConfirmationRequired($a_status)
enableAnonymousFora($a_status)
write access to property anonymous fora
getRbacLogAge()
read access to property rbac log age
const SYSTEM_FOLDER_ID
Definition: constants.php:33
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
global $ilSetting
Definition: privfeed.php:17
$query
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
global $ilDB