ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
5 include_once 'Services/Mail/classes/class.ilMailOptions.php';
6 
16 {
17  const MODE_DESKTOP = 1;
18  const MODE_REGISTRATION = 2;
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  "org_units" => array(
155  "input" => "noneditable",
156  "lang_var" => "objs_orgu",
157  "required_hide" => true,
158  "visib_reg_hide" => true,
159  "course_export_hide" => false,
160  "group_export_hide" => false,
161  "export_hide" => true,
162  "changeable_hide" => true,
163  "changeable_fix_value" => 0,
164  "changeable_lua_hide" => true,
165  "changeable_lua_fix_value" => 0,
166  "method" => "getOrgUnitsRepresentation",
167  "group" => "contact_data"),
168  "institution" => array(
169  "input" => "text",
170  "maxlength" => 80,
171  "size" => 40,
172  "method" => "getInstitution",
173  "group" => "contact_data"),
174  "department" => array(
175  "input" => "text",
176  "maxlength" => 80,
177  "size" => 40,
178  "method" => "getDepartment",
179  "group" => "contact_data"),
180  "street" => array(
181  "input" => "text",
182  "maxlength" => 40,
183  "size" => 40,
184  "method" => "getStreet",
185  "group" => "contact_data"),
186  "zipcode" => array(
187  "input" => "text",
188  "maxlength" => 10,
189  "size" => 10,
190  "method" => "getZipcode",
191  "group" => "contact_data"),
192  "city" => array(
193  "input" => "text",
194  "maxlength" => 40,
195  "size" => 40,
196  "method" => "getCity",
197  "group" => "contact_data"),
198  "country" => array(
199  "input" => "text",
200  "maxlength" => 40,
201  "size" => 40,
202  "method" => "getCountry",
203  "group" => "contact_data"),
204  "sel_country" => array(
205  "input" => "sel_country",
206  "method" => "getSelectedCountry",
207  "group" => "contact_data"),
208  "phone_office" => array(
209  "input" => "text",
210  "maxlength" => 40,
211  "size" => 40,
212  "method" => "getPhoneOffice",
213  "group" => "contact_data"),
214  "phone_home" => array(
215  "input" => "text",
216  "maxlength" => 40,
217  "size" => 40,
218  "method" => "getPhoneHome",
219  "group" => "contact_data"),
220  "phone_mobile" => array(
221  "input" => "text",
222  "maxlength" => 40,
223  "size" => 40,
224  "method" => "getPhoneMobile",
225  "group" => "contact_data"),
226  "fax" => array(
227  "input" => "text",
228  "maxlength" => 40,
229  "size" => 40,
230  "method" => "getFax",
231  "group" => "contact_data"),
232  "email" => array(
233  "input" => "email",
234  "maxlength" => 40,
235  "size" => 40,
236  "method" => "getEmail",
237  "group" => "contact_data"),
238  "hobby" => array(
239  "input" => "textarea",
240  "rows" => 3,
241  "cols" => 45,
242  "method" => "getHobby",
243  "lists_hide" => true,
244  "group" => "contact_data"),
245  "referral_comment" => array(
246  "input" => "textarea",
247  "rows" => 3,
248  "cols" => 45,
249  "method" => "getComment",
250  "course_export_hide" => true,
251  "group_export_hide" => true,
252  "lists_hide" => true,
253  "group" => "contact_data"),
254  "matriculation" => array(
255  "input" => "text",
256  "maxlength" => 40,
257  "size" => 40,
258  "method" => "getMatriculation",
259  "group" => "other"),
260  "language" => array(
261  "input" => "language",
262  "method" => "getLanguage",
263  "required_hide" => true,
264  "visib_reg_hide" => true,
265  "course_export_hide" => true,
266  "group_export_hide" => true,
267  "group" => "settings"),
268  "skin_style" => array(
269  "input" => "skinstyle",
270  "required_hide" => true,
271  "visib_reg_hide" => true,
272  "course_export_hide" => true,
273  "group_export_hide" => true,
274  "group" => "settings"),
275  "hits_per_page" => array(
276  "input" => "hitsperpage",
277  "default" => 10,
278  "options" => array(
279  10 => 10, 15 => 15, 20 => 20, 30 => 30, 40 => 40,
280  50 => 50, 100 => 100, 9999 => 9999),
281  "required_hide" => true,
282  "visib_reg_hide" => true,
283  "course_export_hide" => true,
284  "group_export_hide" => true,
285  "group" => "settings"),
286  /*"show_users_online" => array(
287  "input" => "selection",
288  "default" => "y",
289  "options" => array(
290  "y" => "users_online_show_short_y",
291  "associated" => "users_online_show_short_associated",
292  "n" => "users_online_show_short_n"),
293  "required_hide" => true,
294  "visib_reg_hide" => true,
295  "course_export_hide" => true,
296  "group_export_hide" => true,
297  "group" => "settings"),*/
298  "hide_own_online_status" => array(
299  "input" => "selection",
300  "lang_var" => "awrn_hide_from_awareness",
301  "required_hide" => true,
302  "visib_reg_hide" => true,
303  "course_export_hide" => true,
304  "group_export_hide" => true,
305  "group" => "settings"),
306  "bs_allow_to_contact_me" => array(
307  "input" => "selection",
308  "lang_var" => "buddy_allow_to_contact_me",
309  "required_hide" => true,
310  "visib_reg_hide" => true,
311  "course_export_hide" => true,
312  "group_export_hide" => true,
313  "group" => "settings",
314  "default" => "y",
315  "options" => array(
316  "n" => "buddy_allow_to_contact_me_no",
317  "y" => "buddy_allow_to_contact_me_yes"
318  )
319  ),
320  "chat_osc_accept_msg" => array(
321  "input" => "selection",
322  "lang_var" => "chat_osc_accept_msg",
323  "required_hide" => true,
324  "visib_reg_hide" => true,
325  "course_export_hide" => true,
326  "group_export_hide" => true,
327  "group" => "settings",
328  "default" => "y",
329  "options" => array(
330  "n" => "chat_osc_accepts_messages_no",
331  "y" => "chat_osc_accepts_messages_yes"
332  )
333  ),
334  "preferences" => array(
335  "visible_fix_value" => 1,
336  "changeable_fix_value" => 1,
337  "required_hide" => true,
338  "visib_reg_hide" => true,
339  "course_export_hide" => true,
340  "group_export_hide" => true,
341  "group" => "preferences"),
342  "mail_incoming_mail" => array(
343  "input" => "selection",
344  "default" => "y",
345  "options" => array(
346  IL_MAIL_LOCAL => "mail_incoming_local",
347  IL_MAIL_EMAIL => "mail_incoming_smtp",
348  IL_MAIL_BOTH => "mail_incoming_both"),
349  "required_hide" => true,
350  "visib_reg_hide" => true,
351  "course_export_hide" => true,
352  "group_export_hide" => true,
353  "export_hide" => true,
354  "search_hide" => true,
355  "group" => "settings")
356 
357  );
358 
362  function __construct()
363  {
364  global $lng;
365 
366  $this->skip_groups = array();
367  $this->skip_fields = array();
368 
369  // for hide me from awareness tool text
370  // not nicest workaround, but better than using common block
371  $lng->loadLanguageModule("awrn");
372  $lng->loadLanguageModule("buddysystem");
373  }
374 
378  function getStandardFields()
379  {
380  $fields = array();
381  foreach (self::$user_field as $f => $p)
382  {
383  // skip hidden groups
384  if (in_array($p["group"], $this->skip_groups) ||
385  in_array($f, $this->skip_fields))
386  {
387  continue;
388  }
389  $fields[$f] = $p;
390  }
391  return $fields;
392  }
393 
399  {
400  global $ilSetting;
401 
402  $settings = $ilSetting->getAll();
403 
404  $fields = array();
405  foreach($this->getStandardFields() as $field => $info)
406  {
407  if($ilSetting->get('usr_settings_visib_lua_'.$field,1))
408  {
409  $fields[$field] = $info;
410  }
411  elseif($info['visib_lua_fix_value'])
412  {
413  $fields[$field] = $info;
414  }
415  }
416  return $fields;
417  }
418 
419 
423  function skipGroup($a_group)
424  {
425  $this->skip_groups[] = $a_group;
426  }
427 
431  function skipField($a_field)
432  {
433  $this->skip_fields[] = $a_field;
434  }
435 
439  function addStandardFieldsToForm($a_form, $a_user = NULL, array $custom_fields = NULL)
440  {
441  global $ilSetting, $lng, $rbacreview, $ilias;
442 
443  // custom registration settings
444  if(self::$mode == self::MODE_REGISTRATION)
445  {
446  include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
447  $registration_settings = new ilRegistrationSettings();
448 
449  self::$user_field["username"]["group"] = "login_data";
450  self::$user_field["password"]["group"] = "login_data";
451  self::$user_field["language"]["default"] = $lng->lang_key;
452 
453  // different position for role
454  $roles = self::$user_field["roles"];
455  unset(self::$user_field["roles"]);
456  self::$user_field["roles"] = $roles;
457  self::$user_field["roles"]["group"] = "settings";
458  }
459 
460  $fields = $this->getStandardFields();
461  $current_group = "";
462  $custom_fields_done = false;
463  foreach ($fields as $f => $p)
464  {
465  // next group? -> diplay subheader
466  if (($p["group"] != $current_group) &&
468  {
469  if (is_array($custom_fields) && !$custom_fields_done)
470  {
471  // should be appended to "other" or at least before "settings"
472  if($current_group == "other" || $p["group"] == "settings")
473  {
474  // add "other" subheader
475  if($current_group != "other")
476  {
477  $sh = new ilFormSectionHeaderGUI();
478  $sh->setTitle($lng->txt("other"));
479  $a_form->addItem($sh);
480  }
481  foreach($custom_fields as $custom_field)
482  {
483  $a_form->addItem($custom_field);
484  }
485  $custom_fields_done = true;
486  }
487  }
488 
489  $sh = new ilFormSectionHeaderGUI();
490  $sh->setTitle($lng->txt($p["group"]));
491  $a_form->addItem($sh);
492  $current_group = $p["group"];
493  }
494 
495  $m = "";
496  if (isset($p["method"]))
497  {
498  $m = $p["method"];
499  }
500 
501  $lv = (isset($p["lang_var"]) && $p["lang_var"] != "")
502  ? $p["lang_var"]
503  : $f;
504 
505  switch ($p["input"])
506  {
507  case "login":
508  if ((int)$ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION)
509  {
510  $val = new ilTextInputGUI($lng->txt('username'),'username');
511  if($a_user)
512  {
513  $val->setValue($a_user->getLogin());
514  }
515  $val->setMaxLength($p['maxlength']);
516  $val->setSize(40);
517  $val->setRequired(true);
518  }
519  else
520  {
521  // user account name
522  $val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un');
523  if($a_user)
524  {
525  $val->setValue($a_user->getLogin());
526  }
527  }
528  $a_form->addItem($val);
529  break;
530 
531  case "text":
533  {
534  $ti = new ilTextInputGUI($lng->txt($lv), "usr_".$f);
535  if($a_user)
536  {
537  $ti->setValue($a_user->$m());
538  }
539  $ti->setMaxLength($p["maxlength"]);
540  $ti->setSize($p["size"]);
541  $ti->setRequired($ilSetting->get("require_".$f));
542  if(!$ti->getRequired() || $ti->getValue())
543  {
544  $ti->setDisabled($ilSetting->get("usr_settings_disable_".$f));
545  }
546  $a_form->addItem($ti);
547  }
548  break;
549 
550  case "sel_country":
552  {
553  include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
554  $ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_".$f);
555  if($a_user)
556  {
557  $ci->setValue($a_user->$m());
558  }
559  $ci->setRequired($ilSetting->get("require_".$f));
560  if(!$ci->getRequired() || $ci->getValue())
561  {
562  $ci->setDisabled($ilSetting->get("usr_settings_disable_".$f));
563  }
564  $a_form->addItem($ci);
565  }
566  break;
567 
568  case "birthday":
570  {
571  $bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_".$f);
572  include_once "./Services/Calendar/classes/class.ilDateTime.php";
573  $date = null;
574  if ($a_user && strlen($a_user->$m()))
575  {
576  $date = new ilDateTime($a_user->$m(), IL_CAL_DATE);
577  $bi->setDate($date);
578  }
579  $bi->setRequired($ilSetting->get("require_".$f));
580  if(!$bi->getRequired() || $date)
581  {
582  $bi->setDisabled($ilSetting->get("usr_settings_disable_".$f));
583  }
584  $a_form->addItem($bi);
585  }
586  break;
587 
588  case "radio":
590  {
591  $rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_".$f);
592  if($a_user)
593  {
594  $rg->setValue($a_user->$m());
595  }
596  foreach ($p["values"] as $k => $v)
597  {
598  $op = new ilRadioOption($lng->txt($v), $k);
599  $rg->addOption($op);
600  }
601  $rg->setRequired($ilSetting->get("require_".$f));
602  if(!$rg->getRequired() || $rg->getValue())
603  {
604  $rg->setDisabled($ilSetting->get("usr_settings_disable_".$f));
605  }
606  $a_form->addItem($rg);
607  }
608  break;
609 
610  case "picture":
611  if (ilUserProfile::userSettingVisible("upload") && $a_user)
612  {
613  $ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
614  $ii->setDisabled($ilSetting->get("usr_settings_disable_upload"));
615 
616  $upload = $a_form->getFileUpload("userfile");
617  if($upload["name"])
618  {
619  $ii->setPending($upload["name"]);
620  }
621  else
622  {
623  $im = ilObjUser::_getPersonalPicturePath($a_user->getId(), "small", true,
624  true);
625  if ($im != "")
626  {
627  $ii->setImage($im);
628  $ii->setAlt($lng->txt("personal_picture"));
629  }
630  }
631 
632  $a_form->addItem($ii);
633  }
634  break;
635 
636  case "roles":
637  if(self::$mode == self::MODE_DESKTOP)
638  {
640  {
641  $global_roles = $rbacreview->getGlobalRoles();
642  foreach($global_roles as $role_id)
643  {
644  if (in_array($role_id,$rbacreview->assignedRoles($a_user->getId())))
645  {
646  $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
647  $role_names .= $roleObj->getTitle().", ";
648  unset($roleObj);
649  }
650  }
651  $dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr");
652  $dr->setValue(substr($role_names,0,-2));
653  $a_form->addItem($dr);
654  }
655  }
656  else if(self::$mode == self::MODE_REGISTRATION)
657  {
658  if($registration_settings->roleSelectionEnabled())
659  {
660  include_once("./Services/AccessControl/classes/class.ilObjRole.php");
661  $options = array();
662  foreach (ilObjRole::_lookupRegisterAllowed() as $role)
663  {
664  $options[$role["id"]] = $role["title"];
665  }
666  // registration form validation will take care of missing field / value
667  if($options)
668  {
669  if(sizeof($options) > 1)
670  {
671  $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_".$f);
672  $ta->setOptions($options);
673  $ta->setRequired($ilSetting->get("require_".$f));
674  if(!$ta->getRequired())
675  {
676  $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
677  }
678  }
679  // no need for select if only 1 option
680  else
681  {
682  $ta = new ilHiddenInputGUI("usr_".$f);
683  $ta->setValue(array_shift(array_keys($options)));
684  }
685  $a_form->addItem($ta);
686  }
687  }
688  }
689  break;
690 
691  case "email":
693  {
694  $em = new ilEMailInputGUI($lng->txt($lv), "usr_".$f);
695  if($a_user)
696  {
697  $em->setValue($a_user->$m());
698  }
699  $em->setRequired($ilSetting->get("require_".$f));
700  if(!$em->getRequired() || $em->getValue())
701  {
702  $em->setDisabled($ilSetting->get("usr_settings_disable_".$f));
703  }
704  if(self::MODE_REGISTRATION == self::$mode)
705  {
706  $em->setRetype(true);
707  }
708  $a_form->addItem($em);
709  }
710  break;
711 
712  case "textarea":
714  {
715  $ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_".$f);
716  if($a_user)
717  {
718  $ta->setValue($a_user->$m());
719  }
720  $ta->setRows($p["rows"]);
721  $ta->setCols($p["cols"]);
722  $ta->setRequired($ilSetting->get("require_".$f));
723  if(!$ta->getRequired() || $ta->getValue())
724  {
725  $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
726  }
727  $a_form->addItem($ta);
728  }
729  break;
730 
731  case "password":
732  if (self::$mode == self::MODE_REGISTRATION)
733  {
734  if(!$registration_settings->passwordGenerationEnabled())
735  {
736  $ta = new ilPasswordInputGUI($lng->txt($lv), "usr_".$f);
737  $ta->setRequired(true);
738  $ta->setInfo(ilUtil::getPasswordRequirementsInfo());
739  // $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
740  }
741  else
742  {
743  $ta = new ilNonEditableValueGUI($lng->txt($lv));
744  $ta->setValue($lng->txt("reg_passwd_via_mail"));
745  }
746  $a_form->addItem($ta);
747  }
748  break;
749 
750  case "language":
752  {
753  $ta = new ilSelectInputGUI($lng->txt($lv), "usr_".$f);
754  if($a_user)
755  {
756  $ta->setValue($a_user->$m());
757  }
758  $options = array();
759  $lng->loadLanguageModule("meta");
760  foreach ($lng->getInstalledLanguages() as $lang_key)
761  {
762  $options[$lang_key] = $lng->txt("meta_l_".$lang_key);
763  }
764  asort($options); // #9728
765  $ta->setOptions($options);
766  $ta->setRequired($ilSetting->get("require_".$f));
767  if(!$ta->getRequired() || $ta->getValue())
768  {
769  $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
770  }
771  $a_form->addItem($ta);
772  }
773  break;
774 
775  case "multitext":
777  {
778  $ti = new ilTextInputGUI($lng->txt($lv), "usr_".$f);
779  $ti->setMulti(true);
780  if($a_user)
781  {
782  $ti->setValue($a_user->$m());
783  }
784  $ti->setMaxLength($p["maxlength"]);
785  $ti->setSize($p["size"]);
786  $ti->setRequired($ilSetting->get("require_".$f));
787  if(!$ti->getRequired() || $ti->getValue())
788  {
789  $ti->setDisabled($ilSetting->get("usr_settings_disable_".$f));
790  }
791  if($this->ajax_href)
792  {
793  // add field to ajax call
794  $ti->setDataSource($this->ajax_href."&f=".$f);
795  }
796  $a_form->addItem($ti);
797  }
798  break;
799  case "noneditable":
800  if (self::$mode == self::MODE_DESKTOP && ilUserProfile::userSettingVisible($f)) {
801  $ne = new ilNonEditableValueGUI($lng->txt($lv));
802  $ne->setValue($a_user->$m());
803  $a_form->addItem($ne);
804  }
805  break;
806  }
807  }
808 
809  // append custom fields as "other"
810  if(is_array($custom_fields) && !$custom_fields_done)
811  {
812  // add "other" subheader
813  if($current_group != "other")
814  {
815  $sh = new ilFormSectionHeaderGUI();
816  $sh->setTitle($lng->txt("other"));
817  $a_form->addItem($sh);
818  }
819  foreach($custom_fields as $custom_field)
820  {
821  $a_form->addItem($custom_field);
822  }
823  }
824  }
825 
826  public function setAjaxCallback($a_href)
827  {
828  $this->ajax_href = $a_href;
829  }
830 
834  static function userSettingVisible($a_setting)
835  {
836  global $ilSetting;
837 
838  if(self::$mode == self::MODE_DESKTOP)
839  {
840  return ($ilSetting->get("usr_settings_hide_".$a_setting) != 1);
841  }
842  else
843  {
844  if(isset(self::$user_field[$a_setting]["visib_reg_hide"]) && self::$user_field[$a_setting]["visib_reg_hide"] === true)
845  {
846  return true;
847  }
848  return ($ilSetting->get("usr_settings_visib_reg_".$a_setting, "1") || $ilSetting->get("require_".$a_setting, "0"));
849  }
850  }
851 
852  static function setMode($mode)
853  {
854  global $lng;
855 
856  if(in_array($mode, array(self::MODE_DESKTOP, self::MODE_REGISTRATION)))
857  {
858  self::$mode = $mode;
859  return true;
860  }
861  return false;
862  }
863 
872  static function isProfileIncomplete($a_user, $a_include_udf = true, $a_personal_data_only = true)
873  {
874  global $ilSetting;
875 
876  // standard fields
877  foreach(self::$user_field as $field => $definition)
878  {
879  // only if visible in personal data
880  if($a_personal_data_only && $ilSetting->get("usr_settings_hide_".$field))
881  {
882  continue;
883  }
884 
885  if($ilSetting->get("require_".$field) && $definition["method"])
886  {
887  $value = $a_user->{$definition["method"]}();
888  if($value == "")
889  {
890  return true;
891  }
892  }
893  }
894 
895  // custom fields
896  if($a_include_udf)
897  {
898  $user_defined_data = $a_user->getUserDefinedData();
899 
900  include_once './Services/User/classes/class.ilUserDefinedFields.php';
901  $user_defined_fields = ilUserDefinedFields::_getInstance();
902  foreach($user_defined_fields->getRequiredDefinitions() as $field => $definition)
903  {
904  // only if visible in personal data
905  if($a_personal_data_only && !$definition["visible"])
906  {
907  continue;
908  }
909 
910  if(!$user_defined_data["f_".$field])
911  {
912  ilLoggerFactory::getLogger('user')->info('Profile is incomplete due to missing required udf.');
913  return true;
914  }
915  }
916  }
917 
918  return false;
919  }
920 
931  protected static function isEditableByUser($setting)
932  {
938  global $ilSetting;
939 
940  // Not visible in personal data or not changeable
941  if( $ilSetting->get('usr_settings_hide_'.$setting) == 1 ||
942  $ilSetting->get('usr_settings_disable_'.$setting) == 1 )
943  {
944  // User has no chance to edit this field
945  return false;
946  }
947 
948  return true;
949  }
950 
960  public static function getIgnorableRequiredSettings()
961  {
967  global $ilSetting;
968 
969  $ignorableSettings = array();
970 
971  foreach(self::$user_field as $field => $definition)
972  {
973  // !!!username and password must not be ignored!!!
974  if( 'username' == $field ||
975  'password' == $field )
976  {
977  continue;
978  }
979 
980  // Field is not required -> continue
981  if( !$ilSetting->get('require_'.$field) )
982  {
983  continue;
984  }
985 
986  if( self::isEditableByUser($field) )
987  {
988  $ignorableSettings[] = $field;
989  }
990  }
991 
992  return $ignorableSettings;
993  }
994 }
995 ?>
static isProfileIncomplete($a_user, $a_include_udf=true, $a_personal_data_only=true)
Check if all required personal data fields are set.
setValue($a_value)
Set Value.
This class represents an option in a radio group.
const IL_MAIL_BOTH
const IL_MAIL_EMAIL
static _getInstance()
Get instance.
getLocalUserAdministrationFields()
Get visible fields in local user administration.
This class represents a selection list property in a property form.
static _lookupRegisterAllowed()
get all roles that are activated in user registration
This class represents a selection list property in a property form.
getStandardFields()
Get standard user fields array.
This class represents a section header in a property form.
__construct()
Constructor.
static userSettingVisible($a_setting)
Checks whether user setting is visible.
setValue($a_value)
Set Value.
Class ilUserProfile.
static getIgnorableRequiredSettings()
Returns an array of all ignorable profiel fields.
This class represents a email property in a property form.
const IL_MAIL_LOCAL
skipField($a_field)
Skip a field.
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
static isEditableByUser($setting)
Returns whether a profile setting is editable by an user in the profile gui.
This class represents a hidden form property in a property form.
$info
Definition: example_052.php:80
This class represents a property in a property form.
if(!is_array($argv)) $options
setValue($a_value)
Set Value.
This class represents a text property in a property form.
Date and time handling
This class represents a password property in a property form.
setOptions($a_options)
Set Options.
static setMode($mode)
Create styles array
The data for the language used.
Class ilObjAuthSettingsGUI.
This class represents an image file property in a property form.
const IL_CAL_DATE
addStandardFieldsToForm($a_form, $a_user=NULL, array $custom_fields=NULL)
Add standard fields to form.
This class represents a non editable value in a property form.
setMulti($a_multi, $a_sortable=false, $a_addremove=true)
Set Multi.
global $ilSetting
Definition: privfeed.php:17
setDate($a_date, $a_format)
set date
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
setDisabled($a_disabled)
This class represents a text property in a property form.
static getLogger($a_component_id)
Get component logger.
setValue($a_value)
Set Value.
setDisabled($a_disabled)
Set Disabled.
setRequired($a_required)
Set Required.
skipGroup($a_group)
Skip a group.