ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 private $rbac_log;
50 private $ref_id;
53
61 private function __construct()
62 {
63 global $ilSetting,$ilDB;
64
65 $this->db = $ilDB;
66 $this->settings = $ilSetting;
67
68 $this->read();
69 }
70
77 public static function _getInstance()
78 {
79 if (is_object(self::$instance)) {
80 return self::$instance;
81 }
82 return self::$instance = new ilPrivacySettings();
83 }
84
85 public function getPrivacySettingsRefId()
86 {
87 return $this->ref_id;
88 }
89
90 public function enabledCourseExport()
91 {
93 }
94
95 public function enabledGroupExport()
96 {
98 }
99
106 public function checkExportAccess($a_ref_id, $a_user_id = 0)
107 {
108 global $ilUser,$ilAccess,$rbacsystem;
109
110 $user_id = $a_user_id ? $a_user_id : $ilUser->getId();
111
112 if (ilObject::_lookupType($a_ref_id, true) == 'crs') {
113 return $this->enabledCourseExport() and $ilAccess->checkAccessOfUser($user_id, 'manage_members', '', $a_ref_id) and $rbacsystem->checkAccessOfUser($user_id, 'export_member_data', $this->getPrivacySettingsRefId());
114 } else {
115 return $this->enabledGroupExport() and $ilAccess->checkAccessOfUser($user_id, 'manage_members', '', $a_ref_id) and $rbacsystem->checkAccessOfUser($user_id, 'export_member_data', $this->getPrivacySettingsRefId());
116 }
117 }
118
119 public function enableCourseExport($a_status)
120 {
121 $this->export_course = (bool) $a_status;
122 }
123
124 public function enableGroupExport($a_status)
125 {
126 $this->export_group = (bool) $a_status;
127 }
128
133 public function enableForaStatistics($a_status)
134 {
135 $this->fora_statistics = (bool) $a_status;
136 }
137
142 public function enabledForaStatistics()
143 {
145 }
146
151 public function enableAnonymousFora($a_status)
152 {
153 $this->anonymous_fora = (bool) $a_status;
154 }
155
160 public function enabledAnonymousFora()
161 {
163 }
164
169 public function enableRbacLog($a_status)
170 {
171 $this->rbac_log = (bool) $a_status;
172 }
173
178 public function enabledRbacLog()
179 {
180 return $this->rbac_log;
181 }
182
187 public function setRbacLogAge($a_age)
188 {
189 $this->rbac_log_age = (int) $a_age;
190 }
191
196 public function getRbacLogAge()
197 {
198 return $this->rbac_log_age;
199 }
200
202 {
203 switch ($a_type) {
204 case 'crs':
205 return $this->courseConfirmationRequired();
206
207 case 'grp':
208 return $this->groupConfirmationRequired();
209 }
210 return false;
211 }
212
214 {
216 }
217
219 {
221 }
222
223 public function setCourseConfirmationRequired($a_status)
224 {
225 $this->export_confirm_course = (bool) $a_status;
226 }
227
228 public function setGroupConfirmationRequired($a_status)
229 {
230 $this->export_confirm_group = (bool) $a_status;
231 }
232
240 public function showGroupAccessTimes($a_status)
241 {
242 $this->show_grp_access_times = $a_status;
243 }
244
251 public function enabledGroupAccessTimes()
252 {
253 return (bool) $this->show_grp_access_times;
254 }
255
263 public function showCourseAccessTimes($a_status)
264 {
265 $this->show_crs_access_times = $a_status;
266 }
267
274 public function enabledCourseAccessTimes()
275 {
276 return (bool) $this->show_crs_access_times;
277 }
278
284 public function enabledAccessTimesByType($a_obj_type)
285 {
286 switch ($a_obj_type) {
287 case 'crs':
288 return $this->enabledCourseAccessTimes();
289
290 case 'grp':
291 return $this->enabledGroupAccessTimes();
292 }
293 }
294
300 public function save()
301 {
302 $this->settings->set('ps_export_confirm', (bool) $this->courseConfirmationRequired());
303 $this->settings->set('ps_export_confirm_group', (bool) $this->groupConfirmationRequired());
304 $this->settings->set('ps_export_course', (bool) $this->enabledCourseExport());
305 $this->settings->set('ps_export_group', (bool) $this->enabledGroupExport());
306 $this->settings->set('enable_fora_statistics', (bool) $this->enabledForaStatistics());
307 $this->settings->set('enable_anonymous_fora', (bool) $this->enabledAnonymousFora());
308 $this->settings->set('ps_access_times', (bool) $this->enabledGroupAccessTimes());
309 $this->settings->set('ps_crs_access_times', (bool) $this->enabledCourseAccessTimes());
310 $this->settings->set('rbac_log', (bool) $this->enabledRbacLog());
311 $this->settings->set('rbac_log_age', (int) $this->getRbacLogAge());
312 $this->settings->set('enable_sahs_pd', (int) $this->enabledSahsProtocolData());
313 $this->settings->set('ps_export_scorm', (bool) $this->enabledExportSCORM());
314 }
322 private function read()
323 {
324 global $ilDB;
325
326 $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data " .
327 "WHERE tree.parent = " . $ilDB->quote(SYSTEM_FOLDER_ID, 'integer') . " " .
328 "AND object_data.type = 'ps' " .
329 "AND object_reference.ref_id = tree.child " .
330 "AND object_reference.obj_id = object_data.obj_id";
331 $res = $this->db->query($query);
333 $this->ref_id = $row["ref_id"];
334
335 $this->export_course = (bool) $this->settings->get('ps_export_course', false);
336 $this->export_group = (bool) $this->settings->get('ps_export_group', false);
337 $this->export_confirm_course = (bool) $this->settings->get('ps_export_confirm', false);
338 $this->export_confirm_group = (bool) $this->settings->get('ps_export_confirm_group', false);
339 $this->fora_statistics = (bool) $this->settings->get('enable_fora_statistics', false);
340 $this->anonymous_fora = (bool) $this->settings->get('enable_anonymous_fora', false);
341 $this->show_grp_access_times = (bool) $this->settings->get('ps_access_times', false);
342 $this->show_crs_access_times = (bool) $this->settings->get('ps_crs_access_times', false);
343 $this->rbac_log = (bool) $this->settings->get('rbac_log', false);
344 $this->rbac_log_age = (int) $this->settings->get('rbac_log_age', 6);
345 $this->sahs_protocol_data = (int) $this->settings->get('enable_sahs_pd', 0);
346 $this->export_scorm = (bool) $this->settings->get('ps_export_scorm', false);
347 }
348
354 public function validate()
355 {
356 return 0;
357 }
358
359 public function enabledSahsProtocolData()
360 {
361 return (int) $this->sahs_protocol_data;
362 }
363 public function enableSahsProtocolData($status)
364 {
365 $this->sahs_protocol_data = (int) $status;
366 }
367
368 // show and export protocol data with name
369 public function enabledExportSCORM()
370 {
371 return $this->export_scorm;
372 }
373 public function enableExportSCORM($a_status)
374 {
375 $this->export_scorm = (bool) $a_status;
376 }
377}
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()
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
enabledAccessTimesByType($a_obj_type)
Check if access time are enabled for a specific type.
static _getInstance()
Get instance of ilPrivacySettings.
enabledAnonymousFora()
read access to property enable anonymous fora
setCourseConfirmationRequired($a_status)
enableAnonymousFora($a_status)
write access to property anonymous fora
getRbacLogAge()
read access to property rbac log age
global $ilSetting
Definition: privfeed.php:17
$query
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
global $ilDB
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92