ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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;
45  private $anonymous_fora;
46  private $rbac_log;
47  private $rbac_log_age;
50  private $ref_id;
52  private $export_scorm;
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  {
81  return self::$instance;
82  }
83  return self::$instance = new ilPrivacySettings();
84  }
85 
86  public function getPrivacySettingsRefId()
87  {
88  return $this->ref_id;
89  }
90 
91  public function enabledCourseExport()
92  {
93  return $this->export_course;
94  }
95 
96  public function enabledGroupExport()
97  {
98  return $this->export_group;
99  }
100 
107  public function checkExportAccess($a_ref_id,$a_user_id = 0)
108  {
109  global $ilUser,$ilAccess,$rbacsystem;
110 
111  $user_id = $a_user_id ? $a_user_id : $ilUser->getId();
112 
113  if(ilObject::_lookupType($a_ref_id, true) == 'crs')
114  {
115  return $this->enabledCourseExport() and $ilAccess->checkAccessOfUser($user_id,'write','',$a_ref_id) and $rbacsystem->checkAccessOfUser($user_id,'export_member_data',$this->getPrivacySettingsRefId());
116  }
117  else
118  {
119  return $this->enabledGroupExport() and $ilAccess->checkAccessOfUser($user_id,'write','',$a_ref_id) and $rbacsystem->checkAccessOfUser($user_id,'export_member_data',$this->getPrivacySettingsRefId());
120  }
121  }
122 
123  public function enableCourseExport($a_status)
124  {
125  $this->export_course = (bool) $a_status;
126  }
127 
128  public function enableGroupExport($a_status)
129  {
130  $this->export_group = (bool) $a_status;
131  }
132 
137  public function enableForaStatistics ($a_status)
138  {
139  $this->fora_statistics = (bool) $a_status;
140  }
141 
146  public function enabledForaStatistics ()
147  {
148  return $this->fora_statistics;
149  }
150 
155  public function enableAnonymousFora ($a_status)
156  {
157  $this->anonymous_fora = (bool) $a_status;
158  }
159 
164  public function enabledAnonymousFora ()
165  {
166  return $this->anonymous_fora;
167  }
168 
173  public function enableRbacLog ($a_status)
174  {
175  $this->rbac_log = (bool) $a_status;
176  }
177 
182  public function enabledRbacLog ()
183  {
184  return $this->rbac_log;
185  }
186 
191  public function setRbacLogAge ($a_age)
192  {
193  $this->rbac_log_age = (int) $a_age;
194  }
195 
200  public function getRbacLogAge ()
201  {
202  return $this->rbac_log_age;
203  }
204 
205  public function confirmationRequired($a_type)
206  {
207  switch($a_type)
208  {
209  case 'crs':
210  return $this->courseConfirmationRequired();
211 
212  case 'grp':
213  return $this->groupConfirmationRequired();
214  }
215  return false;
216  }
217 
218  public function courseConfirmationRequired()
219  {
221  }
222 
223  public function groupConfirmationRequired()
224  {
226  }
227 
228  public function setCourseConfirmationRequired($a_status)
229  {
230  $this->export_confirm_course = (bool) $a_status;
231  }
232 
233  public function setGroupConfirmationRequired($a_status)
234  {
235  $this->export_confirm_group = (bool) $a_status;
236  }
237 
245  public function showGroupAccessTimes($a_status)
246  {
247  $this->show_grp_access_times = $a_status;
248  }
249 
256  public function enabledGroupAccessTimes()
257  {
258  return (bool) $this->show_grp_access_times;
259  }
260 
268  public function showCourseAccessTimes($a_status)
269  {
270  $this->show_crs_access_times = $a_status;
271  }
272 
279  public function enabledCourseAccessTimes()
280  {
281  return (bool) $this->show_crs_access_times;
282  }
283 
289  public function enabledAccessTimesByType($a_obj_type)
290  {
291  switch($a_obj_type)
292  {
293  case 'crs':
294  return $this->enabledCourseAccessTimes();
295 
296  case 'grp':
297  return $this->enabledGroupAccessTimes();
298  }
299 
300  }
301 
307  public function save()
308  {
309  $this->settings->set('ps_export_confirm',(bool) $this->courseConfirmationRequired());
310  $this->settings->set('ps_export_confirm_group',(bool) $this->groupConfirmationRequired());
311  $this->settings->set('ps_export_course',(bool) $this->enabledCourseExport());
312  $this->settings->set('ps_export_group',(bool) $this->enabledGroupExport());
313  $this->settings->set('enable_fora_statistics',(bool) $this->enabledForaStatistics());
314  $this->settings->set('enable_anonymous_fora',(bool) $this->enabledAnonymousFora());
315  $this->settings->set('ps_access_times',(bool) $this->enabledGroupAccessTimes());
316  $this->settings->set('ps_crs_access_times',(bool) $this->enabledCourseAccessTimes());
317  $this->settings->set('rbac_log',(bool) $this->enabledRbacLog());
318  $this->settings->set('rbac_log_age',(int) $this->getRbacLogAge());
319  $this->settings->set('enable_sahs_pd',(int) $this->enabledSahsProtocolData());
320  $this->settings->set('ps_export_scorm',(bool) $this->enabledExportSCORM());
321  }
329  private function read()
330  {
331  global $ilDB;
332 
333  $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data ".
334  "WHERE tree.parent = ".$ilDB->quote(SYSTEM_FOLDER_ID,'integer')." ".
335  "AND object_data.type = 'ps' ".
336  "AND object_reference.ref_id = tree.child ".
337  "AND object_reference.obj_id = object_data.obj_id";
338  $res = $this->db->query($query);
339  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
340  $this->ref_id = $row["ref_id"];
341 
342  $this->export_course = (bool) $this->settings->get('ps_export_course',false);
343  $this->export_group = (bool) $this->settings->get('ps_export_group',false);
344  $this->export_confirm_course = (bool) $this->settings->get('ps_export_confirm',false);
345  $this->export_confirm_group = (bool) $this->settings->get('ps_export_confirm_group',false);
346  $this->fora_statistics = (bool) $this->settings->get('enable_fora_statistics',false);
347  $this->anonymous_fora = (bool) $this->settings->get('enable_anonymous_fora',false);
348  $this->show_grp_access_times = (bool) $this->settings->get('ps_access_times',false);
349  $this->show_crs_access_times = (bool) $this->settings->get('ps_crs_access_times',false);
350  $this->rbac_log = (bool) $this->settings->get('rbac_log',false);
351  $this->rbac_log_age = (int) $this->settings->get('rbac_log_age',6);
352  $this->sahs_protocol_data = (int) $this->settings->get('enable_sahs_pd', 0);
353  $this->export_scorm = (bool) $this->settings->get('ps_export_scorm',false);
354  }
355 
361  public function validate()
362  {
363  return 0;
364  }
365 
366  public function enabledSahsProtocolData()
367  {
368  return (int) $this->sahs_protocol_data;
369  }
370  public function enableSahsProtocolData($status)
371  {
372  $this->sahs_protocol_data = (int) $status;
373  }
374 
375  // show and export protocol data with name
376  public function enabledExportSCORM()
377  {
378  return $this->export_scorm;
379  }
380  public function enableExportSCORM($a_status)
381  {
382  $this->export_scorm = (bool) $a_status;
383  }
384 
385 
386 }
387 ?>