Add standard fields to form.
405 {
407
408
409 if(self::$mode == self::MODE_REGISTRATION)
410 {
411 include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
413
414 self::$user_field["username"]["group"] = "login_data";
415 self::$user_field["password"]["group"] = "login_data";
416 self::$user_field[
"language"][
"default"] =
$lng->lang_key;
417
418
419 $roles = self::$user_field["roles"];
420 unset(self::$user_field["roles"]);
421 self::$user_field["roles"] = $roles;
422 self::$user_field["roles"]["group"] = "settings";
423 }
424
426 $current_group = "";
427 $custom_fields_done = false;
428 foreach ($fields as $f => $p)
429 {
430
431 if (($p["group"] != $current_group) &&
433 {
434 if (is_array($custom_fields) && !$custom_fields_done)
435 {
436
437 if($current_group == "other" || $p["group"] == "settings")
438 {
439
440 if($current_group != "other")
441 {
443 $sh->setTitle(
$lng->txt(
"other"));
444 $a_form->addItem($sh);
445 }
446 foreach($custom_fields as $custom_field)
447 {
448 $a_form->addItem($custom_field);
449 }
450 $custom_fields_done = true;
451 }
452 }
453
455 $sh->setTitle(
$lng->txt($p[
"group"]));
456 $a_form->addItem($sh);
457 $current_group = $p["group"];
458 }
459
460 $m = "";
461 if (isset($p["method"]))
462 {
463 $m = $p["method"];
464 }
465
466 $lv = (isset($p["lang_var"]) && $p["lang_var"] != "")
467 ? $p["lang_var"]
468 : $f;
469
470 switch ($p["input"])
471 {
472 case "login":
474 {
476 if($a_user)
477 {
478 $val->setValue($a_user->getLogin());
479 }
480 $val->setMaxLength(32);
481 $val->setSize(40);
482 $val->setRequired(true);
483 }
484 else
485 {
486
488 if($a_user)
489 {
490 $val->setValue($a_user->getLogin());
491 }
492 }
493 $a_form->addItem($val);
494 break;
495
496 case "text":
498 {
500 if($a_user)
501 {
502 $ti->setValue($a_user->$m());
503 }
504 $ti->setMaxLength($p["maxlength"]);
505 $ti->setSize($p["size"]);
506 $ti->setRequired(
$ilSetting->get(
"require_".$f));
507 if(!$ti->getRequired() || $ti->getValue())
508 {
509 $ti->setDisabled(
$ilSetting->get(
"usr_settings_disable_".$f));
510 }
511 $a_form->addItem($ti);
512 }
513 break;
514
515 case "sel_country":
517 {
518 include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
520 if($a_user)
521 {
522 $ci->setValue($a_user->$m());
523 }
524 $ci->setRequired(
$ilSetting->get(
"require_".$f));
525 if(!$ci->getRequired() || $ci->getValue())
526 {
527 $ci->setDisabled(
$ilSetting->get(
"usr_settings_disable_".$f));
528 }
529 $a_form->addItem($ci);
530 }
531 break;
532
533 case "birthday":
535 {
537 include_once "./Services/Calendar/classes/class.ilDateTime.php";
538 $date = null;
539 if ($a_user && strlen($a_user->$m()))
540 {
542 $bi->setDate($date);
543 }
544 $bi->setShowEmpty(true);
545 $bi->setStartYear(1900);
546 $bi->setRequired(
$ilSetting->get(
"require_".$f));
547 if(!$bi->getRequired() || $date)
548 {
549 $bi->setDisabled(
$ilSetting->get(
"usr_settings_disable_".$f));
550 }
551 $a_form->addItem($bi);
552 }
553 break;
554
555 case "radio":
557 {
559 if($a_user)
560 {
561 $rg->setValue($a_user->$m());
562 }
563 foreach ($p["values"] as $k => $v)
564 {
566 $rg->addOption($op);
567 }
568 $rg->setRequired(
$ilSetting->get(
"require_".$f));
569 if(!$rg->getRequired() || $rg->getValue())
570 {
571 $rg->setDisabled(
$ilSetting->get(
"usr_settings_disable_".$f));
572 }
573 $a_form->addItem($rg);
574 }
575 break;
576
577 case "picture":
579 {
581 $ii->setDisabled(
$ilSetting->get(
"usr_settings_disable_upload"));
582
583 $upload = $a_form->getFileUpload("userfile");
584 if($upload["name"])
585 {
586 $ii->setPending($upload["name"]);
587 }
588 else
589 {
591 true);
592 if ($im != "")
593 {
594 $ii->setImage($im);
595 $ii->setAlt(
$lng->txt(
"personal_picture"));
596 }
597 }
598
599 $a_form->addItem($ii);
600 }
601 break;
602
603 case "roles":
604 if(self::$mode == self::MODE_DESKTOP)
605 {
607 {
608 $global_roles = $rbacreview->getGlobalRoles();
609 foreach($global_roles as $role_id)
610 {
611 if (in_array($role_id,$rbacreview->assignedRoles($a_user->getId())))
612 {
613 $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
614 $role_names .= $roleObj->getTitle().", ";
615 unset($roleObj);
616 }
617 }
619 $dr->setValue(substr($role_names,0,-2));
620 $a_form->addItem($dr);
621 }
622 }
623 else if(self::$mode == self::MODE_REGISTRATION)
624 {
625 if($registration_settings->roleSelectionEnabled())
626 {
627 include_once("./Services/AccessControl/classes/class.ilObjRole.php");
630 {
631 $options[$role[
"id"]] = $role[
"title"];
632 }
633
635 {
637 {
640 $ta->setRequired(
$ilSetting->get(
"require_".$f));
641 if(!$ta->getRequired())
642 {
643 $ta->setDisabled(
$ilSetting->get(
"usr_settings_disable_".$f));
644 }
645 }
646
647 else
648 {
650 $ta->setValue(array_shift(array_keys(
$options)));
651 }
652 $a_form->addItem($ta);
653 }
654 }
655 }
656 break;
657
658 case "email":
660 {
662 if($a_user)
663 {
664 $em->setValue($a_user->$m());
665 }
666 $em->setRequired(
$ilSetting->get(
"require_".$f));
667 if(!$em->getRequired() || $em->getValue())
668 {
669 $em->setDisabled(
$ilSetting->get(
"usr_settings_disable_".$f));
670 }
671 if(self::MODE_REGISTRATION == self::$mode)
672 {
673 $em->setRetype(true);
674 }
675 $a_form->addItem($em);
676 }
677 break;
678
679 case "textarea":
681 {
683 if($a_user)
684 {
685 $ta->setValue($a_user->$m());
686 }
687 $ta->setRows($p["rows"]);
688 $ta->setCols($p["cols"]);
689 $ta->setRequired(
$ilSetting->get(
"require_".$f));
690 if(!$ta->getRequired() || $ta->getValue())
691 {
692 $ta->setDisabled(
$ilSetting->get(
"usr_settings_disable_".$f));
693 }
694 $a_form->addItem($ta);
695 }
696 break;
697
698 case "messenger":
700 {
701 $im_arr = $p["types"];
702 foreach ($im_arr as $im_name)
703 {
705 if($a_user)
706 {
707 $im->setValue($a_user->getInstantMessengerId($im_name));
708 }
709 $im->setMaxLength($p["maxlength"]);
710 $im->setSize($p["size"]);
711 $im->setRequired(
$ilSetting->get(
"require_".
"instant_messengers"));
712 if(!$im->getRequired() || $im->getValue())
713 {
714 $im->setDisabled(
$ilSetting->get(
"usr_settings_disable_".
"instant_messengers"));
715 }
716 $a_form->addItem($im);
717 }
718 }
719 break;
720
721 case "password":
722 if (self::$mode == self::MODE_REGISTRATION)
723 {
724 if(!$registration_settings->passwordGenerationEnabled())
725 {
727 $ta->setRequired(true);
728
729 }
730 else
731 {
733 $ta->setValue(
$lng->txt(
"reg_passwd_via_mail"));
734 }
735 $a_form->addItem($ta);
736 }
737 break;
738
739 case "language":
741 {
743 if($a_user)
744 {
745 $ta->setValue($a_user->$m());
746 }
748 $lng->loadLanguageModule(
"meta");
749 foreach (
$lng->getInstalledLanguages() as $lang_key)
750 {
752 }
755 $ta->setRequired(
$ilSetting->get(
"require_".$f));
756 if(!$ta->getRequired() || $ta->getValue())
757 {
758 $ta->setDisabled(
$ilSetting->get(
"usr_settings_disable_".$f));
759 }
760 $a_form->addItem($ta);
761 }
762 break;
763
764 case "multitext":
766 {
768 $ti->setMulti(true);
769 if($a_user)
770 {
771 $ti->setValue($a_user->$m());
772 }
773 $ti->setMaxLength($p["maxlength"]);
774 $ti->setSize($p["size"]);
775 $ti->setRequired(
$ilSetting->get(
"require_".$f));
776 if(!$ti->getRequired() || $ti->getValue())
777 {
778 $ti->setDisabled(
$ilSetting->get(
"usr_settings_disable_".$f));
779 }
780 if($this->ajax_href)
781 {
782
783 $ti->setDataSource($this->ajax_href."&f=".$f);
784 }
785 $a_form->addItem($ti);
786 }
787 break;
788 }
789 }
790
791
792 if(is_array($custom_fields) && !$custom_fields_done)
793 {
794
795 if($current_group != "other")
796 {
798 $sh->setTitle(
$lng->txt(
"other"));
799 $a_form->addItem($sh);
800 }
801 foreach($custom_fields as $custom_field)
802 {
803 $a_form->addItem($custom_field);
804 }
805 }
806 }
@classDescription Date and time handling
This class represents a non editable value in a property form.
_lookupRegisterAllowed()
get all roles that are activated in user registration
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
This class represents an option in a radio group.
Class ilObjAuthSettingsGUI.
This class represents a text area property in a property form.
This class represents a text property in a property form.
getStandardFields()
Get standard user fields array.
static userSettingVisible($a_setting)
Checks whether user setting is visible.
if(!is_array($argv)) $options