ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
40  private $export_course;
41  private $export_group;
46 
51 
53  private $anonymous_fora;
54  private $rbac_log;
55  private $rbac_log_age;
59  private $ref_id;
61  private $export_scorm;
62 
70  private function __construct()
71  {
72  global $DIC;
73 
74  $ilSetting = $DIC['ilSetting'];
75  $ilDB = $DIC['ilDB'];
76 
77  $this->db = $ilDB;
78  $this->settings = $ilSetting;
79 
80  $this->read();
81  }
82 
89  public static function _getInstance()
90  {
91  if (is_object(self::$instance)) {
92  return self::$instance;
93  }
94  return self::$instance = new ilPrivacySettings();
95  }
96 
97  public function getPrivacySettingsRefId()
98  {
99  return $this->ref_id;
100  }
101 
102  public function enabledCourseExport()
103  {
104  return $this->export_course;
105  }
106 
107  public function enabledGroupExport()
108  {
109  return $this->export_group;
110  }
111 
113  {
115  }
116 
121  {
123  }
124 
128  public function enableParticipantsListInCourses($a_status)
129  {
130  $this->participants_list_course_enabled = $a_status;
131  }
132 
139  public function checkExportAccess($a_ref_id, $a_user_id = 0)
140  {
141  global $DIC;
142 
143  $ilUser = $DIC['ilUser'];
144  $ilAccess = $DIC['ilAccess'];
145  $rbacsystem = $DIC['rbacsystem'];
146 
147  $user_id = $a_user_id ? $a_user_id : $ilUser->getId();
148 
149  if (ilObject::_lookupType($a_ref_id, true) == 'crs') {
150  return $this->enabledCourseExport() and $ilAccess->checkAccessOfUser($user_id, 'manage_members', '', $a_ref_id) and $rbacsystem->checkAccessOfUser($user_id, 'export_member_data', $this->getPrivacySettingsRefId());
151  } elseif (ilObject::_lookupType($a_ref_id, true) == 'grp') {
152  return $this->enabledGroupExport() and $ilAccess->checkAccessOfUser($user_id, 'manage_members', '', $a_ref_id) and $rbacsystem->checkAccessOfUser($user_id, 'export_member_data', $this->getPrivacySettingsRefId());
153  } elseif (ilObject::_lookupType($a_ref_id, true) == 'lso') {
154  return $this->enabledLearningSequenceExport() and $ilAccess->checkAccessOfUser($user_id, 'manage_members', '', $a_ref_id) and $rbacsystem->checkAccessOfUser($user_id, 'export_member_data', $this->getPrivacySettingsRefId());
155  }
156  }
157 
158  public function enableCourseExport($a_status)
159  {
160  $this->export_course = (bool) $a_status;
161  }
162 
163  public function enableGroupExport($a_status)
164  {
165  $this->export_group = (bool) $a_status;
166  }
167 
168  public function enableLearningSequenceExport($a_status)
169  {
170  $this->export_learning_sequence = (bool) $a_status;
171  }
172 
177  public function enableForaStatistics($a_status)
178  {
179  $this->fora_statistics = (bool) $a_status;
180  }
181 
186  public function enabledForaStatistics()
187  {
188  return $this->fora_statistics;
189  }
190 
195  public function enableAnonymousFora($a_status)
196  {
197  $this->anonymous_fora = (bool) $a_status;
198  }
199 
204  public function enabledAnonymousFora()
205  {
206  return $this->anonymous_fora;
207  }
208 
213  public function enableRbacLog($a_status)
214  {
215  $this->rbac_log = (bool) $a_status;
216  }
217 
222  public function enabledRbacLog()
223  {
224  return $this->rbac_log;
225  }
226 
231  public function setRbacLogAge($a_age)
232  {
233  $this->rbac_log_age = (int) $a_age;
234  }
235 
240  public function getRbacLogAge()
241  {
242  return $this->rbac_log_age;
243  }
244 
245  public function confirmationRequired($a_type)
246  {
247  switch ($a_type) {
248  case 'crs':
249  return $this->courseConfirmationRequired();
250 
251  case 'grp':
252  return $this->groupConfirmationRequired();
253 
254  case 'lso':
255  return $this->learningSequenceConfirmationRequired();
256  }
257  return false;
258  }
259 
260  public function courseConfirmationRequired()
261  {
263  }
264 
265  public function groupConfirmationRequired()
266  {
268  }
269 
271  {
273  }
274 
275  public function setCourseConfirmationRequired($a_status)
276  {
277  $this->export_confirm_course = (bool) $a_status;
278  }
279 
280  public function setGroupConfirmationRequired($a_status)
281  {
282  $this->export_confirm_group = (bool) $a_status;
283  }
284 
285  public function setLearningSequenceConfirmationRequired($a_status)
286  {
287  $this->export_confirm_learning_sequence = (bool) $a_status;
288  }
289 
297  public function showGroupAccessTimes($a_status)
298  {
299  $this->show_grp_access_times = $a_status;
300  }
301 
308  public function enabledGroupAccessTimes()
309  {
310  return (bool) $this->show_grp_access_times;
311  }
312 
320  public function showCourseAccessTimes($a_status)
321  {
322  $this->show_crs_access_times = $a_status;
323  }
324 
332  {
333  return (bool) $this->show_lso_access_times;
334  }
335 
343  public function showLearningSequenceAccessTimes($a_status)
344  {
345  $this->show_lso_access_times = $a_status;
346  }
347 
354  public function enabledCourseAccessTimes()
355  {
356  return (bool) $this->show_crs_access_times;
357  }
358 
364  public function enabledAccessTimesByType($a_obj_type)
365  {
366  switch ($a_obj_type) {
367  case 'crs':
368  return $this->enabledCourseAccessTimes();
369 
370  case 'grp':
371  return $this->enabledGroupAccessTimes();
372  }
373  }
374 
380  public function save()
381  {
382  $this->settings->set('ps_export_confirm', (bool) $this->courseConfirmationRequired());
383  $this->settings->set('ps_export_confirm_group', (bool) $this->groupConfirmationRequired());
384  $this->settings->set('ps_export_confirm_learning_sequence', (bool) $this->learningSequenceConfirmationRequired());
385  $this->settings->set('ps_export_course', (bool) $this->enabledCourseExport());
386  $this->settings->set('ps_export_group', (bool) $this->enabledGroupExport());
387  $this->settings->set('ps_export_learning_sequence', (bool) $this->enabledLearningSequenceExport());
388  $this->settings->set('enable_fora_statistics', (bool) $this->enabledForaStatistics());
389  $this->settings->set('enable_anonymous_fora', (bool) $this->enabledAnonymousFora());
390  $this->settings->set('ps_access_times', (bool) $this->enabledGroupAccessTimes());
391  $this->settings->set('ps_crs_access_times', (bool) $this->enabledCourseAccessTimes());
392  $this->settings->set('rbac_log', (bool) $this->enabledRbacLog());
393  $this->settings->set('rbac_log_age', (int) $this->getRbacLogAge());
394  $this->settings->set('enable_sahs_pd', (int) $this->enabledSahsProtocolData());
395  $this->settings->set('ps_export_scorm', (bool) $this->enabledExportSCORM());
396 
397  $this->settings->set('participants_list_courses', (bool) $this->participantsListInCoursesEnabled());
398  }
406  private function read()
407  {
408  global $DIC;
409 
410  $ilDB = $DIC['ilDB'];
411 
412  $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data " .
413  "WHERE tree.parent = " . $ilDB->quote(SYSTEM_FOLDER_ID, 'integer') . " " .
414  "AND object_data.type = 'ps' " .
415  "AND object_reference.ref_id = tree.child " .
416  "AND object_reference.obj_id = object_data.obj_id";
417  $res = $this->db->query($query);
419  $this->ref_id = $row["ref_id"];
420 
421  $this->export_course = (bool) $this->settings->get('ps_export_course', false);
422  $this->export_group = (bool) $this->settings->get('ps_export_group', false);
423  $this->export_confirm_course = (bool) $this->settings->get('ps_export_confirm', false);
424  $this->export_confirm_group = (bool) $this->settings->get('ps_export_confirm_group', false);
425  $this->fora_statistics = (bool) $this->settings->get('enable_fora_statistics', false);
426  $this->anonymous_fora = (bool) $this->settings->get('enable_anonymous_fora', false);
427  $this->show_grp_access_times = (bool) $this->settings->get('ps_access_times', false);
428  $this->show_crs_access_times = (bool) $this->settings->get('ps_crs_access_times', false);
429  $this->rbac_log = (bool) $this->settings->get('rbac_log', false);
430  $this->rbac_log_age = (int) $this->settings->get('rbac_log_age', 6);
431  $this->sahs_protocol_data = (int) $this->settings->get('enable_sahs_pd', 0);
432  $this->export_scorm = (bool) $this->settings->get('ps_export_scorm', false);
433  $this->enableParticipantsListInCourses((bool) $this->settings->get('participants_list_courses', $this->participantsListInCoursesEnabled()));
434  }
435 
441  public function validate()
442  {
443  return 0;
444  }
445 
446  public function enabledSahsProtocolData()
447  {
448  return (int) $this->sahs_protocol_data;
449  }
450  public function enableSahsProtocolData($status)
451  {
452  $this->sahs_protocol_data = (int) $status;
453  }
454 
455  // show and export protocol data with name
456  public function enabledExportSCORM()
457  {
458  return $this->export_scorm;
459  }
460  public function enableExportSCORM($a_status)
461  {
462  $this->export_scorm = (bool) $a_status;
463  }
464 }
enabledGroupAccessTimes()
check if group access time are visible
__construct()
Private constructor: use _getInstance()
settings()
Definition: settings.php:2
enabledCourseAccessTimes()
check if access time are enabled in courses
showCourseAccessTimes($a_status)
show course access times
global $DIC
Definition: saml.php:7
validate()
validate settings
showLearningSequenceAccessTimes($a_status)
show lso access times
enableForaStatistics($a_status)
write access to property fora statitics
enableAnonymousFora($a_status)
write access to property anonymous fora
$a_type
Definition: workflow.php:92
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...
foreach($_POST as $key=> $value) $res
setLearningSequenceConfirmationRequired($a_status)
Singleton class that stores all privacy settings.
showGroupAccessTimes($a_status)
Show group last access times.
enabledForaStatistics()
read access to property enable fora statistics
$ilUser
Definition: imgupload.php:18
$query
enabledRbacLog()
read access to property enable rbac log
static _lookupType($a_id, $a_reference=false)
lookup object type
$row
enabledAnonymousFora()
read access to property enable anonymous fora
global $ilSetting
Definition: privfeed.php:17
global $ilDB
enabledAccessTimesByType($a_obj_type)
Check if access time are enabled for a specific type.
setCourseConfirmationRequired($a_status)
static _getInstance()
Get instance of ilPrivacySettings.
setRbacLogAge($a_age)
write access to property rbac log age
enableParticipantsListInCourses($a_status)
getRbacLogAge()
read access to property rbac log age
enabledLearningSequenceAccessTimes()
check if access time are enabled in lso
enableRbacLog($a_status)
write access to property rbac_log