368 $ilias = $DIC[
'ilias'];
369 $ilias->raiseError(
"Invalid role selection in registration" .
370 ", IP: " .
$_SERVER[
"REMOTE_ADDR"], $ilias->error_obj->FATAL);
375 $this->userObj->setAuthMode(
'local');
378 $this->user_profile->skipGroup(
"preferences");
379 $this->user_profile->skipGroup(
"settings");
380 $this->user_profile->skipField(
"password");
381 $this->user_profile->skipField(
"birthday");
382 $this->user_profile->skipField(
"upload");
383 foreach ($this->user_profile->getStandardFields() as $k => $v) {
385 $method =
"set" . substr($v[
"method"], 3);
386 if (method_exists($this->userObj, $method)) {
387 if ($k !==
"username") {
390 $field_obj = $this->
form->getItemByPostVar($k);
392 $this->userObj->$method($this->
form->getInput($k));
398 $this->userObj->setFullName();
400 $birthday_obj = $this->
form->getItemByPostVar(
"usr_birthday");
402 $birthday = $this->
form->getInput(
"usr_birthday");
403 $this->userObj->setBirthday($birthday);
406 $this->userObj->setTitle($this->userObj->getFullname());
407 $this->userObj->setDescription($this->userObj->getEmail());
409 if ($this->registration_settings->passwordGenerationEnabled()) {
411 $password = $password[0];
413 $password = $this->
form->getInput(
"usr_password");
415 $this->userObj->setPasswd($password);
419 $defs = $user_defined_fields->getRegistrationDefinitions();
421 foreach ($defs as $definition) {
422 $f =
"udf_" . $definition[
'field_id'];
423 $item = $this->
form->getItemByPostVar(
$f);
424 if ($item && !$item->getDisabled()) {
425 $udf[$definition[
'field_id']] = $this->
form->getInput(
$f);
428 $this->userObj->setUserDefinedData($udf);
430 $this->userObj->setTimeLimitOwner(7);
432 $access_limit =
null;
434 $this->code_was_used =
false;
435 $code_has_access_limit =
false;
436 $code_local_roles = [];
437 if ($this->code_enabled) {
438 $code_local_roles = $code_has_access_limit =
null;
441 $code = $this->
form->getInput(
'usr_registration_code');
445 $this->code_was_used =
true;
449 if ($code_data[
"role_local"]) {
451 $code_local_roles = explode(
";", $code_data[
"role_local"]);
453 if ($code_data[
"alimit"]) {
455 $code_has_access_limit =
true;
457 switch ($code_data[
"alimit"]) {
459 $abs = date_parse($code_data[
"alimitdt"]);
460 $access_limit = mktime(23, 59, 59, $abs[
'month'], $abs[
'day'], $abs[
'year']);
464 $rel = unserialize($code_data[
"alimitdt"], [
'allowed_classes' =>
false]);
465 $access_limit = (
int) ($rel[
"d"] * 86400 + $rel[
"m"] * 2592000 + $rel[
"y"] * 31536000 + time());
473 if (!($this->code_was_used && $code_has_access_limit) &&
474 $this->registration_settings->getAccessLimitation()) {
476 switch ($access_limitations_obj->getMode($a_role)) {
478 $access_limit = $access_limitations_obj->getAbsolute($a_role);
482 $rel_d = $access_limitations_obj->getRelative($a_role,
'd');
483 $rel_m = $access_limitations_obj->getRelative($a_role,
'm');
484 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + time();
490 $this->userObj->setTimeLimitUnlimited(
false);
491 $this->userObj->setTimeLimitUntil($access_limit);
493 $this->userObj->setTimeLimitUnlimited(
true);
494 $this->userObj->setTimeLimitUntil(time());
497 $this->userObj->setTimeLimitFrom(time());
501 $this->userObj->create();
506 $this->userObj->setActive(
true, 0);
508 $this->userObj->setActive(
false, 0);
510 $this->userObj->setActive(
false, 0);
515 $this->userObj->setLastPasswordChangeTS(time());
517 $this->userObj->setIsSelfRegistered(
true);
520 $this->userObj->saveAsNew();
523 $this->userObj->updateOwner();
526 $this->userObj->setLanguage($this->
form->getInput(
'usr_language'));
529 $DIC[
'legalDocuments']->selfRegistration()->userCreation($this->userObj);
531 if ($this->
http->wrapper()->query()->has(
'target')) {
532 $this->userObj->setPref(
534 $this->
http->wrapper()->query()->retrieve(
536 $this->
refinery->kindlyTo()->string()
540 $this->userObj->setPref(
'bs_allow_to_contact_me', $this->
settings->get(
'bs_allow_to_contact_me',
'n'));
541 $this->userObj->setPref(
'chat_osc_accept_msg', $this->
settings->get(
'chat_osc_accept_msg',
'n'));
542 $this->userObj->setPref(
'chat_broadcast_typing', $this->
settings->get(
'chat_broadcast_typing',
'n'));
543 $this->userObj->writePrefs();
545 $this->rbacadmin->assignUser($a_role, $this->userObj->getId());
548 if ($this->code_was_used && is_array($code_local_roles)) {
549 $code_local_roles =
array_map(intval(...), array_unique($code_local_roles));
550 foreach ($code_local_roles as $local_role_obj_id) {
553 $this->rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
556 $role_obj =
$GLOBALS[
'DIC'][
'rbacreview']->getObjectOfRole($local_role_obj_id);
561 $role_ref = end($role_refs);
571 return (
string) $password;
static _getAllReferences(int $id)
get all reference ids for object ID
static getCodeData(string $code)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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