ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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" => 64,
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 "required_hide" => true, // #17302
249 "group" => "instant_messengers"),
250 "matriculation" => array(
251 "input" => "text",
252 "maxlength" => 40,
253 "size" => 40,
254 "method" => "getMatriculation",
255 "group" => "other"),
256 "delicious" => array(
257 "input" => "text",
258 "maxlength" => 40,
259 "size" => 40,
260 "method" => "getDelicious",
261 "group" => "other"),
262 "language" => array(
263 "input" => "language",
264 "method" => "getLanguage",
265 "required_hide" => true,
266 "visib_reg_hide" => true,
267 "course_export_hide" => true,
268 "group_export_hide" => true,
269 "group" => "settings"),
270 "skin_style" => array(
271 "input" => "skinstyle",
272 "required_hide" => true,
273 "visib_reg_hide" => true,
274 "course_export_hide" => true,
275 "group_export_hide" => true,
276 "group" => "settings"),
277 "hits_per_page" => array(
278 "input" => "hitsperpage",
279 "default" => 10,
280 "options" => array(
281 10 => 10, 15 => 15, 20 => 20, 30 => 30, 40 => 40,
282 50 => 50, 100 => 100, 9999 => 9999),
283 "required_hide" => true,
284 "visib_reg_hide" => true,
285 "course_export_hide" => true,
286 "group_export_hide" => true,
287 "group" => "settings"),
288 /*"show_users_online" => array(
289 "input" => "selection",
290 "default" => "y",
291 "options" => array(
292 "y" => "users_online_show_short_y",
293 "associated" => "users_online_show_short_associated",
294 "n" => "users_online_show_short_n"),
295 "required_hide" => true,
296 "visib_reg_hide" => true,
297 "course_export_hide" => true,
298 "group_export_hide" => true,
299 "group" => "settings"),*/
300 "hide_own_online_status" => array(
301 "input" => "selection",
302 "lang_var" => "awrn_hide_from_awareness",
303 "required_hide" => true,
304 "visib_reg_hide" => true,
305 "course_export_hide" => true,
306 "group_export_hide" => true,
307 "group" => "settings"),
308 "bs_allow_to_contact_me" => array(
309 "input" => "selection",
310 "lang_var" => "buddy_allow_to_contact_me",
311 "required_hide" => true,
312 "visib_reg_hide" => true,
313 "course_export_hide" => true,
314 "group_export_hide" => true,
315 "group" => "settings"),
316 "preferences" => array(
317 "visible_fix_value" => 1,
318 "changeable_fix_value" => 1,
319 "required_hide" => true,
320 "visib_reg_hide" => true,
321 "course_export_hide" => true,
322 "group_export_hide" => true,
323 "group" => "preferences"),
324 "mail_incoming_mail" => array(
325 "input" => "selection",
326 "default" => "y",
327 "options" => array(
328 IL_MAIL_LOCAL => "mail_incoming_local",
329 IL_MAIL_EMAIL => "mail_incoming_smtp",
330 IL_MAIL_BOTH => "mail_incoming_both"),
331 "required_hide" => true,
332 "visib_reg_hide" => true,
333 "course_export_hide" => true,
334 "group_export_hide" => true,
335 "export_hide" => true,
336 "search_hide" => true,
337 "group" => "settings")
338
339 );
340
344 function __construct()
345 {
346 global $lng;
347
348 $this->skip_groups = array();
349 $this->skip_fields = array();
350
351 // for hide me from awareness tool text
352 // not nicest workaround, but better than using common block
353 $lng->loadLanguageModule("awrn");
354 $lng->loadLanguageModule("buddysystem");
355 }
356
361 {
362 $fields = array();
363 foreach (self::$user_field as $f => $p)
364 {
365 // skip hidden groups
366 if (in_array($p["group"], $this->skip_groups) ||
367 in_array($f, $this->skip_fields))
368 {
369 continue;
370 }
371 $fields[$f] = $p;
372 }
373 return $fields;
374 }
375
381 {
382 global $ilSetting;
383
384 $settings = $ilSetting->getAll();
385
386 $fields = array();
387 foreach($this->getStandardFields() as $field => $info)
388 {
389 if($ilSetting->get('usr_settings_visib_lua_'.$field,1))
390 {
391 $fields[$field] = $info;
392 }
393 elseif($info['visib_lua_fix_value'])
394 {
395 $fields[$field] = $info;
396 }
397 }
398 return $fields;
399 }
400
401
405 function skipGroup($a_group)
406 {
407 $this->skip_groups[] = $a_group;
408 }
409
413 function skipField($a_field)
414 {
415 $this->skip_fields[] = $a_field;
416 }
417
421 function addStandardFieldsToForm($a_form, $a_user = NULL, array $custom_fields = NULL)
422 {
423 global $ilSetting, $lng, $rbacreview, $ilias;
424
425 // custom registration settings
426 if(self::$mode == self::MODE_REGISTRATION)
427 {
428 include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
429 $registration_settings = new ilRegistrationSettings();
430
431 self::$user_field["username"]["group"] = "login_data";
432 self::$user_field["password"]["group"] = "login_data";
433 self::$user_field["language"]["default"] = $lng->lang_key;
434
435 // different position for role
436 $roles = self::$user_field["roles"];
437 unset(self::$user_field["roles"]);
438 self::$user_field["roles"] = $roles;
439 self::$user_field["roles"]["group"] = "settings";
440 }
441
442 $fields = $this->getStandardFields();
443 $current_group = "";
444 $custom_fields_done = false;
445 foreach ($fields as $f => $p)
446 {
447 // next group? -> diplay subheader
448 if (($p["group"] != $current_group) &&
450 {
451 if (is_array($custom_fields) && !$custom_fields_done)
452 {
453 // should be appended to "other" or at least before "settings"
454 if($current_group == "other" || $p["group"] == "settings")
455 {
456 // add "other" subheader
457 if($current_group != "other")
458 {
459 $sh = new ilFormSectionHeaderGUI();
460 $sh->setTitle($lng->txt("other"));
461 $a_form->addItem($sh);
462 }
463 foreach($custom_fields as $custom_field)
464 {
465 $a_form->addItem($custom_field);
466 }
467 $custom_fields_done = true;
468 }
469 }
470
471 $sh = new ilFormSectionHeaderGUI();
472 $sh->setTitle($lng->txt($p["group"]));
473 $a_form->addItem($sh);
474 $current_group = $p["group"];
475 }
476
477 $m = "";
478 if (isset($p["method"]))
479 {
480 $m = $p["method"];
481 }
482
483 $lv = (isset($p["lang_var"]) && $p["lang_var"] != "")
484 ? $p["lang_var"]
485 : $f;
486
487 switch ($p["input"])
488 {
489 case "login":
490 if ((int)$ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION)
491 {
492 $val = new ilTextInputGUI($lng->txt('username'),'username');
493 if($a_user)
494 {
495 $val->setValue($a_user->getLogin());
496 }
497 $val->setMaxLength($p['maxlength']);
498 $val->setSize(40);
499 $val->setRequired(true);
500 }
501 else
502 {
503 // user account name
504 $val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un');
505 if($a_user)
506 {
507 $val->setValue($a_user->getLogin());
508 }
509 }
510 $a_form->addItem($val);
511 break;
512
513 case "text":
515 {
516 $ti = new ilTextInputGUI($lng->txt($lv), "usr_".$f);
517 if($a_user)
518 {
519 $ti->setValue($a_user->$m());
520 }
521 $ti->setMaxLength($p["maxlength"]);
522 $ti->setSize($p["size"]);
523 $ti->setRequired($ilSetting->get("require_".$f));
524 if(!$ti->getRequired() || $ti->getValue())
525 {
526 $ti->setDisabled($ilSetting->get("usr_settings_disable_".$f));
527 }
528 $a_form->addItem($ti);
529 }
530 break;
531
532 case "sel_country":
534 {
535 include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
536 $ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_".$f);
537 if($a_user)
538 {
539 $ci->setValue($a_user->$m());
540 }
541 $ci->setRequired($ilSetting->get("require_".$f));
542 if(!$ci->getRequired() || $ci->getValue())
543 {
544 $ci->setDisabled($ilSetting->get("usr_settings_disable_".$f));
545 }
546 $a_form->addItem($ci);
547 }
548 break;
549
550 case "birthday":
552 {
553 $bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_".$f);
554 include_once "./Services/Calendar/classes/class.ilDateTime.php";
555 $date = null;
556 if ($a_user && strlen($a_user->$m()))
557 {
558 $date = new ilDateTime($a_user->$m(), IL_CAL_DATE);
559 $bi->setDate($date);
560 }
561 $bi->setShowEmpty(true);
562 $bi->setStartYear(1900);
563 $bi->setRequired($ilSetting->get("require_".$f));
564 if(!$bi->getRequired() || $date)
565 {
566 $bi->setDisabled($ilSetting->get("usr_settings_disable_".$f));
567 }
568 $a_form->addItem($bi);
569 }
570 break;
571
572 case "radio":
574 {
575 $rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_".$f);
576 if($a_user)
577 {
578 $rg->setValue($a_user->$m());
579 }
580 foreach ($p["values"] as $k => $v)
581 {
582 $op = new ilRadioOption($lng->txt($v), $k);
583 $rg->addOption($op);
584 }
585 $rg->setRequired($ilSetting->get("require_".$f));
586 if(!$rg->getRequired() || $rg->getValue())
587 {
588 $rg->setDisabled($ilSetting->get("usr_settings_disable_".$f));
589 }
590 $a_form->addItem($rg);
591 }
592 break;
593
594 case "picture":
595 if (ilUserProfile::userSettingVisible("upload") && $a_user)
596 {
597 $ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
598 $ii->setDisabled($ilSetting->get("usr_settings_disable_upload"));
599
600 $upload = $a_form->getFileUpload("userfile");
601 if($upload["name"])
602 {
603 $ii->setPending($upload["name"]);
604 }
605 else
606 {
607 $im = ilObjUser::_getPersonalPicturePath($a_user->getId(), "small", true,
608 true);
609 if ($im != "")
610 {
611 $ii->setImage($im);
612 $ii->setAlt($lng->txt("personal_picture"));
613 }
614 }
615
616 $a_form->addItem($ii);
617 }
618 break;
619
620 case "roles":
621 if(self::$mode == self::MODE_DESKTOP)
622 {
624 {
625 $global_roles = $rbacreview->getGlobalRoles();
626 foreach($global_roles as $role_id)
627 {
628 if (in_array($role_id,$rbacreview->assignedRoles($a_user->getId())))
629 {
630 $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
631 $role_names .= $roleObj->getTitle().", ";
632 unset($roleObj);
633 }
634 }
635 $dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr");
636 $dr->setValue(substr($role_names,0,-2));
637 $a_form->addItem($dr);
638 }
639 }
640 else if(self::$mode == self::MODE_REGISTRATION)
641 {
642 if($registration_settings->roleSelectionEnabled())
643 {
644 include_once("./Services/AccessControl/classes/class.ilObjRole.php");
645 $options = array();
646 foreach (ilObjRole::_lookupRegisterAllowed() as $role)
647 {
648 $options[$role["id"]] = $role["title"];
649 }
650 // registration form validation will take care of missing field / value
651 if($options)
652 {
653 if(sizeof($options) > 1)
654 {
655 $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_".$f);
656 $ta->setOptions($options);
657 $ta->setRequired($ilSetting->get("require_".$f));
658 if(!$ta->getRequired())
659 {
660 $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
661 }
662 }
663 // no need for select if only 1 option
664 else
665 {
666 $ta = new ilHiddenInputGUI("usr_".$f);
667 $ta->setValue(array_shift(array_keys($options)));
668 }
669 $a_form->addItem($ta);
670 }
671 }
672 }
673 break;
674
675 case "email":
677 {
678 $em = new ilEMailInputGUI($lng->txt($lv), "usr_".$f);
679 if($a_user)
680 {
681 $em->setValue($a_user->$m());
682 }
683 $em->setRequired($ilSetting->get("require_".$f));
684 if(!$em->getRequired() || $em->getValue())
685 {
686 $em->setDisabled($ilSetting->get("usr_settings_disable_".$f));
687 }
688 if(self::MODE_REGISTRATION == self::$mode)
689 {
690 $em->setRetype(true);
691 }
692 $a_form->addItem($em);
693 }
694 break;
695
696 case "textarea":
698 {
699 $ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_".$f);
700 if($a_user)
701 {
702 $ta->setValue($a_user->$m());
703 }
704 $ta->setRows($p["rows"]);
705 $ta->setCols($p["cols"]);
706 $ta->setRequired($ilSetting->get("require_".$f));
707 if(!$ta->getRequired() || $ta->getValue())
708 {
709 $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
710 }
711 $a_form->addItem($ta);
712 }
713 break;
714
715 case "messenger":
716 if (ilUserProfile::userSettingVisible("instant_messengers"))
717 {
718 $im_arr = $p["types"];
719 foreach ($im_arr as $im_name)
720 {
721 $im = new ilTextInputGUI($lng->txt("im_".$im_name), "usr_im_".$im_name);
722 if($a_user)
723 {
724 $im->setValue($a_user->getInstantMessengerId($im_name));
725 }
726 $im->setMaxLength($p["maxlength"]);
727 $im->setSize($p["size"]);
728 // $im->setRequired($ilSetting->get("require_"."instant_messengers"));
729 if(!$im->getRequired() || $im->getValue())
730 {
731 $im->setDisabled($ilSetting->get("usr_settings_disable_"."instant_messengers"));
732 }
733 $a_form->addItem($im);
734 }
735 }
736 break;
737
738 case "password":
739 if (self::$mode == self::MODE_REGISTRATION)
740 {
741 if(!$registration_settings->passwordGenerationEnabled())
742 {
743 $ta = new ilPasswordInputGUI($lng->txt($lv), "usr_".$f);
744 $ta->setRequired(true);
745 // $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
746 }
747 else
748 {
749 $ta = new ilNonEditableValueGUI($lng->txt($lv));
750 $ta->setValue($lng->txt("reg_passwd_via_mail"));
751 }
752 $a_form->addItem($ta);
753 }
754 break;
755
756 case "language":
758 {
759 $ta = new ilSelectInputGUI($lng->txt($lv), "usr_".$f);
760 if($a_user)
761 {
762 $ta->setValue($a_user->$m());
763 }
764 $options = array();
765 $lng->loadLanguageModule("meta");
766 foreach ($lng->getInstalledLanguages() as $lang_key)
767 {
768 $options[$lang_key] = $lng->txt("meta_l_".$lang_key);
769 }
770 asort($options); // #9728
771 $ta->setOptions($options);
772 $ta->setRequired($ilSetting->get("require_".$f));
773 if(!$ta->getRequired() || $ta->getValue())
774 {
775 $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
776 }
777 $a_form->addItem($ta);
778 }
779 break;
780
781 case "multitext":
783 {
784 $ti = new ilTextInputGUI($lng->txt($lv), "usr_".$f);
785 $ti->setMulti(true);
786 if($a_user)
787 {
788 $ti->setValue($a_user->$m());
789 }
790 $ti->setMaxLength($p["maxlength"]);
791 $ti->setSize($p["size"]);
792 $ti->setRequired($ilSetting->get("require_".$f));
793 if(!$ti->getRequired() || $ti->getValue())
794 {
795 $ti->setDisabled($ilSetting->get("usr_settings_disable_".$f));
796 }
797 if($this->ajax_href)
798 {
799 // add field to ajax call
800 $ti->setDataSource($this->ajax_href."&f=".$f);
801 }
802 $a_form->addItem($ti);
803 }
804 break;
805 }
806 }
807
808 // append custom fields as "other"
809 if(is_array($custom_fields) && !$custom_fields_done)
810 {
811 // add "other" subheader
812 if($current_group != "other")
813 {
814 $sh = new ilFormSectionHeaderGUI();
815 $sh->setTitle($lng->txt("other"));
816 $a_form->addItem($sh);
817 }
818 foreach($custom_fields as $custom_field)
819 {
820 $a_form->addItem($custom_field);
821 }
822 }
823 }
824
825 public function setAjaxCallback($a_href)
826 {
827 $this->ajax_href = $a_href;
828 }
829
833 static function userSettingVisible($a_setting)
834 {
835 global $ilSetting;
836
837 if(self::$mode == self::MODE_DESKTOP)
838 {
839 return ($ilSetting->get("usr_settings_hide_".$a_setting) != 1);
840 }
841 else
842 {
843 if(isset(self::$user_field[$a_setting]["visib_reg_hide"]) && self::$user_field[$a_setting]["visib_reg_hide"] === true)
844 {
845 return true;
846 }
847 return ($ilSetting->get("usr_settings_visib_reg_".$a_setting, "1") || $ilSetting->get("require_".$a_setting, "0"));
848 }
849 }
850
851 static function setMode($mode)
852 {
853 global $lng;
854
855 if(in_array($mode, array(self::MODE_DESKTOP, self::MODE_REGISTRATION)))
856 {
857 self::$mode = $mode;
858 return true;
859 }
860 return false;
861 }
862
871 static function isProfileIncomplete($a_user, $a_include_udf = true, $a_personal_data_only = true)
872 {
873 global $ilSetting;
874
875 // standard fields
876 foreach(self::$user_field as $field => $definition)
877 {
878 // only if visible in personal data
879 if($a_personal_data_only && $ilSetting->get("usr_settings_hide_".$field))
880 {
881 continue;
882 }
883
884 if($ilSetting->get("require_".$field) && $definition["method"])
885 {
886 $value = $a_user->{$definition["method"]}();
887 if($value == "")
888 {
889 return true;
890 }
891 }
892 }
893
894 // custom fields
895 if($a_include_udf)
896 {
897 $user_defined_data = $a_user->getUserDefinedData();
898
899 include_once './Services/User/classes/class.ilUserDefinedFields.php';
900 $user_defined_fields = ilUserDefinedFields::_getInstance();
901 foreach($user_defined_fields->getRequiredDefinitions() as $field => $definition)
902 {
903 // only if visible in personal data
904 if($a_personal_data_only && !$definition["visible"])
905 {
906 continue;
907 }
908
909 if(!$user_defined_data["f_".$field])
910 {
911 return true;
912 }
913 }
914 }
915
916 return false;
917 }
918
929 protected static function isEditableByUser($setting)
930 {
936 global $ilSetting;
937
938 // Not visible in personal data or not changeable
939 if( $ilSetting->get('usr_settings_hide_'.$setting) == 1 ||
940 $ilSetting->get('usr_settings_disable_'.$setting) == 1 )
941 {
942 // User has no chance to edit this field
943 return false;
944 }
945
946 return true;
947 }
948
958 public static function getIgnorableRequiredSettings()
959 {
965 global $ilSetting;
966
967 $ignorableSettings = array();
968
969 foreach(self::$user_field as $field => $definition)
970 {
971 // !!!username and password must not be ignored!!!
972 if( 'username' == $field ||
973 'password' == $field )
974 {
975 continue;
976 }
977
978 // Field is not required -> continue
979 if( !$ilSetting->get('require_'.$field) )
980 {
981 continue;
982 }
983
984 if( self::isEditableByUser($field) )
985 {
986 $ignorableSettings[] = $field;
987 }
988 }
989
990 return $ignorableSettings;
991 }
992}
993?>
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.
$info
Definition: example_052.php:80
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
if(!is_array($argv)) $options