49        $this->ctrl->saveParameter($this, 
'lang');
 
   52        $this->lng->loadLanguageModule(
'registration');
 
   56        $this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
 
   57            $this->registration_settings->getAllowCodes());
 
   59        $this->termsOfServiceEvaluation = 
$DIC[
'tos.document.evaluator'];
 
   67        if ($this->registration_settings->getRegistrationType() == 
IL_REG_DISABLED) {
 
   69            $ilErr->raiseError($this->lng->txt(
'reg_disabled'), 
$ilErr->FATAL);
 
   72        $cmd = $this->ctrl->getCmd();
 
   82        $gtpl->setPermanentLink(
'usr', 
null, 
'registration');
 
   92        $tpl = ilStartUpGUI::initStartUpTemplate(array(
'tpl.usr_registration.html', 
'Services/Registration'), 
true);
 
   93        $tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'registration'));
 
   98        $tpl->setVariable(
'FORM', $this->form->getHTML());
 
  108        $ilUser->setLanguage($this->lng->getLangKey());
 
  109        $ilUser->setId(ANONYMOUS_USER_ID);
 
  115        $this->form->setFormAction($this->ctrl->getFormAction($this));
 
  120        if ($this->code_enabled) {
 
  122            $field->setTitle($this->lng->txt(
'registration_codes_type_reg'));
 
  123            $this->form->addItem($field);
 
  124            $code = 
new ilTextInputGUI($this->lng->txt(
"registration_code"), 
"usr_registration_code");
 
  127            if ((
bool) $this->registration_settings->registrationCodeRequired()) {
 
  128                $code->setRequired(
true);
 
  129                $code->setInfo($this->lng->txt(
"registration_code_required_info"));
 
  131                $code->setInfo($this->lng->txt(
"registration_code_optional_info"));
 
  133            $this->form->addItem($code);
 
  138        $user_defined_data = 
$ilUser->getUserDefinedData();
 
  141        $custom_fields = array();
 
  143        foreach ($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition) {
 
  147                $user_defined_data[
'f_' . $field_id]
 
  150                $custom_fields[
'udf_' . $definition[
'field_id']] = $fprop;
 
  157        $up->skipGroup(
"preferences");
 
  159        $up->setAjaxCallback(
 
  160            $this->ctrl->getLinkTarget($this, 
'doProfileAutoComplete', 
'', 
true)
 
  163        $this->lng->loadLanguageModule(
"user");
 
  166        $up->addStandardFieldsToForm($this->form, 
null, $custom_fields);
 
  167        unset($custom_fields);
 
  171        $flang = $this->form->getItemByPostVar(
"usr_language");
 
  173            $flang->setValue($this->lng->getLangKey());
 
  177        if ($this->code_enabled) {
 
  178            $role = $this->form->getItemByPostVar(
"usr_roles");
 
  179            if ($role && $role->getType() == 
"select") {
 
  180                $role->setInfo($this->lng->txt(
"registration_code_role_info"));
 
  186        foreach ($this->registration_settings->getAllowedDomains() as $item) {
 
  191        if (
sizeof($domains)) {
 
  192            $mail_obj = $this->form->getItemByPostVar(
'usr_email');
 
  193            $mail_obj->setInfo(sprintf(
 
  194                $this->lng->txt(
"reg_email_domains"),
 
  195                implode(
", ", $domains)
 
  197                ($this->code_enabled ? $this->lng->txt(
"reg_email_domains_code") : 
""));
 
  202            $mail_obj = $this->form->getItemByPostVar(
'usr_email');
 
  204                $mail_obj->setRequired(
true);
 
  209            $document = $this->termsOfServiceEvaluation->document();
 
  212            $field->setTitle($this->lng->txt(
'usr_agreement'));
 
  213            $this->form->addItem($field);
 
  216            $field->setHTML(
'<div id="agreement">' . $document->content() . 
'</div>');
 
  217            $this->form->addItem($field);
 
  219            $field = 
new ilCheckboxInputGUI($this->lng->txt(
'accept_usr_agreement'), 
'accept_terms_of_service');
 
  220            $field->setRequired(
true);
 
  222            $this->form->addItem($field);
 
  226        if (ilCaptchaUtil::isActiveForRegistration()) {
 
  227            $captcha = 
new ilCaptchaInputGUI($this->lng->txt(
"captcha_code"), 
'captcha_code');
 
  228            $captcha->setRequired(
true);
 
  229            $this->form->addItem($captcha);
 
  232        $this->form->addCommandButton(
"saveForm", $this->lng->txt(
"register"));
 
  240        $rbacreview = 
$DIC->rbac()->review();
 
  243        $form_valid = $this->form->checkInput();
 
  246        $valid_code = $valid_role = 
false;
 
  249        if ($this->code_enabled) {
 
  250            $code = $this->form->getInput(
'usr_registration_code');
 
  253                $this->registration_settings->registrationCodeRequired() ||
 
  258                    $code_obj = $this->form->getItemByPostVar(
'usr_registration_code');
 
  259                    $code_obj->setAlert($this->lng->txt(
'registration_code_not_valid'));
 
  266                    if ($role_id && $rbacreview->isGlobalRole($role_id)) {
 
  267                        $valid_role = $role_id;
 
  276            $email = $this->form->getInput(
"usr_email");
 
  280                foreach ($this->registration_settings->getAllowedDomains() as $item) {
 
  285                if (
sizeof($domains)) {
 
  287                    foreach ($domains as $domain) {
 
  288                        $domain = str_replace(
"*", 
"~~~", $domain);
 
  289                        $domain = preg_quote($domain);
 
  290                        $domain = str_replace(
"~~~", 
".+", $domain);
 
  291                        if (preg_match(
"/^" . $domain . 
"$/", 
$email, $hit)) {
 
  297                        $mail_obj = $this->form->getItemByPostVar(
'usr_email');
 
  298                        $mail_obj->setAlert(sprintf(
 
  299                            $this->lng->txt(
"reg_email_domains"),
 
  300                            implode(
", ", $domains)
 
  310            !$this->registration_settings->passwordGenerationEnabled() &&
 
  313            $passwd_obj = $this->form->getItemByPostVar(
'usr_password');
 
  314            $passwd_obj->setAlert($this->lng->txt($error_lng_var));
 
  318        $showGlobalTermsOfServieFailure = 
false;
 
  320            $agr_obj = $this->form->getItemByPostVar(
'accept_terms_of_service');
 
  322                $agr_obj->setAlert($this->lng->txt(
'force_accept_usr_agreement'));
 
  325                $showGlobalTermsOfServieFailure = 
true;
 
  332            if ($this->registration_settings->roleSelectionEnabled()) {
 
  333                $selected_role = $this->form->getInput(
"usr_roles");
 
  335                    $valid_role = (int) $selected_role;
 
  341                $valid_role = (int) $registration_role_assignments->getRoleByEmail($this->form->getInput(
"usr_email"));
 
  352        $login_obj = $this->form->getItemByPostVar(
'username');
 
  353        $login = $this->form->getInput(
"username");
 
  354        $captcha = $this->form->getItemByPostVar(
"captcha_code");
 
  356            $login_obj->setAlert($this->lng->txt(
"login_invalid"));
 
  362                if (empty($captcha) || empty($captcha->getAlert())) {
 
  363                    $login_obj->setAlert($this->lng->txt(
"login_exists"));
 
  366            } elseif ((
int) 
$ilSetting->get(
'allow_change_loginname') &&
 
  367                (
int) 
$ilSetting->get(
'reuse_of_loginnames') == 0 &&
 
  369                if (empty($captcha) || empty($captcha->getAlert())) {
 
  370                    $login_obj->setAlert($this->lng->txt(
"login_exists"));
 
  378        } elseif ($showGlobalTermsOfServieFailure) {
 
  379            $this->lng->loadLanguageModule(
'tos');
 
  381                $this->lng->txt(
'tos_account_reg_not_possible'),
 
  385            $password = $this->__createUser($valid_role);
 
  387            return $this->
login();
 
  389        $this->form->setValuesByPost();
 
  393    protected function __createUser($a_role)
 
  402        $rbacadmin = 
$DIC->rbac()->admin();
 
  409            $ilias = 
$DIC[
'ilias'];
 
  410            $ilias->raiseError(
"Invalid role selection in registration" .
 
  411                ", IP: " . 
$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
 
  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");
 
  463        $defs = $user_defined_fields->getRegistrationDefinitions();
 
  465        foreach (
$_POST as $k => $v) {
 
  466            if (substr($k, 0, 4) == 
"udf_") {
 
  471        $this->userObj->setUserDefinedData($udf);
 
  473        $this->userObj->setTimeLimitOwner(7);
 
  476        $access_limit = 
null;
 
  478        $this->code_was_used = 
false;
 
  479        if ($this->code_enabled) {
 
  480            $code_local_roles = $code_has_access_limit = 
null;
 
  483            $code = $this->form->getInput(
'usr_registration_code');
 
  488                $this->code_was_used = 
true;
 
  492                if ($code_data[
"role_local"]) {
 
  494                    $code_local_roles = explode(
";", $code_data[
"role_local"]);
 
  496                if ($code_data[
"alimit"]) {
 
  498                    $code_has_access_limit = 
true;
 
  500                    switch ($code_data[
"alimit"]) {
 
  502                            $abs = date_parse($code_data[
"alimitdt"]);
 
  503                            $access_limit = mktime(23, 59, 59, $abs[
'month'], $abs[
'day'], $abs[
'year']);
 
  507                            $rel = unserialize($code_data[
"alimitdt"]);
 
  508                            $access_limit = $rel[
"d"] * 86400 + $rel[
"m"] * 2592000 +
 
  509                                $rel[
"y"] * 31536000 + time();
 
  517        if (!($this->code_was_used && $code_has_access_limit) &&
 
  518            $this->registration_settings->getAccessLimitation()) {
 
  520            switch ($access_limitations_obj->getMode($a_role)) {
 
  522                    $access_limit = $access_limitations_obj->getAbsolute($a_role);
 
  526                    $rel_d = (int) $access_limitations_obj->getRelative($a_role, 
'd');
 
  527                    $rel_m = (int) $access_limitations_obj->getRelative($a_role, 
'm');
 
  528                    $rel_y = (int) $access_limitations_obj->getRelative($a_role, 
'y');
 
  529                    $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
 
  535            $this->userObj->setTimeLimitUnlimited(0);
 
  536            $this->userObj->setTimeLimitUntil($access_limit);
 
  538            $this->userObj->setTimeLimitUnlimited(1);
 
  539            $this->userObj->setTimeLimitUntil(time());
 
  542        $this->userObj->setTimeLimitFrom(time());
 
  546        $this->userObj->create();
 
  549        if ($this->registration_settings->getRegistrationType() == 
IL_REG_DIRECT ||
 
  550            $this->registration_settings->getRegistrationType() == 
IL_REG_CODES ||
 
  551            $this->code_was_used) {
 
  552            $this->userObj->setActive(1, 0);
 
  553        } elseif ($this->registration_settings->getRegistrationType() == 
IL_REG_ACTIVATION) {
 
  554            $this->userObj->setActive(0, 0);
 
  556            $this->userObj->setActive(0, 0);
 
  559        $this->userObj->updateOwner();
 
  563        $this->userObj->setLastPasswordChangeTS(time());
 
  565        $this->userObj->setIsSelfRegistered(
true);
 
  568        $this->userObj->saveAsNew();
 
  571        $this->userObj->setLanguage($this->form->getInput(
'usr_language'));
 
  574        if ($handleDocument) {
 
  575            $helper = new \ilTermsOfServiceHelper();
 
  577            $helper->trackAcceptance($this->userObj, $this->termsOfServiceEvaluation->document());
 
  580        $hits_per_page = 
$ilSetting->get(
"hits_per_page");
 
  581        if ($hits_per_page < 10) {
 
  584        $this->userObj->setPref(
"hits_per_page", $hits_per_page);
 
  585        if (strlen(
$_GET[
'target']) > 0) {
 
  594        $this->userObj->setPref(
'bs_allow_to_contact_me', 
$ilSetting->get(
'bs_allow_to_contact_me', 
'n'));
 
  595        $this->userObj->setPref(
'chat_osc_accept_msg', 
$ilSetting->get(
'chat_osc_accept_msg', 
'n'));
 
  596        $this->userObj->writePrefs();
 
  599        $rbacadmin->assignUser((
int) $a_role, $this->userObj->getId());
 
  602        if ($this->code_was_used && is_array($code_local_roles)) {
 
  603            foreach (array_unique($code_local_roles) as $local_role_obj_id) {
 
  606                    $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
 
  609                    $role_obj = 
$GLOBALS[
'DIC'][
'rbacreview']->getObjectOfRole($local_role_obj_id);
 
  614                            $role_ref = end($role_refs);
 
  631        if ($this->registration_settings->getRegistrationType() == 
IL_REG_APPROVE && !$this->code_was_used) {
 
  634            $mail->setRecipients($this->registration_settings->getApproveRecipients());
 
  635            $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
 
  640            $mail->setRecipients($this->registration_settings->getApproveRecipients());
 
  641            $mail->setAdditionalInformation(array(
'usr' => $this->userObj));
 
  647        if ($this->registration_settings->getRegistrationType() == 
IL_REG_ACTIVATION && !$this->code_was_used) {
 
  651            $mail->setRecipients(array($this->userObj));
 
  652            $mail->setAdditionalInformation(
 
  654                     'usr' => $this->userObj,
 
  655                     'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
 
  661                $this->registration_settings,
 
  665            $accountMail->withDirectRegistrationMode()->send($this->userObj, 
$password, $this->code_was_used);
 
  672        $f = 
$DIC->ui()->factory();
 
  673        $renderer = 
$DIC->ui()->renderer();
 
  675        $tpl = ilStartUpGUI::initStartUpTemplate(array(
'tpl.usr_registered.html', 
'Services/Registration'), 
false);
 
  676        $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'registration'));
 
  678        $tpl->setVariable(
"TXT_WELCOME", $this->lng->txt(
"welcome") . 
", " . $this->userObj->getTitle() . 
"!");
 
  681                $this->registration_settings->getRegistrationType() == 
IL_REG_DIRECT ||
 
  682                $this->registration_settings->getRegistrationType() == 
IL_REG_CODES ||
 
  685            !$this->registration_settings->passwordGenerationEnabled()
 
  687            $tpl->setVariable(
'TXT_REGISTERED', $this->lng->txt(
'txt_registered'));
 
  689            $login_link = $renderer->render(
$f->link()->standard($this->lng->txt(
'login_to_ilias'), 
'./login.php?cmd=force_login&lang=' . $this->userObj->getLanguage()));
 
  690            $tpl->setVariable(
'LOGIN_LINK', $login_link);
 
  691        } elseif ($this->registration_settings->getRegistrationType() == 
IL_REG_APPROVE) {
 
  692            $tpl->setVariable(
'TXT_REGISTERED', $this->lng->txt(
'txt_submitted'));
 
  693        } elseif ($this->registration_settings->getRegistrationType() == 
IL_REG_ACTIVATION) {
 
  694            $tpl->setVariable(
'TXT_REGISTERED', $this->lng->txt(
'reg_confirmation_link_successful'));
 
  696            $tpl->setVariable(
'TXT_REGISTERED', $this->lng->txt(
'txt_registered_passw_gen'));
 
  706    protected function showLogin()
 
  712        $auth_session = 
$DIC[
'ilAuthSession'];
 
  713        $auth_session->setAuthenticated(
 
  715            $DIC->user()->getId()
 
  718        return ilInitialisation::redirectToStartingPage();
 
  723        $field_id = (string) $_REQUEST[
"f"];
 
  724        $term = (string) $_REQUEST[
"term"];
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
Class ilAccountRegistrationGUI.
$termsOfServiceEvaluation
__distributeMails($password)
$recommended_content_manager
Class ilAccountRegistrationMail.
static getInstance()
Get instance.
static initUserAccount()
Init user with current account id.
static encode($mixed, $suppress_native=false)
static getLogger($a_component_id)
Get component logger.
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.
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 _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)
Recommended content manager (business logic)
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 printToGlobalTemplate($tpl)
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 prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl