ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 */
3include_once("./Services/Object/classes/class.ilObjectGUI.php");
4include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
5include_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
32 }
33
34 public static function initErrorMessages()
35 {
36 global $lng;
37
38 if (is_array(self::$ERROR_MESSAGE)) {
39 return;
40 }
41
42 $lng->loadLanguageModule('ps');
43
45 ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_AUTO_HTTPS => $lng->txt("ps_error_message_https_header_missing"),
48 ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MIN_LENGTH => $lng->txt('ps_error_message_invalid_password_min_length'),
49 ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_LENGTH => $lng->txt('ps_error_message_invalid_password_max_length'),
50 ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_AGE => $lng->txt('ps_error_message_invalid_password_max_age'),
51 ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_LOGIN_MAX_ATTEMPTS => $lng->txt('ps_error_message_invalid_login_max_attempts'),
52 ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN1 => $lng->txt('ps_error_message_password_min1_because_chars'),
53 ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN2 => $lng->txt('ps_error_message_password_min2_because_chars_numbers'),
54 ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN3 => $lng->txt('ps_error_message_password_min3_because_chars_numbers_sc'),
56 );
57 }
58
65 public function executeCommand()
66 {
67 global $rbacsystem,$ilErr,$ilAccess;
68
69 $next_class = $this->ctrl->getNextClass($this);
70 $cmd = $this->ctrl->getCmd();
71
72 $this->prepareOutput();
73
74 if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
75 $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
76 }
77
78 switch ($next_class) {
79 case 'ilpermissiongui':
80 $this->tabs_gui->setTabActive('perm_settings');
81 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
82 $perm_gui = new ilPermissionGUI($this);
83 $ret =&$this->ctrl->forwardCommand($perm_gui);
84 break;
85
86 default:
87 if (!$cmd || $cmd == 'view') {
88 $cmd = "showPrivacy";
89 }
90
91 $this->$cmd();
92 break;
93 }
94 return true;
95 }
96
103 public function getAdminTabs()
104 {
105 global $rbacsystem;
106
107 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
108 $this->tabs_gui->addTarget(
109 "show_privacy",
110 $this->ctrl->getLinkTarget($this, "showPrivacy"),
111 'showPrivacy'
112 );
113 $this->tabs_gui->addTarget(
114 "show_security",
115 $this->ctrl->getLinkTarget($this, "showSecurity"),
116 'showSecurity'
117 );
118 }
119
120 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
121 $this->tabs_gui->addTarget(
122 "perm_settings",
123 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
124 array(),
125 'ilpermissiongui'
126 );
127 }
128 }
129
135 public function showPrivacy()
136 {
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 ilUtil::sendInfo($this->lng->txt('ps_warning_modify'));
149 }
150
151 $value = array();
152 if ($privacy->enabledCourseExport()) {
153 $value[] = "export_course";
154 }
155 if ($privacy->enabledGroupExport()) {
156 $value[] = "export_group";
157 }
158 if ($privacy->courseConfirmationRequired()) {
159 $value[] = "export_confirm_course";
160 }
161 if ($privacy->groupConfirmationRequired()) {
162 $value[] = "export_confirm_group";
163 }
164 if ($privacy->enabledGroupAccessTimes()) {
165 $value[] = "grp_access_times";
166 }
167 if ($privacy->enabledCourseAccessTimes()) {
168 $value[] = "crs_access_times";
169 }
170 $group = new ilCheckboxGroupInputGUI($this->lng->txt('ps_profile_export'), 'profile_protection');
171 $group->setValue($value);
172 $check = new ilCheckboxOption();
173 $check->setTitle($this->lng->txt('ps_export_course'));
174 $check->setValue('export_course');
175 $group->addOption($check);
176 $check = new ilCheckboxOption();
177 $check->setTitle($this->lng->txt('ps_export_groups'));
178 $check->setValue('export_group');
179 $group->addOption($check);
180 $check = new ilCheckboxOption();
181 $check->setTitle($this->lng->txt('ps_export_confirm'));
182 $check->setValue('export_confirm_course');
183 $group->addOption($check);
184 $check = new ilCheckboxOption();
185 $check->setTitle($this->lng->txt('ps_export_confirm_group'));
186 $check->setValue('export_confirm_group');
187 $group->addOption($check);
188 $check = new ilCheckboxOption();
189 $check->setTitle($this->lng->txt('ps_show_grp_access'));
190 $check->setValue('grp_access_times');
191 $group->addOption($check);
192 $check = new ilCheckboxOption();
193 $check->setTitle($this->lng->txt('ps_show_crs_access'));
194 $check->setValue('crs_access_times');
195 $group->addOption($check);
196 $form->addItem($group);
197
198 include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
201 $form,
202 $this
203 );
204
205 if ($this->checkPermissionBool("write")) {
206 $form->addCommandButton('save_privacy', $this->lng->txt('save'));
207 }
208 $this->tpl->setContent($form->getHTML());
209 }
210
216 public function showSecurity()
217 {
219
220 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
221
223
224 $this->tabs_gui->setTabActive('show_security');
225
226 $form = new ilPropertyFormGUI();
227 $form->setFormAction($this->ctrl->getFormAction($this));
228 $form->setTitle($this->lng->txt('ps_security_protection'));
229
230 include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
233 $form,
234 $this
235 );
236
237 // $form->addCommandButton('save_security',$this->lng->txt('save'));
238 $this->tpl->setContent($form->getHTML());
239 }
240
247 public function save_privacy()
248 {
249 global $ilErr,$ilAccess, $ilSetting;
250
251 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
252 $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
253 }
254
255 if ((int) $_POST['rbac_log_age'] > 24) {
256 $_POST['rbac_log_age'] = 24;
257 } elseif ((int) $_POST['rbac_log_age'] < 1) {
258 $_POST['rbac_log_age'] = 1;
259 }
260
261 $_POST['profile_protection'] = isset($_POST['profile_protection']) ? $_POST['profile_protection'] : array();
262
264
265 // to determine if agreements need to be reset - see below
266 $old_settings = array(
267 'export_course' => $privacy->enabledCourseExport(),
268 'export_group' => $privacy->enabledGroupExport(),
269 'export_confirm_course' => $privacy->courseConfirmationRequired(),
270 'export_confirm_group' => $privacy->groupConfirmationRequired(),
271 'crs_access_times' => $privacy->enabledCourseAccessTimes(),
272 'grp_access_times' => $privacy->enabledGroupAccessTimes()
273 );
274
275 $privacy->enableCourseExport((int) in_array('export_course', $_POST['profile_protection']));
276 $privacy->enableGroupExport((int) in_array('export_group', $_POST['profile_protection']));
277 $privacy->setCourseConfirmationRequired((int) in_array('export_confirm_course', $_POST['profile_protection']));
278 $privacy->setGroupConfirmationRequired((int) in_array('export_confirm_group', $_POST['profile_protection']));
279 $privacy->showGroupAccessTimes((int) in_array('grp_access_times', $_POST['profile_protection']));
280 $privacy->showCourseAccessTimes((int) in_array('crs_access_times', $_POST['profile_protection']));
281
282 // validate settings
283 $code = $privacy->validate();
284
285 // if error code != 0, display error and do not save
286 if ($code != 0) {
287 $msg = $this->getErrorMessage($code);
289 } else {
290 $privacy->save();
291
292 // reset agreements?
293 $do_reset = false;
294 if (!$old_settings['export_course'] && $privacy->enabledCourseExport()) {
295 $do_reset = true;
296 }
297 if (!$do_reset && !$old_settings['export_group'] && $privacy->enabledGroupExport()) {
298 $do_reset = true;
299 }
300 if (!$do_reset && !$old_settings['export_confirm_course'] && $privacy->courseConfirmationRequired()) {
301 $do_reset = true;
302 }
303 if (!$do_reset && !$old_settings['export_confirm_group'] && $privacy->groupConfirmationRequired()) {
304 $do_reset = true;
305 }
306 if (!$do_reset && !$old_settings['crs_access_times'] && $privacy->enabledCourseAccessTimes()) {
307 $do_reset = true;
308 }
309 if (!$do_reset && !$old_settings['grp_access_times'] && $privacy->enabledGroupAccessTimes()) {
310 $do_reset = true;
311 }
312 if ($do_reset) {
313 include_once('Services/Membership/classes/class.ilMemberAgreement.php');
315 }
316 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
317 }
318
319 $this->showPrivacy();
320 }
321
328 public function save_security()
329 {
330 global $ilErr,$ilAccess, $ilSetting, $rbacreview, $ilUser;
331
332 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
333 $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
334 }
335
336 /*
337 $security = ilSecuritySettings::_getInstance();
338
339 $code = $security->validate();
340
341 // if error code != 0, display error and do not save
342 if ($code != 0)
343 {
344 $msg = $this->getErrorMessage ($code);
345 ilUtil::sendFailure($msg);
346 } else
347 {
348 $security->save();
349 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
350 }
351 */
352
353 $this->showSecurity();
354 }
355
356
364 public static function getErrorMessage($code)
365 {
368 }
369
370 public function addToExternalSettingsForm($a_form_id)
371 {
372 switch ($a_form_id) {
374
376
377 $subitems = array(
378 'ps_export_course' => array($privacy->enabledCourseExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
379 'ps_export_confirm' => array($privacy->courseConfirmationRequired(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
380 'ps_show_crs_access' => array($privacy->enabledCourseAccessTimes(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
381 );
382 $fields = array(
383 'ps_profile_export' => array(null, null, $subitems)
384 );
385 return array(array("showPrivacy", $fields));
386
388
390
391 $subitems = array(
392 'ps_export_groups' => array($privacy->enabledGroupExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
393 'ps_export_confirm_group' => array($privacy->groupConfirmationRequired(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
394 'ps_show_grp_access' => array($privacy->enabledGroupAccessTimes(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
395 );
396 $fields = array(
397 'ps_profile_export' => array(null, null, $subitems)
398 );
399 return array(array("showPrivacy", $fields));
400 }
401 }
402}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
This class represents a property in a property form.
This class represents an option in a checkbox group.
static _hasAgreements()
Check if there is any user agreement.
static _reset()
Reset all.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
save_security()
Save security settings.
static getErrorMessage($code)
return error message for error code
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static _getInstance()
Get instance of ilPrivacySettings.
This class represents a property form user interface.
const SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN2
const SECURITY_SETTINGS_ERR_CODE_INVALID_LOGIN_MAX_ATTEMPTS
static $SECURITY_SETTINGS_ERR_CODE_HTTP_NOT_AVAILABLE
const SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_LENGTH
const SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN3
const SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_AGE
const SECURITY_SETTINGS_ERR_CODE_PASSWORD_MAX_LENGTH_LESS_MIN_LENGTH
const SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN1
const SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MIN_LENGTH
static $SECURITY_SETTINGS_ERR_CODE_HTTPS_NOT_AVAILABLE
static _getInstance()
Get instance of ilSecuritySettings.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$code
Definition: example_050.php:99
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
if(isset($_POST['submit'])) $form
$ilUser
Definition: imgupload.php:18