ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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::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'),
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 {
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 ilUtil::sendInfo($this->lng->txt('ps_warning_modify'));
150 }
151
152 $value = array();
153 if($privacy->enabledCourseExport())
154 {
155 $value[] = "export_course";
156 }
157 if($privacy->enabledGroupExport())
158 {
159 $value[] = "export_group";
160 }
161 if($privacy->courseConfirmationRequired())
162 {
163 $value[] = "export_confirm_course";
164 }
165 if($privacy->groupConfirmationRequired())
166 {
167 $value[] = "export_confirm_group";
168 }
169 if($privacy->enabledGroupAccessTimes())
170 {
171 $value[] = "grp_access_times";
172 }
173 if($privacy->enabledCourseAccessTimes())
174 {
175 $value[] = "crs_access_times";
176 }
177 $group = new ilCheckboxGroupInputGUI($this->lng->txt('ps_profile_export'),'profile_protection');
178 $group->setValue($value);
179 $check = new ilCheckboxOption();
180 $check->setTitle($this->lng->txt('ps_export_course'));
181 $check->setValue('export_course');
182 $group->addOption($check);
183 $check = new ilCheckboxOption();
184 $check->setTitle($this->lng->txt('ps_export_groups'));
185 $check->setValue('export_group');
186 $group->addOption($check);
187 $check = new ilCheckboxOption();
188 $check->setTitle($this->lng->txt('ps_export_confirm'));
189 $check->setValue('export_confirm_course');
190 $group->addOption($check);
191 $check = new ilCheckboxOption();
192 $check->setTitle($this->lng->txt('ps_export_confirm_group'));
193 $check->setValue('export_confirm_group');
194 $group->addOption($check);
195 $check = new ilCheckboxOption();
196 $check->setTitle($this->lng->txt('ps_show_grp_access'));
197 $check->setValue('grp_access_times');
198 $group->addOption($check);
199 $check = new ilCheckboxOption();
200 $check->setTitle($this->lng->txt('ps_show_crs_access'));
201 $check->setValue('crs_access_times');
202 $group->addOption($check);
203 $form->addItem($group);
204
205 include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
208 $form,
209 $this
210 );
211
212 $form->addCommandButton('save_privacy',$this->lng->txt('save'));
213 $this->tpl->setContent($form->getHTML());
214 }
215
221 public function showSecurity()
222 {
223 global $ilSetting, $ilUser, $rbacreview;
224
225 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
226
228
229 $this->tabs_gui->setTabActive('show_security');
230
231 $form = new ilPropertyFormGUI();
232 $form->setFormAction($this->ctrl->getFormAction($this));
233 $form->setTitle($this->lng->txt('ps_security_protection'));
234
235 include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
238 $form,
239 $this
240 );
241
242 // $form->addCommandButton('save_security',$this->lng->txt('save'));
243 $this->tpl->setContent($form->getHTML());
244 }
245
252 public function save_privacy()
253 {
254 global $ilErr,$ilAccess, $ilSetting;
255
256 if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
257 {
258 $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
259 }
260
261 if((int) $_POST['rbac_log_age'] > 24)
262 {
263 $_POST['rbac_log_age'] = 24;
264 }
265 else if((int) $_POST['rbac_log_age'] < 1)
266 {
267 $_POST['rbac_log_age'] = 1;
268 }
269
270 $_POST['profile_protection'] = isset($_POST['profile_protection']) ? $_POST['profile_protection'] : array();
271
273
274 // to determine if agreements need to be reset - see below
275 $old_settings = array(
276 'export_course' => $privacy->enabledCourseExport(),
277 'export_group' => $privacy->enabledGroupExport(),
278 'export_confirm_course' => $privacy->courseConfirmationRequired(),
279 'export_confirm_group' => $privacy->groupConfirmationRequired(),
280 'crs_access_times' => $privacy->enabledCourseAccessTimes(),
281 'grp_access_times' => $privacy->enabledGroupAccessTimes()
282 );
283
284 $privacy->enableCourseExport((int) in_array('export_course', $_POST['profile_protection']));
285 $privacy->enableGroupExport((int) in_array('export_group', $_POST['profile_protection']));
286 $privacy->setCourseConfirmationRequired((int) in_array('export_confirm_course', $_POST['profile_protection']));
287 $privacy->setGroupConfirmationRequired((int) in_array('export_confirm_group', $_POST['profile_protection']));
288 $privacy->showGroupAccessTimes((int) in_array('grp_access_times', $_POST['profile_protection']));
289 $privacy->showCourseAccessTimes((int) in_array('crs_access_times', $_POST['profile_protection']));
290
291 // validate settings
292 $code = $privacy->validate();
293
294 // if error code != 0, display error and do not save
295 if ($code != 0)
296 {
297 $msg = $this->getErrorMessage ($code);
299 }
300 else
301 {
302 $privacy->save();
303
304 // reset agreements?
305 $do_reset = false;
306 if(!$old_settings['export_course'] && $privacy->enabledCourseExport())
307 {
308 $do_reset = true;
309 }
310 if(!$do_reset && !$old_settings['export_group'] && $privacy->enabledGroupExport())
311 {
312 $do_reset = true;
313 }
314 if(!$do_reset && !$old_settings['export_confirm_course'] && $privacy->courseConfirmationRequired())
315 {
316 $do_reset = true;
317 }
318 if(!$do_reset && !$old_settings['export_confirm_group'] && $privacy->groupConfirmationRequired())
319 {
320 $do_reset = true;
321 }
322 if(!$do_reset && !$old_settings['crs_access_times'] && $privacy->enabledCourseAccessTimes())
323 {
324 $do_reset = true;
325 }
326 if(!$do_reset && !$old_settings['grp_access_times'] && $privacy->enabledGroupAccessTimes())
327 {
328 $do_reset = true;
329 }
330 if($do_reset)
331 {
332 include_once('Services/Membership/classes/class.ilMemberAgreement.php');
334 }
335 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
336 }
337
338 $this->showPrivacy();
339 }
340
347 public function save_security()
348 {
349 global $ilErr,$ilAccess, $ilSetting, $rbacreview, $ilUser;
350
351 if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
352 {
353 $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
354 }
355
356 /*
357 $security = ilSecuritySettings::_getInstance();
358
359 $code = $security->validate();
360
361 // if error code != 0, display error and do not save
362 if ($code != 0)
363 {
364 $msg = $this->getErrorMessage ($code);
365 ilUtil::sendFailure($msg);
366 } else
367 {
368 $security->save();
369 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
370 }
371 */
372
373 $this->showSecurity();
374 }
375
376
384 public static function getErrorMessage ($code)
385 {
388 }
389
390 public function addToExternalSettingsForm($a_form_id)
391 {
392 switch($a_form_id)
393 {
395
397
398 $subitems = array(
399 'ps_export_course' => array($privacy->enabledCourseExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
400 'ps_export_confirm' => array($privacy->courseConfirmationRequired(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
401 'ps_show_crs_access' => array($privacy->enabledCourseAccessTimes(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
402 );
403 $fields = array(
404 'ps_profile_export' => array(null, null, $subitems)
405 );
406 return array(array("showPrivacy", $fields));
407
409
411
412 $subitems = array(
413 'ps_export_groups' => array($privacy->enabledGroupExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
414 'ps_export_confirm_group' => array($privacy->groupConfirmationRequired(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
415 'ps_show_grp_access' => array($privacy->enabledGroupAccessTimes(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
416 );
417 $fields = array(
418 'ps_profile_export' => array(null, null, $subitems)
419 );
420 return array(array("showPrivacy", $fields));
421 }
422 }
423}
424
425?>
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()
prepare output
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.
$_POST['username']
Definition: cron.php:12
$code
Definition: example_050.php:99
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
global $ilUser
Definition: imgupload.php:15