38 require_once
'./Services/Registration/classes/class.ilRegistrationSettings.php';
39 require_once
"./Services/User/classes/class.ilUserAgreement.php";
57 $this->ctrl->saveParameter($this,
'lang');
60 $this->lng->loadLanguageModule(
'registration');
69 if($this->registration_settings->getRegistrationType() ==
IL_REG_DISABLED)
71 $ilErr->raiseError($this->lng->txt(
'reg_disabled'),$ilErr->FATAL);
74 $next_class = $this->ctrl->getNextClass($this);
75 $cmd = $this->ctrl->getCmd();
98 $ilLog->write(
"Entered login");
100 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.usr_registered.html");
102 $this->tpl->setVariable(
"IMG_USER",
104 $this->tpl->setVariable(
"TXT_PAGEHEADLINE", $lng->txt(
"registration"));
105 $this->tpl->setVariable(
"TXT_WELCOME", $lng->txt(
"welcome").
", ".$this->userObj->getTitle().
"!");
107 if ($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT and
108 !$this->registration_settings->passwordGenerationEnabled())
110 $this->tpl->setCurrentBlock(
"activation");
111 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_registered"));
112 $this->tpl->setVariable(
"FORMACTION",
"login.php?cmd=post&target=".
$_GET[
"target"]);
113 $this->tpl->setVariable(
"TARGET",
"target=\"_parent\"");
114 $this->tpl->setVariable(
"TXT_LOGIN", $lng->txt(
"login_to_ilias"));
115 $this->tpl->setVariable(
"USERNAME",$this->userObj->getLogin());
116 $this->tpl->setVariable(
"PASSWORD",
$_POST[
"user"][
'passwd']);
117 $this->tpl->parseCurrentBlock();
119 else if ($this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE)
121 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_submitted"));
123 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
125 $this->tpl->setVariable(
"TXT_REGISTERED", sprintf($lng->txt(
"reg_confirmation_link_successful"),
'./login.php'));
126 $this->tpl->setVariable(
"REDIRECT_URL",
'./login.php');
130 $this->tpl->setVariable(
"TXT_REGISTERED", $lng->txt(
"txt_registered_passw_gen"));
137 $data[
"fields"] = array();
138 $data[
"fields"][
"login"] =
"";
140 if (!$this->registration_settings->passwordGenerationEnabled())
142 $data[
"fields"][
"passwd"] =
"";
143 $data[
"fields"][
"passwd2"] =
"";
146 $data[
"fields"][
"title"] =
"";
147 $data[
"fields"][
"gender"] =
"";
148 $data[
"fields"][
"firstname"] =
"";
149 $data[
"fields"][
"lastname"] =
"";
150 $data[
"fields"][
"institution"] =
"";
151 $data[
"fields"][
"department"] =
"";
152 $data[
"fields"][
"street"] =
"";
153 $data[
"fields"][
"city"] =
"";
154 $data[
"fields"][
"zipcode"] =
"";
155 $data[
"fields"][
"country"] =
"";
156 $data[
"fields"][
"phone_office"] =
"";
157 $data[
"fields"][
"phone_home"] =
"";
158 $data[
"fields"][
"phone_mobile"] =
"";
159 $data[
"fields"][
"fax"] =
"";
160 $data[
"fields"][
"email"] =
"";
161 $data[
"fields"][
"hobby"] =
"";
162 $data[
"fields"][
"referral_comment"] =
"";
163 $data[
"fields"][
"matriculation"] =
"";
164 $data[
"fields"][
"delicious"] =
"";
173 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.usr_registration.html");
174 $this->tpl->addBlockFile(
"STATUSLINE",
"statusline",
"tpl.statusline.html");
177 $settings = $ilias->getAllSettings();
184 foreach((array)
$data[
"fields"] as
$key => $val)
186 if(!in_array(
$key, array(
'login')))
189 if( isset($settings[
'require_' .
$key]) && (
int)$settings[
'require_' . $key] ||
190 (
int)$ilSetting->get(
'usr_settings_visib_reg_' . $key,
'1') ||
191 in_array($key, array(
'passwd',
'passwd2')) ||
193 $this->registration_settings->passwordGenerationEnabled() ||
195 $this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE
198 $this->tpl->setCurrentBlock($key.
"_section");
206 $str = $lng->txt(
$key);
209 $str = $lng->txt(
'person_title');
213 if (((isset($settings[
'require_' .
$key]) &&
214 (
int)$settings[
'require_' . $key]))
215 || in_array($key, array(
'login',
'passwd')) ||
216 ($key ==
'email' && ($this->registration_settings->passwordGenerationEnabled() ||
218 $this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE )))
220 $str = $str .
'<span class="asterisk">*</span>';
223 if($key ==
'passwd2')
226 $str = $lng->txt(
'retype_password');
227 $str = $str .
'<span class="asterisk">*</span>';
230 $this->tpl->setVariable(
"TXT_".strtoupper($key), $str);
233 if($key ==
'matriculation' || $key ==
'delicious')
235 $this->display_odata =
true;
237 else if(in_array($key, array(
'title',
'gender',
'firstname',
'lastname')))
239 $this->display_pdata =
true;
241 else if(in_array($key, array(
'institution',
'department',
'street',
'city',
242 'zipcode',
'country',
'phone_office',
'phone_home',
243 'phone_mobile',
'fax',
'email',
'hobby',
'referral_comment')))
245 $this->display_cdata =
true;
250 $this->tpl->setVariable(
'TXT_GENDER_F', $lng->txt(
'gender_f'));
251 $this->tpl->setVariable(
'TXT_GENDER_M', $lng->txt(
'gender_m'));
257 $gender = strtoupper(
$_POST[
'user'][
'gender']);
260 $this->tpl->setVariable(
'BTN_GENDER_'.$gender,
'checked="checked"');
265 if(!in_array($key, array(
'login')))
267 $this->tpl->parseCurrentBlock();
271 if($this->registration_settings->passwordGenerationEnabled())
273 $this->tpl->setCurrentBlock(
'select_password');
274 $this->tpl->setVariable(
"TXT_PASSWD_SELECT", $lng->txt(
"passwd"));
275 $this->tpl->setVariable(
"TXT_PASSWD_VIA_MAIL", $lng->txt(
"reg_passwd_via_mail"));
276 $this->tpl->parseCurrentBlock();
279 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
280 $this->tpl->setVariable(
"TXT_SAVE", $lng->txt(
"register"));
281 $this->tpl->setVariable(
"TXT_REQUIRED_FIELDS", $lng->txt(
"required_field"));
282 $this->tpl->setVariable(
"TXT_SETTINGS", $lng->txt(
"settings"));
283 $this->tpl->setVariable(
"TXT_LOGIN_DATA", $lng->txt(
"login_data"));
284 $this->tpl->setVariable(
"TXT_LANGUAGE",$lng->txt(
"language"));
285 $this->tpl->setVariable(
"TXT_OK",$lng->txt(
"ok"));
286 $this->tpl->setVariable(
"TXT_CHOOSE_LANGUAGE", $lng->txt(
"choose_language"));
287 $this->tpl->setVariable(
"REG_LANG_FORMACTION",
288 $this->ctrl->getFormAction($this));
291 $languages = $lng->getInstalledLanguages();
293 $count = (int) round(count($languages) / 2);
296 foreach ($languages as $lang_key)
305 $this->tpl->setCurrentBlock(
"languages");
306 $this->tpl->setVariable(
"LINK_LANG",$this->ctrl->getLinkTarget($this,
'displayForm'));
307 $this->tpl->setVariable(
"LANG_NAME",
309 $this->tpl->setVariable(
"LANG_ICON", $lang_key);
310 $this->tpl->setVariable(
"BORDER", 0);
311 $this->tpl->setVariable(
"VSPACE", 0);
312 $this->tpl->parseCurrentBlock();
318 $selected_lang = (isset(
$_POST[
"user"][
"language"])) ?
319 $_POST[
"user"][
"language"] : $lng->lang_key;
321 foreach ($languages as $lang_key)
323 $this->tpl->setCurrentBlock(
"language_selection");
324 $this->tpl->setVariable(
"LANG", $lng->txt(
"lang_".$lang_key));
325 $this->tpl->setVariable(
"LANGSHORT", $lang_key);
327 if ($selected_lang == $lang_key)
329 $this->tpl->setVariable(
"SELECTED_LANG",
"selected=\"selected\"");
332 $this->tpl->parseCurrentBlock();
336 $this->tpl->setVariable(
"IMG_USER",
338 $this->tpl->setVariable(
"TXT_PAGEHEADLINE", $lng->txt(
"registration"));
339 $this->tpl->setVariable(
"TXT_PAGETITLE",
"ILIAS3 - ".$lng->txt(
"registration"));
340 $this->tpl->setVariable(
"TXT_REGISTER_INFO", $lng->txt(
"register_info"));
343 $this->tpl->setVariable(
"ACCEPT_AGREEMENT", $lng->txt(
"accept_usr_agreement") .
'<span class="asterisk">*</span>');
348 if($this->display_pdata)
350 $this->tpl->setCurrentBlock(
'block_headline_personalinfo');
351 $this->tpl->setVariable(
"TXT_PERSONAL_DATA", $lng->txt(
"personal_data"));
352 $this->tpl->parseCurrentBlock();
355 if($this->display_cdata)
357 $this->tpl->setCurrentBlock(
'block_headline_contactinfo');
358 $this->tpl->setVariable(
"TXT_CONTACT_DATA", $lng->txt(
"contact_data"));
359 $this->tpl->parseCurrentBlock();
362 if($this->display_odata)
364 $this->tpl->setCurrentBlock(
'block_headline_otherdata');
365 $this->tpl->setVariable(
"TXT_OTHER", $lng->txt(
"user_profile_other"));
366 $this->tpl->parseCurrentBlock();
372 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
375 #$user_defined_data = $ilUser->getUserDefinedData();
376 foreach($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition)
378 $this->display_odata =
true;
382 $old = isset(
$_POST[
"udf"][$field_id]) ?
383 $_POST[
"udf"][$field_id] :
'';
386 $this->tpl->setCurrentBlock(
"field_text");
387 $this->tpl->setVariable(
"FIELD_NAME",
'udf['.$definition[
'field_id'].
']');
389 if(!$definition[
'changeable'])
391 $this->tpl->setVariable(
"DISABLED_FIELD",
'disabled=\"disabled\"');
393 $this->tpl->parseCurrentBlock();
397 include_once
"./Services/RTE/classes/class.ilRTE.php";
399 include_once
"./Services/RTE/classes/class.$rtestring.php";
400 $rte =
new $rtestring();
401 include_once
"./Services/Form/classes/class.ilTextAreaInputGUI.php";
403 $rte->addCustomRTESupport(0,
"", $ta->getRteTags());
405 $old = isset(
$_POST[
"udf"][$field_id]) ?
406 $_POST[
"udf"][$field_id] :
'';
408 $this->tpl->setCurrentBlock(
"field_wysiwyg");
409 $this->tpl->setVariable(
"FIELD_NAME",
'udf['.$definition[
'field_id'].
']');
411 if(!$definition[
'changeable'])
413 $this->tpl->setVariable(
"DISABLED_FIELD",
'disabled=\"disabled\"');
415 $this->tpl->parseCurrentBlock();
419 $this->tpl->setCurrentBlock(
"field_select");
421 'udf['.$definition[
'field_id'].
']',
422 $user_defined_fields->fieldValuesToSelectArray(
423 $definition[
'field_values']),
426 $this->tpl->parseCurrentBlock();
428 $this->tpl->setCurrentBlock(
"user_defined");
430 if($definition[
'required'])
432 $name = $definition[
'field_name'].
"<span class=\"asterisk\">*</span>";
436 $name = $definition[
'field_name'];
438 $this->tpl->setVariable(
"TXT_FIELD_NAME",
$name);
439 $this->tpl->parseCurrentBlock();
447 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
450 foreach($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition)
452 if($definition[
'required'] and !strlen(
$_POST[
'udf'][$field_id]))
465 require_once
'Services/User/classes/class.ilObjUser.php';
468 $settings = $ilias->getAllSettings();
471 if (
$_POST[
"status"] !=
"accepted")
479 $require_keys = array();
480 $this->profile_incomplete =
false;
483 if(in_array(
$key, array(
'login',
'passwd',
'passwd2')))
485 $require_keys[] =
$key;
489 if((
int)$settings[
'require_'.
$key])
491 #if((int)$settings['usr_settings_visib_reg_'.$key])
493 $require_keys[] =
$key;
497 # $this->profile_incomplete = true;
503 if(($this->registration_settings->passwordGenerationEnabled() ||
505 $this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE ) &&
506 !in_array(
'email', $require_keys))
508 $require_keys[] =
'email';
511 foreach($require_keys as
$key => $val)
513 if(empty(
$_POST[
'user'][$val]))
515 ilUtil::sendFailure($lng->txt(
'fill_out_all_required_fields') .
': ' . $lng->txt($val),
true);
556 if((
int)$ilSetting->get(
'allow_change_loginname') &&
557 (int)$ilSetting->get(
'prevent_reuse_of_loginnames') &&
565 if (!$this->registration_settings->passwordGenerationEnabled())
568 if (
$_POST[
"user"][
"passwd"] !=
$_POST[
"user"][
"passwd2"])
588 $_POST[
"user"][
"passwd"] = $passwd[0];
603 $this->userObj->assignData(
$_POST[
"user"]);
604 $this->userObj->setTitle($this->userObj->getFullname());
605 $this->userObj->setDescription($this->userObj->getEmail());
607 if($this->profile_incomplete)
608 $this->userObj->setProfileIncomplete(
true);
611 $this->userObj->setTimeLimitOwner(7);
613 if ($this->registration_settings->getAccessLimitation())
615 include_once
'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
619 if ($this->registration_settings->roleSelectionEnabled())
621 $default_role =
$_POST[
'user'][
'default_role'];
626 include_once
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
629 $default_role = $registration_role_assignments->getRoleByEmail($this->userObj->getEmail());
632 $access_limit_mode = $access_limitations_obj->getMode($default_role);
634 if ($access_limit_mode ==
'absolute')
636 $access_limit = $access_limitations_obj->getAbsolute($default_role);
637 $this->userObj->setTimeLimitUnlimited(0);
638 $this->userObj->setTimeLimitUntil($access_limit);
640 elseif ($access_limit_mode ==
'relative')
642 $rel_d = (int) $access_limitations_obj->getRelative($default_role,
'd');
643 $rel_m = (int) $access_limitations_obj->getRelative($default_role,
'm');
644 $rel_y = (int) $access_limitations_obj->getRelative($default_role,
'y');
646 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
647 $this->userObj->setTimeLimitUnlimited(0);
648 $this->userObj->setTimeLimitUntil($access_limit);
652 $this->userObj->setTimeLimitUnlimited(1);
653 $this->userObj->setTimeLimitUntil(time());
658 $this->userObj->setTimeLimitUnlimited(1);
659 $this->userObj->setTimeLimitUntil(time());
662 $this->userObj->setTimeLimitFrom(time());
664 $this->userObj->setUserDefinedData(
$_POST[
'udf']);
665 $this->userObj->create();
667 if($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT)
669 $this->userObj->setActive(1);
671 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
673 $this->userObj->setActive(0,0);
677 $this->userObj->setActive(0,0);
680 $this->userObj->updateOwner();
686 $this->userObj->setLastPasswordChangeTS( time() );
689 $this->userObj->saveAsNew();
692 $this->userObj->writeAccepted();
695 $this->userObj->setLanguage(
$_POST[
"user"][
"language"]);
696 $hits_per_page = $ilias->getSetting(
"hits_per_page");
697 if ($hits_per_page < 10)
701 $this->userObj->setPref(
"hits_per_page", $ilias->getSetting(
"hits_per_page"));
702 $show_online = $ilias->getSetting(
"show_users_online");
703 if ($show_online ==
"")
707 $this->userObj->setPref(
"show_users_online", $show_online);
708 $this->userObj->writePrefs();
726 include_once(
"./Services/AccessControl/classes/class.ilObjRole.php");
727 if ($this->registration_settings->roleSelectionEnabled() and
730 $ilias->raiseError(
"Invalid role selection in registration: ".
732 ", IP: ".$_SERVER[
"REMOTE_ADDR"],$ilias->error_obj->FATAL);
742 if($this->registration_settings->roleSelectionEnabled())
744 return $rbacadmin->assignUser((
int)
$_POST[
'user'][
'default_role'],
745 $this->userObj->getId(),
true);
749 include_once
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
753 return $rbacadmin->assignUser((
int) $registration_role_assignments->getRoleByEmail($this->userObj->getEmail()),
754 $this->userObj->getId(),
760 if(!$this->registration_settings->roleSelectionEnabled())
766 include_once(
"./Services/AccessControl/classes/class.ilObjRole.php");
770 foreach ($reg_roles as $role)
772 $rol[$role[
"id"]] = $role[
"title"];
775 $this->tpl->setCurrentBlock(
"role");
776 $this->tpl->setVariable(
"TXT_DEFAULT_ROLE",$this->lng->txt(
'default_role'));
778 "user[default_role]",
780 $this->tpl->parseCurrentBlock();
789 include_once
'./Services/Language/classes/class.ilLanguage.php';
790 include_once
'./Services/User/classes/class.ilObjUser.php';
791 include_once
"Services/Mail/classes/class.ilFormatMail.php";
793 include_once
'./Services/Registration/classes/class.ilRegistrationMailNotification.php';
795 $settings = $ilias->getAllSettings();
798 if($this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE)
802 $mail->setRecipients($this->registration_settings->getApproveRecipients());
803 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
810 $mail->setRecipients($this->registration_settings->getApproveRecipients());
811 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
820 include_once
'Services/Mail/classes/class.ilMail.php';
821 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
824 $subject = $this->lng->txt(
"reg_mail_subject_confirmation");
828 $body = $this->lng->txt(
"reg_mail_body_salutation").
" ".$this->userObj->getFullname().
",\n\n";
829 $body .= $this->lng->txt(
'reg_mail_body_confirmation').
"\n".
830 ILIAS_HTTP_PATH.
'/confirmReg.php?client_id='.CLIENT_ID.
"&rh=".$hashcode.
"\n\n";
832 $body .= sprintf($this->lng->txt(
'reg_mail_body_2_confirmation'),
835 $body .= $this->lng->txt(
'reg_mail_body_3_confirmation');
837 $mail_obj->enableSoap(
false);
838 $mail_obj->appendInstallationSignature(
true);
839 $mail_obj->sendMail($this->userObj->getEmail(),
'',
'',
842 array(), array(
'normal'));
847 include_once(
"Services/Mail/classes/class.ilAccountMail.php");
848 include_once
'./Services/User/classes/class.ilObjUserFolder.php';
850 if (trim($amail[
"body"]) !=
"" && trim($amail[
"subject"]) !=
"")
853 $acc_mail->setUser($this->userObj);
854 if ($this->registration_settings->passwordGenerationEnabled())
856 $acc_mail->setUserPassword(
$_POST[
"user"][
"passwd"]);
862 include_once
"Services/Mail/classes/class.ilMimeMail.php";
865 $mmail->autoCheck(
false);
866 $mmail->From($settings[
"admin_email"]);
867 $mmail->To($this->userObj->getEmail());
870 $subject = $this->lng->txt(
"reg_mail_subject");
873 $body = $this->lng->txt(
"reg_mail_body_salutation").
" ".$this->userObj->getFullname().
",\n\n".
874 $this->lng->txt(
"reg_mail_body_text1").
"\n\n".
875 $this->lng->txt(
"reg_mail_body_text2").
"\n".
876 ILIAS_HTTP_PATH.
"/login.php?client_id=".$ilias->client_id.
"\n";
877 $body .= $this->lng->txt(
"login").
": ".$this->userObj->getLogin().
"\n";
879 if ($this->registration_settings->passwordGenerationEnabled())
881 $body.= $this->lng->txt(
"passwd").
": ".
$_POST[
"user"][
"passwd"].
"\n";
886 if($this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE)
888 $body .= ($this->lng->txt(
'reg_mail_body_pwd_generation').
"\n\n");
891 $body .= ($this->lng->txt(
"reg_mail_body_text3").
"\n\r");
892 $body .= $this->userObj->getProfileAsString($this->lng);
893 $mmail->Subject($subject);