ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjPrivacySecurityGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 include_once("./Services/Object/classes/class.ilObjectGUI.php");
4 include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
5 include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
6 
19 {
20  private static $ERROR_MESSAGE;
26  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
27  {
28  $this->type = 'ps';
29  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
30 
32  }
33 
34  public static function initErrorMessages()
35  {
36  global $lng;
37 
38  if(is_array(self::$ERROR_MESSAGE))
39  {
40  return;
41  }
42 
43  $lng->loadLanguageModule('ps');
44 
46  ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_AUTO_HTTPS => $lng->txt("ps_error_message_https_header_missing"),
49  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MIN_LENGTH => $lng->txt('ps_error_message_invalid_password_min_length'),
50  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_LENGTH => $lng->txt('ps_error_message_invalid_password_max_length'),
51  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_AGE => $lng->txt('ps_error_message_invalid_password_max_age'),
52  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_LOGIN_MAX_ATTEMPTS => $lng->txt('ps_error_message_invalid_login_max_attempts'),
53  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN1 => $lng->txt('ps_error_message_password_min1_because_chars'),
54  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN2 => $lng->txt('ps_error_message_password_min2_because_chars_numbers'),
55  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN3 => $lng->txt('ps_error_message_password_min3_because_chars_numbers_sc'),
56  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MAX_LENGTH_LESS_MIN_LENGTH => $lng->txt('ps_error_message_password_max_less_min')
57  );
58  }
59 
66  public function executeCommand()
67  {
68  global $rbacsystem,$ilErr,$ilAccess;
69 
70  $next_class = $this->ctrl->getNextClass($this);
71  $cmd = $this->ctrl->getCmd();
72 
73  $this->prepareOutput();
74 
75  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
76  {
77  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
78  }
79 
80  switch($next_class)
81  {
82  case 'ilpermissiongui':
83  $this->tabs_gui->setTabActive('perm_settings');
84  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
85  $perm_gui =& new ilPermissionGUI($this);
86  $ret =& $this->ctrl->forwardCommand($perm_gui);
87  break;
88 
89  default:
90  if(!$cmd || $cmd == 'view')
91  {
92  $cmd = "showPrivacy";
93  }
94 
95  $this->$cmd();
96  break;
97  }
98  return true;
99  }
100 
107  public function getAdminTabs()
108  {
109  global $rbacsystem;
110 
111  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
112  {
113  $this->tabs_gui->addTarget("show_privacy",
114  $this->ctrl->getLinkTarget($this, "showPrivacy"),
115  'showPrivacy');
116  $this->tabs_gui->addTarget("show_security",
117  $this->ctrl->getLinkTarget($this, "showSecurity"),
118  'showSecurity');
119 
120  }
121 
122  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
123  {
124  $this->tabs_gui->addTarget("perm_settings",
125  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
126  array(),'ilpermissiongui');
127  }
128  }
129 
135  public function showPrivacy()
136  {
137  $privacy = ilPrivacySettings::_getInstance();
138 
139  $this->tabs_gui->setTabActive('show_privacy');
140 
141  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
142  $form = new ilPropertyFormGUI();
143  $form->setFormAction($this->ctrl->getFormAction($this));
144  $form->setTitle($this->lng->txt('ps_privacy_protection'));
145 
146  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
148  {
149  $html = new ilNonEditableValueGUI();
150  $html->setValue($this->lng->txt('ps_warning_modify'));
151  $form->addItem($html);
152  }
153 
154  $value = array();
155  if($privacy->enabledCourseExport())
156  {
157  $value[] = "export_course";
158  }
159  if($privacy->enabledGroupExport())
160  {
161  $value[] = "export_group";
162  }
163  if($privacy->courseConfirmationRequired())
164  {
165  $value[] = "export_confirm_course";
166  }
167  if($privacy->groupConfirmationRequired())
168  {
169  $value[] = "export_confirm_group";
170  }
171  if($privacy->enabledGroupAccessTimes())
172  {
173  $value[] = "grp_access_times";
174  }
175  if($privacy->enabledCourseAccessTimes())
176  {
177  $value[] = "crs_access_times";
178  }
179  $group = new ilCheckboxGroupInputGUI($this->lng->txt('ps_profile_export'),'profile_protection');
180  $group->setValue($value);
181  $check = new ilCheckboxOption();
182  $check->setTitle($this->lng->txt('ps_export_course'));
183  $check->setValue('export_course');
184  $group->addOption($check);
185  $check = new ilCheckboxOption();
186  $check->setTitle($this->lng->txt('ps_export_groups'));
187  $check->setValue('export_group');
188  $group->addOption($check);
189  $check = new ilCheckboxOption();
190  $check->setTitle($this->lng->txt('ps_export_confirm'));
191  $check->setValue('export_confirm_course');
192  $group->addOption($check);
193  $check = new ilCheckboxOption();
194  $check->setTitle($this->lng->txt('ps_export_confirm_group'));
195  $check->setValue('export_confirm_group');
196  $group->addOption($check);
197  $check = new ilCheckboxOption();
198  $check->setTitle($this->lng->txt('ps_show_grp_access'));
199  $check->setValue('grp_access_times');
200  $group->addOption($check);
201  $check = new ilCheckboxOption();
202  $check->setTitle($this->lng->txt('ps_show_crs_access'));
203  $check->setValue('crs_access_times');
204  $group->addOption($check);
205  $form->addItem($group);
206 
207  include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
210  $form,
211  $this
212  );
213 
214  $form->addCommandButton('save_privacy',$this->lng->txt('save'));
215  $this->tpl->setContent($form->getHTML());
216  }
217 
223  public function showSecurity()
224  {
225  global $ilSetting, $ilUser, $rbacreview;
226 
227  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
228 
229  $security = ilSecuritySettings::_getInstance();
230 
231  $this->tabs_gui->setTabActive('show_security');
232 
233  $form = new ilPropertyFormGUI();
234  $form->setFormAction($this->ctrl->getFormAction($this));
235  $form->setTitle($this->lng->txt('ps_security_protection'));
236 
237  include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
240  $form,
241  $this
242  );
243 
244  // $form->addCommandButton('save_security',$this->lng->txt('save'));
245  $this->tpl->setContent($form->getHTML());
246  }
247 
254  public function save_privacy()
255  {
256  global $ilErr,$ilAccess, $ilSetting;
257 
258  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
259  {
260  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
261  }
262 
263  if((int) $_POST['rbac_log_age'] > 24)
264  {
265  $_POST['rbac_log_age'] = 24;
266  }
267  else if((int) $_POST['rbac_log_age'] < 1)
268  {
269  $_POST['rbac_log_age'] = 1;
270  }
271 
272  $_POST['profile_protection'] = isset($_POST['profile_protection']) ? $_POST['profile_protection'] : array();
273 
274  $privacy = ilPrivacySettings::_getInstance();
275 
276  // to determine if agreements need to be reset - see below
277  $old_settings = array(
278  'export_course' => $privacy->enabledCourseExport(),
279  'export_group' => $privacy->enabledGroupExport(),
280  'export_confirm_course' => $privacy->courseConfirmationRequired(),
281  'export_confirm_group' => $privacy->groupConfirmationRequired(),
282  'crs_access_times' => $privacy->enabledCourseAccessTimes(),
283  'grp_access_times' => $privacy->enabledGroupAccessTimes()
284  );
285 
286  $privacy->enableCourseExport((int) in_array('export_course', $_POST['profile_protection']));
287  $privacy->enableGroupExport((int) in_array('export_group', $_POST['profile_protection']));
288  $privacy->setCourseConfirmationRequired((int) in_array('export_confirm_course', $_POST['profile_protection']));
289  $privacy->setGroupConfirmationRequired((int) in_array('export_confirm_group', $_POST['profile_protection']));
290  $privacy->showGroupAccessTimes((int) in_array('grp_access_times', $_POST['profile_protection']));
291  $privacy->showCourseAccessTimes((int) in_array('crs_access_times', $_POST['profile_protection']));
292 
293  // validate settings
294  $code = $privacy->validate();
295 
296  // if error code != 0, display error and do not save
297  if ($code != 0)
298  {
299  $msg = $this->getErrorMessage ($code);
300  ilUtil::sendFailure($msg);
301  }
302  else
303  {
304  $privacy->save();
305 
306  // reset agreements?
307  $do_reset = false;
308  if(!$old_settings['export_course'] && $privacy->enabledCourseExport())
309  {
310  $do_reset = true;
311  }
312  if(!$do_reset && !$old_settings['export_group'] && $privacy->enabledGroupExport())
313  {
314  $do_reset = true;
315  }
316  if(!$do_reset && !$old_settings['export_confirm_course'] && $privacy->courseConfirmationRequired())
317  {
318  $do_reset = true;
319  }
320  if(!$do_reset && !$old_settings['export_confirm_group'] && $privacy->groupConfirmationRequired())
321  {
322  $do_reset = true;
323  }
324  if(!$do_reset && !$old_settings['crs_access_times'] && $privacy->enabledCourseAccessTimes())
325  {
326  $do_reset = true;
327  }
328  if(!$do_reset && !$old_settings['grp_access_times'] && $privacy->enabledGroupAccessTimes())
329  {
330  $do_reset = true;
331  }
332  if($do_reset)
333  {
334  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
336  }
337  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
338  }
339 
340  $this->showPrivacy();
341  }
342 
349  public function save_security()
350  {
351  global $ilErr,$ilAccess, $ilSetting, $rbacreview, $ilUser;
352 
353  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
354  {
355  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
356  }
357 
358  /*
359  $security = ilSecuritySettings::_getInstance();
360 
361  $code = $security->validate();
362 
363  // if error code != 0, display error and do not save
364  if ($code != 0)
365  {
366  $msg = $this->getErrorMessage ($code);
367  ilUtil::sendFailure($msg);
368  } else
369  {
370  $security->save();
371  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
372  }
373  */
374 
375  $this->showSecurity();
376  }
377 
378 
386  public static function getErrorMessage ($code)
387  {
390  }
391 
392  public function addToExternalSettingsForm($a_form_id)
393  {
394  switch($a_form_id)
395  {
397 
398  $privacy = ilPrivacySettings::_getInstance();
399 
400  $subitems = array(
401  'ps_export_course' => array($privacy->enabledCourseExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
402  'ps_export_confirm' => array($privacy->courseConfirmationRequired(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
403  'ps_show_crs_access' => array($privacy->enabledCourseAccessTimes(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
404  );
405  $fields = array(
406  'ps_profile_export' => array(null, null, $subitems)
407  );
408  return array(array("showPrivacy", $fields));
409 
411 
412  $privacy = ilPrivacySettings::_getInstance();
413 
414  $subitems = array(
415  'ps_export_groups' => array($privacy->enabledGroupExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
416  'ps_export_confirm_group' => array($privacy->groupConfirmationRequired(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
417  'ps_show_grp_access' => array($privacy->enabledGroupAccessTimes(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
418  );
419  $fields = array(
420  'ps_profile_export' => array(null, null, $subitems)
421  );
422  return array(array("showPrivacy", $fields));
423  }
424  }
425 }
426 
427 ?>