355 $ilias = $DIC[
'ilias'];
356 $ilias->raiseError(
"Invalid role selection in registration" .
357 ", IP: " .
$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
362 $this->user_profile->skipGroup(
"preferences");
363 $this->user_profile->skipGroup(
"settings");
364 $this->user_profile->skipField(
"password");
365 $this->user_profile->skipField(
"birthday");
366 $this->user_profile->skipField(
"upload");
367 foreach ($this->user_profile->getStandardFields() as $k => $v) {
369 $method =
"set" . substr($v[
"method"], 3);
370 if (method_exists($this->userObj, $method)) {
371 if ($k !==
"username") {
374 $field_obj = $this->
form->getItemByPostVar($k);
376 $this->userObj->$method($this->
form->getInput($k));
382 $this->userObj->setFullName();
384 $birthday_obj = $this->
form->getItemByPostVar(
"usr_birthday");
386 $birthday = $this->
form->getInput(
"usr_birthday");
387 $this->userObj->setBirthday($birthday);
390 $this->userObj->setTitle($this->userObj->getFullname());
391 $this->userObj->setDescription($this->userObj->getEmail());
393 if ($this->registration_settings->passwordGenerationEnabled()) {
395 $password = $password[0];
397 $password = $this->
form->getInput(
"usr_password");
399 $this->userObj->setPasswd($password);
403 $defs = $user_defined_fields->getRegistrationDefinitions();
405 foreach ($defs as $definition) {
406 $f =
"udf_" . $definition[
'field_id'];
407 $item = $this->
form->getItemByPostVar(
$f);
408 if ($item && !$item->getDisabled()) {
409 $udf[$definition[
'field_id']] = $this->
form->getInput(
$f);
412 $this->userObj->setUserDefinedData($udf);
414 $this->userObj->setTimeLimitOwner(7);
416 $access_limit = null;
418 $this->code_was_used =
false;
419 $code_has_access_limit =
false;
420 $code_local_roles = [];
421 if ($this->code_enabled) {
422 $code_local_roles = $code_has_access_limit = null;
425 $code = $this->
form->getInput(
'usr_registration_code');
429 $this->code_was_used =
true;
433 if ($code_data[
"role_local"]) {
435 $code_local_roles = explode(
";", $code_data[
"role_local"]);
437 if ($code_data[
"alimit"]) {
439 $code_has_access_limit =
true;
441 switch ($code_data[
"alimit"]) {
443 $abs = date_parse($code_data[
"alimitdt"]);
444 $access_limit = mktime(23, 59, 59, $abs[
'month'], $abs[
'day'], $abs[
'year']);
448 $rel = unserialize($code_data[
"alimitdt"], [
'allowed_classes' =>
false]);
449 $access_limit = (
int) ($rel[
"d"] * 86400 + $rel[
"m"] * 2592000 + $rel[
"y"] * 31536000 + time());
457 if (!($this->code_was_used && $code_has_access_limit) &&
458 $this->registration_settings->getAccessLimitation()) {
460 switch ($access_limitations_obj->getMode($a_role)) {
462 $access_limit = $access_limitations_obj->getAbsolute($a_role);
466 $rel_d = $access_limitations_obj->getRelative($a_role,
'd');
467 $rel_m = $access_limitations_obj->getRelative($a_role,
'm');
468 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + time();
474 $this->userObj->setTimeLimitUnlimited(
false);
475 $this->userObj->setTimeLimitUntil($access_limit);
477 $this->userObj->setTimeLimitUnlimited(
true);
478 $this->userObj->setTimeLimitUntil(time());
481 $this->userObj->setTimeLimitFrom(time());
485 $this->userObj->create();
490 $this->userObj->setActive(
true, 0);
492 $this->userObj->setActive(
false, 0);
494 $this->userObj->setActive(
false, 0);
499 $this->userObj->setLastPasswordChangeTS(time());
501 $this->userObj->setIsSelfRegistered(
true);
504 $this->userObj->saveAsNew();
507 $this->userObj->updateOwner();
510 $this->userObj->setLanguage($this->
form->getInput(
'usr_language'));
513 $DIC[
'legalDocuments']->selfRegistration()->userCreation($this->userObj);
515 $hits_per_page = $this->
settings->get(
"hits_per_page");
516 if ($hits_per_page < 10) {
519 $this->userObj->setPref(
"hits_per_page", $hits_per_page);
520 if ($this->
http->wrapper()->query()->has(
'target')) {
521 $this->userObj->setPref(
523 $this->
http->wrapper()->query()->retrieve(
525 $this->
refinery->kindlyTo()->string()
529 $this->userObj->setPref(
'bs_allow_to_contact_me', $this->
settings->get(
'bs_allow_to_contact_me',
'n'));
530 $this->userObj->setPref(
'chat_osc_accept_msg', $this->
settings->get(
'chat_osc_accept_msg',
'n'));
531 $this->userObj->setPref(
'chat_broadcast_typing', $this->
settings->get(
'chat_broadcast_typing',
'n'));
532 $this->userObj->writePrefs();
534 $this->rbacadmin->assignUser($a_role, $this->userObj->getId());
537 if ($this->code_was_used && is_array($code_local_roles)) {
538 foreach (array_unique($code_local_roles) as $local_role_obj_id) {
541 $this->rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
544 $role_obj =
$GLOBALS[
'DIC'][
'rbacreview']->getObjectOfRole($local_role_obj_id);
549 $role_ref = end($role_refs);
559 return (
string) $password;
static _getAllReferences(int $id)
get all reference ids for object ID
static getCodeData(string $code)
static http()
Fetches the global http state from ILIAS.
Class class.ilRegistrationAccessLimitation.
static generatePasswords(int $a_number)
Generate a number of passwords.
form( $class_path, string $cmd, string $submit_caption="")
static useCode(string $code)
static _lookupType(int $id, bool $reference=false)
const CONTEXT_REGISTRATION