39 $lng = $DIC->language();
44 $this->ctrl->saveParameter($this,
'lang');
47 $this->lng->loadLanguageModule(
'registration');
51 $this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
52 $this->registration_settings->getAllowCodes());
54 $this->termsOfServiceEvaluation = $DIC[
'tos.document.evaluator'];
64 if ($this->registration_settings->getRegistrationType() ==
IL_REG_DISABLED) {
65 $ilErr->raiseError($this->lng->txt(
'reg_disabled'),
$ilErr->FATAL);
68 $next_class = $this->ctrl->getNextClass($this);
69 $cmd = $this->ctrl->getCmd();
71 switch ($next_class) {
80 $tpl->setPermanentLink(
'usr', null,
'registration');
91 ilStartUpGUI::initStartUpTemplate(array(
'tpl.usr_registration.html',
'Services/Registration'),
true);
92 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'registration'));
97 $this->tpl->setVariable(
'FORM', $this->form->getHTML());
106 $ilUser->setLanguage($this->lng->getLangKey());
107 $ilUser->setId(ANONYMOUS_USER_ID);
113 $this->form->setFormAction($this->ctrl->getFormAction($this));
118 if ($this->code_enabled) {
120 $field->setTitle($this->lng->txt(
'registration_codes_type_reg'));
121 $this->form->addItem($field);
125 if ((
bool) $this->registration_settings->registrationCodeRequired()) {
126 $code->setRequired(
true);
127 $code->setInfo($this->lng->txt(
"registration_code_required_info"));
129 $code->setInfo($this->lng->txt(
"registration_code_optional_info"));
131 $this->form->addItem(
$code);
136 $user_defined_data =
$ilUser->getUserDefinedData();
139 $custom_fields = array();
141 foreach ($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition) {
145 $user_defined_data[
'f_' . $field_id]
148 $custom_fields[
'udf_' . $definition[
'field_id']] = $fprop;
155 $up->skipGroup(
"preferences");
157 $up->setAjaxCallback(
158 $this->ctrl->getLinkTarget($this,
'doProfileAutoComplete',
'',
true)
161 $this->lng->loadLanguageModule(
"user");
164 $up->addStandardFieldsToForm($this->form, null, $custom_fields);
165 unset($custom_fields);
169 $flang = $this->form->getItemByPostVar(
"usr_language");
171 $flang->setValue($this->lng->getLangKey());
175 if ($this->code_enabled) {
176 $role = $this->form->getItemByPostVar(
"usr_roles");
177 if ($role && $role->getType() ==
"select") {
178 $role->setInfo($this->lng->txt(
"registration_code_role_info"));
184 foreach ($this->registration_settings->getAllowedDomains() as $item) {
189 if (
sizeof($domains)) {
190 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
191 $mail_obj->setInfo(sprintf(
192 $this->lng->txt(
"reg_email_domains"),
193 implode(
", ", $domains)
195 ($this->code_enabled ? $this->lng->txt(
"reg_email_domains_code") :
""));
200 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
202 $mail_obj->setRequired(
true);
207 $document = $this->termsOfServiceEvaluation->document();
210 $field->setTitle($this->lng->txt(
'usr_agreement'));
211 $this->form->addItem($field);
214 $field->setHTML(
'<div id="agreement">' . $document->content() .
'</div>');
215 $this->form->addItem($field);
217 $field =
new ilCheckboxInputGUI($this->lng->txt(
'accept_usr_agreement'),
'accept_terms_of_service');
220 $this->form->addItem($field);
224 if (ilCaptchaUtil::isActiveForRegistration()) {
225 $captcha =
new ilCaptchaInputGUI($this->lng->txt(
"captcha_code"),
'captcha_code');
227 $this->form->addItem($captcha);
230 $this->form->addCommandButton(
"saveForm", $this->lng->txt(
"register"));
238 $rbacreview = $DIC->rbac()->review();
241 $form_valid = $this->form->checkInput();
244 $valid_code = $valid_role =
false;
247 if ($this->code_enabled) {
248 $code = $this->form->getInput(
'usr_registration_code');
251 $this->registration_settings->registrationCodeRequired() ||
256 $code_obj = $this->form->getItemByPostVar(
'usr_registration_code');
257 $code_obj->setAlert($this->lng->txt(
'registration_code_not_valid'));
264 if ($role_id && $rbacreview->isGlobalRole($role_id)) {
265 $valid_role = $role_id;
274 $email = $this->form->getInput(
"usr_email");
278 foreach ($this->registration_settings->getAllowedDomains() as $item) {
283 if (
sizeof($domains)) {
285 foreach ($domains as
$domain) {
286 $domain = str_replace(
"*",
"~~~", $domain);
287 $domain = preg_quote($domain);
288 $domain = str_replace(
"~~~",
".+", $domain);
289 if (preg_match(
"/^" . $domain .
"$/",
$email, $hit)) {
295 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
296 $mail_obj->setAlert(sprintf(
297 $this->lng->txt(
"reg_email_domains"),
298 implode(
", ", $domains)
308 !$this->registration_settings->passwordGenerationEnabled() &&
311 $passwd_obj = $this->form->getItemByPostVar(
'usr_password');
312 $passwd_obj->setAlert($this->lng->txt($error_lng_var));
316 $showGlobalTermsOfServieFailure =
false;
318 $agr_obj = $this->form->getItemByPostVar(
'accept_terms_of_service');
320 $agr_obj->setAlert($this->lng->txt(
'force_accept_usr_agreement'));
323 $showGlobalTermsOfServieFailure =
true;
330 if ($this->registration_settings->roleSelectionEnabled()) {
331 $selected_role = $this->form->getInput(
"usr_roles");
333 $valid_role = (int) $selected_role;
339 $valid_role = (int) $registration_role_assignments->getRoleByEmail($this->form->getInput(
"usr_email"));
350 $login_obj = $this->form->getItemByPostVar(
'username');
351 $login = $this->form->getInput(
"username");
352 $captcha = $this->form->getItemByPostVar(
"captcha_code");
354 $login_obj->setAlert($this->lng->txt(
"login_invalid"));
357 if(!empty($captcha) && empty($captcha->getAlert()) || empty($captcha)) {
358 $login_obj->setAlert($this->lng->txt(
"login_exists"));
361 } elseif ((
int)
$ilSetting->get(
'allow_change_loginname') &&
362 (int)
$ilSetting->get(
'reuse_of_loginnames') == 0 &&
364 if(!empty($captcha) && empty($captcha->getAlert()) || empty($captcha)) {
365 $login_obj->setAlert($this->lng->txt(
"login_exists"));
372 } elseif ($showGlobalTermsOfServieFailure) {
373 $this->lng->loadLanguageModule(
'tos');
375 $this->lng->txt(
'tos_account_reg_not_possible'),
379 $password = $this->__createUser($valid_role);
381 return $this->
login();
384 $this->form->setValuesByPost();
389 protected function __createUser($a_role)
398 $rbacadmin = $DIC->rbac()->admin();
405 $ilias = $DIC[
'ilias'];
406 $ilias->raiseError(
"Invalid role selection in registration" .
407 ", IP: " .
$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
417 $up->skipGroup(
"preferences");
418 $up->skipGroup(
"settings");
419 $up->skipField(
"password");
420 $up->skipField(
"birthday");
421 $up->skipField(
"upload");
422 foreach ($up->getStandardFields() as $k => $v) {
424 $method =
"set" . substr($v[
"method"], 3);
425 if (method_exists($this->userObj, $method)) {
426 if ($k !=
"username") {
429 $field_obj = $this->form->getItemByPostVar($k);
431 $this->userObj->$method($this->form->getInput($k));
437 $this->userObj->setFullName();
439 $birthday_obj = $this->form->getItemByPostVar(
"usr_birthday");
441 $birthday = $this->form->getInput(
"usr_birthday");
442 $this->userObj->setBirthday($birthday);
445 $this->userObj->setTitle($this->userObj->getFullname());
446 $this->userObj->setDescription($this->userObj->getEmail());
448 if ($this->registration_settings->passwordGenerationEnabled()) {
452 $password = $this->form->getInput(
"usr_password");
459 $defs = $user_defined_fields->getRegistrationDefinitions();
461 foreach (
$_POST as $k => $v) {
462 if (substr($k, 0, 4) ==
"udf_") {
467 $this->userObj->setUserDefinedData($udf);
469 $this->userObj->setTimeLimitOwner(7);
472 $access_limit = null;
474 $this->code_was_used =
false;
475 if ($this->code_enabled) {
476 $code_local_roles = $code_has_access_limit = null;
479 $code = $this->form->getInput(
'usr_registration_code');
484 $this->code_was_used =
true;
488 if ($code_data[
"role_local"]) {
490 $code_local_roles = explode(
";", $code_data[
"role_local"]);
492 if ($code_data[
"alimit"]) {
494 $code_has_access_limit =
true;
496 switch ($code_data[
"alimit"]) {
498 $abs = date_parse($code_data[
"alimitdt"]);
499 $access_limit = mktime(23, 59, 59, $abs[
'month'], $abs[
'day'], $abs[
'year']);
503 $rel = unserialize($code_data[
"alimitdt"]);
504 $access_limit = $rel[
"d"] * 86400 + $rel[
"m"] * 2592000 +
505 $rel[
"y"] * 31536000 + time();
513 if (!($this->code_was_used && $code_has_access_limit) &&
514 $this->registration_settings->getAccessLimitation()) {
516 switch ($access_limitations_obj->getMode($a_role)) {
518 $access_limit = $access_limitations_obj->getAbsolute($a_role);
522 $rel_d = (int) $access_limitations_obj->getRelative($a_role,
'd');
523 $rel_m = (int) $access_limitations_obj->getRelative($a_role,
'm');
524 $rel_y = (int) $access_limitations_obj->getRelative($a_role,
'y');
525 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
531 $this->userObj->setTimeLimitUnlimited(0);
532 $this->userObj->setTimeLimitUntil($access_limit);
534 $this->userObj->setTimeLimitUnlimited(1);
535 $this->userObj->setTimeLimitUntil(time());
538 $this->userObj->setTimeLimitFrom(time());
542 $this->userObj->create();
545 if ($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT ||
546 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
548 $this->userObj->setActive(1, 0);
549 } elseif ($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION) {
550 $this->userObj->setActive(0, 0);
552 $this->userObj->setActive(0, 0);
555 $this->userObj->updateOwner();
559 $this->userObj->setLastPasswordChangeTS(time());
561 $this->userObj->setIsSelfRegistered(
true);
564 $this->userObj->saveAsNew();
567 $this->userObj->setLanguage($this->form->getInput(
'usr_language'));
570 if ($handleDocument) {
571 $helper = new \ilTermsOfServiceHelper();
573 $helper->trackAcceptance($this->userObj, $this->termsOfServiceEvaluation->document());
576 $hits_per_page =
$ilSetting->get(
"hits_per_page");
577 if ($hits_per_page < 10) {
580 $this->userObj->setPref(
"hits_per_page", $hits_per_page);
581 if (strlen(
$_GET[
'target']) > 0) {
590 $this->userObj->setPref(
'bs_allow_to_contact_me',
$ilSetting->get(
'bs_allow_to_contact_me',
'n'));
591 $this->userObj->setPref(
'chat_osc_accept_msg',
$ilSetting->get(
'chat_osc_accept_msg',
'n'));
592 $this->userObj->writePrefs();
595 $rbacadmin->assignUser((
int) $a_role, $this->userObj->getId());
598 if ($this->code_was_used && is_array($code_local_roles)) {
599 foreach (array_unique($code_local_roles) as $local_role_obj_id) {
602 $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
605 $role_obj =
$GLOBALS[
'DIC'][
'rbacreview']->getObjectOfRole($local_role_obj_id);
610 $role_ref = end($role_refs);
628 $mail->setRecipients($this->registration_settings->getApproveRecipients());
629 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
634 $mail->setRecipients($this->registration_settings->getApproveRecipients());
635 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
645 $mail->setRecipients(array($this->userObj));
646 $mail->setAdditionalInformation(
648 'usr' => $this->userObj,
649 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
655 $this->registration_settings,
659 $accountMail->withDirectRegistrationMode()->send($this->userObj,
$password, $this->code_was_used);
666 $f = $DIC->ui()->factory();
667 $renderer = $DIC->ui()->renderer();
669 ilStartUpGUI::initStartUpTemplate(array(
'tpl.usr_registered.html',
'Services/Registration'),
false);
670 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'registration'));
672 $this->tpl->setVariable(
"TXT_WELCOME", $this->lng->txt(
"welcome") .
", " . $this->userObj->getTitle() .
"!");
675 $this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT ||
676 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
679 !$this->registration_settings->passwordGenerationEnabled()
681 $this->tpl->setVariable(
'TXT_REGISTERED', $this->lng->txt(
'txt_registered'));
683 $login_link = $renderer->render(
$f->link()->standard($this->lng->txt(
'login_to_ilias'),
'./login.php?cmd=force_login&lang=' . $this->userObj->getLanguage()));
684 $this->tpl->setVariable(
'LOGIN_LINK', $login_link);
685 } elseif ($this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE) {
686 $this->tpl->setVariable(
'TXT_REGISTERED', $this->lng->txt(
'txt_submitted'));
687 } elseif ($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION) {
688 $this->tpl->setVariable(
'TXT_REGISTERED', $this->lng->txt(
'reg_confirmation_link_successful'));
690 $this->tpl->setVariable(
'TXT_REGISTERED', $this->lng->txt(
'txt_registered_passw_gen'));
699 protected function showLogin()
705 $auth_session = $DIC[
'ilAuthSession'];
706 $auth_session->setAuthenticated(
708 $DIC->user()->getId()
710 ilInitialisation::initUserAccount();
711 return ilInitialisation::redirectToStartingPage();
716 $field_id = (string) $_REQUEST[
"f"];
717 $term = (string) $_REQUEST[
"term"];
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$termsOfServiceEvaluation
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static getCodeData($code)
Class for mime mail registration notifications.
static _getInstance()
Get instance.
Class ilAccountRegistrationGUI.
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static getInstance()
Get instance.
const TYPE_NOTIFICATION_ACTIVATION
static getAutocompleteResult($a_field_id, $a_term)
static generatePasswords($a_number)
Generate a number of passwords.
__distributeMails($password)
static _getAllReferences($a_id)
get all reference ids of object
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getInstance()
Get instance.
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
const TYPE_NOTIFICATION_APPROVERS
static getCodeRole($code)
static encode($mixed, $suppress_native=false)
Class ilAccountRegistrationMail.
static isValidRegistrationCode($a_code)
Check if given code is a valid registration code.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static getLogger($a_component_id)
Get component logger.
if(!array_key_exists('domain', $_REQUEST)) $domain
const CONTEXT_REGISTRATION
static _lookupAllowRegister($a_role_id)
check whether role is allowed in user registration or not
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
static _doesLoginnameExistInHistory($a_login)
Checks wether the passed loginname already exists in history.
const TYPE_NOTIFICATION_CONFIRMATION