357 : string
358 {
359
360 if (!$a_role) {
362
363 $ilias =
$DIC[
'ilias'];
364 $ilias->raiseError("Invalid role selection in registration" .
365 ", IP: " .
$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
366 }
367
370 $this->userObj->setAuthMode('local');
371 }
372
373 $this->userObj = $this->user_profile->addFormValuesToUser(
375 Context::Registration,
376 $this->userObj
377 );
378 $this->userObj->setTitle($this->userObj->getFullname());
379 $this->userObj->setDescription($this->userObj->getEmail());
380
381 $this->userObj->setLogin(
382 $this->
form->getInput(
'username')
383 );
384
385 if ($this->registration_settings->passwordGenerationEnabled()) {
387 $password = $password[0];
388 } else {
389 $password = $this->
form->getInput(
"password");
390 }
391
392 $this->userObj->setLanguage(
393 $this->user_settings->getValueFromLegacyFormByDefinitionClass(
394 LanguageSetting::class,
395 $this->form
396 )
397 );
398
399 $this->userObj->setPasswd($password);
400
401 $access_limit = null;
402
403 $this->code_was_used = false;
404 $code_has_access_limit = false;
405 $code_local_roles = [];
406 if ($this->code_enabled) {
407 $code_local_roles = $code_has_access_limit = null;
408
409
410 $code = $this->
form->getInput(
'usr_registration_code');
411 if ($code) {
412
414 $this->code_was_used = true;
415
416
418 if ($code_data["role_local"]) {
419
420 $code_local_roles = explode(";", $code_data["role_local"]);
421 }
422 if ($code_data["alimit"]) {
423
424 $code_has_access_limit = true;
425
426 switch ($code_data["alimit"]) {
427 case "absolute":
428 $abs = date_parse($code_data["alimitdt"]);
429 $access_limit = mktime(23, 59, 59, $abs['month'], $abs['day'], $abs['year']);
430 break;
431
432 case "relative":
433 $rel = unserialize($code_data["alimitdt"], ['allowed_classes' => false]);
434 $access_limit = (
int) ($rel[
"d"] * 86400 + $rel[
"m"] * 2592000 + $rel[
"y"] * 31536000 + time());
435 break;
436 }
437 }
438 }
439 }
440
441
442 if (!($this->code_was_used && $code_has_access_limit) &&
443 $this->registration_settings->getAccessLimitation()) {
445 switch ($access_limitations_obj->getMode($a_role)) {
446 case 'absolute':
447 $access_limit = $access_limitations_obj->getAbsolute($a_role);
448 break;
449
450 case 'relative':
451 $rel_d = $access_limitations_obj->getRelative($a_role, 'd');
452 $rel_m = $access_limitations_obj->getRelative($a_role, 'm');
453 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + time();
454 break;
455 }
456 }
457
458 if ($access_limit) {
459 $this->userObj->setTimeLimitUnlimited(false);
460 $this->userObj->setTimeLimitUntil($access_limit);
461 } else {
462 $this->userObj->setTimeLimitUnlimited(true);
463 $this->userObj->setTimeLimitUntil(time());
464 }
465
466 $this->userObj->setTimeLimitFrom(time());
467
469
470 $this->userObj->create();
471
474 $this->code_was_used) {
475 $this->userObj->setActive(true, 0);
477 $this->userObj->setActive(false, 0);
478 } else {
479 $this->userObj->setActive(false, 0);
480 }
481
482
483
484 $this->userObj->setLastPasswordChangeTS(time());
485
486 $this->userObj->setIsSelfRegistered(true);
487
488
489 $this->userObj->saveAsNew();
490
491
492 $this->userObj->updateOwner();
493
494
495 $this->userObj->setLanguage($this->
form->getInput(
'usr_language'));
496
498 $DIC[
'legalDocuments']->selfRegistration()->userCreation($this->userObj);
499
500 if ($this->
http->wrapper()->query()->has(
'target')) {
501 $this->userObj->setPref(
502 'reg_target',
503 $this->
http->wrapper()->query()->retrieve(
504 'target',
505 $this->refinery->kindlyTo()->string()
506 )
507 );
508 }
509 $this->userObj->setPref(
'bs_allow_to_contact_me', $this->
settings->get(
'bs_allow_to_contact_me',
'n'));
510 $this->userObj->setPref(
'chat_osc_accept_msg', $this->
settings->get(
'chat_osc_accept_msg',
'n'));
511 $this->userObj->setPref(
'chat_broadcast_typing', $this->
settings->get(
'chat_broadcast_typing',
'n'));
512 $this->userObj->writePrefs();
513
514 $this->rbacadmin->assignUser($a_role, $this->userObj->getId());
515
516
517 if ($this->code_was_used && is_array($code_local_roles)) {
518 $code_local_roles = array_map(intval(...), array_unique($code_local_roles));
519 foreach ($code_local_roles as $local_role_obj_id) {
520
522 $this->rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
523
524
525 $role_obj =
$GLOBALS[
'DIC'][
'rbacreview']->getObjectOfRole($local_role_obj_id);
527 case 'crs':
528 case 'grp':
530 $role_ref = end($role_refs);
531
532
533
534 break;
535 }
536 }
537 }
538 }
539
540 return (string) $password;
541 }
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static useCode(string $code)
static getCodeData(string $code)
Class class.ilRegistrationAccessLimitation.
static generatePasswords(int $a_number)
Generate a number of passwords.
const CONTEXT_REGISTRATION