18 require_once
'./Services/Registration/classes/class.ilRegistrationSettings.php';
19 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
39 $this->ctrl->saveParameter($this,
'lang');
42 $this->lng->loadLanguageModule(
'registration');
46 $this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
47 $this->registration_settings->getAllowCodes());
54 if ($this->registration_settings->getRegistrationType() ==
IL_REG_DISABLED) {
55 $ilErr->raiseError($this->lng->txt(
'reg_disabled'), $ilErr->FATAL);
58 $next_class = $this->ctrl->getNextClass($this);
59 $cmd = $this->ctrl->getCmd();
61 switch ($next_class) {
70 $tpl->setPermanentLink(
'usr', null,
'registration');
78 public function displayForm()
85 ilStartUpGUI::initStartUpTemplate(
array(
'tpl.usr_registration.html',
'Services/Registration'),
true);
86 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'registration'));
91 $this->tpl->setVariable(
'FORM', $this->form->getHTML());
99 include_once
'Services/jQuery/classes/class.iljQueryUtil.php';
102 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
104 $this->form->setFormAction($this->ctrl->getFormAction($this));
109 if ($this->code_enabled) {
110 include_once
'Services/Registration/classes/class.ilRegistrationCode.php';
114 if ((
bool) $this->registration_settings->registrationCodeRequired()) {
115 $code->setRequired(
true);
116 $code->setInfo($lng->txt(
"registration_code_required_info"));
118 $code->setInfo($lng->txt(
"registration_code_optional_info"));
120 $this->form->addItem(
$code);
126 $user_defined_data = $ilUser->getUserDefinedData();
128 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
130 $custom_fields =
array();
131 foreach ($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition) {
133 $custom_fields[
"udf_" . $definition[
'field_id']] =
134 new ilTextInputGUI($definition[
'field_name'],
"udf_" . $definition[
'field_id']);
135 $custom_fields[
"udf_" . $definition[
'field_id']]->setValue($user_defined_data[
"f_" . $field_id]);
136 $custom_fields[
"udf_" . $definition[
'field_id']]->setMaxLength(255);
137 $custom_fields[
"udf_" . $definition[
'field_id']]->setSize(40);
139 $custom_fields[
"udf_" . $definition[
'field_id']] =
141 $custom_fields[
"udf_" . $definition[
'field_id']]->setValue($user_defined_data[
"f_" . $field_id]);
142 $custom_fields[
"udf_" . $definition[
'field_id']]->setUseRte(
true);
144 $custom_fields[
"udf_" . $definition[
'field_id']] =
145 new ilSelectInputGUI($definition[
'field_name'],
"udf_" . $definition[
'field_id']);
146 $custom_fields[
"udf_" . $definition[
'field_id']]->setValue($user_defined_data[
"f_" . $field_id]);
147 $custom_fields[
"udf_" . $definition[
'field_id']]->setOptions(
148 $user_defined_fields->fieldValuesToSelectArray($definition[
'field_values'])
151 if ($definition[
'required']) {
152 $custom_fields[
"udf_" . $definition[
'field_id']]->setRequired(
true);
155 if ($definition[
'field_type'] ==
UDF_TYPE_SELECT && !$user_defined_data[
"f_" . $field_id]) {
156 $options = $custom_fields[
"udf_" . $definition[
'field_id']]->getOptions();
157 $custom_fields[
"udf_" . $definition[
'field_id']]->setOptions(
$options);
162 include_once(
"./Services/User/classes/class.ilUserProfile.php");
165 $up->skipGroup(
"preferences");
167 $up->setAjaxCallback(
168 $this->ctrl->getLinkTarget($this,
'doProfileAutoComplete',
'',
true)
171 $lng->loadLanguageModule(
"user");
174 $up->addStandardFieldsToForm($this->form, null, $custom_fields);
175 unset($custom_fields);
179 $flang = $this->form->getItemByPostVar(
"usr_language");
181 $flang->setValue($lng->getLangKey());
185 if ($this->code_enabled) {
186 $role = $this->form->getItemByPostVar(
"usr_roles");
187 if ($role && $role->getType() ==
"select") {
188 $role->setInfo($lng->txt(
"registration_code_role_info"));
194 foreach ($this->registration_settings->getAllowedDomains() as $item) {
199 if (
sizeof($domains)) {
200 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
201 $mail_obj->setInfo(sprintf(
202 $lng->txt(
"reg_email_domains"),
203 implode(
", ", $domains)
205 ($this->code_enabled ? $lng->txt(
"reg_email_domains_code") :
""));
210 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
212 $mail_obj->setRequired(
true);
216 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
220 $field->setTitle($lng->txt(
'usr_agreement'));
221 $this->form->addItem($field);
224 $field->setHTML(
'<div id="agreement">' . $document->getContent() .
'</div>');
225 $this->form->addItem($field);
227 $field =
new ilCheckboxInputGUI($lng->txt(
'accept_usr_agreement'),
'accept_terms_of_service');
230 $this->form->addItem($field);
233 require_once
'Services/Captcha/classes/class.ilCaptchaUtil.php';
234 if (ilCaptchaUtil::isActiveForRegistration()) {
235 require_once
'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
238 $this->form->addItem($captcha);
241 $this->form->addCommandButton(
"saveForm", $lng->txt(
"register"));
249 $form_valid = $this->form->checkInput();
251 require_once
'Services/User/classes/class.ilObjUser.php';
254 $valid_code = $valid_role =
false;
257 if ($this->code_enabled) {
258 $code = $this->form->getInput(
'usr_registration_code');
261 $this->registration_settings->registrationCodeRequired() ||
265 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
267 $code_obj = $this->form->getItemByPostVar(
'usr_registration_code');
268 $code_obj->setAlert($lng->txt(
'registration_code_not_valid'));
275 if ($role_id && $rbacreview->isGlobalRole($role_id)) {
276 $valid_role = $role_id;
285 $email = $this->form->getInput(
"usr_email");
289 foreach ($this->registration_settings->getAllowedDomains() as $item) {
294 if (
sizeof($domains)) {
296 foreach ($domains as
$domain) {
297 $domain = str_replace(
"*",
"~~~", $domain);
298 $domain = preg_quote($domain);
299 $domain = str_replace(
"~~~",
".+", $domain);
300 if (preg_match(
"/^" . $domain .
"$/",
$email, $hit)) {
306 $mail_obj = $this->form->getItemByPostVar(
'usr_email');
307 $mail_obj->setAlert(sprintf(
308 $lng->txt(
"reg_email_domains"),
309 implode(
", ", $domains)
319 !$this->registration_settings->passwordGenerationEnabled() &&
322 $passwd_obj = $this->form->getItemByPostVar(
'usr_password');
323 $passwd_obj->setAlert($lng->txt($error_lng_var));
328 $agr_obj = $this->form->getItemByPostVar(
'accept_terms_of_service');
330 $agr_obj->setAlert($lng->txt(
'force_accept_usr_agreement'));
340 if ($this->registration_settings->roleSelectionEnabled()) {
341 include_once
"./Services/AccessControl/classes/class.ilObjRole.php";
342 $selected_role = $this->form->getInput(
"usr_roles");
344 $valid_role = (int) $selected_role;
349 include_once
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
351 $valid_role = (int) $registration_role_assignments->getRoleByEmail($this->form->getInput(
"usr_email"));
362 $login_obj = $this->form->getItemByPostVar(
'username');
363 $login = $this->form->getInput(
"username");
364 $captcha = $this->form->getItemByPostVar(
"captcha_code");
366 $login_obj->setAlert($lng->txt(
"login_invalid"));
369 if(!empty($captcha) && empty($captcha->getAlert()) || empty($captcha)) {
370 $login_obj->setAlert($lng->txt(
"login_exists"));
373 } elseif ((
int) $ilSetting->get(
'allow_change_loginname') &&
374 (int) $ilSetting->get(
'reuse_of_loginnames') == 0 &&
376 if(!empty($captcha) && empty($captcha->getAlert()) || empty($captcha)) {
377 $login_obj->setAlert($lng->txt(
"login_exists"));
385 $password = $this->__createUser($valid_role);
391 $this->form->setValuesByPost();
392 $this->displayForm();
396 protected function __createUser($a_role)
409 $ilias->raiseError(
"Invalid role selection in registration" .
410 ", IP: " .
$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
416 include_once(
"./Services/User/classes/class.ilUserProfile.php");
421 $up->skipGroup(
"preferences");
422 $up->skipGroup(
"settings");
423 $up->skipField(
"password");
424 $up->skipField(
"birthday");
425 $up->skipField(
"upload");
426 foreach ($up->getStandardFields() as $k => $v) {
428 $method =
"set" . substr($v[
"method"], 3);
429 if (method_exists($this->userObj, $method)) {
430 if ($k !=
"username") {
433 $field_obj = $this->form->getItemByPostVar($k);
435 $this->userObj->$method($this->form->getInput($k));
441 $this->userObj->setFullName();
443 $birthday_obj = $this->form->getItemByPostVar(
"usr_birthday");
445 $birthday = $this->form->getInput(
"usr_birthday");
446 $this->userObj->setBirthday($birthday);
449 $this->userObj->setTitle($this->userObj->getFullname());
450 $this->userObj->setDescription($this->userObj->getEmail());
452 if ($this->registration_settings->passwordGenerationEnabled()) {
456 $password = $this->form->getInput(
"usr_password");
462 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
464 $defs = $user_defined_fields->getRegistrationDefinitions();
466 foreach (
$_POST as $k => $v) {
467 if (substr($k, 0, 4) ==
"udf_") {
472 $this->userObj->setUserDefinedData($udf);
474 $this->userObj->setTimeLimitOwner(7);
477 $access_limit = null;
479 $this->code_was_used =
false;
480 if ($this->code_enabled) {
481 $code_local_roles = $code_has_access_limit = null;
484 $code = $this->form->getInput(
'usr_registration_code');
486 include_once
'./Services/Registration/classes/class.ilRegistrationCode.php';
490 $this->code_was_used =
true;
494 if ($code_data[
"role_local"]) {
496 $code_local_roles = explode(
";", $code_data[
"role_local"]);
498 if ($code_data[
"alimit"]) {
500 $code_has_access_limit =
true;
502 switch ($code_data[
"alimit"]) {
504 $abs = date_parse($code_data[
"alimitdt"]);
505 $access_limit = mktime(23, 59, 59, $abs[
'month'], $abs[
'day'], $abs[
'year']);
509 $rel = unserialize($code_data[
"alimitdt"]);
510 $access_limit = $rel[
"d"] * 86400 + $rel[
"m"] * 2592000 +
511 $rel[
"y"] * 31536000 +
time();
519 if (!($this->code_was_used && $code_has_access_limit) &&
520 $this->registration_settings->getAccessLimitation()) {
521 include_once
'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
523 switch ($access_limitations_obj->getMode($a_role)) {
525 $access_limit = $access_limitations_obj->getAbsolute($a_role);
529 $rel_d = (int) $access_limitations_obj->getRelative($a_role,
'd');
530 $rel_m = (int) $access_limitations_obj->getRelative($a_role,
'm');
531 $rel_y = (int) $access_limitations_obj->getRelative($a_role,
'y');
532 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 +
time();
538 $this->userObj->setTimeLimitUnlimited(0);
539 $this->userObj->setTimeLimitUntil($access_limit);
541 $this->userObj->setTimeLimitUnlimited(1);
542 $this->userObj->setTimeLimitUntil(
time());
545 $this->userObj->setTimeLimitFrom(
time());
547 include_once
'./Services/User/classes/class.ilUserCreationContext.php';
550 $this->userObj->create();
553 if ($this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT ||
554 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
556 $this->userObj->setActive(1, 0);
557 } elseif ($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION) {
558 $this->userObj->setActive(0, 0);
560 $this->userObj->setActive(0, 0);
563 $this->userObj->updateOwner();
567 $this->userObj->setLastPasswordChangeTS(
time());
569 $this->userObj->setIsSelfRegistered(
true);
572 $this->userObj->saveAsNew();
574 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
578 $this->userObj->setLanguage($this->form->getInput(
'usr_language'));
579 $hits_per_page = $ilSetting->get(
"hits_per_page");
580 if ($hits_per_page < 10) {
583 $this->userObj->setPref(
"hits_per_page", $hits_per_page);
584 if (strlen(
$_GET[
'target']) > 0) {
593 $this->userObj->setPref(
'bs_allow_to_contact_me', $ilSetting->get(
'bs_allow_to_contact_me',
'n'));
594 $this->userObj->setPref(
'chat_osc_accept_msg', $ilSetting->get(
'chat_osc_accept_msg',
'n'));
595 $this->userObj->writePrefs();
598 $rbacadmin->assignUser((
int) $a_role, $this->userObj->getId());
601 if ($this->code_was_used && is_array($code_local_roles)) {
602 foreach (array_unique($code_local_roles) as $local_role_obj_id) {
605 $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
608 $role_obj =
$GLOBALS[
'rbacreview']->getObjectOfRole($local_role_obj_id);
613 $role_ref = end($role_refs);
628 include_once
'./Services/Language/classes/class.ilLanguage.php';
629 include_once
'./Services/User/classes/class.ilObjUser.php';
630 include_once
"Services/Mail/classes/class.ilFormatMail.php";
631 include_once
'./Services/Registration/classes/class.ilRegistrationMailNotification.php';
637 $mail->setRecipients($this->registration_settings->getApproveRecipients());
638 $mail->setAdditionalInformation(
array(
'usr' => $this->userObj));
643 $mail->setRecipients($this->registration_settings->getApproveRecipients());
644 $mail->setAdditionalInformation(
array(
'usr' => $this->userObj));
651 include_once
'./Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
655 $mail->setRecipients(
array($this->userObj));
656 $mail->setAdditionalInformation(
658 'usr' => $this->userObj,
659 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
665 $this->registration_settings,
669 $accountMail->withDirectRegistrationMode()->send($this->userObj,
$password, $this->code_was_used);
683 ilStartUpGUI::initStartUpTemplate(
array(
'tpl.usr_registered.html',
'Services/Registration'),
false);
684 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'registration'));
686 $this->tpl->setVariable(
"TXT_WELCOME", $lng->txt(
"welcome") .
", " . $this->userObj->getTitle() .
"!");
689 $this->registration_settings->getRegistrationType() ==
IL_REG_DIRECT ||
690 $this->registration_settings->getRegistrationType() ==
IL_REG_CODES ||
693 !$this->registration_settings->passwordGenerationEnabled()
698 $this->tpl->setCurrentBlock(
'activation');
699 $this->tpl->setVariable(
'TXT_REGISTERED', $lng->txt(
'txt_registered'));
702 $this->tpl->setVariable(
'FORMACTION',
$action);
704 $this->tpl->setVariable(
'TXT_LOGIN', $lng->txt(
'login_to_ilias'));
705 $this->tpl->parseCurrentBlock();
706 } elseif ($this->registration_settings->getRegistrationType() ==
IL_REG_APPROVE) {
707 $this->tpl->setVariable(
'TXT_REGISTERED', $lng->txt(
'txt_submitted'));
708 } elseif ($this->registration_settings->getRegistrationType() ==
IL_REG_ACTIVATION) {
709 $login_url =
'./login.php?cmd=force_login&lang=' . $this->userObj->getLanguage();
710 $this->tpl->setVariable(
'TXT_REGISTERED', sprintf($lng->txt(
'reg_confirmation_link_successful'), $login_url));
711 $this->tpl->setVariable(
'REDIRECT_URL', $login_url);
713 $this->tpl->setVariable(
'TXT_REGISTERED', $lng->txt(
'txt_registered_passw_gen'));
722 protected function showLogin()
727 $auth_session =
$GLOBALS[
'DIC'][
'ilAuthSession'];
728 $auth_session->setAuthenticated(
732 ilInitialisation::initUserAccount();
733 return ilInitialisation::redirectToStartingPage();
738 $field_id = (
string) $_REQUEST[
"f"];
739 $term = (
string) $_REQUEST[
"term"];
741 include_once
"Services/User/classes/class.ilPublicUserProfileGUI.php";
744 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
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
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static getAutocompleteResult($a_field_id, $a_term)
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
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 _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.
static getByLanguageObject(ilLanguage $lng)
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
Create styles array
The data for the language used.
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.
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)
inits and adds the jQuery JS-File to the global or a passed template
static getLogger($a_component_id)
Get component logger.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
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
static _doesLoginnameExistInHistory($a_login)
Checks wether the passed loginname already exists in history.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
const TYPE_NOTIFICATION_CONFIRMATION