ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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" => 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  "group_export_hide" => true,
64  "lists_hide" => true,
65  "group" => "personal_data"),
66  "firstname" => array(
67  "input" => "text",
68  "maxlength" => 32,
69  "size" => 40,
70  "method" => "getFirstname",
71  "required_fix_value" => 1,
72  "visib_reg_fix_value" => 1,
73  'visib_lua_fix_value' => 1,
74  "course_export_fix_value" => 1,
75  "group_export_fix_value" => 1,
76  "group" => "personal_data"),
77  "lastname" => array(
78  "input" => "text",
79  "maxlength" => 32,
80  "size" => 40,
81  "method" => "getLastname",
82  "required_fix_value" => 1,
83  "visib_reg_fix_value" => 1,
84  'visib_lua_fix_value' => 1,
85  "course_export_fix_value" => 1,
86  "group_export_fix_value" => 1,
87  "group" => "personal_data"),
88  "title" => array(
89  "input" => "text",
90  "lang_var" => "person_title",
91  "maxlength" => 32,
92  "size" => 40,
93  "method" => "getUTitle",
94  "group" => "personal_data"),
95  "birthday" => array(
96  "input" => "birthday",
97  "lang_var" => "birthday",
98  "maxlength" => 32,
99  "size" => 40,
100  "method" => "getBirthday",
101  "group" => "personal_data"),
102  "gender" => array(
103  "input" => "radio",
104  "values" => array("f" => "gender_f", "m" => "gender_m"),
105  "method" => "getGender",
106  "group" => "personal_data"),
107  "upload" => array(
108  "input" => "picture",
109  "required_hide" => true,
110  "visib_reg_hide" => true,
111  "course_export_hide" => true,
112  "group_export_hide" => true,
113  "lists_hide" => true,
114  "lang_var" => "personal_picture",
115  "group" => "personal_data"),
116  "roles" => array(
117  "input" => "roles",
118  "changeable_hide" => true,
119  "required_hide" => true,
120  "visib_reg_hide" => true,
121  "export_hide" => true,
122  "course_export_hide" => true,
123  "lists_hide" => true,
124  "group" => "personal_data"),
125  "institution" => array(
126  "input" => "text",
127  "maxlength" => 80,
128  "size" => 40,
129  "method" => "getInstitution",
130  "group" => "contact_data"),
131  "department" => array(
132  "input" => "text",
133  "maxlength" => 80,
134  "size" => 40,
135  "method" => "getDepartment",
136  "group" => "contact_data"),
137  "street" => array(
138  "input" => "text",
139  "maxlength" => 40,
140  "size" => 40,
141  "method" => "getStreet",
142  "group" => "contact_data"),
143  "zipcode" => array(
144  "input" => "text",
145  "maxlength" => 10,
146  "size" => 10,
147  "method" => "getZipcode",
148  "group" => "contact_data"),
149  "city" => array(
150  "input" => "text",
151  "maxlength" => 40,
152  "size" => 40,
153  "method" => "getCity",
154  "group" => "contact_data"),
155  "country" => array(
156  "input" => "text",
157  "maxlength" => 40,
158  "size" => 40,
159  "method" => "getCountry",
160  "group" => "contact_data"),
161  "sel_country" => array(
162  "input" => "sel_country",
163  "method" => "getSelectedCountry",
164  "group" => "contact_data"),
165  "phone_office" => array(
166  "input" => "text",
167  "maxlength" => 40,
168  "size" => 40,
169  "method" => "getPhoneOffice",
170  "group" => "contact_data"),
171  "phone_home" => array(
172  "input" => "text",
173  "maxlength" => 40,
174  "size" => 40,
175  "method" => "getPhoneHome",
176  "group" => "contact_data"),
177  "phone_mobile" => array(
178  "input" => "text",
179  "maxlength" => 40,
180  "size" => 40,
181  "method" => "getPhoneMobile",
182  "group" => "contact_data"),
183  "fax" => array(
184  "input" => "text",
185  "maxlength" => 40,
186  "size" => 40,
187  "method" => "getFax",
188  "group" => "contact_data"),
189  "email" => array(
190  "input" => "email",
191  "maxlength" => 40,
192  "size" => 40,
193  "method" => "getEmail",
194  "group" => "contact_data"),
195  "hobby" => array(
196  "input" => "textarea",
197  "rows" => 3,
198  "cols" => 45,
199  "method" => "getHobby",
200  "lists_hide" => true,
201  "group" => "contact_data"),
202  "referral_comment" => array(
203  "input" => "textarea",
204  "rows" => 3,
205  "cols" => 45,
206  "method" => "getComment",
207  "course_export_hide" => true,
208  "group_export_hide" => true,
209  "lists_hide" => true,
210  "group" => "contact_data"),
211  "instant_messengers" => array(
212  "input" => "messenger",
213  "types" => array("icq","yahoo","msn","aim","skype","jabber","voip"),
214  "maxlength" => 40,
215  "size" => 40,
216  "course_export_hide" => true,
217  "group_export_hide" => true,
218  "lists_hide" => true,
219  "group" => "instant_messengers"),
220  "matriculation" => array(
221  "input" => "text",
222  "maxlength" => 40,
223  "size" => 40,
224  "method" => "getMatriculation",
225  "group" => "other"),
226  "delicious" => array(
227  "input" => "text",
228  "maxlength" => 40,
229  "size" => 40,
230  "method" => "getDelicious",
231  "group" => "other"),
232  "language" => array(
233  "input" => "language",
234  "method" => "getLanguage",
235  "required_hide" => true,
236  "visib_reg_hide" => true,
237  "course_export_hide" => true,
238  "group_export_hide" => true,
239  "group" => "settings"),
240  "skin_style" => array(
241  "input" => "skinstyle",
242  "required_hide" => true,
243  "visib_reg_hide" => true,
244  "course_export_hide" => true,
245  "group_export_hide" => true,
246  "group" => "settings"),
247  "hits_per_page" => array(
248  "input" => "hitsperpage",
249  "default" => 10,
250  "options" => array(
251  10 => 10, 15 => 15, 20 => 20, 30 => 30, 40 => 40,
252  50 => 50, 100 => 100, 9999 => 9999),
253  "required_hide" => true,
254  "visib_reg_hide" => true,
255  "course_export_hide" => true,
256  "group_export_hide" => true,
257  "group" => "settings"),
258  "show_users_online" => array(
259  "input" => "selection",
260  "default" => "y",
261  "options" => array(
262  "y" => "users_online_show_short_y",
263  "associated" => "users_online_show_short_associated",
264  "n" => "users_online_show_short_n"),
265  "required_hide" => true,
266  "visib_reg_hide" => true,
267  "course_export_hide" => true,
268  "group_export_hide" => true,
269  "group" => "settings"),
270  "hide_own_online_status" => array(
271  "input" => "selection",
272  "required_hide" => true,
273  "visib_reg_hide" => true,
274  "course_export_hide" => true,
275  "group_export_hide" => true,
276  "group" => "settings"),
277  "preferences" => array(
278  "visible_fix_value" => 1,
279  "changeable_fix_value" => 1,
280  "required_hide" => true,
281  "visib_reg_hide" => true,
282  "course_export_hide" => true,
283  "group_export_hide" => true,
284  "group" => "preferences"),
285  "mail_incoming_mail" => array(
286  "input" => "selection",
287  "default" => "y",
288  "options" => array(
289  IL_MAIL_LOCAL => "mail_incoming_local",
290  IL_MAIL_EMAIL => "mail_incoming_smtp",
291  IL_MAIL_BOTH => "mail_incoming_both"),
292  "required_hide" => true,
293  "visib_reg_hide" => true,
294  "course_export_hide" => true,
295  "group_export_hide" => true,
296  "export_hide" => true,
297  "search_hide" => true,
298  "group" => "settings")
299 
300  );
301 
305  function __construct()
306  {
307  $this->skip_groups = array();
308  $this->skip_fields = array();
309  }
310 
314  function getStandardFields()
315  {
316  $fields = array();
317  foreach (self::$user_field as $f => $p)
318  {
319  // skip hidden groups
320  if (in_array($p["group"], $this->skip_groups) ||
321  in_array($f, $this->skip_fields))
322  {
323  continue;
324  }
325  $fields[$f] = $p;
326  }
327  return $fields;
328  }
329 
335  {
336  global $ilSetting;
337 
338  $settings = $ilSetting->getAll();
339 
340  $fields = array();
341  foreach($this->getStandardFields() as $field => $info)
342  {
343  if($ilSetting->get('usr_settings_visib_lua_'.$field,1))
344  {
345  $fields[$field] = $info;
346  }
347  elseif($info['visib_lua_fix_value'])
348  {
349  $fields[$field] = $info;
350  }
351  }
352  return $fields;
353  }
354 
355 
359  function skipGroup($a_group)
360  {
361  $this->skip_groups[] = $a_group;
362  }
363 
367  function skipField($a_field)
368  {
369  $this->skip_fields[] = $a_field;
370  }
371 
375  function addStandardFieldsToForm($a_form, $a_user = NULL, array $custom_fields = NULL)
376  {
377  global $ilSetting, $lng, $rbacreview, $ilias;
378 
379  // custom registration settings
380  if(self::$mode == self::MODE_REGISTRATION)
381  {
382  include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
383  $registration_settings = new ilRegistrationSettings();
384 
385  self::$user_field["username"]["group"] = "login_data";
386  self::$user_field["password"]["group"] = "login_data";
387  self::$user_field["language"]["default"] = $lng->lang_key;
388 
389  // different position for role
390  $roles = self::$user_field["roles"];
391  unset(self::$user_field["roles"]);
392  self::$user_field["roles"] = $roles;
393  self::$user_field["roles"]["group"] = "settings";
394  }
395 
396  $fields = $this->getStandardFields();
397  $current_group = "";
398  $custom_fields_done = false;
399  foreach ($fields as $f => $p)
400  {
401  // next group? -> diplay subheader
402  if (($p["group"] != $current_group) &&
404  {
405  if (is_array($custom_fields) && !$custom_fields_done)
406  {
407  // should be appended to "other" or at least before "settings"
408  if($current_group == "other" || $p["group"] == "settings")
409  {
410  // add "other" subheader
411  if($current_group != "other")
412  {
413  $sh = new ilFormSectionHeaderGUI();
414  $sh->setTitle($lng->txt("other"));
415  $a_form->addItem($sh);
416  }
417  foreach($custom_fields as $custom_field)
418  {
419  $a_form->addItem($custom_field);
420  }
421  $custom_fields_done = true;
422  }
423  }
424 
425  $sh = new ilFormSectionHeaderGUI();
426  $sh->setTitle($lng->txt($p["group"]));
427  $a_form->addItem($sh);
428  $current_group = $p["group"];
429  }
430 
431  $m = "";
432  if (isset($p["method"]))
433  {
434  $m = $p["method"];
435  }
436 
437  $lv = (isset($p["lang_var"]) && $p["lang_var"] != "")
438  ? $p["lang_var"]
439  : $f;
440 
441  switch ($p["input"])
442  {
443  case "login":
444  if ((int)$ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION)
445  {
446  $val = new ilTextInputGUI($lng->txt('username'),'username');
447  if($a_user)
448  {
449  $val->setValue($a_user->getLogin());
450  }
451  $val->setMaxLength(32);
452  $val->setSize(40);
453  $val->setRequired(true);
454  }
455  else
456  {
457  // user account name
458  $val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un');
459  if($a_user)
460  {
461  $val->setValue($a_user->getLogin());
462  }
463  }
464  $a_form->addItem($val);
465  break;
466 
467  case "text":
469  {
470  $ti = new ilTextInputGUI($lng->txt($lv), "usr_".$f);
471  if($a_user)
472  {
473  $ti->setValue($a_user->$m());
474  }
475  $ti->setMaxLength($p["maxlength"]);
476  $ti->setSize($p["size"]);
477  $ti->setRequired($ilSetting->get("require_".$f));
478  if(!$ti->getRequired() || $ti->getValue())
479  {
480  $ti->setDisabled($ilSetting->get("usr_settings_disable_".$f));
481  }
482  $a_form->addItem($ti);
483  }
484  break;
485 
486  case "sel_country":
488  {
489  include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
490  $ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_".$f);
491  if($a_user)
492  {
493  $ci->setValue($a_user->$m());
494  }
495  $ci->setRequired($ilSetting->get("require_".$f));
496  if(!$ci->getRequired() || $ci->getValue())
497  {
498  $ci->setDisabled($ilSetting->get("usr_settings_disable_".$f));
499  }
500  $a_form->addItem($ci);
501  }
502  break;
503 
504  case "birthday":
506  {
507  $bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_".$f);
508  include_once "./Services/Calendar/classes/class.ilDateTime.php";
509  $date = null;
510  if ($a_user && strlen($a_user->$m()))
511  {
512  $date = new ilDateTime($a_user->$m(), IL_CAL_DATE);
513  $bi->setDate($date);
514  }
515  $bi->setShowEmpty(true);
516  $bi->setStartYear(1900);
517  $bi->setRequired($ilSetting->get("require_".$f));
518  if(!$bi->getRequired() || $date)
519  {
520  $bi->setDisabled($ilSetting->get("usr_settings_disable_".$f));
521  }
522  $a_form->addItem($bi);
523  }
524  break;
525 
526  case "radio":
528  {
529  $rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_".$f);
530  if($a_user)
531  {
532  $rg->setValue($a_user->$m());
533  }
534  foreach ($p["values"] as $k => $v)
535  {
536  $op = new ilRadioOption($lng->txt($v), $k);
537  $rg->addOption($op);
538  }
539  $rg->setRequired($ilSetting->get("require_".$f));
540  if(!$rg->getRequired() || $rg->getValue())
541  {
542  $rg->setDisabled($ilSetting->get("usr_settings_disable_".$f));
543  }
544  $a_form->addItem($rg);
545  }
546  break;
547 
548  case "picture":
549  if (ilUserProfile::userSettingVisible("upload") && $a_user)
550  {
551  $ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
552  $ii->setDisabled($ilSetting->get("usr_settings_disable_upload"));
553 
554  $upload = $a_form->getFileUpload("userfile");
555  if($upload["name"])
556  {
557  $ii->setPending($upload["name"]);
558  }
559  else
560  {
561  $im = ilObjUser::_getPersonalPicturePath($a_user->getId(), "small", true,
562  true);
563  if ($im != "")
564  {
565  $ii->setImage($im);
566  $ii->setAlt($lng->txt("personal_picture"));
567  }
568  }
569 
570  // ilinc link as info
571  if (ilUserProfile::userSettingVisible("upload") and
572  $ilSetting->get("ilinc_active"))
573  {
574  include_once ('./Modules/ILinc/classes/class.ilObjiLincUser.php');
575  $ilinc_user = new ilObjiLincUser($a_user);
576 
577  if ($ilinc_user->id)
578  {
579  include_once ('./Modules/ILinc/classes/class.ilnetucateXMLAPI.php');
580  $ilincAPI = new ilnetucateXMLAPI();
581  $ilincAPI->uploadPicture($ilinc_user);
582  $response = $ilincAPI->sendRequest("uploadPicture");
583 
584  // return URL to user's personal page
585  $url = trim($response->data['url']['cdata']);
586  $desc =
587  $lng->txt("ilinc_upload_pic_text")." ".
588  '<a href="'.$url.'">'.$lng->txt("ilinc_upload_pic_linktext").'</a>';
589  $ii->setInfo($desc);
590  }
591  }
592 
593  $a_form->addItem($ii);
594  }
595  break;
596 
597  case "roles":
598  if(self::$mode == self::MODE_DESKTOP)
599  {
601  {
602  $global_roles = $rbacreview->getGlobalRoles();
603  foreach($global_roles as $role_id)
604  {
605  if (in_array($role_id,$rbacreview->assignedRoles($a_user->getId())))
606  {
607  $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
608  $role_names .= $roleObj->getTitle().", ";
609  unset($roleObj);
610  }
611  }
612  $dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr");
613  $dr->setValue(substr($role_names,0,-2));
614  $a_form->addItem($dr);
615  }
616  }
617  else if(self::$mode == self::MODE_REGISTRATION)
618  {
619  if($registration_settings->roleSelectionEnabled())
620  {
621  include_once("./Services/AccessControl/classes/class.ilObjRole.php");
622  $options = array();
623  foreach (ilObjRole::_lookupRegisterAllowed() as $role)
624  {
625  $options[$role["id"]] = $role["title"];
626  }
627  // registration form validation will take care of missing field / value
628  if($options)
629  {
630  if(sizeof($options) > 1)
631  {
632  $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_".$f);
633  $ta->setOptions($options);
634  $ta->setRequired($ilSetting->get("require_".$f));
635  if(!$ta->getRequired())
636  {
637  $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
638  }
639  }
640  // no need for select if only 1 option
641  else
642  {
643  $ta = new ilHiddenInputGUI("usr_".$f);
644  $ta->setValue(array_shift(array_keys($options)));
645  }
646  $a_form->addItem($ta);
647  }
648  }
649  }
650  break;
651 
652  case "email":
654  {
655  $em = new ilEMailInputGUI($lng->txt($lv), "usr_".$f);
656  if($a_user)
657  {
658  $em->setValue($a_user->$m());
659  }
660  $em->setRequired($ilSetting->get("require_".$f));
661  if(!$em->getRequired() || $em->getValue())
662  {
663  $em->setDisabled($ilSetting->get("usr_settings_disable_".$f));
664  }
665  if(self::MODE_REGISTRATION == self::$mode)
666  {
667  $em->setRetype(true);
668  }
669  $a_form->addItem($em);
670  }
671  break;
672 
673  case "textarea":
675  {
676  $ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_".$f);
677  if($a_user)
678  {
679  $ta->setValue($a_user->$m());
680  }
681  $ta->setRows($p["rows"]);
682  $ta->setCols($p["cols"]);
683  $ta->setRequired($ilSetting->get("require_".$f));
684  if(!$ta->getRequired() || $ta->getValue())
685  {
686  $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
687  }
688  $a_form->addItem($ta);
689  }
690  break;
691 
692  case "messenger":
693  if (ilUserProfile::userSettingVisible("instant_messengers"))
694  {
695  $im_arr = $p["types"];
696  foreach ($im_arr as $im_name)
697  {
698  $im = new ilTextInputGUI($lng->txt("im_".$im_name), "usr_im_".$im_name);
699  if($a_user)
700  {
701  $im->setValue($a_user->getInstantMessengerId($im_name));
702  }
703  $im->setMaxLength($p["maxlength"]);
704  $im->setSize($p["size"]);
705  $im->setRequired($ilSetting->get("require_"."instant_messengers"));
706  if(!$im->getRequired() || $im->getValue())
707  {
708  $im->setDisabled($ilSetting->get("usr_settings_disable_"."instant_messengers"));
709  }
710  $a_form->addItem($im);
711  }
712  }
713  break;
714 
715  case "password":
716  if (self::$mode == self::MODE_REGISTRATION)
717  {
718  if(!$registration_settings->passwordGenerationEnabled())
719  {
720  $ta = new ilPasswordInputGUI($lng->txt($lv), "usr_".$f);
721  $ta->setRequired(true);
722  // $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
723  }
724  else
725  {
726  $ta = new ilNonEditableValueGUI($lng->txt($lv));
727  $ta->setValue($lng->txt("reg_passwd_via_mail"));
728  }
729  $a_form->addItem($ta);
730  }
731  break;
732 
733  case "language":
735  {
736  $ta = new ilSelectInputGUI($lng->txt($lv), "usr_".$f);
737  if($a_user)
738  {
739  $ta->setValue($a_user->$m());
740  }
741  $options = array();
742  $lng->loadLanguageModule("meta");
743  foreach ($lng->getInstalledLanguages() as $lang_key)
744  {
745  $options[$lang_key] = $lng->txt("meta_l_".$lang_key);
746  }
747  asort($options); // #9728
748  $ta->setOptions($options);
749  $ta->setRequired($ilSetting->get("require_".$f));
750  if(!$ta->getRequired() || $ta->getValue())
751  {
752  $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
753  }
754  $a_form->addItem($ta);
755  }
756  break;
757  }
758  }
759 
760  // append custom fields as "other"
761  if(is_array($custom_fields) && !$custom_fields_done)
762  {
763  // add "other" subheader
764  if($current_group != "other")
765  {
766  $sh = new ilFormSectionHeaderGUI();
767  $sh->setTitle($lng->txt("other"));
768  $a_form->addItem($sh);
769  }
770  foreach($custom_fields as $custom_field)
771  {
772  $a_form->addItem($custom_field);
773  }
774  }
775  }
776 
777 
781  static function userSettingVisible($a_setting)
782  {
783  global $ilSetting;
784 
785  if(self::$mode == self::MODE_DESKTOP)
786  {
787  return ($ilSetting->get("usr_settings_hide_".$a_setting) != 1);
788  }
789  else
790  {
791  if(isset(self::$user_field[$a_setting]["visib_reg_hide"]) && self::$user_field[$a_setting]["visib_reg_hide"] === true)
792  {
793  return true;
794  }
795  return ($ilSetting->get("usr_settings_visib_reg_".$a_setting, "1") || $ilSetting->get("require_".$a_setting, "0"));
796  }
797  }
798 
799  static function setMode($mode)
800  {
801  global $lng;
802 
803  if(in_array($mode, array(self::MODE_DESKTOP, self::MODE_REGISTRATION)))
804  {
805  self::$mode = $mode;
806  return true;
807  }
808  return false;
809  }
810 
819  static function isProfileIncomplete($a_user, $a_include_udf = true, $a_personal_data_only = true)
820  {
821  global $ilSetting;
822 
823  // standard fields
824  foreach(self::$user_field as $field => $definition)
825  {
826  // only if visible in personal data
827  if($a_personal_data_only && $ilSetting->get("usr_settings_hide_".$field))
828  {
829  continue;
830  }
831 
832  if($ilSetting->get("require_".$field) && $definition["method"])
833  {
834  $value = $a_user->{$definition["method"]}();
835  if($value == "")
836  {
837  return true;
838  }
839  }
840  }
841 
842  // custom fields
843  if($a_include_udf)
844  {
845  $user_defined_data = $a_user->getUserDefinedData();
846 
847  include_once './Services/User/classes/class.ilUserDefinedFields.php';
848  $user_defined_fields = ilUserDefinedFields::_getInstance();
849  foreach($user_defined_fields->getRequiredDefinitions() as $field => $definition)
850  {
851  // only if visible in personal data
852  if($a_personal_data_only && !$definition["visible"])
853  {
854  continue;
855  }
856 
857  if(!$user_defined_data["f_".$field])
858  {
859  return true;
860  }
861  }
862  }
863 
864  return false;
865  }
866 
877  protected static function isEditableByUser($setting)
878  {
884  global $ilSetting;
885 
886  // Not visible in personal data or not changeable
887  if( $ilSetting->get('usr_settings_hide_'.$setting) == 1 ||
888  $ilSetting->get('usr_settings_disable_'.$setting) == 1 )
889  {
890  // User has no chance to edit this field
891  return false;
892  }
893 
894  return true;
895  }
896 
906  public static function getIgnorableRequiredSettings()
907  {
913  global $ilSetting;
914 
915  $ignorableSettings = array();
916 
917  foreach(self::$user_field as $field => $definition)
918  {
919  // !!!username and password must not be ignored!!!
920  if( 'username' == $field ||
921  'password' == $field )
922  {
923  continue;
924  }
925 
926  // Field is not required -> continue
927  if( !$ilSetting->get('require_'.$field) )
928  {
929  continue;
930  }
931 
932  if( self::isEditableByUser($field) )
933  {
934  $ignorableSettings[] = $field;
935  }
936  }
937 
938  return $ignorableSettings;
939  }
940 }
941 ?>