18require_once 
'./Services/Registration/classes/class.ilRegistrationSettings.php';
 
   19require_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';
 
  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                require_once 
'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
 
  241                        $field->setTitle(
$lng->txt(
'usr_agreement'));
 
  242                        $this->form->addItem($field);
 
  245                        $field->setHTML(
'<div id="agreement">' . $document->getContent() . 
'</div>');
 
  246                        $this->form->addItem($field);
 
  249                        $field->setRequired(
true);
 
  251                        $this->form->addItem($field);
 
  254                require_once 
'Services/Captcha/classes/class.ilCaptchaUtil.php';
 
  255                if(ilCaptchaUtil::isActiveForRegistration())
 
  257                        require_once 
'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
 
  259                        $captcha->setRequired(
true);
 
  260                        $this->form->addItem($captcha);
 
  263                $this->form->addCommandButton(
"saveForm", 
$lng->txt(
"register"));               
 
  271                $form_valid = $this->form->checkInput();
 
  273                require_once 
'Services/User/classes/class.ilObjUser.php';
 
  277                $valid_code = $valid_role = 
false;
 
  280                if($this->code_enabled)
 
  282                        $code = $this->form->getInput(
'usr_registration_code');                 
 
  285                                $this->registration_settings->registrationCodeRequired() ||
 
  290                                include_once 
'./Services/Registration/classes/class.ilRegistrationCode.php';
 
  293                                        $code_obj = $this->form->getItemByPostVar(
'usr_registration_code');
 
  294                                        $code_obj->setAlert(
$lng->txt(
'registration_code_not_valid'));
 
  303                                        if($role_id && $rbacreview->isGlobalRole($role_id))
 
  305                                                $valid_role = $role_id;
 
  315                        $email = $this->form->getInput(
"usr_email");
 
  320                                foreach($this->registration_settings->getAllowedDomains() as $item)
 
  330                                        foreach($domains as $domain)
 
  332                                                $domain = str_replace(
"*", 
"~~~", $domain);
 
  333                                                $domain = preg_quote($domain);
 
  334                                                $domain = str_replace(
"~~~", 
".+", $domain);                                    
 
  335                                                if(preg_match(
"/^".$domain.
"$/", $email, $hit))
 
  343                                                $mail_obj = $this->form->getItemByPostVar(
'usr_email');
 
  344                                                $mail_obj->setAlert(
sprintf(
$lng->txt(
"reg_email_domains"),
 
  345                                                        implode(
", ", $domains)));
 
  354                        !$this->registration_settings->passwordGenerationEnabled() &&
 
  358                        $passwd_obj = $this->form->getItemByPostVar(
'usr_password');
 
  359                        $passwd_obj->setAlert(
$lng->txt($error_lng_var));
 
  365                        $agr_obj = $this->form->getItemByPostVar(
'accept_terms_of_service');
 
  368                                $agr_obj->setAlert(
$lng->txt(
'force_accept_usr_agreement'));
 
  381                        if ($this->registration_settings->roleSelectionEnabled())
 
  383                                include_once 
"./Services/AccessControl/classes/class.ilObjRole.php";
 
  384                                $selected_role = $this->form->getInput(
"usr_roles");
 
  387                                        $valid_role = (int)$selected_role;
 
  393                                include_once 
'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
 
  395                                $valid_role = (int)$registration_role_assignments->getRoleByEmail($this->form->getInput(
"usr_email"));
 
  407                $login_obj = $this->form->getItemByPostVar(
'username');
 
  408                $login = $this->form->getInput(
"username");
 
  411                        $login_obj->setAlert(
$lng->txt(
"login_invalid"));
 
  416                        $login_obj->setAlert(
$lng->txt(
"login_exists"));
 
  419                else if ((
int)
$ilSetting->get(
'allow_change_loginname') &&
 
  420                        (
int)
$ilSetting->get(
'reuse_of_loginnames') == 0 &&
 
  423                        $login_obj->setAlert(
$lng->txt(
'login_exists'));
 
  433                        $password = $this->__createUser($valid_role);
 
  435                        $this->login($password);
 
  439                $this->form->setValuesByPost();
 
  440                $this->displayForm();
 
  444        protected function __createUser($a_role)
 
  458                        $ilias->raiseError(
"Invalid role selection in registration".
 
  459                                ", IP: ".
$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
 
  465                include_once(
"./Services/User/classes/class.ilUserProfile.php");
 
  470                $up->skipGroup(
"preferences");
 
  471                $up->skipGroup(
"settings");
 
  472                $up->skipField(
"password");
 
  473                $up->skipField(
"birthday");
 
  474                $up->skipField(
"upload");
 
  475                foreach ($up->getStandardFields() as $k => $v)
 
  479                                $method = 
"set".substr($v[
"method"], 3);
 
  480                                if(method_exists($this->userObj, $method))
 
  482                                        if ($k != 
"username")
 
  486                                        $field_obj = $this->form->getItemByPostVar($k);
 
  490                                                $this->userObj->$method($this->form->getInput($k));
 
  496                $this->userObj->setFullName();
 
  498                $birthday_obj = $this->form->getItemByPostVar(
"usr_birthday");
 
  501                        $birthday = $this->form->getInput(
"usr_birthday");
 
  502                        $this->userObj->setBirthday($birthday);
 
  505                $this->userObj->setTitle($this->userObj->getFullname());
 
  506                $this->userObj->setDescription($this->userObj->getEmail());
 
  508                if ($this->registration_settings->passwordGenerationEnabled())
 
  511                        $password = $password[0];
 
  515                        $password = $this->form->getInput(
"usr_password");
 
  517                $this->userObj->setPasswd($password);
 
  521                include_once 
'./Services/User/classes/class.ilUserDefinedFields.php';
 
  523                $defs = $user_defined_fields->getRegistrationDefinitions();
 
  525                foreach (
$_POST as $k => $v)
 
  527                        if (substr($k, 0, 4) == 
"udf_")
 
  533                $this->userObj->setUserDefinedData($udf);
 
  535                $this->userObj->setTimeLimitOwner(7);
 
  538                $access_limit = 
null;
 
  540                $this->code_was_used = 
false;
 
  541                if($this->code_enabled)
 
  543                        $code_local_roles = $code_has_access_limit = 
null;
 
  546                        $code = $this->form->getInput(
'usr_registration_code');                                                 
 
  549                                include_once 
'./Services/Registration/classes/class.ilRegistrationCode.php';
 
  553                                $this->code_was_used = 
true;
 
  557                                if($code_data[
"role_local"])
 
  560                                        $code_local_roles = explode(
";", $code_data[
"role_local"]);
 
  562                                if($code_data[
"alimit"])
 
  565                                        $code_has_access_limit = 
true;
 
  567                                        switch($code_data[
"alimit"])
 
  570                                                        $abs = date_parse($code_data[
"alimitdt"]);
 
  571                                                        $access_limit = mktime(23, 59, 59, $abs[
'month'], $abs[
'day'], $abs[
'year']);
 
  575                                                        $rel = unserialize($code_data[
"alimitdt"]);
 
  576                                                        $access_limit = $rel[
"d"] * 86400 + $rel[
"m"] * 2592000 + 
 
  577                                                                $rel[
"y"] * 31536000 + time();          
 
  585                if (!($this->code_was_used && $code_has_access_limit) &&
 
  586                        $this->registration_settings->getAccessLimitation())
 
  588                        include_once 
'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
 
  590                        switch($access_limitations_obj->getMode($a_role))
 
  593                                        $access_limit = $access_limitations_obj->getAbsolute($a_role);
 
  597                                        $rel_d = (int) $access_limitations_obj->getRelative($a_role,
'd');
 
  598                                        $rel_m = (int) $access_limitations_obj->getRelative($a_role,
'm');
 
  599                                        $rel_y = (int) $access_limitations_obj->getRelative($a_role,
'y');
 
  600                                        $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();         
 
  607                        $this->userObj->setTimeLimitUnlimited(0);
 
  608                        $this->userObj->setTimeLimitUntil($access_limit);
 
  612                        $this->userObj->setTimeLimitUnlimited(1);
 
  613                        $this->userObj->setTimeLimitUntil(time());
 
  616                $this->userObj->setTimeLimitFrom(time());
 
  618                include_once 
'./Services/User/classes/class.ilUserCreationContext.php';
 
  621                $this->userObj->create();
 
  624                if($this->registration_settings->getRegistrationType() == 
IL_REG_DIRECT ||
 
  625                        $this->registration_settings->getRegistrationType() == 
IL_REG_CODES ||
 
  626                        $this->code_was_used)
 
  628                        $this->userObj->setActive(1,0);
 
  630                else if($this->registration_settings->getRegistrationType() == 
IL_REG_ACTIVATION)
 
  632                        $this->userObj->setActive(0,0);
 
  636                        $this->userObj->setActive(0,0);
 
  639                $this->userObj->updateOwner();
 
  643                $this->userObj->setLastPasswordChangeTS( time() );
 
  645                $this->userObj->setIsSelfRegistered(
true);
 
  648                $this->userObj->saveAsNew();
 
  650                require_once 
'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
 
  654                $this->userObj->setLanguage($this->form->getInput(
'usr_language'));
 
  655                $hits_per_page = 
$ilSetting->get(
"hits_per_page");
 
  656                if ($hits_per_page < 10)
 
  660                $this->userObj->setPref(
"hits_per_page", $hits_per_page);
 
  661                if(strlen(
$_GET[
'target']) > 0)
 
  671                $this->userObj->setPref(
'bs_allow_to_contact_me',  
$ilSetting->get(
'bs_allow_to_contact_me', 
'n'));
 
  672                $this->userObj->setPref(
'chat_osc_accept_msg', 
$ilSetting->get(
'chat_osc_accept_msg', 
'n'));
 
  673                $this->userObj->writePrefs();
 
  676                $rbacadmin->assignUser((
int)$a_role, $this->userObj->getId());
 
  679                if($this->code_was_used && is_array($code_local_roles))
 
  681                        foreach(array_unique($code_local_roles) as $local_role_obj_id)
 
  686                                        $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
 
  689                                        $role_obj = 
$GLOBALS[
'rbacreview']->getObjectOfRole($local_role_obj_id);
 
  695                                                        $role_ref = end($role_refs);
 
  710                include_once 
'./Services/Language/classes/class.ilLanguage.php';
 
  711                include_once 
'./Services/User/classes/class.ilObjUser.php';
 
  712                include_once 
"Services/Mail/classes/class.ilFormatMail.php";
 
  713                include_once 
'./Services/Registration/classes/class.ilRegistrationMailNotification.php';
 
  716                if($this->registration_settings->getRegistrationType() == 
IL_REG_APPROVE && !$this->code_was_used)
 
  720                        $mail->setRecipients($this->registration_settings->getApproveRecipients());
 
  721                        $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
 
  728                        $mail->setRecipients($this->registration_settings->getApproveRecipients());
 
  729                        $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
 
  736                if($this->registration_settings->getRegistrationType() == 
IL_REG_ACTIVATION && !$this->code_was_used)
 
  738                        include_once 
'./Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
 
  742                        $mail->setRecipients(array($this->userObj));
 
  743                        $mail->setAdditionalInformation(
 
  745                                         'usr'           => $this->userObj,
 
  746                                         'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
 
  754                        include_once(
"Services/Mail/classes/class.ilAccountMail.php");
 
  755                        include_once 
'./Services/User/classes/class.ilObjUserFolder.php';
 
  758                        if (trim($amail[
"body"]) == 
"" || trim($amail[
"subject"]) == 
"")
 
  762                        if (trim($amail[
"body"]) != 
"" && trim($amail[
"subject"]) != 
"")
 
  765                                $acc_mail->setUser($this->userObj);
 
  766                                if ($this->registration_settings->passwordGenerationEnabled())
 
  768                                        $acc_mail->setUserPassword($password);
 
  771                                if($amail[
"att_file"])
 
  773                                        include_once 
"Services/User/classes/class.ilFSStorageUserFolder.php";
 
  776                                        $path = $fs->getAbsolutePath().
"/";
 
  778                                        $acc_mail->addAttachment(
$path.
"/".$amail[
"lang"], $amail[
"att_file"]);
 
  785                                include_once 
"Services/Mail/classes/class.ilMimeMail.php";
 
  788                                $mmail->autoCheck(
false);
 
  790                                $mmail->To($this->userObj->getEmail());
 
  793                                $subject = $this->lng->txt(
"reg_mail_subject");
 
  796                                $body = $this->lng->txt(
"reg_mail_body_salutation").
" ".$this->userObj->getFullname().
",\n\n".
 
  797                                        $this->lng->txt(
"reg_mail_body_text1").
"\n\n".
 
  798                                        $this->lng->txt(
"reg_mail_body_text2").
"\n".
 
  799                                        ILIAS_HTTP_PATH.
"/login.php?client_id=".CLIENT_ID.
"\n";                 
 
  800                                $body .= $this->lng->txt(
"login").
": ".$this->userObj->getLogin().
"\n";
 
  802                                if ($this->registration_settings->passwordGenerationEnabled())
 
  804                                        $body.= $this->lng->txt(
"passwd").
": ".$password.
"\n";
 
  809                                if($this->registration_settings->getRegistrationType() == 
IL_REG_APPROVE && !$this->code_was_used)
 
  811                                        $body .= ($this->lng->txt(
'reg_mail_body_pwd_generation').
"\n\n");
 
  814                                $body .= ($this->lng->txt(
"reg_mail_body_text3").
"\n\r");
 
  815                                $body .= $this->userObj->getProfileAsString($this->lng);
 
  816                                $mmail->Subject($subject);
 
  826        public function login($password)
 
  833                ilStartUpGUI::initStartUpTemplate(array(
'tpl.usr_registered.html', 
'Services/Registration'), 
false);
 
  834                $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'registration'));
 
  836                $this->tpl->setVariable(
"TXT_WELCOME", 
$lng->txt(
"welcome") . 
", " . $this->userObj->getTitle() . 
"!");
 
  839                                $this->registration_settings->getRegistrationType() == 
IL_REG_DIRECT ||
 
  840                                $this->registration_settings->getRegistrationType() == 
IL_REG_CODES ||
 
  843                        !$this->registration_settings->passwordGenerationEnabled()
 
  849                        $this->tpl->setCurrentBlock(
'activation');
 
  850                        $this->tpl->setVariable(
'TXT_REGISTERED', 
$lng->txt(
'txt_registered'));
 
  853                        $this->tpl->setVariable(
'FORMACTION', $action);
 
  855                        $this->tpl->setVariable(
'TXT_LOGIN', 
$lng->txt(
'login_to_ilias'));
 
  856                        $this->tpl->parseCurrentBlock();
 
  858                else if($this->registration_settings->getRegistrationType() == 
IL_REG_APPROVE)
 
  860                        $this->tpl->setVariable(
'TXT_REGISTERED', 
$lng->txt(
'txt_submitted'));
 
  862                else if($this->registration_settings->getRegistrationType() == 
IL_REG_ACTIVATION)
 
  864                        $login_url = 
'./login.php?cmd=force_login&lang=' . $this->userObj->getLanguage();
 
  865                        $this->tpl->setVariable(
'TXT_REGISTERED', 
sprintf(
$lng->txt(
'reg_confirmation_link_successful'), $login_url));
 
  866                        $this->tpl->setVariable(
'REDIRECT_URL', $login_url);
 
  870                        $this->tpl->setVariable(
'TXT_REGISTERED', 
$lng->txt(
'txt_registered_passw_gen'));
 
  879        protected function showLogin()
 
  884                $auth_session = 
$GLOBALS[
'DIC'][
'ilAuthSession'];
 
  885                $auth_session->setAuthenticated(
 
  889                ilInitialisation::initUserAccount();
 
  890                return ilInitialisation::redirectToStartingPage();
 
  895                $field_id = (string)$_REQUEST[
"f"];
 
  896                $term = (string)$_REQUEST[
"term"];
 
  898                include_once 
"Services/User/classes/class.ilPublicUserProfileGUI.php";
 
  902                        include_once 
'Services/JSON/classes/class.ilJsonUtil.php';
 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
const USER_FOLDER_ID
Class ilObjUserFolder.
Class ilAccountRegistrationGUI.
__distributeMails($password, $a_language=null)
static encode($mixed, $suppress_native=false)
this class encapsulates the PHP mail() function.
static _lookupAllowRegister($a_role_id)
check whether role is allowed in user registration or not
static _lookupNewAccountMail($a_lang)
static _doesLoginnameExistInHistory($a_login)
Checks wether the passed loginname already exists in history.
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...
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static getAutocompleteResult($a_field_id, $a_term)
static getCodeRole($code)
static isValidRegistrationCode($a_code)
Check if given code is a valid registration code.
static getCodeData($code)
const TYPE_NOTIFICATION_CONFIRMATION
const TYPE_NOTIFICATION_APPROVERS
Class for mime mail registration notifications.
const TYPE_NOTIFICATION_ACTIVATION
Class ilObjAuthSettingsGUI.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
static trackAcceptance(ilObjUser $user, ilTermsOfServiceSignableDocument $document)
static getByLanguageObject(ilLanguage $lng)
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getInstance()
Get instance.
const CONTEXT_REGISTRATION
static _getInstance()
Get instance.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static generatePasswords($a_number)
Generate a number of passwords.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static initjQuery($a_tpl=null)
Init jQuery.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
if(!is_array($argv)) $options
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']