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);
87 foreach ($lng->getInstalledLanguages() as $lang_key)
89 $this->tpl->setCurrentBlock(
"languages");
90 $this->tpl->setVariable(
"LINK_LANG",$this->ctrl->getLinkTarget($this,
'displayForm'));
91 $this->tpl->setVariable(
"LANG_NAME",
93 $this->tpl->setVariable(
"LANG_ICON", $lang_key);
94 $this->tpl->setVariable(
"BORDER", 0);
95 $this->tpl->setVariable(
"VSPACE", 0);
96 $this->tpl->parseCurrentBlock();
103 $this->tpl->setVariable(
"FORM", $this->form->getHTML());
108 global
$lng, $ilUser;
110 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
112 $this->form->setFormAction($this->ctrl->getFormAction($this));
117 $user_defined_data = $ilUser->getUserDefinedData();
119 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
121 $custom_fields = array();
122 foreach($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition)
126 $custom_fields[
"udf_".$definition[
'field_id']] =
127 new ilTextInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
128 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
129 $custom_fields[
"udf_".$definition[
'field_id']]->setMaxLength(255);
130 $custom_fields[
"udf_".$definition[
'field_id']]->setSize(40);
134 $custom_fields[
"udf_".$definition[
'field_id']] =
136 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
137 $custom_fields[
"udf_".$definition[
'field_id']]->setUseRte(
true);
141 $custom_fields[
"udf_".$definition[
'field_id']] =
142 new ilSelectInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
143 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
144 $custom_fields[
"udf_".$definition[
'field_id']]->setOptions(
145 $user_defined_fields->fieldValuesToSelectArray($definition[
'field_values']));
147 if($definition[
'required'])
149 $custom_fields[
"udf_".$definition[
'field_id']]->setRequired(
true);
154 include_once(
"./Services/User/classes/class.ilUserProfile.php");
157 $up->skipGroup(
"preferences");
160 $up->addStandardFieldsToForm($this->form, NULL, $custom_fields);
161 unset($custom_fields);
167 $field->setTitle($lng->txt(
"usr_agreement"));
168 $this->form->addItem($field);
172 $this->form->addItem($field);
177 $this->form->addItem($field);
179 $this->form->addCommandButton(
"saveForm", $lng->txt(
"register"));
187 if($this->form->checkInput())
189 require_once
'Services/User/classes/class.ilObjUser.php';
195 if(!$this->form->getInput(
"usr_agreement"))
202 if($this->registration_settings->registrationCodeRequired() ||
203 $this->registration_settings->getAllowCodes())
205 $code = $this->form->getInput(
"usr_registration_code");
206 if($code || $this->registration_settings->registrationCodeRequired())
208 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
211 $code_obj = $this->form->getItemByPostVar(
'usr_registration_code');
212 $code_obj->setAlert($lng->txt(
'registration_code_not_valid'));
219 $login_obj = $this->form->getItemByPostVar(
'username');
220 $login = $this->form->getInput(
"username");
223 $login_obj->setAlert($lng->txt(
"login_invalid"));
228 $login_obj->setAlert($lng->txt(
"login_exists"));
231 else if ((
int)$ilSetting->get(
'allow_change_loginname') &&
232 (int)$ilSetting->get(
'prevent_reuse_of_loginnames') &&
235 $login_obj->setAlert($lng->txt(
'login_exists'));
250 $this->
login($password);
255 $this->form->setValuesByPost();
266 include_once(
"./Services/User/classes/class.ilUserProfile.php");
271 $up->skipGroup(
"preferences");
272 $up->skipGroup(
"settings");
273 $up->skipGroup(
"instant_messengers");
274 $up->skipField(
"password");
275 $up->skipField(
"birthday");
276 $up->skipField(
"upload");
277 foreach (
$up->getStandardFields() as $k => $v)
281 $method =
"set".substr($v[
"method"], 3);
282 if(method_exists($this->userObj, $method))
284 if ($k !=
"username")
288 $field_obj = $this->form->getItemByPostVar($k);
291 $this->userObj->$method($this->form->getInput($k));
297 $this->userObj->setFullName();
299 $birthday_obj = $this->form->getItemByPostVar(
"usr_birthday");
302 $birthday = $this->form->getInput(
"usr_birthday");
303 $birthday = $birthday[
"date"];
306 if(!is_array($birthday))
308 $this->userObj->setBirthday($birthday);
313 $map = array(
"icq",
"yahoo",
"msn",
"aim",
"skype",
"jabber",
"voip");
316 $field =
"usr_im_".$client;
317 $field_obj = $this->form->getItemByPostVar($field);
320 $this->userObj->setInstantMessengerId($client, $this->form->getInput($field));
324 $this->userObj->setTitle($this->userObj->getFullname());
325 $this->userObj->setDescription($this->userObj->getEmail());
327 if ($this->registration_settings->passwordGenerationEnabled())
330 $password = $password[0];
334 $password = $this->form->getInput(
"usr_password");
336 $this->userObj->setPasswd($password);
340 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
342 $defs = $user_defined_fields->getRegistrationDefinitions();
344 foreach (
$_POST as $k => $v)
346 if (substr($k, 0, 4) ==
"udf_")
352 $this->userObj->setUserDefinedData($udf);
354 $this->userObj->setTimeLimitOwner(7);
357 $default_role =
false;
358 if ($this->registration_settings->roleSelectionEnabled())
360 $default_role = $this->form->getInput(
'usr_roles');
365 include_once
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
367 $default_role = $registration_role_assignments->getRoleByEmail($this->userObj->getEmail());
371 $code = $this->form->getInput(
'usr_registration_code');
372 $this->code_was_used =
false;
373 if($this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
374 ($code && $this->registration_settings->getAllowCodes()))
376 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
379 $this->code_was_used =
true;
383 if ($this->registration_settings->getAccessLimitation())
385 include_once
'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
388 $access_limit_mode = $access_limitations_obj->getMode($default_role);
389 if ($access_limit_mode ==
'absolute')
391 $access_limit = $access_limitations_obj->getAbsolute($default_role);
392 $this->userObj->setTimeLimitUnlimited(0);
393 $this->userObj->setTimeLimitUntil($access_limit);
395 elseif ($access_limit_mode ==
'relative')
397 $rel_d = (int) $access_limitations_obj->getRelative($default_role,
'd');
398 $rel_m = (int) $access_limitations_obj->getRelative($default_role,
'm');
399 $rel_y = (int) $access_limitations_obj->getRelative($default_role,
'y');
401 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
402 $this->userObj->setTimeLimitUnlimited(0);
403 $this->userObj->setTimeLimitUntil($access_limit);
407 $this->userObj->setTimeLimitUnlimited(1);
408 $this->userObj->setTimeLimitUntil(time());
413 $this->userObj->setTimeLimitUnlimited(1);
414 $this->userObj->setTimeLimitUntil(time());
417 $this->userObj->setTimeLimitFrom(time());
419 $this->userObj->create();
422 if($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT ||
423 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
426 $this->userObj->setActive(1,0);
428 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
430 $this->userObj->setActive(0,0);
434 $this->userObj->setActive(0,0);
437 $this->userObj->updateOwner();
442 $this->userObj->setLastPasswordChangeTS( time() );
445 $this->userObj->saveAsNew();
448 $this->userObj->writeAccepted();
451 $this->userObj->setLanguage($this->form->getInput(
'usr_language'));
452 $hits_per_page = $ilSetting->get(
"hits_per_page");
453 if ($hits_per_page < 10)
457 $this->userObj->setPref(
"hits_per_page", $hits_per_page);
458 $show_online = $ilSetting->get(
"show_users_online");
459 if ($show_online ==
"")
463 $this->userObj->setPref(
"show_users_online", $show_online);
464 $this->userObj->writePrefs();
466 $rbacadmin->assignUser((
int)$default_role, $this->userObj->getId(),
true);
476 include_once(
"./Services/AccessControl/classes/class.ilObjRole.php");
477 if ($this->registration_settings->roleSelectionEnabled() and
480 $ilias->raiseError(
"Invalid role selection in registration: ".
482 ", IP: ".$_SERVER[
"REMOTE_ADDR"],$ilias->error_obj->FATAL);
491 include_once
'./Services/Language/classes/class.ilLanguage.php';
492 include_once
'./Services/User/classes/class.ilObjUser.php';
493 include_once
"Services/Mail/classes/class.ilFormatMail.php";
494 include_once
'./Services/Registration/classes/class.ilRegistrationMailNotification.php';
501 $mail->setRecipients($this->registration_settings->getApproveRecipients());
502 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
509 $mail->setRecipients($this->registration_settings->getApproveRecipients());
510 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
519 include_once
'Services/Mail/classes/class.ilMail.php';
520 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
523 $subject = $this->lng->txt(
"reg_mail_subject_confirmation");
527 $body = $this->lng->txt(
"reg_mail_body_salutation").
" ".$this->userObj->getFullname().
",\n\n";
528 $body .= $this->lng->txt(
'reg_mail_body_confirmation').
"\n".
529 ILIAS_HTTP_PATH.
'/confirmReg.php?client_id='.CLIENT_ID.
"&rh=".$hashcode.
"\n\n";
531 $body .= sprintf($this->lng->txt(
'reg_mail_body_2_confirmation'),
534 $body .= $this->lng->txt(
'reg_mail_body_3_confirmation');
536 $mail_obj->enableSoap(
false);
537 $mail_obj->appendInstallationSignature(
true);
538 $mail_obj->sendMail($this->userObj->getEmail(),
'',
'',
541 array(), array(
'normal'));
546 include_once(
"Services/Mail/classes/class.ilAccountMail.php");
547 include_once
'./Services/User/classes/class.ilObjUserFolder.php';
549 if (trim($amail[
"body"]) !=
"" && trim($amail[
"subject"]) !=
"")
552 $acc_mail->setUser($this->userObj);
553 if ($this->registration_settings->passwordGenerationEnabled())
555 $acc_mail->setUserPassword($password);
561 include_once
"Services/Mail/classes/class.ilMimeMail.php";
564 $mmail->autoCheck(
false);
565 $mmail->From($ilSetting->get(
"admin_email"));
566 $mmail->To($this->userObj->getEmail());
569 $subject = $this->lng->txt(
"reg_mail_subject");
572 $body = $this->lng->txt(
"reg_mail_body_salutation").
" ".$this->userObj->getFullname().
",\n\n".
573 $this->lng->txt(
"reg_mail_body_text1").
"\n\n".
574 $this->lng->txt(
"reg_mail_body_text2").
"\n".
575 ILIAS_HTTP_PATH.
"/login.php?client_id=".$ilias->client_id.
"\n";
576 $body .= $this->lng->txt(
"login").
": ".$this->userObj->getLogin().
"\n";
578 if ($this->registration_settings->passwordGenerationEnabled())
580 $body.= $this->lng->txt(
"passwd").
": ".$password.
"\n";
587 $body .= ($this->lng->txt(
'reg_mail_body_pwd_generation').
"\n\n");
590 $body .= ($this->lng->txt(
"reg_mail_body_text3").
"\n\r");
591 $body .= $this->userObj->getProfileAsString($this->lng);
592 $mmail->Subject($subject);
603 $ilLog->write(
"Entered login");
605 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.usr_registered.html");
607 $this->tpl->setVariable(
"IMG_USER",
609 $this->tpl->setVariable(
"TXT_PAGEHEADLINE", $lng->txt(
"registration"));
610 $this->tpl->setVariable(
"TXT_WELCOME", $lng->txt(
"welcome").
", ".$this->userObj->getTitle().
"!");
612 if (($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT or
613 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES or
615 !$this->registration_settings->passwordGenerationEnabled())
617 $this->tpl->setCurrentBlock(
"activation");
618 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_registered"));
619 $this->tpl->setVariable(
"FORMACTION",
"login.php?cmd=post&target=".
$_GET[
"target"]);
620 $this->tpl->setVariable(
"TARGET",
"target=\"_parent\"");
621 $this->tpl->setVariable(
"TXT_LOGIN", $lng->txt(
"login_to_ilias"));
622 $this->tpl->setVariable(
"USERNAME",$this->userObj->getLogin());
623 $this->tpl->setVariable(
"PASSWORD",$password);
624 $this->tpl->parseCurrentBlock();
626 else if ($this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE)
628 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_submitted"));
630 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
632 $this->tpl->setVariable(
"TXT_REGISTERED", sprintf($lng->txt(
"reg_confirmation_link_successful"),
'./login.php'));
633 $this->tpl->setVariable(
"REDIRECT_URL",
'./login.php');
637 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_registered_passw_gen"));