18 require_once
'./Services/Registration/classes/class.ilRegistrationSettings.php';
19 require_once
"./Services/User/classes/class.ilUserAgreement.php";
36 $this->ctrl->saveParameter($this,
'lang');
39 $this->lng->loadLanguageModule(
'registration');
48 if($this->registration_settings->getRegistrationType() ==
IL_REG_DISABLED)
50 $ilErr->raiseError($this->lng->txt(
'reg_disabled'),$ilErr->FATAL);
53 $next_class = $this->ctrl->getNextClass($this);
54 $cmd = $this->ctrl->getCmd();
77 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.usr_registration.html");
78 $this->tpl->addBlockFile(
"STATUSLINE",
"statusline",
"tpl.statusline.html");
80 $this->tpl->setVariable(
"TXT_PAGEHEADLINE", $lng->txt(
"registration"));
83 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
84 $this->tpl->setVariable(
"TXT_OK",$lng->txt(
"ok"));
85 $this->tpl->setVariable(
"TXT_CHOOSE_LANGUAGE", $lng->txt(
"choose_language"));
86 $this->ctrl->getFormAction($this);
89 foreach ($lng->getInstalledLanguages() as $lang_key)
95 $this->tpl->setCurrentBlock(
"languages");
96 foreach($lang_opts as $lang_key => $lang_caption)
98 $this->tpl->setVariable(
"LANG_NAME", $lang_caption);
99 $this->tpl->setVariable(
"LANG_ICON", $lang_key);
101 if($lang_key == $lng->getLangKey())
103 $this->tpl->setVariable(
"SELECTED_LANG",
" selected=\"selected\"");
106 $this->tpl->parseCurrentBlock();
113 $this->tpl->setVariable(
"FORM", $this->form->getHTML());
118 global
$lng, $ilUser;
120 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
122 $this->form->setFormAction($this->ctrl->getFormAction($this));
124 $display_code = ($this->registration_settings->registrationCodeRequired() ||
125 $this->registration_settings->getAllowCodes());
129 if($display_code && (!isset(
$_POST[
"usr_registration_code"]) || $a_force_code))
137 include_once
'Services/Registration/classes/class.ilRegistrationCode.php';
138 $code =
new ilTextInputGUI($lng->txt(
"registration_code"),
"usr_registration_code");
141 if((
bool)$this->registration_settings->registrationCodeRequired())
143 $code->setRequired(
true);
144 $code->setInfo($lng->txt(
"registration_code_required_info"));
148 $code->setInfo($lng->txt(
"registration_code_optional_info"));
151 $this->form->addItem($code);
153 $this->form->addCommandButton(
"saveCodeForm", $lng->txt(
"send"));
157 if(!$this->registration_code)
159 $this->registration_code =
$_POST[
"usr_registration_code"];
163 $predefined_role = null;
164 if($this->registration_code)
167 $code->
setValue($this->registration_code);
168 $this->form->addItem($code);
170 include_once
'Services/Registration/classes/class.ilRegistrationCode.php';
174 else if($display_code)
178 $this->form->addItem($code);
183 $user_defined_data = $ilUser->getUserDefinedData();
185 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
187 $custom_fields = array();
188 foreach($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition)
192 $custom_fields[
"udf_".$definition[
'field_id']] =
193 new ilTextInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
194 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
195 $custom_fields[
"udf_".$definition[
'field_id']]->setMaxLength(255);
196 $custom_fields[
"udf_".$definition[
'field_id']]->setSize(40);
200 $custom_fields[
"udf_".$definition[
'field_id']] =
202 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
203 $custom_fields[
"udf_".$definition[
'field_id']]->setUseRte(
true);
207 $custom_fields[
"udf_".$definition[
'field_id']] =
208 new ilSelectInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
209 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
210 $custom_fields[
"udf_".$definition[
'field_id']]->setOptions(
211 $user_defined_fields->fieldValuesToSelectArray($definition[
'field_values']));
213 if($definition[
'required'])
215 $custom_fields[
"udf_".$definition[
'field_id']]->setRequired(
true);
220 include_once(
"./Services/User/classes/class.ilUserProfile.php");
223 $up->skipGroup(
"preferences");
226 $up->addStandardFieldsToForm($this->form, NULL, $custom_fields);
227 unset($custom_fields);
232 $field->setTitle($lng->txt(
"usr_agreement"));
233 $this->form->addItem($field);
237 $this->form->addItem($field);
242 $this->form->addItem($field);
247 $this->form->removeItemByPostVar(
"usr_roles");
250 $role->setValue($predefined_role);
251 $this->form->addItem($role);
254 $this->form->addCommandButton(
"saveForm", $lng->txt(
"register"));
263 if($this->form->checkInput())
265 $code = $this->form->getInput(
"usr_registration_code");
269 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
272 $code_obj = $this->form->getItemByPostVar(
'usr_registration_code');
273 $code_obj->setAlert($lng->txt(
'registration_code_not_valid'));
278 $this->registration_code = $code;
291 $this->form->setValuesByPost();
300 $form_valid = $this->form->checkInput();
302 require_once
'Services/User/classes/class.ilObjUser.php';
306 if(!$this->form->getInput(
"usr_agreement"))
308 $agr_obj = $this->form->getItemByPostVar(
'usr_agreement');
309 $agr_obj->setAlert($lng->txt(
"force_accept_usr_agreement"));
316 if ($this->registration_settings->roleSelectionEnabled())
318 include_once
"./Services/AccessControl/classes/class.ilObjRole.php";
319 $selected_role = $this->form->getInput(
"usr_roles");
328 include_once
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
330 if ($registration_role_assignments->getRoleByEmail($this->form->getInput(
"usr_email")))
344 $login_obj = $this->form->getItemByPostVar(
'username');
345 $login = $this->form->getInput(
"username");
348 $login_obj->setAlert($lng->txt(
"login_invalid"));
353 $login_obj->setAlert($lng->txt(
"login_exists"));
356 else if ((
int)$ilSetting->get(
'allow_change_loginname') &&
357 (int)$ilSetting->get(
'prevent_reuse_of_loginnames') &&
360 $login_obj->setAlert($lng->txt(
'login_exists'));
372 $this->
login($password);
376 $this->form->setValuesByPost();
387 include_once(
"./Services/User/classes/class.ilUserProfile.php");
392 $up->skipGroup(
"preferences");
393 $up->skipGroup(
"settings");
394 $up->skipGroup(
"instant_messengers");
395 $up->skipField(
"password");
396 $up->skipField(
"birthday");
397 $up->skipField(
"upload");
398 foreach ($up->getStandardFields() as $k => $v)
402 $method =
"set".substr($v[
"method"], 3);
403 if(method_exists($this->userObj, $method))
405 if ($k !=
"username")
409 $field_obj = $this->form->getItemByPostVar($k);
413 $this->userObj->$method($this->form->getInput($k));
419 $this->userObj->setFullName();
421 $birthday_obj = $this->form->getItemByPostVar(
"usr_birthday");
424 $birthday = $this->form->getInput(
"usr_birthday");
425 $birthday = $birthday[
"date"];
428 if(!is_array($birthday))
430 $this->userObj->setBirthday($birthday);
435 $map = array(
"icq",
"yahoo",
"msn",
"aim",
"skype",
"jabber",
"voip");
438 $field =
"usr_im_".$client;
439 $field_obj = $this->form->getItemByPostVar($field);
442 $this->userObj->setInstantMessengerId($client, $this->form->getInput($field));
446 $this->userObj->setTitle($this->userObj->getFullname());
447 $this->userObj->setDescription($this->userObj->getEmail());
449 if ($this->registration_settings->passwordGenerationEnabled())
452 $password = $password[0];
456 $password = $this->form->getInput(
"usr_password");
458 $this->userObj->setPasswd($password);
462 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
464 $defs = $user_defined_fields->getRegistrationDefinitions();
466 foreach (
$_POST as $k => $v)
468 if (substr($k, 0, 4) ==
"udf_")
474 $this->userObj->setUserDefinedData($udf);
476 $this->userObj->setTimeLimitOwner(7);
479 $default_role =
false;
480 if ($this->registration_settings->roleSelectionEnabled())
482 $default_role = $this->form->getInput(
'usr_roles');
487 include_once
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
489 $default_role = $registration_role_assignments->getRoleByEmail($this->userObj->getEmail());
493 $code = $this->form->getInput(
'usr_registration_code');
494 $this->code_was_used =
false;
495 if($this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
496 ($code && $this->registration_settings->getAllowCodes()))
498 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
500 $this->code_was_used =
true;
506 $default_role = $code_role;
514 $ilias->raiseError(
"Invalid role selection in registration".
515 ", IP: ".$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
518 if ($this->registration_settings->getAccessLimitation())
520 include_once
'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
523 $access_limit_mode = $access_limitations_obj->getMode($default_role);
524 if ($access_limit_mode ==
'absolute')
526 $access_limit = $access_limitations_obj->getAbsolute($default_role);
527 $this->userObj->setTimeLimitUnlimited(0);
528 $this->userObj->setTimeLimitUntil($access_limit);
530 elseif ($access_limit_mode ==
'relative')
532 $rel_d = (int) $access_limitations_obj->getRelative($default_role,
'd');
533 $rel_m = (int) $access_limitations_obj->getRelative($default_role,
'm');
534 $rel_y = (int) $access_limitations_obj->getRelative($default_role,
'y');
536 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
537 $this->userObj->setTimeLimitUnlimited(0);
538 $this->userObj->setTimeLimitUntil($access_limit);
542 $this->userObj->setTimeLimitUnlimited(1);
543 $this->userObj->setTimeLimitUntil(time());
548 $this->userObj->setTimeLimitUnlimited(1);
549 $this->userObj->setTimeLimitUntil(time());
552 $this->userObj->setTimeLimitFrom(time());
554 $this->userObj->create();
557 if($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT ||
558 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
561 $this->userObj->setActive(1,0);
563 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
565 $this->userObj->setActive(0,0);
569 $this->userObj->setActive(0,0);
572 $this->userObj->updateOwner();
577 $this->userObj->setLastPasswordChangeTS( time() );
580 $this->userObj->saveAsNew();
583 $this->userObj->writeAccepted();
586 $this->userObj->setLanguage($this->form->getInput(
'usr_language'));
587 $hits_per_page = $ilSetting->get(
"hits_per_page");
588 if ($hits_per_page < 10)
592 $this->userObj->setPref(
"hits_per_page", $hits_per_page);
593 $show_online = $ilSetting->get(
"show_users_online");
594 if ($show_online ==
"")
598 $this->userObj->setPref(
"show_users_online", $show_online);
599 $this->userObj->writePrefs();
601 $rbacadmin->assignUser((
int)$default_role, $this->userObj->getId(),
true);
610 include_once
'./Services/Language/classes/class.ilLanguage.php';
611 include_once
'./Services/User/classes/class.ilObjUser.php';
612 include_once
"Services/Mail/classes/class.ilFormatMail.php";
613 include_once
'./Services/Registration/classes/class.ilRegistrationMailNotification.php';
620 $mail->setRecipients($this->registration_settings->getApproveRecipients());
621 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
628 $mail->setRecipients($this->registration_settings->getApproveRecipients());
629 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
638 include_once
'./Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
642 $mail->setRecipients(array($this->userObj));
643 $mail->setAdditionalInformation(
645 'usr' => $this->userObj,
646 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
654 include_once(
"Services/Mail/classes/class.ilAccountMail.php");
655 include_once
'./Services/User/classes/class.ilObjUserFolder.php';
657 if (trim($amail[
"body"]) !=
"" && trim($amail[
"subject"]) !=
"")
660 $acc_mail->setUser($this->userObj);
661 if ($this->registration_settings->passwordGenerationEnabled())
663 $acc_mail->setUserPassword($password);
669 include_once
"Services/Mail/classes/class.ilMimeMail.php";
672 $mmail->autoCheck(
false);
673 $mmail->From($ilSetting->get(
"admin_email"));
674 $mmail->To($this->userObj->getEmail());
677 $subject = $this->lng->txt(
"reg_mail_subject");
680 $body = $this->lng->txt(
"reg_mail_body_salutation").
" ".$this->userObj->getFullname().
",\n\n".
681 $this->lng->txt(
"reg_mail_body_text1").
"\n\n".
682 $this->lng->txt(
"reg_mail_body_text2").
"\n".
683 ILIAS_HTTP_PATH.
"/login.php?client_id=".CLIENT_ID.
"\n";
684 $body .= $this->lng->txt(
"login").
": ".$this->userObj->getLogin().
"\n";
686 if ($this->registration_settings->passwordGenerationEnabled())
688 $body.= $this->lng->txt(
"passwd").
": ".$password.
"\n";
695 $body .= ($this->lng->txt(
'reg_mail_body_pwd_generation').
"\n\n");
698 $body .= ($this->lng->txt(
"reg_mail_body_text3").
"\n\r");
699 $body .= $this->userObj->getProfileAsString($this->lng);
700 $mmail->Subject($subject);
711 $ilLog->write(
"Entered login");
713 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.usr_registered.html");
715 $this->tpl->setVariable(
"IMG_USER",
717 $this->tpl->setVariable(
"TXT_PAGEHEADLINE", $lng->txt(
"registration"));
718 $this->tpl->setVariable(
"TXT_WELCOME", $lng->txt(
"welcome").
", ".$this->userObj->getTitle().
"!");
720 if (($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT or
721 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES or
723 !$this->registration_settings->passwordGenerationEnabled())
725 $this->tpl->setCurrentBlock(
"activation");
726 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_registered"));
727 $this->tpl->setVariable(
"FORMACTION",
"login.php?cmd=post&target=".
$_GET[
"target"]);
728 if(IS_PAYMENT_ENABLED && isset(
$_SESSION[
'forceShoppingCartRedirect']))
730 $this->tpl->setVariable(
"FORMACTION",
'./login.php?forceShoppingCartRedirect=1');
732 $this->tpl->setVariable(
"TARGET",
"target=\"_parent\"");
733 $this->tpl->setVariable(
"TXT_LOGIN", $lng->txt(
"login_to_ilias"));
734 $this->tpl->setVariable(
"USERNAME",$this->userObj->getLogin());
735 $this->tpl->setVariable(
"PASSWORD",$password);
736 $this->tpl->parseCurrentBlock();
738 else if ($this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE)
740 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_submitted"));
742 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
744 $this->tpl->setVariable(
"TXT_REGISTERED", sprintf($lng->txt(
"reg_confirmation_link_successful"),
'./login.php'));
745 $this->tpl->setVariable(
"REDIRECT_URL",
'./login.php');
749 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_registered_passw_gen"));