ILIAS  release_4-3 Revision
 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 
60  private function __construct()
61  {
62  global $ilSetting,$ilDB;
63 
64  $this->db = $ilDB;
65  $this->settings = $ilSetting;
66 
67  $this->read();
68  }
69 
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 save()
290  {
291  $this->settings->set('ps_export_confirm',(bool) $this->courseConfirmationRequired());
292  $this->settings->set('ps_export_confirm_group',(bool) $this->groupConfirmationRequired());
293  $this->settings->set('ps_export_course',(bool) $this->enabledCourseExport());
294  $this->settings->set('ps_export_group',(bool) $this->enabledGroupExport());
295  $this->settings->set('enable_fora_statistics',(bool) $this->enabledForaStatistics());
296  $this->settings->set('enable_anonymous_fora',(bool) $this->enabledAnonymousFora());
297  $this->settings->set('ps_access_times',(bool) $this->enabledGroupAccessTimes());
298  $this->settings->set('ps_crs_access_times',(bool) $this->enabledCourseAccessTimes());
299  $this->settings->set('rbac_log',(bool) $this->enabledRbacLog());
300  $this->settings->set('rbac_log_age',(int) $this->getRbacLogAge());
301  $this->settings->set('enable_sahs_pd',(int) $this->enabledSahsProtocolData());
302 
303  }
311  private function read()
312  {
313  global $ilDB;
314 
315  $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data ".
316  "WHERE tree.parent = ".$ilDB->quote(SYSTEM_FOLDER_ID,'integer')." ".
317  "AND object_data.type = 'ps' ".
318  "AND object_reference.ref_id = tree.child ".
319  "AND object_reference.obj_id = object_data.obj_id";
320  $res = $this->db->query($query);
321  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
322  $this->ref_id = $row["ref_id"];
323 
324  $this->export_course = (bool) $this->settings->get('ps_export_course',false);
325  $this->export_group = (bool) $this->settings->get('ps_export_group',false);
326  $this->export_confirm_course = (bool) $this->settings->get('ps_export_confirm',false);
327  $this->export_confirm_group = (bool) $this->settings->get('ps_export_confirm_group',false);
328  $this->fora_statistics = (bool) $this->settings->get('enable_fora_statistics',false);
329  $this->anonymous_fora = (bool) $this->settings->get('enable_anonymous_fora',false);
330  $this->show_grp_access_times = (bool) $this->settings->get('ps_access_times',false);
331  $this->show_crs_access_times = (bool) $this->settings->get('ps_crs_access_times',false);
332  $this->rbac_log = (bool) $this->settings->get('rbac_log',false);
333  $this->rbac_log_age = (int) $this->settings->get('rbac_log_age',6);
334  $this->sahs_protocol_data = (int) $this->settings->get('enable_sahs_pd', 0);
335  }
336 
342  public function validate()
343  {
344  return 0;
345  }
346 
347  public function enabledSahsProtocolData()
348  {
349  return (int) $this->sahs_protocol_data;
350  }
351  public function enableSahsProtocolData($status)
352  {
353  $this->sahs_protocol_data = (int) $status;
354  }
355 
356 }
357 ?>