ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
30 
31  self::initErrorMessages();
32  }
33 
34  public static function initErrorMessages()
35  {
36  global $DIC;
37 
38  $lng = $DIC['lng'];
39 
40  if (is_array(self::$ERROR_MESSAGE)) {
41  return;
42  }
43 
44  $lng->loadLanguageModule('ps');
45 
47  ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_AUTO_HTTPS => $lng->txt("ps_error_message_https_header_missing"),
50  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MIN_LENGTH => $lng->txt('ps_error_message_invalid_password_min_length'),
51  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_LENGTH => $lng->txt('ps_error_message_invalid_password_max_length'),
52  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_AGE => $lng->txt('ps_error_message_invalid_password_max_age'),
53  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_LOGIN_MAX_ATTEMPTS => $lng->txt('ps_error_message_invalid_login_max_attempts'),
54  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN1 => $lng->txt('ps_error_message_password_min1_because_chars'),
55  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN2 => $lng->txt('ps_error_message_password_min2_because_chars_numbers'),
56  ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN3 => $lng->txt('ps_error_message_password_min3_because_chars_numbers_sc'),
58  );
59  }
60 
67  public function executeCommand()
68  {
69  global $DIC;
70 
71  $rbacsystem = $DIC['rbacsystem'];
72  $ilErr = $DIC['ilErr'];
73  $ilAccess = $DIC['ilAccess'];
74 
75  $next_class = $this->ctrl->getNextClass($this);
76  $cmd = $this->ctrl->getCmd();
77 
78  $this->prepareOutput();
79 
80  if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
81  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
82  }
83 
84  switch ($next_class) {
85  case 'ilpermissiongui':
86  $this->tabs_gui->setTabActive('perm_settings');
87  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
88  $perm_gui = new ilPermissionGUI($this);
89  $ret = &$this->ctrl->forwardCommand($perm_gui);
90  break;
91 
92  default:
93  if (!$cmd || $cmd == 'view') {
94  $cmd = "showPrivacy";
95  }
96 
97  $this->$cmd();
98  break;
99  }
100  return true;
101  }
102 
109  public function getAdminTabs()
110  {
111  global $DIC;
112 
113  $rbacsystem = $DIC['rbacsystem'];
114 
115  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
116  $this->tabs_gui->addTarget(
117  "show_privacy",
118  $this->ctrl->getLinkTarget($this, "showPrivacy"),
119  'showPrivacy'
120  );
121  $this->tabs_gui->addTarget(
122  "show_security",
123  $this->ctrl->getLinkTarget($this, "showSecurity"),
124  'showSecurity'
125  );
126  }
127 
128  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
129  $this->tabs_gui->addTarget(
130  "perm_settings",
131  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
132  array(),
133  'ilpermissiongui'
134  );
135  }
136  }
137 
143  public function showPrivacy()
144  {
145  $privacy = ilPrivacySettings::_getInstance();
146 
147  $this->tabs_gui->setTabActive('show_privacy');
148 
149  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
150  $form = new ilPropertyFormGUI();
151  $form->setFormAction($this->ctrl->getFormAction($this));
152  $form->setTitle($this->lng->txt('ps_privacy_protection'));
153 
154  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
156  ilUtil::sendInfo($this->lng->txt('ps_warning_modify'));
157  }
158 
159  $value = array();
160  if ($privacy->enabledCourseExport()) {
161  $value[] = "export_course";
162  }
163  if ($privacy->enabledGroupExport()) {
164  $value[] = "export_group";
165  }
166  if ($privacy->courseConfirmationRequired()) {
167  $value[] = "export_confirm_course";
168  }
169  if ($privacy->groupConfirmationRequired()) {
170  $value[] = "export_confirm_group";
171  }
172  if ($privacy->enabledGroupAccessTimes()) {
173  $value[] = "grp_access_times";
174  }
175  if ($privacy->enabledCourseAccessTimes()) {
176  $value[] = "crs_access_times";
177  }
178  if ($privacy->participantsListInCoursesEnabled()) {
179  $value[] = 'participants_list_courses';
180  }
181  $group = new ilCheckboxGroupInputGUI($this->lng->txt('ps_profile_export'), 'profile_protection');
182  $group->setValue($value);
183  $check = new ilCheckboxOption();
184  $check->setTitle($this->lng->txt('ps_export_course'));
185  $check->setValue('export_course');
186  $group->addOption($check);
187  $check = new ilCheckboxOption();
188  $check->setTitle($this->lng->txt('ps_export_groups'));
189  $check->setValue('export_group');
190  $group->addOption($check);
191  $check = new ilCheckboxOption();
192  $check->setTitle($this->lng->txt('ps_export_confirm'));
193  $check->setValue('export_confirm_course');
194  $group->addOption($check);
195  $check = new ilCheckboxOption();
196  $check->setTitle($this->lng->txt('ps_export_confirm_group'));
197  $check->setValue('export_confirm_group');
198  $group->addOption($check);
199  $check = new ilCheckboxOption();
200  $check->setTitle($this->lng->txt('ps_show_grp_access'));
201  $check->setValue('grp_access_times');
202  $group->addOption($check);
203  $check = new ilCheckboxOption();
204  $check->setTitle($this->lng->txt('ps_show_crs_access'));
205  $check->setValue('crs_access_times');
206  $group->addOption($check);
207  $form->addItem($group);
208  $check = new \ilCheckboxOption();
209  $check->setTitle($this->lng->txt('ps_participants_list_courses'));
210  $check->setValue('participants_list_courses');
211  $group->addOption($check);
212 
213  include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
216  $form,
217  $this
218  );
219 
220  if ($this->checkPermissionBool("write")) {
221  $form->addCommandButton('save_privacy', $this->lng->txt('save'));
222  }
223  $this->tpl->setContent($form->getHTML());
224  }
225 
231  public function showSecurity()
232  {
233  global $DIC;
234 
235  $ilSetting = $DIC['ilSetting'];
236  $ilUser = $DIC['ilUser'];
237  $rbacreview = $DIC['rbacreview'];
238 
239  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
240 
241  $security = ilSecuritySettings::_getInstance();
242 
243  $this->tabs_gui->setTabActive('show_security');
244 
245  $form = new ilPropertyFormGUI();
246  $form->setFormAction($this->ctrl->getFormAction($this));
247  $form->setTitle($this->lng->txt('ps_security_protection'));
248 
249  include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
252  $form,
253  $this
254  );
255 
256  // $form->addCommandButton('save_security',$this->lng->txt('save'));
257  $this->tpl->setContent($form->getHTML());
258  }
259 
266  public function save_privacy()
267  {
268  global $DIC;
269 
270  $ilErr = $DIC['ilErr'];
271  $ilAccess = $DIC['ilAccess'];
272  $ilSetting = $DIC['ilSetting'];
273 
274  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
275  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
276  }
277 
278  if ((int) $_POST['rbac_log_age'] > 24) {
279  $_POST['rbac_log_age'] = 24;
280  } elseif ((int) $_POST['rbac_log_age'] < 1) {
281  $_POST['rbac_log_age'] = 1;
282  }
283 
284  $_POST['profile_protection'] = isset($_POST['profile_protection']) ? $_POST['profile_protection'] : array();
285 
286  $privacy = ilPrivacySettings::_getInstance();
287 
288  // to determine if agreements need to be reset - see below
289  $old_settings = array(
290  'export_course' => $privacy->enabledCourseExport(),
291  'export_group' => $privacy->enabledGroupExport(),
292  'export_confirm_course' => $privacy->courseConfirmationRequired(),
293  'export_confirm_group' => $privacy->groupConfirmationRequired(),
294  'crs_access_times' => $privacy->enabledCourseAccessTimes(),
295  'grp_access_times' => $privacy->enabledGroupAccessTimes(),
296  'participants_list_courses' => $privacy->participantsListInCoursesEnabled()
297  );
298 
299  $privacy->enableCourseExport((int) in_array('export_course', $_POST['profile_protection']));
300  $privacy->enableGroupExport((int) in_array('export_group', $_POST['profile_protection']));
301  $privacy->setCourseConfirmationRequired((int) in_array('export_confirm_course', $_POST['profile_protection']));
302  $privacy->setGroupConfirmationRequired((int) in_array('export_confirm_group', $_POST['profile_protection']));
303  $privacy->showGroupAccessTimes((int) in_array('grp_access_times', $_POST['profile_protection']));
304  $privacy->showCourseAccessTimes((int) in_array('crs_access_times', $_POST['profile_protection']));
305  $privacy->enableParticipantsListInCourses((bool) in_array('participants_list_courses', $_POST['profile_protection']));
306 
307  // validate settings
308  $code = $privacy->validate();
309 
310  // if error code != 0, display error and do not save
311  if ($code != 0) {
312  $msg = $this->getErrorMessage($code);
313  ilUtil::sendFailure($msg);
314  } else {
315  $privacy->save();
316 
317  // reset agreements?
318  $do_reset = false;
319  if (!$old_settings['export_course'] && $privacy->enabledCourseExport()) {
320  $do_reset = true;
321  }
322  if (!$do_reset && !$old_settings['export_group'] && $privacy->enabledGroupExport()) {
323  $do_reset = true;
324  }
325  if (!$do_reset && !$old_settings['export_confirm_course'] && $privacy->courseConfirmationRequired()) {
326  $do_reset = true;
327  }
328  if (!$do_reset && !$old_settings['export_confirm_group'] && $privacy->groupConfirmationRequired()) {
329  $do_reset = true;
330  }
331  if (!$do_reset && !$old_settings['crs_access_times'] && $privacy->enabledCourseAccessTimes()) {
332  $do_reset = true;
333  }
334  if (!$do_reset && !$old_settings['grp_access_times'] && $privacy->enabledGroupAccessTimes()) {
335  $do_reset = true;
336  }
337  if ($do_reset) {
338  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
340  }
341  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
342  }
343 
344  $this->showPrivacy();
345  }
346 
353  public function save_security()
354  {
355  global $DIC;
356 
357  $ilErr = $DIC['ilErr'];
358  $ilAccess = $DIC['ilAccess'];
359  $ilSetting = $DIC['ilSetting'];
360  $rbacreview = $DIC['rbacreview'];
361  $ilUser = $DIC['ilUser'];
362 
363  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
364  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
365  }
366 
367  /*
368  $security = ilSecuritySettings::_getInstance();
369 
370  $code = $security->validate();
371 
372  // if error code != 0, display error and do not save
373  if ($code != 0)
374  {
375  $msg = $this->getErrorMessage ($code);
376  ilUtil::sendFailure($msg);
377  } else
378  {
379  $security->save();
380  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
381  }
382  */
383 
384  $this->showSecurity();
385  }
386 
387 
395  public static function getErrorMessage($code)
396  {
397  self::initErrorMessages();
399  }
400 
401  public function addToExternalSettingsForm($a_form_id)
402  {
403  switch ($a_form_id) {
405 
406  $privacy = ilPrivacySettings::_getInstance();
407 
408  $subitems = array(
409  'ps_export_course' => array($privacy->enabledCourseExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
410  'ps_export_confirm' => array($privacy->courseConfirmationRequired(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
411  'ps_show_crs_access' => array($privacy->enabledCourseAccessTimes(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
412  'ps_participants_list_courses' => [$privacy->participantsListInCoursesEnabled(), \ilAdministrationSettingsFormHandler::VALUE_BOOL]
413  );
414  $fields = array(
415  'ps_profile_export' => array(null, null, $subitems)
416  );
417  return array(array("showPrivacy", $fields));
418 
420 
421  $privacy = ilPrivacySettings::_getInstance();
422 
423  $subitems = array(
424  'ps_export_groups' => array($privacy->enabledGroupExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
425  'ps_export_confirm_group' => array($privacy->groupConfirmationRequired(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
426  'ps_show_grp_access' => array($privacy->enabledGroupAccessTimes(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
427  );
428  $fields = array(
429  'ps_profile_export' => array(null, null, $subitems)
430  );
431  return array(array("showPrivacy", $fields));
432  }
433  }
434 }
showSecurity()
Show Privacy settings.
This class represents an option in a checkbox group.
const SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN2
This class represents a property form user interface.
const SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MIN_LENGTH
global $DIC
Definition: saml.php:7
static getErrorMessage($code)
return error message for error code
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
const SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_LENGTH
$code
Definition: example_050.php:99
static _reset()
Reset all.
const SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_AGE
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
save_privacy()
Save privacy settings.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
prepareOutput($a_show_subobjects=true)
prepare output
if(isset($_POST['submit'])) $form
Class ilObjectGUI Basic methods of all Output classes.
save_security()
Save security settings.
$ilUser
Definition: imgupload.php:18
This class represents a property in a property form.
static _hasAgreements()
Check if there is any user agreement.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
showPrivacy()
Show Privacy settings.
const SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN3
global $ilSetting
Definition: privfeed.php:17
$ret
Definition: parser.php:6
const SECURITY_SETTINGS_ERR_CODE_INVALID_LOGIN_MAX_ATTEMPTS
const SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN1
const SECURITY_SETTINGS_ERR_CODE_PASSWORD_MAX_LENGTH_LESS_MIN_LENGTH
static $SECURITY_SETTINGS_ERR_CODE_HTTPS_NOT_AVAILABLE
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static _getInstance()
Get instance of ilPrivacySettings.
static _getInstance()
Get instance of ilSecuritySettings.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
static $SECURITY_SETTINGS_ERR_CODE_HTTP_NOT_AVAILABLE
$_POST["username"]