24 require_once
'./Services/Registration/classes/class.ilRegistrationSettings.php';
50 $this->lng->loadLanguageModule(
'administration');
51 $this->lng->loadLanguageModule(
'registration');
53 $this->ref_id = (int)
$_GET[
'ref_id'];
60 $next_class = $this->ctrl->getNextClass($this);
61 $cmd = $this->ctrl->getCmd();
79 if(!$ilAccess->checkAccess(
'read',
'',$this->ref_id))
81 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_read"),$ilErr->MESSAGE);
84 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.registration_settings.html',
'Services/Registration');
86 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
87 $this->tpl->setVariable(
"TXT_REGISTRATION_SETTINGS",$this->lng->txt(
'reg_settings_header'));
88 $this->tpl->setVariable(
"TXT_REG_TYPE",$this->lng->txt(
'reg_type'));
89 $this->tpl->setVariable(
"TXT_REG_DEACTIVATED",$this->lng->txt(
'reg_disabled'));
90 $this->tpl->setVariable(
"REG_DEACTIVATED_DESC",$this->lng->txt(
'reg_disabled_info'));
91 $this->tpl->setVariable(
"TXT_DIRECT",$this->lng->txt(
'reg_direct'));
92 $this->tpl->setVariable(
"REG_DIRECT_DESC",$this->lng->txt(
'reg_direct_info'));
93 $this->tpl->setVariable(
"TXT_APPROVE",$this->lng->txt(
'reg_approve'));
94 $this->tpl->setVariable(
"REG_APPROVE_DESC",$this->lng->txt(
'reg_approve_info'));
95 $this->tpl->setVariable(
"TXT_ROLE_ASSIGNMENT",$this->lng->txt(
'reg_role_assignment'));
96 $this->tpl->setVariable(
"TXT_REG_FIXED",$this->lng->txt(
'reg_fixed'));
97 $this->tpl->setVariable(
"TXT_AVAILABLE",$this->lng->txt(
'reg_available_roles'));
98 $this->tpl->setVariable(
"TXT_APPROVE_REC",$this->lng->txt(
'approve_recipient'));
99 $this->tpl->setVariable(
"TXT_REG_NOTIFICATION",$this->lng->txt(
'reg_notification'));
100 $this->tpl->setVariable(
"REG_NOTIFICATION_DESC",$this->lng->txt(
'reg_notification_info'));
101 $this->tpl->setVariable(
"TXT_REG_EMAIL",$this->lng->txt(
'reg_email'));
103 $this->tpl->setVariable(
"TXT_REG_ACTIVATION_LINK",$this->lng->txt(
'reg_type_confirmation'));
104 $this->tpl->setVariable(
"REG_INFO_ACTIVATION",$this->lng->txt(
'reg_type_confirmation_info'));
106 $this->tpl->setVariable(
"TXT_REG_ACCESS_LIMITATIONS",$this->lng->txt(
'reg_access_limitations'));
107 $this->tpl->setVariable(
"TXT_ENABLE_ACCESS_LIMITATIONS",$this->lng->txt(
'reg_enable_access_limitations'));
109 $this->tpl->setVariable(
"EDIT",$this->lng->txt(
'edit'));
110 $this->tpl->setVariable(
"LINK_EDIT_FIXED",$this->ctrl->getLinkTarget($this,
'editRoles'));
111 $this->tpl->setVariable(
"LINK_EDIT_EMAIL",$this->ctrl->getLinkTarget($this,
'editEmailAssignments'));
112 $this->tpl->setVariable(
"LINK_EDIT_ACCESS_LIMITATIONS",$this->ctrl->getLinkTarget($this,
'editRoleAccessLimitations'));
119 $this->tpl->setVariable(
"TXT_NEW_ACCOUNT_MAIL",
120 $this->lng->txt(
'user_new_account_mail'));
121 $this->tpl->setVariable(
"TXT_JUMP_ACCOUNT_MAIL",
122 $this->lng->txt(
'edit'));
123 $ilCtrl->setParameterByClass(
"ilobjuserfoldergui",
"ref_id",
USER_FOLDER_ID);
124 $this->tpl->setVariable(
"HREF_NEW_ACCOUNT_MAIL",
125 $ilCtrl->getLinkTargetByClass(array(
"iladministrationgui",
"ilobjuserfoldergui"),
"newAccountMail"));
126 $ilCtrl->setParameterByClass(
"ilobjuserfoldergui",
"ref_id",
$_GET[
"ref_id"]);
129 $this->tpl->setVariable(
"TXT_REG_PWD_FORWARD",$this->lng->txt(
'passwd_generation'));
130 $this->tpl->setVariable(
"REG_INFO_PWD",$this->lng->txt(
'reg_info_pwd'));
140 $this->tpl->setVariable(
"RADIO_APPROVE",
ilUtil::formRadioButton($this->registration_settings->approveEnabled(),
144 $this->tpl->setVariable(
"CHECK_ACTIVATION_REG",
ilUtil::formRadioButton($this->registration_settings->activationEnabled(),
148 $this->tpl->setVariable(
"APPROVER",
ilUtil::prepareFormOutput($this->registration_settings->getApproveRecipientLogins()));
151 $this->tpl->setVariable(
"CHECK_PWD",
ilUtil::formCheckbox($this->registration_settings->passwordGenerationEnabled(),
155 $this->tpl->setVariable(
"RADIO_FIXED",
ilUtil::formRadioButton($this->registration_settings->roleSelectionEnabled(),
159 $this->tpl->setVariable(
"RADIO_EMAIL",
ilUtil::formRadioButton($this->registration_settings->automaticRoleAssignmentEnabled(),
163 if ($this->registration_settings->getAccessLimitation())
165 $this->tpl->setVariable(
"REG_ACCESS_LIMITATION_CHECK",
"checked=\"checked\"");
166 $this->tpl->setVariable(
"CSS_DISPLAY_ACCESS_LIMITATION",
"block");
170 $this->tpl->setVariable(
"CSS_DISPLAY_ACCESS_LIMITATION",
"none");
173 $this->tpl->setVariable(
'REG_HASH_LIFE_TIME', (
int)$this->registration_settings->getRegistrationHashLifetime());
174 $this->tpl->setVariable(
'REG_HASH_LIFE_TIME_INFO', $this->lng->txt(
'reg_confirmation_hash_life_time_info'));
177 $this->tpl->setVariable(
"TXT_SAVE",$this->lng->txt(
'save'));
184 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
186 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"),$ilErr->MESSAGE);
189 $this->registration_settings->setRegistrationType((
int)
$_POST[
'reg_type']);
190 $this->registration_settings->setPasswordGenerationStatus((
int) $_POST[
'reg_pwd']);
191 $this->registration_settings->setApproveRecipientLogins(
ilUtil::stripSlashes($_POST[
'reg_approver']));
192 $this->registration_settings->setRoleType((
int) $_POST[
'reg_role_type']);
193 $this->registration_settings->setAccessLimitation((
int) $_POST[
'reg_access_limitation']);
195 if(!preg_match(
'/^([0]|([1-9][0-9]*))([\.,][0-9][0-9]*)?$/', (
int)$_POST[
'reg_hash_life_time']))
196 $this->registration_settings->setRegistrationHashLifetime(0);
198 $this->registration_settings->setRegistrationHashLifetime((
int)$_POST[
'reg_hash_life_time']);
200 if($error_code = $this->registration_settings->validate())
206 ilUtil::sendFailure($this->lng->txt(
'reg_unknown_recipients').
' '.$this->registration_settings->getUnknown());
212 ilUtil::sendFailure($this->lng->txt(
'reg_approve_needs_recipient').
' '.$this->registration_settings->getUnknown());
219 $this->registration_settings->save();
228 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
230 global $ilAccess,
$ilErr,$rbacreview;
232 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
234 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"),$ilErr->MESSAGE);
237 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.edit_roles.html',
'Services/Registration');
239 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
240 $this->tpl->setVariable(
"TXT_SELECTABLE_ROLES",$this->lng->txt(
'reg_selectable_roles'));
242 $this->tpl->setVariable(
"ACTIONS",$this->lng->txt(
'actions'));
243 $this->tpl->setVariable(
"UPDATE",$this->lng->txt(
'save'));
244 $this->tpl->setVariable(
"CANCEL",$this->lng->txt(
'cancel'));
247 foreach($rbacreview->getGlobalRoles() as $role)
249 if($role == SYSTEM_ROLE_ID or
250 $role == ANONYMOUS_ROLE_ID)
254 $this->tpl->setCurrentBlock(
"roles");
260 $this->tpl->parseCurrentBlock();
267 global $ilAccess,
$ilErr,$rbacreview;
269 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
271 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"),$ilErr->MESSAGE);
274 if(count(
$_POST[
'roles']) < 1)
281 foreach($rbacreview->getGlobalRoles() as $role)
285 $role_obj->setAllowRegister(
$_POST[
'roles'][$role] ? 1 : 0);
298 global $ilAccess,
$ilErr,$rbacreview;
300 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
302 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"),$ilErr->MESSAGE);
307 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.reg_email_role_assignments.html',
'Services/Registration');
308 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
309 $this->tpl->setVariable(
"TXT_EMAIL_ROLE_ASSIGN",$this->lng->txt(
'reg_email_role_assignment'));
310 $this->tpl->setVariable(
"TXT_MAIL",$this->lng->txt(
'reg_email'));
311 $this->tpl->setVariable(
"TXT_ROLE",$this->lng->txt(
'obj_role'));
312 $this->tpl->setVariable(
"TXT_DEFAULT",$this->lng->txt(
'reg_default'));
314 $this->tpl->setVariable(
"TXT_DOMAIN",$this->lng->txt(
'reg_domain'));
317 $this->tpl->setVariable(
"BTN_DELETE",$this->lng->txt(
'delete'));
318 $this->tpl->setVariable(
"BTN_SAVE",$this->lng->txt(
'save'));
319 $this->tpl->setVariable(
"BTN_ADD",$this->lng->txt(
'reg_add_assignment'));
320 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
'cancel'));
323 foreach($this->assignments_obj->getAssignments() as $assignment)
325 $this->tpl->setCurrentBlock(
"roles");
327 $this->tpl->setVariable(
"ASSIGN_ID",$assignment[
'id']);
328 $this->tpl->setVariable(
"DOMAIN",$assignment[
'domain']);
331 $this->tpl->parseCurrentBlock();
335 $this->tpl->setVariable(
"TXT_DEFAULT",$this->lng->txt(
'default'));
343 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
345 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"),$ilErr->MESSAGE);
350 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.reg_role_access_limitations.html',
'Services/Registration');
352 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
353 $this->tpl->setVariable(
"TXT_REG_ROLE_ACCESS_LIMITATIONS",$lng->txt(
'reg_role_access_limitations'));
354 $this->tpl->setVariable(
"TXT_ROLE",$lng->txt(
'obj_role'));
355 $this->tpl->setVariable(
"TXT_ACCESS_LIMITATION_MODE",$lng->txt(
'reg_access_limitation_mode'));
357 $this->tpl->setVariable(
"BTN_SAVE",$lng->txt(
'save'));
358 $this->tpl->setVariable(
"BTN_CANCEL",$lng->txt(
'cancel'));
361 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
365 $this->tpl->setCurrentBlock(
"roles");
367 $this->tpl->setVariable(
"ROLE_ID",$role[
'id']);
368 $this->tpl->setVariable(
"ROLE_TITLE",$role[
'title']);
370 $this->tpl->setVariable(
"CSS_DISPLAY_ABSOLUTE",($this->access_limitations_obj->getMode($role[
'id']) ==
'absolute') ?
'inline' :
'none');
371 $this->tpl->setVariable(
"CSS_DISPLAY_RELATIVE",($this->access_limitations_obj->getMode($role[
'id']) ==
'relative') ?
'inline' :
'none');
372 $this->tpl->setVariable(
"CSS_DISPLAY_UNLIMITED",($this->access_limitations_obj->getMode($role[
'id']) ==
'unlimited') ?
'inline' :
'none');
373 $this->tpl->setVariable(
"TXT_ACCESS_LIMITATION_UNLIMITED", $lng->txt(
'reg_access_limitation_none'));
375 $date = $this->
__prepareDateSelect($this->access_limitations_obj->getAbsolute($role[
'id']));
376 $this->tpl->setVariable(
"SEL_ACCESS_LIMITATION_ABSOLUTE",
ilUtil::makeDateSelect(
'access_limitation_absolute_'.$role[
'id'],$date[
'y'],$date[
'm'],$date[
'd'],
'2007'));
378 $this->tpl->setVariable(
"TXT_DAYS",$lng->txt(
'days'));
379 $this->tpl->setVariable(
"TXT_MONTHS",$lng->txt(
'months'));
380 $this->tpl->setVariable(
"TXT_YEARS",$lng->txt(
'years'));
382 $this->tpl->setVariable(
"DAYS",$this->access_limitations_obj->getRelative($role[
'id'],
'd'));
383 $this->tpl->setVariable(
"MONTHS",$this->access_limitations_obj->getRelative($role[
'id'],
'm'));
384 $this->tpl->setVariable(
"YEARS",$this->access_limitations_obj->getRelative($role[
'id'],
'y'));
385 $this->tpl->parseCurrentBlock();
391 global $ilAccess,
$ilErr,$rbacreview;
393 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
395 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"),$ilErr->MESSAGE);
399 $this->assignments_obj->add();
409 global $ilAccess,
$ilErr,$rbacreview;
411 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
413 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"),$ilErr->MESSAGE);
416 if(!count(
$_POST[
'del_assign']))
425 foreach(
$_POST[
'del_assign'] as $assignment_id)
427 $this->assignments_obj->delete($assignment_id);
438 global $ilAccess,
$ilErr,$rbacreview;
440 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
442 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"),$ilErr->MESSAGE);
447 if (!is_array(
$_POST[
'domain']))
449 $_POST[
'domain'] = array();
457 $this->assignments_obj->setDefaultRole((
int)
$_POST[
'default_role']);
459 if(
$err = $this->assignments_obj->validate())
476 $this->assignments_obj->save();
484 global $ilAccess,
$ilErr,$rbacreview;
486 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
488 $ilErr->raiseError($this->lng->txt(
"msg_no_perm_write"),$ilErr->MESSAGE);
493 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
497 $this->access_limitations_obj->setMode(
$_POST[
'access_limitation_mode_'.$role[
'id']],$role[
'id']);
498 $this->access_limitations_obj->setAbsolute(
$_POST[
'access_limitation_absolute_'.$role[
'id']],$role[
'id']);
499 $this->access_limitations_obj->setRelative(
$_POST[
'access_limitation_relative_'.$role[
'id']],$role[
'id']);
504 if(
$err = $this->access_limitations_obj->validate())
521 $this->access_limitations_obj->save();
530 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
534 $this->tpl->setCurrentBlock(
"fixed_item");
535 $this->tpl->setVariable(
"FIXED_ITEM_TITLE",$role[
'title']);
536 $this->tpl->parseCurrentBlock();
542 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
545 foreach($this->assignments_obj->getAssignments() as $assignment)
547 if(strlen($assignment[
'domain']) and $assignment[
'role'])
549 $this->tpl->setCurrentBlock(
"auto_item");
550 $this->tpl->setVariable(
"AUTO_ITEM_TITLE",$assignment[
'domain']);
552 $this->tpl->parseCurrentBlock();
556 if(strlen($this->assignments_obj->getDefaultRole()))
558 $this->tpl->setCurrentBlock(
"auto_item");
559 $this->tpl->setVariable(
"AUTO_ITEM_TITLE",$this->lng->txt(
'reg_default'));
561 $this->tpl->parseCurrentBlock();
564 $this->tpl->setCurrentBlock(
"auto");
565 $this->tpl->parseCurrentBlock();
575 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
579 $this->tpl->setCurrentBlock(
"access_limitation_item");
580 $this->tpl->setVariable(
"ACCESS_LIMITATION_ITEM_TITLE",$role[
'title']);
582 switch ($this->access_limitations_obj->getMode($role[
'id']))
585 $txt_access_value = $lng->txt(
'reg_access_limitation_limited_until');
586 $txt_access_value .=
" ".ilDatePresentation::formatDate(
new ilDateTime($this->access_limitations_obj->getAbsolute($role[
'id'],
IL_CAL_UNIX)));
590 $years = $this->access_limitations_obj->getRelative($role[
'id'],
'y');
591 $months = $this->access_limitations_obj->getRelative($role[
'id'],
'm');
592 $days = $this->access_limitations_obj->getRelative($role[
'id'],
'd');
594 $txt_access_value = $lng->txt(
'reg_access_limitation_limited_time').
" ";
598 $txt_access_value .= $years.
" ";
599 $txt_access_value .= ($years == 1) ? $lng->txt(
'year') : $lng->txt(
'years');
605 $txt_access_value .=
", ";
609 $txt_access_value .=
" ".$lng->txt(
'and').
" ";
614 $txt_access_value .=
" ".$lng->txt(
'and').
" ";
620 $txt_access_value .= $months.
" ";
621 $txt_access_value .= ($months == 1) ? $lng->txt(
'month') : $lng->txt(
'months');
625 $txt_access_value .=
" ".$lng->txt(
'and').
" ";
631 $txt_access_value .= $days.
" ";
632 $txt_access_value .= ($days == 1) ? $lng->txt(
'day') : $lng->txt(
'days');
637 $txt_access_value = $lng->txt(
'reg_access_limitation_none');
641 $this->tpl->setVariable(
"ACCESS_LIMITATION_VALUE",$txt_access_value);
642 $this->tpl->setVariable(
"EDIT_ITEM",$lng->txt(
'edit'));
643 $this->tpl->parseCurrentBlock();
649 if(is_object($this->assignments_obj))
654 include_once
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
661 if(is_object($this->access_limitations_obj))
666 include_once
'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
673 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
677 $assignments = $this->assignments_obj->getAssignments();
678 $selected = ($assignment_id > 0) ?
679 $assignments[$assignment_id][
'role'] :
680 $this->assignments_obj->getDefaultRole();
684 $roles[0] = $this->lng->txt(
'please_choose');
687 foreach($rbacreview->getGlobalRoles() as $role_id)
689 if($role_id == SYSTEM_ROLE_ID or
690 $role_id == ANONYMOUS_ROLE_ID)
697 if($assignment_id > 0)
700 "role[$assignment_id][role]",
716 'null' => $lng->txt(
'please_choose'),
717 'unlimited' => $lng->txt(
'reg_access_limitation_mode_unlimited'),
718 'absolute' => $lng->txt(
'reg_access_limitation_mode_absolute'),
719 'relative' => $lng->txt(
'reg_access_limitation_mode_relative')
722 $attribs = array(
'onchange' =>
'displayAccessLimitationSelectionForm(document.cmd.access_limitation_mode_'.$a_role_id.
','.$a_role_id.
')');
724 $selected = $this->access_limitations_obj->getMode($a_role_id);
726 return ilUtil::formSelect($selected,
'access_limitation_mode_'.$a_role_id,$options,
false,
true,0,
"",$attribs);
734 $a_unix_time = time();
737 return array(
'y' => date(
'Y',$a_unix_time),
738 'm' => date(
'n',$a_unix_time),
739 'd' => date(
'd',$a_unix_time));