355 $ilias = $DIC[
'ilias'];
356 $ilias->raiseError(
"Invalid role selection in registration" .
357 ", IP: " .
$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
362 $this->userObj->setAuthMode(
'local');
365 $this->user_profile->skipGroup(
"preferences");
366 $this->user_profile->skipGroup(
"settings");
367 $this->user_profile->skipField(
"password");
368 $this->user_profile->skipField(
"birthday");
369 $this->user_profile->skipField(
"upload");
370 foreach ($this->user_profile->getStandardFields() as $k => $v) {
372 $method =
"set" . substr($v[
"method"], 3);
373 if (method_exists($this->userObj, $method)) {
374 if ($k !==
"username") {
377 $field_obj = $this->
form->getItemByPostVar($k);
379 $this->userObj->$method($this->
form->getInput($k));
385 $this->userObj->setFullName();
387 $birthday_obj = $this->
form->getItemByPostVar(
"usr_birthday");
389 $birthday = $this->
form->getInput(
"usr_birthday");
390 $this->userObj->setBirthday($birthday);
393 $this->userObj->setTitle($this->userObj->getFullname());
394 $this->userObj->setDescription($this->userObj->getEmail());
396 if ($this->registration_settings->passwordGenerationEnabled()) {
398 $password = $password[0];
400 $password = $this->
form->getInput(
"usr_password");
402 $this->userObj->setPasswd($password);
406 $defs = $user_defined_fields->getRegistrationDefinitions();
408 foreach ($defs as $definition) {
409 $f =
"udf_" . $definition[
'field_id'];
410 $item = $this->
form->getItemByPostVar(
$f);
411 if ($item && !$item->getDisabled()) {
412 $udf[$definition[
'field_id']] = $this->
form->getInput(
$f);
415 $this->userObj->setUserDefinedData($udf);
417 $this->userObj->setTimeLimitOwner(7);
419 $access_limit = null;
421 $this->code_was_used =
false;
422 $code_has_access_limit =
false;
423 $code_local_roles = [];
424 if ($this->code_enabled) {
425 $code_local_roles = $code_has_access_limit = null;
428 $code = $this->
form->getInput(
'usr_registration_code');
432 $this->code_was_used =
true;
436 if ($code_data[
"role_local"]) {
438 $code_local_roles = explode(
";", $code_data[
"role_local"]);
440 if ($code_data[
"alimit"]) {
442 $code_has_access_limit =
true;
444 switch ($code_data[
"alimit"]) {
446 $abs = date_parse($code_data[
"alimitdt"]);
447 $access_limit = mktime(23, 59, 59, $abs[
'month'], $abs[
'day'], $abs[
'year']);
451 $rel = unserialize($code_data[
"alimitdt"], [
'allowed_classes' =>
false]);
452 $access_limit = (
int) ($rel[
"d"] * 86400 + $rel[
"m"] * 2592000 + $rel[
"y"] * 31536000 + time());
460 if (!($this->code_was_used && $code_has_access_limit) &&
461 $this->registration_settings->getAccessLimitation()) {
463 switch ($access_limitations_obj->getMode($a_role)) {
465 $access_limit = $access_limitations_obj->getAbsolute($a_role);
469 $rel_d = $access_limitations_obj->getRelative($a_role,
'd');
470 $rel_m = $access_limitations_obj->getRelative($a_role,
'm');
471 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + time();
477 $this->userObj->setTimeLimitUnlimited(
false);
478 $this->userObj->setTimeLimitUntil($access_limit);
480 $this->userObj->setTimeLimitUnlimited(
true);
481 $this->userObj->setTimeLimitUntil(time());
484 $this->userObj->setTimeLimitFrom(time());
488 $this->userObj->create();
493 $this->userObj->setActive(
true, 0);
495 $this->userObj->setActive(
false, 0);
497 $this->userObj->setActive(
false, 0);
502 $this->userObj->setLastPasswordChangeTS(time());
504 $this->userObj->setIsSelfRegistered(
true);
507 $this->userObj->saveAsNew();
510 $this->userObj->updateOwner();
513 $this->userObj->setLanguage($this->
form->getInput(
'usr_language'));
516 $DIC[
'legalDocuments']->selfRegistration()->userCreation($this->userObj);
518 $hits_per_page = $this->
settings->get(
"hits_per_page");
519 if ($hits_per_page < 10) {
522 $this->userObj->setPref(
"hits_per_page", $hits_per_page);
523 if ($this->
http->wrapper()->query()->has(
'target')) {
524 $this->userObj->setPref(
526 $this->
http->wrapper()->query()->retrieve(
528 $this->
refinery->kindlyTo()->string()
532 $this->userObj->setPref(
'bs_allow_to_contact_me', $this->
settings->get(
'bs_allow_to_contact_me',
'n'));
533 $this->userObj->setPref(
'chat_osc_accept_msg', $this->
settings->get(
'chat_osc_accept_msg',
'n'));
534 $this->userObj->setPref(
'chat_broadcast_typing', $this->
settings->get(
'chat_broadcast_typing',
'n'));
535 $this->userObj->writePrefs();
537 $this->rbacadmin->assignUser($a_role, $this->userObj->getId());
540 if ($this->code_was_used && is_array($code_local_roles)) {
541 $code_local_roles = array_map(intval(...), array_unique($code_local_roles));
542 foreach ($code_local_roles as $local_role_obj_id) {
545 $this->rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
548 $role_obj =
$GLOBALS[
'DIC'][
'rbacreview']->getObjectOfRole($local_role_obj_id);
553 $role_ref = end($role_refs);
563 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