ILIAS  eassessment Revision 61809
 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;
51 
59  private function __construct()
60  {
61  global $ilSetting,$ilDB;
62 
63  $this->db = $ilDB;
64  $this->settings = $ilSetting;
65 
66  $this->read();
67  }
68 
76  public static function _getInstance()
77  {
78  if(is_object(self::$instance))
79  {
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  {
92  return $this->export_course;
93  }
94 
95  public function enabledGroupExport()
96  {
97  return $this->export_group;
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::_lookupObjId(ilObject::_lookupType($a_ref_id)) == 'crs')
113  {
114  return $this->enabledCourseExport() and $ilAccess->checkAccessOfUser($user_id,'write','',$a_ref_id) and $rbacsystem->checkAccessOfUser($user_id,'export_member_data',$this->getPrivacySettingsRefId());
115  }
116  else
117  {
118  return $this->enabledGroupExport() and $ilAccess->checkAccessOfUser($user_id,'write','',$a_ref_id) and $rbacsystem->checkAccessOfUser($user_id,'export_member_data',$this->getPrivacySettingsRefId());
119  }
120  }
121 
122  public function enableCourseExport($a_status)
123  {
124  $this->export_course = (bool) $a_status;
125  }
126 
127  public function enableGroupExport($a_status)
128  {
129  $this->export_group = (bool) $a_status;
130  }
131 
136  public function enableForaStatistics ($a_status)
137  {
138  $this->fora_statistics = (bool) $a_status;
139  }
140 
145  public function enabledForaStatistics ()
146  {
147  return $this->fora_statistics;
148  }
149 
154  public function enableAnonymousFora ($a_status)
155  {
156  $this->anonymous_fora = (bool) $a_status;
157  }
158 
163  public function enabledAnonymousFora ()
164  {
165  return $this->anonymous_fora;
166  }
167 
172  public function enableRbacLog ($a_status)
173  {
174  $this->rbac_log = (bool) $a_status;
175  }
176 
181  public function enabledRbacLog ()
182  {
183  return $this->rbac_log;
184  }
185 
190  public function setRbacLogAge ($a_age)
191  {
192  $this->rbac_log_age = (int) $a_age;
193  }
194 
199  public function getRbacLogAge ()
200  {
201  return $this->rbac_log_age;
202  }
203 
204  public function confirmationRequired($a_type)
205  {
206  switch($a_type)
207  {
208  case 'crs':
209  return $this->courseConfirmationRequired();
210 
211  case 'grp':
212  return $this->groupConfirmationRequired();
213  }
214  return false;
215  }
216 
217  public function courseConfirmationRequired()
218  {
220  }
221 
222  public function groupConfirmationRequired()
223  {
225  }
226 
227  public function setCourseConfirmationRequired($a_status)
228  {
229  $this->export_confirm_course = (bool) $a_status;
230  }
231 
232  public function setGroupConfirmationRequired($a_status)
233  {
234  $this->export_confirm_group = (bool) $a_status;
235  }
236 
244  public function showGroupAccessTimes($a_status)
245  {
246  $this->show_grp_access_times = $a_status;
247  }
248 
255  public function enabledGroupAccessTimes()
256  {
257  return (bool) $this->show_grp_access_times;
258  }
259 
267  public function showCourseAccessTimes($a_status)
268  {
269  $this->show_crs_access_times = $a_status;
270  }
271 
278  public function enabledCourseAccessTimes()
279  {
280  return (bool) $this->show_crs_access_times;
281  }
282 
288  public function save()
289  {
290  $this->settings->set('ps_export_confirm',(bool) $this->courseConfirmationRequired());
291  $this->settings->set('ps_export_confirm_group',(bool) $this->groupConfirmationRequired());
292  $this->settings->set('ps_export_course',(bool) $this->enabledCourseExport());
293  $this->settings->set('ps_export_group',(bool) $this->enabledGroupExport());
294  $this->settings->set('ps_access_times',(bool) $this->enabledGroupAccessTimes());
295  $this->settings->set('ps_crs_access_times',(bool) $this->enabledCourseAccessTimes());
296  $this->settings->set('rbac_log',(bool) $this->enabledRbacLog());
297  $this->settings->set('rbac_log_age',(int) $this->getRbacLogAge());
298  }
306  private function read()
307  {
308  global $ilDB;
309 
310  $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data ".
311  "WHERE tree.parent = ".$ilDB->quote(SYSTEM_FOLDER_ID,'integer')." ".
312  "AND object_data.type = 'ps' ".
313  "AND object_reference.ref_id = tree.child ".
314  "AND object_reference.obj_id = object_data.obj_id";
315  $res = $this->db->query($query);
316  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
317  $this->ref_id = $row["ref_id"];
318 
319  $this->export_course = (bool) $this->settings->get('ps_export_course',false);
320  $this->export_group = (bool) $this->settings->get('ps_export_group',false);
321  $this->export_confirm_course = (bool) $this->settings->get('ps_export_confirm',false);
322  $this->export_confirm_group = (bool) $this->settings->get('ps_export_confirm_group',false);
323  $this->show_grp_access_times = (bool) $this->settings->get('ps_access_times',false);
324  $this->show_crs_access_times = (bool) $this->settings->get('ps_crs_access_times',false);
325  $this->rbac_log = (bool) $this->settings->get('rbac_log',false);
326  $this->rbac_log_age = (int) $this->settings->get('rbac_log_age',6);
327 
328  }
329 
335  public function validate()
336  {
337  return 0;
338  }
339 
340 
341 }
342 ?>