18 require_once
'./Services/Registration/classes/class.ilRegistrationSettings.php';
19 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
37 $this->ctrl->saveParameter($this,
'lang');
40 $this->lng->loadLanguageModule(
'registration');
44 $this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
45 $this->registration_settings->getAllowCodes());
52 if($this->registration_settings->getRegistrationType() ==
IL_REG_DISABLED)
54 $ilErr->raiseError($this->lng->txt(
'reg_disabled'),$ilErr->FATAL);
57 $next_class = $this->ctrl->getNextClass($this);
58 $cmd = $this->ctrl->getCmd();
80 public function displayForm()
87 ilStartUpGUI::initStartUpTemplate(array(
'tpl.usr_registration.html',
'Services/Registration'),
true);
88 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'registration'));
94 $this->tpl->setVariable(
'FORM', $this->form->getHTML());
102 include_once
'Services/jQuery/classes/class.iljQueryUtil.php';
105 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
107 $this->form->setFormAction($this->ctrl->getFormAction($this));
112 if($this->code_enabled)
114 include_once
'Services/Registration/classes/class.ilRegistrationCode.php';
115 $code =
new ilTextInputGUI($lng->txt(
"registration_code"),
"usr_registration_code");
118 if((
bool)$this->registration_settings->registrationCodeRequired())
120 $code->setRequired(
true);
121 $code->setInfo($lng->txt(
"registration_code_required_info"));
125 $code->setInfo($lng->txt(
"registration_code_optional_info"));
127 $this->form->addItem($code);
133 $user_defined_data = $ilUser->getUserDefinedData();
135 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
137 $custom_fields = array();
138 foreach($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition)
142 $custom_fields[
"udf_".$definition[
'field_id']] =
143 new ilTextInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
144 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
145 $custom_fields[
"udf_".$definition[
'field_id']]->setMaxLength(255);
146 $custom_fields[
"udf_".$definition[
'field_id']]->setSize(40);
150 $custom_fields[
"udf_".$definition[
'field_id']] =
152 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
153 $custom_fields[
"udf_".$definition[
'field_id']]->setUseRte(
true);
157 $custom_fields[
"udf_".$definition[
'field_id']] =
158 new ilSelectInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
159 $custom_fields[
"udf_".$definition[
'field_id']]->setValue($user_defined_data[
"f_".$field_id]);
160 $custom_fields[
"udf_".$definition[
'field_id']]->setOptions(
161 $user_defined_fields->fieldValuesToSelectArray($definition[
'field_values']));
163 if($definition[
'required'])
165 $custom_fields[
"udf_".$definition[
'field_id']]->setRequired(
true);
168 if($definition[
'field_type'] ==
UDF_TYPE_SELECT && !$user_defined_data[
"f_".$field_id])
170 $options = array(
""=>$lng->txt(
"please_select")) + $custom_fields[
"udf_".$definition[
'field_id']]->getOptions();
171 $custom_fields[
"udf_".$definition[
'field_id']]->setOptions(
$options);
176 include_once(
"./Services/User/classes/class.ilUserProfile.php");
179 $up->skipGroup(
"preferences");
181 $up->setAjaxCallback(
182 $this->ctrl->getLinkTarget($this,
'doProfileAutoComplete',
'',
true)
185 $lng->loadLanguageModule(
"user");
188 $up->addStandardFieldsToForm($this->form, NULL, $custom_fields);
189 unset($custom_fields);
193 $flang = $this->form->getItemByPostVar(
"usr_language");
196 $flang->setValue($lng->getLangKey());
200 if($this->code_enabled)
202 $role = $this->form->getItemByPostVar(
"usr_roles");
203 if($role && $role->getType() ==
"select")
205 $role->setInfo($lng->txt(
"registration_code_role_info"));
211 foreach($this->registration_settings->getAllowedDomains() as $item)
220 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
221 $mail_obj->setInfo(sprintf($lng->txt(
"reg_email_domains"),
222 implode(
", ", $domains)).
"<br />".
223 ($this->code_enabled ? $lng->txt(
"reg_email_domains_code") :
""));
229 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
232 $mail_obj->setRequired(
true);
236 if(ilTermsOfServiceHelper::isEnabled())
240 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
243 $field->setTitle($lng->txt(
'usr_agreement'));
244 $this->form->addItem($field);
247 $field->setHTML(
'<div id="agreement">' . $document->getContent() .
'</div>');
248 $this->form->addItem($field);
250 $field =
new ilCheckboxInputGUI($lng->txt(
'accept_usr_agreement'),
'accept_terms_of_service');
253 $this->form->addItem($field);
260 require_once
'Services/Captcha/classes/class.ilCaptchaUtil.php';
261 if(ilCaptchaUtil::isActiveForRegistration())
263 require_once
'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
266 $this->form->addItem($captcha);
269 $this->form->addCommandButton(
"saveForm", $lng->txt(
"register"));
277 $form_valid = $this->form->checkInput();
279 require_once
'Services/User/classes/class.ilObjUser.php';
283 $valid_code = $valid_role =
false;
286 if($this->code_enabled)
288 $code = $this->form->getInput(
'usr_registration_code');
291 $this->registration_settings->registrationCodeRequired() ||
296 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
299 $code_obj = $this->form->getItemByPostVar(
'usr_registration_code');
300 $code_obj->setAlert($lng->txt(
'registration_code_not_valid'));
309 if($role_id && $rbacreview->isGlobalRole($role_id))
311 $valid_role = $role_id;
321 $email = $this->form->getInput(
"usr_email");
326 foreach($this->registration_settings->getAllowedDomains() as $item)
336 foreach($domains as $domain)
338 $domain = str_replace(
"*",
"~~~", $domain);
339 $domain = preg_quote($domain);
340 $domain = str_replace(
"~~~",
".+", $domain);
341 if(preg_match(
"/^".$domain.
"$/", $email, $hit))
349 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
350 $mail_obj->setAlert(sprintf($lng->txt(
"reg_email_domains"),
351 implode(
", ", $domains)));
360 !$this->registration_settings->passwordGenerationEnabled() &&
364 $passwd_obj = $this->form->getItemByPostVar(
'usr_password');
365 $passwd_obj->setAlert($lng->txt($error_lng_var));
369 if(ilTermsOfServiceHelper::isEnabled() && !$this->form->getInput(
'accept_terms_of_service'))
371 $agr_obj = $this->form->getItemByPostVar(
'accept_terms_of_service');
374 $agr_obj->setAlert($lng->txt(
'force_accept_usr_agreement'));
387 if ($this->registration_settings->roleSelectionEnabled())
389 include_once
"./Services/AccessControl/classes/class.ilObjRole.php";
390 $selected_role = $this->form->getInput(
"usr_roles");
393 $valid_role = (int)$selected_role;
399 include_once
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
401 $valid_role = (int)$registration_role_assignments->getRoleByEmail($this->form->getInput(
"usr_email"));
413 $login_obj = $this->form->getItemByPostVar(
'username');
414 $login = $this->form->getInput(
"username");
417 $login_obj->setAlert($lng->txt(
"login_invalid"));
422 $login_obj->setAlert($lng->txt(
"login_exists"));
425 else if ((
int)$ilSetting->get(
'allow_change_loginname') &&
426 (int)$ilSetting->get(
'reuse_of_loginnames') == 0 &&
429 $login_obj->setAlert($lng->txt(
'login_exists'));
439 $password = $this->__createUser($valid_role);
441 $this->login($password);
445 $this->form->setValuesByPost();
446 $this->displayForm();
450 protected function __createUser($a_role)
464 $ilias->raiseError(
"Invalid role selection in registration".
465 ", IP: ".$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
471 include_once(
"./Services/User/classes/class.ilUserProfile.php");
476 $up->skipGroup(
"preferences");
477 $up->skipGroup(
"settings");
478 $up->skipGroup(
"instant_messengers");
479 $up->skipField(
"password");
480 $up->skipField(
"birthday");
481 $up->skipField(
"upload");
482 foreach ($up->getStandardFields() as $k => $v)
486 $method =
"set".substr($v[
"method"], 3);
487 if(method_exists($this->userObj, $method))
489 if ($k !=
"username")
493 $field_obj = $this->form->getItemByPostVar($k);
497 $this->userObj->$method($this->form->getInput($k));
503 $this->userObj->setFullName();
505 $birthday_obj = $this->form->getItemByPostVar(
"usr_birthday");
508 $birthday = $this->form->getInput(
"usr_birthday");
509 $birthday = $birthday[
"date"];
512 if(!is_array($birthday))
514 $this->userObj->setBirthday($birthday);
519 $map = array(
"icq",
"yahoo",
"msn",
"aim",
"skype",
"jabber",
"voip");
522 $field =
"usr_im_".$client;
523 $field_obj = $this->form->getItemByPostVar($field);
526 $this->userObj->setInstantMessengerId($client, $this->form->getInput($field));
530 $this->userObj->setTitle($this->userObj->getFullname());
531 $this->userObj->setDescription($this->userObj->getEmail());
533 if ($this->registration_settings->passwordGenerationEnabled())
536 $password = $password[0];
540 $password = $this->form->getInput(
"usr_password");
542 $this->userObj->setPasswd($password);
546 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
548 $defs = $user_defined_fields->getRegistrationDefinitions();
550 foreach (
$_POST as $k => $v)
552 if (substr($k, 0, 4) ==
"udf_")
558 $this->userObj->setUserDefinedData($udf);
560 $this->userObj->setTimeLimitOwner(7);
563 $access_limit = null;
565 $this->code_was_used =
false;
566 if($this->code_enabled)
568 $code_local_roles = $code_has_access_limit = null;
571 $code = $this->form->getInput(
'usr_registration_code');
574 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
578 $this->code_was_used =
true;
582 if($code_data[
"role_local"])
585 $code_local_roles = explode(
";", $code_data[
"role_local"]);
587 if($code_data[
"alimit"])
590 $code_has_access_limit =
true;
592 switch($code_data[
"alimit"])
595 $abs = date_parse($code_data[
"alimitdt"]);
596 $access_limit = mktime(23, 59, 59, $abs[
'month'], $abs[
'day'], $abs[
'year']);
600 $rel = unserialize($code_data[
"alimitdt"]);
601 $access_limit = $rel[
"d"] * 86400 + $rel[
"m"] * 2592000 +
602 $rel[
"y"] * 31536000 + time();
610 if (!($this->code_was_used && $code_has_access_limit) &&
611 $this->registration_settings->getAccessLimitation())
613 include_once
'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
615 switch($access_limitations_obj->getMode($a_role))
618 $access_limit = $access_limitations_obj->getAbsolute($a_role);
622 $rel_d = (int) $access_limitations_obj->getRelative($a_role,
'd');
623 $rel_m = (int) $access_limitations_obj->getRelative($a_role,
'm');
624 $rel_y = (int) $access_limitations_obj->getRelative($a_role,
'y');
625 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
632 $this->userObj->setTimeLimitUnlimited(0);
633 $this->userObj->setTimeLimitUntil($access_limit);
637 $this->userObj->setTimeLimitUnlimited(1);
638 $this->userObj->setTimeLimitUntil(time());
641 $this->userObj->setTimeLimitFrom(time());
643 include_once
'./Services/User/classes/class.ilUserCreationContext.php';
646 $this->userObj->create();
649 if($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT ||
650 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
653 $this->userObj->setActive(1,0);
655 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
657 $this->userObj->setActive(0,0);
661 $this->userObj->setActive(0,0);
664 $this->userObj->updateOwner();
668 $this->userObj->setLastPasswordChangeTS( time() );
670 $this->userObj->setIsSelfRegistered(
true);
673 $this->userObj->saveAsNew();
677 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
685 $this->userObj->setLanguage($this->form->getInput(
'usr_language'));
686 $hits_per_page = $ilSetting->get(
"hits_per_page");
687 if ($hits_per_page < 10)
691 $this->userObj->setPref(
"hits_per_page", $hits_per_page);
692 $show_online = $ilSetting->get(
"show_users_online");
693 if ($show_online ==
"")
697 $this->userObj->setPref(
"show_users_online", $show_online);
698 $this->userObj->writePrefs();
701 $rbacadmin->assignUser((
int)$a_role, $this->userObj->getId());
704 if($this->code_was_used && is_array($code_local_roles))
706 foreach(array_unique($code_local_roles) as $local_role_obj_id)
711 $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
714 $role_obj =
$GLOBALS[
'rbacreview']->getObjectOfRole($local_role_obj_id);
720 $role_ref = end($role_refs);
735 include_once
'./Services/Language/classes/class.ilLanguage.php';
736 include_once
'./Services/User/classes/class.ilObjUser.php';
737 include_once
"Services/Mail/classes/class.ilFormatMail.php";
738 include_once
'./Services/Registration/classes/class.ilRegistrationMailNotification.php';
745 $mail->setRecipients($this->registration_settings->getApproveRecipients());
746 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
753 $mail->setRecipients($this->registration_settings->getApproveRecipients());
754 $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
763 include_once
'./Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
767 $mail->setRecipients(array($this->userObj));
768 $mail->setAdditionalInformation(
770 'usr' => $this->userObj,
771 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
779 include_once(
"Services/Mail/classes/class.ilAccountMail.php");
780 include_once
'./Services/User/classes/class.ilObjUserFolder.php';
783 if (trim($amail[
"body"]) ==
"" || trim($amail[
"subject"]) ==
"")
787 if (trim($amail[
"body"]) !=
"" && trim($amail[
"subject"]) !=
"")
790 $acc_mail->setUser($this->userObj);
791 if ($this->registration_settings->passwordGenerationEnabled())
793 $acc_mail->setUserPassword($password);
796 if($amail[
"att_file"])
798 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
801 $path = $fs->getAbsolutePath().
"/";
803 $acc_mail->addAttachment(
$path.
"/".$amail[
"lang"], $amail[
"att_file"]);
810 include_once
"Services/Mail/classes/class.ilMimeMail.php";
813 $mmail->autoCheck(
false);
814 $mmail->From($ilSetting->get(
"admin_email"));
815 $mmail->To($this->userObj->getEmail());
818 $subject = $this->lng->txt(
"reg_mail_subject");
821 $body = $this->lng->txt(
"reg_mail_body_salutation").
" ".$this->userObj->getFullname().
",\n\n".
822 $this->lng->txt(
"reg_mail_body_text1").
"\n\n".
823 $this->lng->txt(
"reg_mail_body_text2").
"\n".
824 ILIAS_HTTP_PATH.
"/login.php?client_id=".CLIENT_ID.
"\n";
825 $body .= $this->lng->txt(
"login").
": ".$this->userObj->getLogin().
"\n";
827 if ($this->registration_settings->passwordGenerationEnabled())
829 $body.= $this->lng->txt(
"passwd").
": ".$password.
"\n";
836 $body .= ($this->lng->txt(
'reg_mail_body_pwd_generation').
"\n\n");
839 $body .= ($this->lng->txt(
"reg_mail_body_text3").
"\n\r");
840 $body .= $this->userObj->getProfileAsString($this->lng);
841 $mmail->Subject($subject);
851 public function login($password)
858 ilStartUpGUI::initStartUpTemplate(array(
'tpl.usr_registered.html',
'Services/Registration'),
false);
859 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'registration'));
861 $this->tpl->setVariable(
"TXT_WELCOME", $lng->txt(
"welcome") .
", " . $this->userObj->getTitle() .
"!");
864 $this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT ||
865 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
868 !$this->registration_settings->passwordGenerationEnabled()
871 $this->tpl->setCurrentBlock(
'activation');
872 $this->tpl->setVariable(
'TXT_REGISTERED', $lng->txt(
'txt_registered'));
876 $this->tpl->setVariable(
'FORMACTION',
'./login.php?forceShoppingCartRedirect=1');
878 $this->tpl->setVariable(
'TARGET',
'target="_parent"');
879 $this->tpl->setVariable(
'TXT_LOGIN', $lng->txt(
'login_to_ilias'));
880 $this->tpl->setVariable(
'USERNAME', $this->userObj->getLogin());
881 $this->tpl->setVariable(
'PASSWORD', $password);
882 $this->tpl->parseCurrentBlock();
884 else if($this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE)
886 $this->tpl->setVariable(
'TXT_REGISTERED', $lng->txt(
'txt_submitted'));
888 if(IS_PAYMENT_ENABLED ==
true)
892 $this->tpl->setCurrentBlock(
'activation');
893 include_once
'Services/Payment/classes/class.ilShopLinkBuilder.php';
895 $this->tpl->setVariable(
'FORMACTION', $shop_link->buildLink(
'ilshopshoppingcartgui',
'_forceShoppingCartRedirect_user=' . $this->userObj->getId()));
896 $this->tpl->setVariable(
'TARGET',
'target=\'_parent\'');
898 $this->lng->loadLanguageModule(
'payment');
899 $this->tpl->setVariable(
'TXT_LOGIN', $lng->txt(
'pay_goto_shopping_cart'));
900 $this->tpl->parseCurrentBlock();
901 $this->lng->loadLanguageModule(
'registration');
905 else if($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION)
907 $login_url =
'./login.php?cmd=force_login&lang=' . $this->userObj->getLanguage();
908 $this->tpl->setVariable(
'TXT_REGISTERED', sprintf($lng->txt(
'reg_confirmation_link_successful'), $login_url));
909 $this->tpl->setVariable(
'REDIRECT_URL', $login_url);
913 $this->tpl->setVariable(
'TXT_REGISTERED', $lng->txt(
'txt_registered_passw_gen'));
922 include_once
"Services/User/classes/class.ilPublicUserProfileGUI.php";
926 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
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 get($a_var)
Get a value.
static generatePasswords($a_number)
Generate a number of passwords.
__distributeMails($password, $a_language=null)
static _getAllReferences($a_id)
get all reference ids of object
_lookupNewAccountMail($a_lang)
_lookupAllowRegister($a_role_id)
check whether role is allowed in user registration or not
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
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)
if(!is_array($argv)) $options
this class encapsulates the PHP mail() function.
static isValidRegistrationCode($a_code)
Check if given code is a valid registration code.
static getByLanguageObject(ilLanguage $lng)
setSize($a_size)
Set Size.
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 trackAcceptance(ilObjUser $user, ilTermsOfServiceSignableDocument $document)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilObjAuthSettingsGUI.
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
This class represents a text area property in a property form.
static initjQuery($a_tpl=null)
Init jQuery.
const USER_FOLDER_ID
Class ilObjUserFolder.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
const CONTEXT_REGISTRATION
static _doesLoginnameExistInHistory($a_login)
Checks wether the passed loginname already exists in history.
const TYPE_NOTIFICATION_CONFIRMATION