ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilUserProfile.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4// mjansen@databay.de essential for mail constants, do not remove this include
5include_once 'Services/Mail/classes/class.ilMailOptions.php';
6
16{
17 const MODE_DESKTOP = 1;
19
20 private static $mode = self::MODE_DESKTOP;
21
22 // this array should be used in all places where user data is tackled
23 // in the future: registration, personal profile, user administration
24 // public profile, user import/export
25 // for now this is not implemented yet. Please list places, that already use it:
26 //
27 // - personal profile
28 // - (global) standard user profile fields settings
29 //
30 // the following attributes are defined (can be extended if needed):
31 // - input: input type
32 // standard inputs: text, radio, selection, textarea
33 // special inputs: login
34 // - input dependend attributes
35 // - maxlength, sizte for text
36 // - values array for radio
37 // - cols/rows for text areas
38 // - options array for selections
39 // - method: ilObjUser get-method, e.g. getFirstname
40 // - group: group id (id is also used as lang_var for sub headers in forms
41 // - lang_var: if key should not be used as lang var, this overwrites the usage in forms
42 // - settings property related attributes, settingsproperties are ("visible", "changeable",
43 // "searchable", "required", "export", "course_export" and "registration")
44 // - <settingsproperty>_hide: hide this property in settings (not implemented)
45 // - <settingsproperty>_fix_value: property has a fix value (cannot be changed)
46 private static $user_field = array(
47 "username" => array(
48 "input" => "login",
49 "maxlength" => 32,
50 "size" => 40,
51 "method" => "getLogin",
52 "course_export_fix_value" => 1,
53 "group_export_fix_value" => 1,
54 "changeable_hide" => true,
55 "required_hide" => true,
56 "group" => "personal_data"),
57 "password" => array(
58 "input" => "password",
59 "required_hide" => true,
60 "visib_reg_hide" => true,
61 'visib_lua_fix_value' => 0,
62 "course_export_hide" => true,
63 "export_hide" => false,
64 "group_export_hide" => true,
65 "lists_hide" => true,
66 "group" => "personal_data"),
67 "firstname" => array(
68 "input" => "text",
69 "maxlength" => 32,
70 "size" => 40,
71 "method" => "getFirstname",
72 "required_fix_value" => 1,
73 "visib_reg_fix_value" => 1,
74 'visib_lua_fix_value' => 1,
75 "course_export_fix_value" => 1,
76 "group_export_fix_value" => 1,
77 "group" => "personal_data"),
78 "lastname" => array(
79 "input" => "text",
80 "maxlength" => 32,
81 "size" => 40,
82 "method" => "getLastname",
83 "required_fix_value" => 1,
84 "visib_reg_fix_value" => 1,
85 'visib_lua_fix_value' => 1,
86 "course_export_fix_value" => 1,
87 "group_export_fix_value" => 1,
88 "group" => "personal_data"),
89 "title" => array(
90 "input" => "text",
91 "lang_var" => "person_title",
92 "maxlength" => 32,
93 "size" => 40,
94 "method" => "getUTitle",
95 "group" => "personal_data"),
96 "birthday" => array(
97 "input" => "birthday",
98 "lang_var" => "birthday",
99 "maxlength" => 32,
100 "size" => 40,
101 "method" => "getBirthday",
102 "group" => "personal_data"),
103 "gender" => array(
104 "input" => "radio",
105 "values" => array("f" => "gender_f", "m" => "gender_m"),
106 "method" => "getGender",
107 "group" => "personal_data"),
108 "upload" => array(
109 "input" => "picture",
110 "required_hide" => true,
111 "visib_reg_hide" => true,
112 "course_export_hide" => true,
113 "group_export_hide" => true,
114 "lists_hide" => true,
115 "lang_var" => "personal_picture",
116 "group" => "personal_data"),
117 "roles" => array(
118 "input" => "roles",
119 "changeable_hide" => true,
120 "required_hide" => true,
121 "visib_reg_hide" => true,
122 "export_hide" => true,
123 "course_export_hide" => true,
124 "group_export_hide" => TRUE,
125 "lists_hide" => true,
126 "group" => "personal_data"),
127 "interests_general" => array(
128 "input" => "multitext",
129 "maxlength" => 40,
130 "size" => 40,
131 "method" => "getGeneralInterests",
132 "course_export_hide" => true,
133 "group_export_hide" => true,
134 "lists_hide" => true,
135 "group" => "interests"),
136 "interests_help_offered" => array(
137 "input" => "multitext",
138 "maxlength" => 40,
139 "size" => 40,
140 "method" => "getOfferingHelp",
141 "course_export_hide" => true,
142 "group_export_hide" => true,
143 "lists_hide" => true,
144 "group" => "interests"),
145 "interests_help_looking" => array(
146 "input" => "multitext",
147 "maxlength" => 40,
148 "size" => 40,
149 "method" => "getLookingForHelp",
150 "course_export_hide" => true,
151 "group_export_hide" => true,
152 "lists_hide" => true,
153 "group" => "interests"),
154 "institution" => array(
155 "input" => "text",
156 "maxlength" => 80,
157 "size" => 40,
158 "method" => "getInstitution",
159 "group" => "contact_data"),
160 "department" => array(
161 "input" => "text",
162 "maxlength" => 80,
163 "size" => 40,
164 "method" => "getDepartment",
165 "group" => "contact_data"),
166 "street" => array(
167 "input" => "text",
168 "maxlength" => 40,
169 "size" => 40,
170 "method" => "getStreet",
171 "group" => "contact_data"),
172 "zipcode" => array(
173 "input" => "text",
174 "maxlength" => 10,
175 "size" => 10,
176 "method" => "getZipcode",
177 "group" => "contact_data"),
178 "city" => array(
179 "input" => "text",
180 "maxlength" => 40,
181 "size" => 40,
182 "method" => "getCity",
183 "group" => "contact_data"),
184 "country" => array(
185 "input" => "text",
186 "maxlength" => 40,
187 "size" => 40,
188 "method" => "getCountry",
189 "group" => "contact_data"),
190 "sel_country" => array(
191 "input" => "sel_country",
192 "method" => "getSelectedCountry",
193 "group" => "contact_data"),
194 "phone_office" => array(
195 "input" => "text",
196 "maxlength" => 40,
197 "size" => 40,
198 "method" => "getPhoneOffice",
199 "group" => "contact_data"),
200 "phone_home" => array(
201 "input" => "text",
202 "maxlength" => 40,
203 "size" => 40,
204 "method" => "getPhoneHome",
205 "group" => "contact_data"),
206 "phone_mobile" => array(
207 "input" => "text",
208 "maxlength" => 40,
209 "size" => 40,
210 "method" => "getPhoneMobile",
211 "group" => "contact_data"),
212 "fax" => array(
213 "input" => "text",
214 "maxlength" => 40,
215 "size" => 40,
216 "method" => "getFax",
217 "group" => "contact_data"),
218 "email" => array(
219 "input" => "email",
220 "maxlength" => 40,
221 "size" => 40,
222 "method" => "getEmail",
223 "group" => "contact_data"),
224 "hobby" => array(
225 "input" => "textarea",
226 "rows" => 3,
227 "cols" => 45,
228 "method" => "getHobby",
229 "lists_hide" => true,
230 "group" => "contact_data"),
231 "referral_comment" => array(
232 "input" => "textarea",
233 "rows" => 3,
234 "cols" => 45,
235 "method" => "getComment",
236 "course_export_hide" => true,
237 "group_export_hide" => true,
238 "lists_hide" => true,
239 "group" => "contact_data"),
240 "instant_messengers" => array(
241 "input" => "messenger",
242 "types" => array("icq","yahoo","msn","aim","skype","jabber","voip"),
243 "maxlength" => 40,
244 "size" => 40,
245 "course_export_hide" => true,
246 "group_export_hide" => true,
247 "lists_hide" => true,
248 "group" => "instant_messengers"),
249 "matriculation" => array(
250 "input" => "text",
251 "maxlength" => 40,
252 "size" => 40,
253 "method" => "getMatriculation",
254 "group" => "other"),
255 "delicious" => array(
256 "input" => "text",
257 "maxlength" => 40,
258 "size" => 40,
259 "method" => "getDelicious",
260 "group" => "other"),
261 "language" => array(
262 "input" => "language",
263 "method" => "getLanguage",
264 "required_hide" => true,
265 "visib_reg_hide" => true,
266 "course_export_hide" => true,
267 "group_export_hide" => true,
268 "group" => "settings"),
269 "skin_style" => array(
270 "input" => "skinstyle",
271 "required_hide" => true,
272 "visib_reg_hide" => true,
273 "course_export_hide" => true,
274 "group_export_hide" => true,
275 "group" => "settings"),
276 "hits_per_page" => array(
277 "input" => "hitsperpage",
278 "default" => 10,
279 "options" => array(
280 10 => 10, 15 => 15, 20 => 20, 30 => 30, 40 => 40,
281 50 => 50, 100 => 100, 9999 => 9999),
282 "required_hide" => true,
283 "visib_reg_hide" => true,
284 "course_export_hide" => true,
285 "group_export_hide" => true,
286 "group" => "settings"),
287 "show_users_online" => array(
288 "input" => "selection",
289 "default" => "y",
290 "options" => array(
291 "y" => "users_online_show_short_y",
292 "associated" => "users_online_show_short_associated",
293 "n" => "users_online_show_short_n"),
294 "required_hide" => true,
295 "visib_reg_hide" => true,
296 "course_export_hide" => true,
297 "group_export_hide" => true,
298 "group" => "settings"),
299 "hide_own_online_status" => array(
300 "input" => "selection",
301 "required_hide" => true,
302 "visib_reg_hide" => true,
303 "course_export_hide" => true,
304 "group_export_hide" => true,
305 "group" => "settings"),
306 "preferences" => array(
307 "visible_fix_value" => 1,
308 "changeable_fix_value" => 1,
309 "required_hide" => true,
310 "visib_reg_hide" => true,
311 "course_export_hide" => true,
312 "group_export_hide" => true,
313 "group" => "preferences"),
314 "mail_incoming_mail" => array(
315 "input" => "selection",
316 "default" => "y",
317 "options" => array(
318 IL_MAIL_LOCAL => "mail_incoming_local",
319 IL_MAIL_EMAIL => "mail_incoming_smtp",
320 IL_MAIL_BOTH => "mail_incoming_both"),
321 "required_hide" => true,
322 "visib_reg_hide" => true,
323 "course_export_hide" => true,
324 "group_export_hide" => true,
325 "export_hide" => true,
326 "search_hide" => true,
327 "group" => "settings")
328
329 );
330
334 function __construct()
335 {
336 $this->skip_groups = array();
337 $this->skip_fields = array();
338 }
339
344 {
345 $fields = array();
346 foreach (self::$user_field as $f => $p)
347 {
348 // skip hidden groups
349 if (in_array($p["group"], $this->skip_groups) ||
350 in_array($f, $this->skip_fields))
351 {
352 continue;
353 }
354 $fields[$f] = $p;
355 }
356 return $fields;
357 }
358
364 {
365 global $ilSetting;
366
367 $settings = $ilSetting->getAll();
368
369 $fields = array();
370 foreach($this->getStandardFields() as $field => $info)
371 {
372 if($ilSetting->get('usr_settings_visib_lua_'.$field,1))
373 {
374 $fields[$field] = $info;
375 }
376 elseif($info['visib_lua_fix_value'])
377 {
378 $fields[$field] = $info;
379 }
380 }
381 return $fields;
382 }
383
384
388 function skipGroup($a_group)
389 {
390 $this->skip_groups[] = $a_group;
391 }
392
396 function skipField($a_field)
397 {
398 $this->skip_fields[] = $a_field;
399 }
400
404 function addStandardFieldsToForm($a_form, $a_user = NULL, array $custom_fields = NULL)
405 {
406 global $ilSetting, $lng, $rbacreview, $ilias;
407
408 // custom registration settings
409 if(self::$mode == self::MODE_REGISTRATION)
410 {
411 include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
412 $registration_settings = new ilRegistrationSettings();
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 // different position for role
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
425 $fields = $this->getStandardFields();
426 $current_group = "";
427 $custom_fields_done = false;
428 foreach ($fields as $f => $p)
429 {
430 // next group? -> diplay subheader
431 if (($p["group"] != $current_group) &&
433 {
434 if (is_array($custom_fields) && !$custom_fields_done)
435 {
436 // should be appended to "other" or at least before "settings"
437 if($current_group == "other" || $p["group"] == "settings")
438 {
439 // add "other" subheader
440 if($current_group != "other")
441 {
442 $sh = new ilFormSectionHeaderGUI();
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
454 $sh = new ilFormSectionHeaderGUI();
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":
473 if ((int)$ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION)
474 {
475 $val = new ilTextInputGUI($lng->txt('username'),'username');
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 // user account name
487 $val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un');
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 {
499 $ti = new ilTextInputGUI($lng->txt($lv), "usr_".$f);
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");
519 $ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_".$f);
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 {
536 $bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_".$f);
537 include_once "./Services/Calendar/classes/class.ilDateTime.php";
538 $date = null;
539 if ($a_user && strlen($a_user->$m()))
540 {
541 $date = new ilDateTime($a_user->$m(), IL_CAL_DATE);
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 {
558 $rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_".$f);
559 if($a_user)
560 {
561 $rg->setValue($a_user->$m());
562 }
563 foreach ($p["values"] as $k => $v)
564 {
565 $op = new ilRadioOption($lng->txt($v), $k);
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":
578 if (ilUserProfile::userSettingVisible("upload") && $a_user)
579 {
580 $ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
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 {
590 $im = ilObjUser::_getPersonalPicturePath($a_user->getId(), "small", true,
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 }
618 $dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr");
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");
628 $options = array();
629 foreach (ilObjRole::_lookupRegisterAllowed() as $role)
630 {
631 $options[$role["id"]] = $role["title"];
632 }
633 // registration form validation will take care of missing field / value
634 if($options)
635 {
636 if(sizeof($options) > 1)
637 {
638 $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_".$f);
639 $ta->setOptions($options);
640 $ta->setRequired($ilSetting->get("require_".$f));
641 if(!$ta->getRequired())
642 {
643 $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
644 }
645 }
646 // no need for select if only 1 option
647 else
648 {
649 $ta = new ilHiddenInputGUI("usr_".$f);
650 $ta->setValue(array_shift(array_keys($options)));
651 }
652 $a_form->addItem($ta);
653 }
654 }
655 }
656 break;
657
658 case "email":
660 {
661 $em = new ilEMailInputGUI($lng->txt($lv), "usr_".$f);
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 {
682 $ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_".$f);
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":
699 if (ilUserProfile::userSettingVisible("instant_messengers"))
700 {
701 $im_arr = $p["types"];
702 foreach ($im_arr as $im_name)
703 {
704 $im = new ilTextInputGUI($lng->txt("im_".$im_name), "usr_im_".$im_name);
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 {
726 $ta = new ilPasswordInputGUI($lng->txt($lv), "usr_".$f);
727 $ta->setRequired(true);
728 // $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
729 }
730 else
731 {
732 $ta = new ilNonEditableValueGUI($lng->txt($lv));
733 $ta->setValue($lng->txt("reg_passwd_via_mail"));
734 }
735 $a_form->addItem($ta);
736 }
737 break;
738
739 case "language":
741 {
742 $ta = new ilSelectInputGUI($lng->txt($lv), "usr_".$f);
743 if($a_user)
744 {
745 $ta->setValue($a_user->$m());
746 }
747 $options = array();
748 $lng->loadLanguageModule("meta");
749 foreach ($lng->getInstalledLanguages() as $lang_key)
750 {
751 $options[$lang_key] = $lng->txt("meta_l_".$lang_key);
752 }
753 asort($options); // #9728
754 $ta->setOptions($options);
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 {
767 $ti = new ilTextInputGUI($lng->txt($lv), "usr_".$f);
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 // add field to ajax call
783 $ti->setDataSource($this->ajax_href."&f=".$f);
784 }
785 $a_form->addItem($ti);
786 }
787 break;
788 }
789 }
790
791 // append custom fields as "other"
792 if(is_array($custom_fields) && !$custom_fields_done)
793 {
794 // add "other" subheader
795 if($current_group != "other")
796 {
797 $sh = new ilFormSectionHeaderGUI();
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 }
807
808 public function setAjaxCallback($a_href)
809 {
810 $this->ajax_href = $a_href;
811 }
812
816 static function userSettingVisible($a_setting)
817 {
818 global $ilSetting;
819
820 if(self::$mode == self::MODE_DESKTOP)
821 {
822 return ($ilSetting->get("usr_settings_hide_".$a_setting) != 1);
823 }
824 else
825 {
826 if(isset(self::$user_field[$a_setting]["visib_reg_hide"]) && self::$user_field[$a_setting]["visib_reg_hide"] === true)
827 {
828 return true;
829 }
830 return ($ilSetting->get("usr_settings_visib_reg_".$a_setting, "1") || $ilSetting->get("require_".$a_setting, "0"));
831 }
832 }
833
834 static function setMode($mode)
835 {
836 global $lng;
837
838 if(in_array($mode, array(self::MODE_DESKTOP, self::MODE_REGISTRATION)))
839 {
840 self::$mode = $mode;
841 return true;
842 }
843 return false;
844 }
845
854 static function isProfileIncomplete($a_user, $a_include_udf = true, $a_personal_data_only = true)
855 {
856 global $ilSetting;
857
858 // standard fields
859 foreach(self::$user_field as $field => $definition)
860 {
861 // only if visible in personal data
862 if($a_personal_data_only && $ilSetting->get("usr_settings_hide_".$field))
863 {
864 continue;
865 }
866
867 if($ilSetting->get("require_".$field) && $definition["method"])
868 {
869 $value = $a_user->{$definition["method"]}();
870 if($value == "")
871 {
872 return true;
873 }
874 }
875 }
876
877 // custom fields
878 if($a_include_udf)
879 {
880 $user_defined_data = $a_user->getUserDefinedData();
881
882 include_once './Services/User/classes/class.ilUserDefinedFields.php';
883 $user_defined_fields = ilUserDefinedFields::_getInstance();
884 foreach($user_defined_fields->getRequiredDefinitions() as $field => $definition)
885 {
886 // only if visible in personal data
887 if($a_personal_data_only && !$definition["visible"])
888 {
889 continue;
890 }
891
892 if(!$user_defined_data["f_".$field])
893 {
894 return true;
895 }
896 }
897 }
898
899 return false;
900 }
901
912 protected static function isEditableByUser($setting)
913 {
919 global $ilSetting;
920
921 // Not visible in personal data or not changeable
922 if( $ilSetting->get('usr_settings_hide_'.$setting) == 1 ||
923 $ilSetting->get('usr_settings_disable_'.$setting) == 1 )
924 {
925 // User has no chance to edit this field
926 return false;
927 }
928
929 return true;
930 }
931
941 public static function getIgnorableRequiredSettings()
942 {
948 global $ilSetting;
949
950 $ignorableSettings = array();
951
952 foreach(self::$user_field as $field => $definition)
953 {
954 // !!!username and password must not be ignored!!!
955 if( 'username' == $field ||
956 'password' == $field )
957 {
958 continue;
959 }
960
961 // Field is not required -> continue
962 if( !$ilSetting->get('require_'.$field) )
963 {
964 continue;
965 }
966
967 if( self::isEditableByUser($field) )
968 {
969 $ignorableSettings[] = $field;
970 }
971 }
972
973 return $ignorableSettings;
974 }
975}
976?>
const IL_CAL_DATE
const IL_MAIL_BOTH
const IL_MAIL_LOCAL
const IL_MAIL_EMAIL
This class represents a text property in a property form.
This class represents a selection list property in a property form.
@classDescription Date and time handling
This class represents a email property in a property form.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
This class represents an image file property in a property form.
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 a password property in a property form.
This class represents a property in a property form.
This class represents an option in a radio group.
Class ilObjAuthSettingsGUI.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static _getInstance()
Get instance.
Class ilUserProfile.
__construct()
Constructor.
addStandardFieldsToForm($a_form, $a_user=NULL, array $custom_fields=NULL)
Add standard fields to form.
getStandardFields()
Get standard user fields array.
getLocalUserAdministrationFields()
Get visible fields in local user administration.
skipField($a_field)
Skip a field.
static setMode($mode)
skipGroup($a_group)
Skip a group.
static isEditableByUser($setting)
Returns whether a profile setting is editable by an user in the profile gui.
static userSettingVisible($a_setting)
Checks whether user setting is visible.
static getIgnorableRequiredSettings()
Returns an array of all ignorable profiel fields.
static isProfileIncomplete($a_user, $a_include_udf=true, $a_personal_data_only=true)
Check if all required personal data fields are set.
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
if(!is_array($argv)) $options