18 require_once
'./Services/Registration/classes/class.ilRegistrationSettings.php';
19 require_once
"./Services/User/classes/class.ilUserAgreement.php";
34 $this->ctrl->saveParameter($this,
'lang');
37 $this->lng->loadLanguageModule(
'registration');
41 $this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
42 $this->registration_settings->getAllowCodes());
49 if($this->registration_settings->getRegistrationType() ==
IL_REG_DISABLED)
51 $ilErr->raiseError($this->lng->txt(
'reg_disabled'),$ilErr->FATAL);
54 $next_class = $this->ctrl->getNextClass($this);
55 $cmd = $this->ctrl->getCmd();
78 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.startup_screen.html",
"Services/Init");
80 $this->tpl->addBlockFile(
"STARTUP_CONTENT",
"startup_content",
"tpl.usr_registration.html",
81 "Services/Registration");
82 $this->tpl->addBlockFile(
"STATUSLINE",
"statusline",
"tpl.statusline.html");
84 $this->tpl->setVariable(
"TXT_PAGEHEADLINE", $lng->txt(
"registration"));
87 foreach ($lng->getInstalledLanguages() as $lang_key)
93 if(
sizeof($lang_opts) > 1)
96 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
97 $this->tpl->setVariable(
"TXT_OK",$lng->txt(
"ok"));
98 $this->tpl->setVariable(
"TXT_CHOOSE_LANGUAGE", $lng->txt(
"choose_language"));
102 $this->tpl->setCurrentBlock(
"languages");
103 foreach($lang_opts as $lang_key => $lang_caption)
105 $this->tpl->setVariable(
"LANG_NAME", $lang_caption);
106 $this->tpl->setVariable(
"LANG_ICON", $lang_key);
108 if($lang_key == $lng->getLangKey())
110 $this->tpl->setVariable(
"SELECTED_LANG",
" selected=\"selected\"");
113 $this->tpl->parseCurrentBlock();
121 $this->tpl->setVariable(
"FORM", $this->form->getHTML());
128 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
130 $this->form->setFormAction($this->ctrl->getFormAction($this));
135 if($this->code_enabled)
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"));
150 $this->form->addItem($code);
156 $user_defined_data = $ilUser->getUserDefinedData();
158 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
160 $custom_fields = array();
161 foreach($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition)
165 $custom_fields[
"udf_".$definition[
'field_id']] =
166 new ilTextInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
167 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
168 $custom_fields[
"udf_".$definition[
'field_id']]->setMaxLength(255);
169 $custom_fields[
"udf_".$definition[
'field_id']]->setSize(40);
173 $custom_fields[
"udf_".$definition[
'field_id']] =
175 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
176 $custom_fields[
"udf_".$definition[
'field_id']]->setUseRte(
true);
180 $custom_fields[
"udf_".$definition[
'field_id']] =
181 new ilSelectInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
182 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
183 $custom_fields[
"udf_".$definition[
'field_id']]->setOptions(
184 $user_defined_fields->fieldValuesToSelectArray($definition[
'field_values']));
186 if($definition[
'required'])
188 $custom_fields[
"udf_".$definition[
'field_id']]->setRequired(
true);
193 include_once(
"./Services/User/classes/class.ilUserProfile.php");
196 $up->skipGroup(
"preferences");
199 $up->addStandardFieldsToForm($this->form, NULL, $custom_fields);
200 unset($custom_fields);
204 $flang = $this->form->getItemByPostVar(
"usr_language");
207 $flang->setValue($lng->getLangKey());
211 if($this->code_enabled)
213 $role = $this->form->getItemByPostVar(
"usr_roles");
214 if($role && $role->getType() ==
"select")
216 $role->setInfo($lng->txt(
"registration_code_role_info"));
223 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
224 $mail_obj->setRequired(
true);
231 $field->setTitle($lng->txt(
"usr_agreement"));
232 $this->form->addItem($field);
236 $this->form->addItem($field);
241 $this->form->addItem($field);
244 $this->form->addCommandButton(
"saveForm", $lng->txt(
"register"));
252 $form_valid = $this->form->checkInput();
254 require_once
'Services/User/classes/class.ilObjUser.php';
260 $email = $this->form->getInput(
"usr_email");
265 foreach($this->registration_settings->getAllowedDomains() as $item)
275 foreach($domains as $domain)
277 $domain = str_replace(
"*",
"~~~", $domain);
278 $domain = preg_quote($domain);
279 $domain = str_replace(
"~~~",
".+", $domain);
280 if(preg_match(
"/^".$domain.
"$/", $email, $hit))
288 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
289 $mail_obj->setAlert(sprintf($lng->txt(
"reg_email_domains"),
290 implode(
", ", $domains)));
296 if(!$this->form->getInput(
"usr_agreement"))
298 $agr_obj = $this->form->getItemByPostVar(
'usr_agreement');
299 $agr_obj->setAlert($lng->txt(
"force_accept_usr_agreement"));
306 if($this->code_enabled)
308 $code = $this->form->getInput(
'usr_registration_code');
313 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
316 $code_obj = $this->form->getItemByPostVar(
'usr_registration_code');
317 $code_obj->setAlert($lng->txt(
'registration_code_not_valid'));
332 if ($this->registration_settings->roleSelectionEnabled())
334 include_once
"./Services/AccessControl/classes/class.ilObjRole.php";
335 $selected_role = $this->form->getInput(
"usr_roles");
338 $valid_role = (int)$selected_role;
344 include_once
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
346 $valid_role = (int)$registration_role_assignments->getRoleByEmail($this->form->getInput(
"usr_email"));
358 $login_obj = $this->form->getItemByPostVar(
'username');
359 $login = $this->form->getInput(
"username");
362 $login_obj->setAlert($lng->txt(
"login_invalid"));
367 $login_obj->setAlert($lng->txt(
"login_exists"));
370 else if ((
int)$ilSetting->get(
'allow_change_loginname') &&
371 (int)$ilSetting->get(
'reuse_of_loginnames') == 0 &&
374 $login_obj->setAlert($lng->txt(
'login_exists'));
386 $this->
login($password);
390 $this->form->setValuesByPost();
401 include_once(
"./Services/User/classes/class.ilUserProfile.php");
406 $up->skipGroup(
"preferences");
407 $up->skipGroup(
"settings");
408 $up->skipGroup(
"instant_messengers");
409 $up->skipField(
"password");
410 $up->skipField(
"birthday");
411 $up->skipField(
"upload");
412 foreach ($up->getStandardFields() as $k => $v)
416 $method =
"set".substr($v[
"method"], 3);
417 if(method_exists($this->userObj, $method))
419 if ($k !=
"username")
423 $field_obj = $this->form->getItemByPostVar($k);
427 $this->userObj->$method($this->form->getInput($k));
433 $this->userObj->setFullName();
435 $birthday_obj = $this->form->getItemByPostVar(
"usr_birthday");
438 $birthday = $this->form->getInput(
"usr_birthday");
439 $birthday = $birthday[
"date"];
442 if(!is_array($birthday))
444 $this->userObj->setBirthday($birthday);
449 $map = array(
"icq",
"yahoo",
"msn",
"aim",
"skype",
"jabber",
"voip");
452 $field =
"usr_im_".$client;
453 $field_obj = $this->form->getItemByPostVar($field);
456 $this->userObj->setInstantMessengerId($client, $this->form->getInput($field));
460 $this->userObj->setTitle($this->userObj->getFullname());
461 $this->userObj->setDescription($this->userObj->getEmail());
463 if ($this->registration_settings->passwordGenerationEnabled())
466 $password = $password[0];
470 $password = $this->form->getInput(
"usr_password");
472 $this->userObj->setPasswd($password);
476 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
478 $defs = $user_defined_fields->getRegistrationDefinitions();
480 foreach (
$_POST as $k => $v)
482 if (substr($k, 0, 4) ==
"udf_")
488 $this->userObj->setUserDefinedData($udf);
490 $this->userObj->setTimeLimitOwner(7);
492 $this->code_was_used =
false;
493 if($this->code_enabled)
496 $code = $this->form->getInput(
'usr_registration_code');
500 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
502 $this->code_was_used =
true;
510 $ilias->raiseError(
"Invalid role selection in registration".
511 ", IP: ".$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
514 if ($this->registration_settings->getAccessLimitation())
516 include_once
'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
519 $access_limit_mode = $access_limitations_obj->getMode($a_role);
520 if ($access_limit_mode ==
'absolute')
522 $access_limit = $access_limitations_obj->getAbsolute($a_role);
523 $this->userObj->setTimeLimitUnlimited(0);
524 $this->userObj->setTimeLimitUntil($access_limit);
526 elseif ($access_limit_mode ==
'relative')
528 $rel_d = (int) $access_limitations_obj->getRelative($a_role,
'd');
529 $rel_m = (int) $access_limitations_obj->getRelative($a_role,
'm');
530 $rel_y = (int) $access_limitations_obj->getRelative($a_role,
'y');
532 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
533 $this->userObj->setTimeLimitUnlimited(0);
534 $this->userObj->setTimeLimitUntil($access_limit);
538 $this->userObj->setTimeLimitUnlimited(1);
539 $this->userObj->setTimeLimitUntil(time());
544 $this->userObj->setTimeLimitUnlimited(1);
545 $this->userObj->setTimeLimitUntil(time());
548 $this->userObj->setTimeLimitFrom(time());
550 $this->userObj->create();
553 if($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT ||
554 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
557 $this->userObj->setActive(1,0);
559 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
561 $this->userObj->setActive(0,0);
565 $this->userObj->setActive(0,0);
568 $this->userObj->updateOwner();
573 $this->userObj->setLastPasswordChangeTS( time() );
575 $this->userObj->setIsSelfRegistered(
true);
578 $this->userObj->saveAsNew();
581 $this->userObj->writeAccepted();
584 $this->userObj->setLanguage($this->form->getInput(
'usr_language'));
585 $hits_per_page = $ilSetting->get(
"hits_per_page");
586 if ($hits_per_page < 10)
590 $this->userObj->setPref(
"hits_per_page", $hits_per_page);
591 $show_online = $ilSetting->get(
"show_users_online");
592 if ($show_online ==
"")
596 $this->userObj->setPref(
"show_users_online", $show_online);
597 $this->userObj->writePrefs();
599 $rbacadmin->assignUser((
int)$a_role, $this->userObj->getId(),
true);
608 include_once
'./Services/Language/classes/class.ilLanguage.php';
609 include_once
'./Services/User/classes/class.ilObjUser.php';
610 include_once
"Services/Mail/classes/class.ilFormatMail.php";
611 include_once
'./Services/Registration/classes/class.ilRegistrationMailNotification.php';
618 $mail->setRecipients($this->registration_settings->getApproveRecipients());
619 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
626 $mail->setRecipients($this->registration_settings->getApproveRecipients());
627 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
636 include_once
'./Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
640 $mail->setRecipients(array($this->userObj));
641 $mail->setAdditionalInformation(
643 'usr' => $this->userObj,
644 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
652 include_once(
"Services/Mail/classes/class.ilAccountMail.php");
653 include_once
'./Services/User/classes/class.ilObjUserFolder.php';
656 if (trim($amail[
"body"]) ==
"" || trim($amail[
"subject"]) ==
"")
660 if (trim($amail[
"body"]) !=
"" && trim($amail[
"subject"]) !=
"")
663 $acc_mail->setUser($this->userObj);
664 if ($this->registration_settings->passwordGenerationEnabled())
666 $acc_mail->setUserPassword($password);
669 if($amail[
"att_file"])
671 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
674 $path = $fs->getAbsolutePath().
"/";
676 $acc_mail->addAttachment(
$path.
"/".$amail[
"lang"], $amail[
"att_file"]);
683 include_once
"Services/Mail/classes/class.ilMimeMail.php";
686 $mmail->autoCheck(
false);
687 $mmail->From($ilSetting->get(
"admin_email"));
688 $mmail->To($this->userObj->getEmail());
691 $subject = $this->lng->txt(
"reg_mail_subject");
694 $body = $this->lng->txt(
"reg_mail_body_salutation").
" ".$this->userObj->getFullname().
",\n\n".
695 $this->lng->txt(
"reg_mail_body_text1").
"\n\n".
696 $this->lng->txt(
"reg_mail_body_text2").
"\n".
697 ILIAS_HTTP_PATH.
"/login.php?client_id=".CLIENT_ID.
"\n";
698 $body .= $this->lng->txt(
"login").
": ".$this->userObj->getLogin().
"\n";
700 if ($this->registration_settings->passwordGenerationEnabled())
702 $body.= $this->lng->txt(
"passwd").
": ".$password.
"\n";
709 $body .= ($this->lng->txt(
'reg_mail_body_pwd_generation').
"\n\n");
712 $body .= ($this->lng->txt(
"reg_mail_body_text3").
"\n\r");
713 $body .= $this->userObj->getProfileAsString($this->lng);
714 $mmail->Subject($subject);
725 $ilLog->write(
"Entered login");
727 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.startup_screen.html",
"Services/Init");
729 $this->tpl->addBlockFile(
"STARTUP_CONTENT",
"startup_content",
"tpl.usr_registered.html",
730 "Services/Registration");
732 $this->tpl->setVariable(
"IMG_USER",
734 $this->tpl->setVariable(
"TXT_PAGEHEADLINE", $lng->txt(
"registration"));
735 $this->tpl->setVariable(
"TXT_WELCOME", $lng->txt(
"welcome").
", ".$this->userObj->getTitle().
"!");
737 if (($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT or
738 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES or
740 !$this->registration_settings->passwordGenerationEnabled())
742 $this->tpl->setCurrentBlock(
"activation");
743 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_registered"));
744 $this->tpl->setVariable(
"FORMACTION",
"login.php?cmd=post&target=".
$_GET[
"target"]);
745 if(isset(
$_SESSION[
'forceShoppingCartRedirect']))
747 $this->tpl->setVariable(
"FORMACTION",
'./login.php?forceShoppingCartRedirect=1');
749 $this->tpl->setVariable(
"TARGET",
"target=\"_parent\"");
750 $this->tpl->setVariable(
"TXT_LOGIN", $lng->txt(
"login_to_ilias"));
751 $this->tpl->setVariable(
"USERNAME",$this->userObj->getLogin());
752 $this->tpl->setVariable(
"PASSWORD",$password);
753 $this->tpl->parseCurrentBlock();
755 else if ($this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE)
757 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_submitted"));
759 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
761 $login_url =
'./login.php?cmd=force_login&lang='.$this->userObj->getLanguage();
762 $this->tpl->setVariable(
"TXT_REGISTERED", sprintf($lng->txt(
"reg_confirmation_link_successful"), $login_url));
763 $this->tpl->setVariable(
"REDIRECT_URL", $login_url);
767 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_registered_passw_gen"));