ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilObjUserGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 use ILIAS\Repository\ExternalGUIService as RepositoryGUIs;
29 
37 {
40  private ilHelpGUI $help;
41  private ilTabsGUI $tabs;
42  private RepositoryGUIs $repository_guis;
44 
48 
50 
51  private string $requested_letter = '';
52  private string $requested_baseClass = '';
53  private string $requested_search = '';
57  private array $back_target;
58  private bool $update;
59  private array $selectable_roles;
60  private int $default_role;
61  private string $default_layout_and_style;
63 
64  private int $usrf_ref_id;
66 
67  public function __construct(
68  $a_data,
69  int $a_id,
70  bool $a_call_by_reference = false,
71  bool $a_prepare_output = true
72  ) {
74  global $DIC;
75  $this->ctrl = $DIC['ilCtrl'];
76  $this->tabs = $DIC['ilTabs'];
77  $this->help = $DIC['ilHelp'];
78  $this->repository_guis = $DIC->repository()->gui();
79  $this->mail_sender_factory = $DIC->mail()->mime()->senderFactory();
80 
81  $this->user_profile = new ilUserProfile();
82 
83  $this->default_layout_and_style = $DIC['ilClientIniFile']->readVariable('layout', 'skin') .
84  ':' . $DIC['ilClientIniFile']->readVariable('layout', 'style');
85 
86  $this->type = 'usr';
87  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
88  $this->usrf_ref_id = $this->ref_id;
89 
90  $this->uploads = $DIC->upload();
91  $this->irss = $DIC->resourceStorage();
92  $this->stakeholder = new ilUserProfilePictureStakeholder();
93 
94  $this->ctrl->saveParameter($this, ['obj_id', 'letter']);
95  $this->ctrl->setParameterByClass('ilobjuserfoldergui', 'letter', $this->requested_letter);
96  $this->lng->loadLanguageModule('user');
97 
98  $this->user_request = new UserGUIRequest(
99  $DIC->http(),
100  $DIC->refinery()
101  );
102 
103  $this->requested_letter = $this->user_request->getLetter();
104  $this->requested_baseClass = $this->user_request->getBaseClass();
105  $this->requested_search = $this->user_request->getSearch();
106  $this->legal_documents = $DIC['legalDocuments'];
107  }
108 
109  public function executeCommand(): void
110  {
111  $next_class = $this->ctrl->getNextClass($this);
112  $cmd = $this->ctrl->getCmd();
113 
114  $this->prepareOutput();
115 
116  switch ($next_class) {
117  case 'illearningprogressgui':
118  $new_gui = new ilLearningProgressGUI(
121  $this->object->getId()
122  );
123  $this->ctrl->forwardCommand($new_gui);
124  break;
125 
126  case strtolower(ilObjectOwnershipManagementGUI::class):
127  $this->ctrl->forwardCommand(
128  $this->repository_guis->ownershipManagementGUI(
129  $this->object->getId()
130  )
131  );
132  break;
133 
134  default:
135  if ($cmd == '' || $cmd == 'view') {
136  $cmd = 'edit';
137  }
138  $cmd .= 'Object';
139  $this->$cmd();
140  break;
141  }
142  }
143 
144  protected function setTitleAndDescription(): void
145  {
146  if (strtolower(get_class($this->object)) == 'ilobjuser') {
147  $this->tpl->setTitle('[' . $this->object->getLogin() . '] ' . $this->object->getTitle());
148  $this->tpl->setDescription($this->object->getLongDescription());
149  $this->tpl->setTitleIcon(
150  ilUtil::getImagePath('standard/icon_' . $this->object->getType() . '.svg'),
151  $this->lng->txt('obj_' . $this->object->getType())
152  );
153  } else {
154  parent::setTitleAndDescription();
155  }
156  }
157 
158  public function cancelObject(): void
159  {
160  ilSession::clear('saved_post');
161 
162  if (strtolower($this->requested_baseClass) == 'iladministrationgui') {
163  $this->ctrl->redirectByClass('ilobjuserfoldergui', 'view');
164  } else {
165  $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
166  }
167  }
168 
169  public function getAdminTabs(): void
170  {
171  $this->getTabs();
172  }
173 
174  protected function getTabs(): void
175  {
176  $this->tabs_gui->clearTargets();
177 
178  $this->help->setScreenIdComponent('usr');
179 
180  if ($this->requested_search) {
181  $this->tabs_gui->setBackTarget(
182  $this->lng->txt('search_results'),
183  ilSession::get('usr_search_link')
184  );
185 
186  $this->tabs_gui->addTarget(
187  'properties',
188  $this->ctrl->getLinkTarget($this, 'edit'),
189  ['edit', '', 'view'],
190  get_class($this),
191  '',
192  true
193  );
194  } else {
195  $this->tabs_gui->addTarget(
196  'properties',
197  $this->ctrl->getLinkTarget($this, 'edit'),
198  ['edit', '', 'view'],
199  get_class($this)
200  );
201  }
202 
203  if ($this->checkAccessToRolesTab()) {
204  $this->tabs_gui->addTarget(
205  'role_assignment',
206  $this->ctrl->getLinkTarget($this, 'roleassignment'),
207  ['roleassignment'],
208  get_class($this)
209  );
210  }
211 
212  // learning progress
213  if ($this->rbac_system->checkAccess('read', $this->ref_id) and
216  $this->tabs_gui->addTarget(
217  'learning_progress',
218  $this->ctrl->getLinkTargetByClass('illearningprogressgui', ''),
219  '',
220  ['illplistofobjectsgui', 'illplistofsettingsgui', 'illearningprogressgui', 'illplistofprogressgui']
221  );
222  }
223 
224  $this->tabs_gui->addTarget(
225  'user_ownership',
226  $this->ctrl->getLinkTargetByClass('ilobjectownershipmanagementgui', ''),
227  '',
228  'ilobjectownershipmanagementgui'
229  );
230  }
231 
235  public function setBackTarget(
236  string $a_text,
237  string $a_link
238  ): void {
239  $this->back_target = ['text' => $a_text, 'link' => $a_link];
240  }
241 
242  public function __checkUserDefinedRequiredFields(): bool
243  {
244  $this->user_defined_fields = ilUserDefinedFields::_getInstance();
245 
246  $udfs = $this->user_request->getUDFs();
247  foreach ($this->user_defined_fields->getDefinitions() as $field_id => $definition) {
248  if ($definition['required'] and !strlen($udfs[$field_id])) {
249  return false;
250  }
251  }
252  return true;
253  }
254 
255  public function __showUserDefinedFields(): void
256  {
257  $user_defined_data = null;
258  $this->user_defined_fields = ilUserDefinedFields::_getInstance();
259 
260  if ($this->object->getType() == 'usr') {
261  $user_defined_data = $this->object->getUserDefinedData();
262  }
263  foreach ($this->user_defined_fields->getDefinitions() as $field_id => $definition) {
264  $error_post_vars = ilSession::get('error_post_vars');
265  $old = $error_post_vars['udf'][$field_id] ?? $user_defined_data[$field_id];
266 
267  if ($definition['field_type'] == UDF_TYPE_TEXT) {
268  $this->tpl->setCurrentBlock('field_text');
269  $this->tpl->setVariable('FIELD_NAME', 'udf[' . $definition['field_id'] . ']');
270  $this->tpl->setVariable('FIELD_VALUE', ilLegacyFormElementsUtil::prepareFormOutput($old));
271  } else {
272  $this->tpl->setCurrentBlock('field_select');
273  $this->tpl->setVariable(
274  'SELECT_BOX',
276  $old,
277  'udf[' . $definition['field_id'] . ']',
278  $this->user_defined_fields->fieldValuesToSelectArray(
279  $definition['field_values']
280  ),
281  false,
282  true
283  )
284  );
285  }
286  $this->tpl->parseCurrentBlock();
287  $this->tpl->setCurrentBlock('user_defined');
288 
289  if ($definition['required']) {
290  $name = $definition['field_name'] . '<span class="asterisk">*</span>';
291  } else {
292  $name = $definition['field_name'];
293  }
294  $this->tpl->setVariable('TXT_FIELD_NAME', $name);
295  $this->tpl->parseCurrentBlock();
296  }
297  }
298 
299  public function initCreate(): void
300  {
301  if ($this->usrf_ref_id != USER_FOLDER_ID) {
302  $this->tabs_gui->clearTargets();
303  }
304 
305  // role selection
306  $obj_list = $this->rbac_review->getRoleListByObject(ROLE_FOLDER_ID);
307  $rol = [];
308  foreach ($obj_list as $obj_data) {
309  // allow only 'assign_users' marked roles if called from category
310  if ($this->object->getRefId() != USER_FOLDER_ID && !in_array(
312  $this->rbac_review->assignedRoles($this->user->getId())
313  )) {
314  if (!ilObjRole::_getAssignUsersStatus($obj_data['obj_id'])) {
315  continue;
316  }
317  }
318  // exclude anonymous role from list
319  if ($obj_data['obj_id'] != ANONYMOUS_ROLE_ID) {
320  // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
321  if ($obj_data['obj_id'] != SYSTEM_ROLE_ID || in_array(
323  $this->rbac_review->assignedRoles($this->user->getId())
324  )) {
325  $rol[$obj_data['obj_id']] = $obj_data['title'];
326  }
327  }
328  }
329 
330  if (!count($rol)) {
331  $this->ilias->raiseError(
332  $this->lng->txt('msg_no_roles_users_can_be_assigned_to'),
333  $this->ilias->error_obj->MESSAGE
334  );
335  }
336 
337  $keys = array_keys($rol);
338 
339  // set pre defined user role to default
340  if (in_array(4, $keys)) {
341  $this->default_role = 4;
342  } else {
343  if (count($keys) > 1 && in_array(2, $keys)) {
344  // remove admin role as preselectable role
345  foreach ($keys as $key => $val) {
346  if ($val == 2) {
347  unset($keys[$key]);
348  break;
349  }
350  }
351  }
352 
353  $this->default_role = array_shift($keys);
354  }
355  $this->selectable_roles = $rol;
356  }
357 
361  public function createObject(): void
362  {
363  if (!$this->rbac_system->checkAccess('create_usr', $this->usrf_ref_id)
364  && !$this->rbac_system->checkAccess('cat_administrate_users', $this->usrf_ref_id)) {
365  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
366  }
367 
368  $this->initCreate();
369  $this->initForm('create');
370  $this->renderForm();
371  }
372 
376  public function saveObject(): void
377  {
378  if (!$this->rbac_system->checkAccess('create_usr', $this->usrf_ref_id)
379  && !$this->access->checkAccess('cat_administrate_users', '', $this->usrf_ref_id)) {
380  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
381  }
382 
383  $this->initCreate();
384  $this->initForm('create');
385 
386  // Manipulate form so ignore required fields are no more required. This has to be done before ilPropertyFormGUI::checkInput() is called.
387  $profile_maybe_incomplete = false;
388  if ($this->form_gui->getInput('ignore_rf', false)) {
389  $profile_maybe_incomplete = $this->handleIgnoredRequiredFields();
390  }
391 
392  if (!$this->form_gui->checkInput()) {
393  $this->form_gui->setValuesByPost();
394  $this->renderForm();
395  return;
396  }
397 
398  // checks passed. save user
399  $user_object = $this->loadValuesFromForm();
400  if ($this->user->getId() === (int) SYSTEM_USER_ID
401  || !in_array(SYSTEM_ROLE_ID, $this->rbac_review->assignedRoles($this->object->getId()))
402  || in_array(SYSTEM_ROLE_ID, $this->rbac_review->assignedRoles($this->user->getId()))) {
403  $user_object->setPasswd($this->form_gui->getInput('passwd'), ilObjUser::PASSWD_PLAIN);
404  }
405  $user_object->setTitle($user_object->getFullname());
406  $user_object->setDescription($user_object->getEmail());
407 
408  $this->loadUserDefinedDataFromForm($user_object);
409 
410  $user_object->create();
411 
413  $user_object->setExternalAccount($this->form_gui->getInput('ext_account'));
414  }
415 
416  // set a timestamp for last_password_change
417  // this ts is needed by ilSecuritySettings
418  $user_object->setLastPasswordChangeTS(time());
419 
420  //insert user data in table user_data
421  $user_object->saveAsNew();
422 
423  // setup user preferences
424  if ($this->isSettingChangeable('language')) {
425  $user_object->setLanguage($this->form_gui->getInput('language'));
426  }
427 
428  if ($this->isSettingChangeable('skin_style')) {
429  //set user skin and style
430  $sknst = explode(':', $this->form_gui->getInput('skin_style'));
431 
432  if ($user_object->getPref('style') != $sknst[1] ||
433  $user_object->getPref('skin') != $sknst[0]) {
434  $user_object->setPref('skin', $sknst[0]);
435  $user_object->setPref('style', $sknst[1]);
436  }
437  }
438  if ($this->isSettingChangeable('session_reminder')) {
439  $user_object->setPref('session_reminder_lead_time', (string) $this->form_gui->getInput('session_reminder_lead_time'));
440  }
441  if ($this->isSettingChangeable('hide_own_online_status')) {
442  $user_object->setPref(
443  'hide_own_online_status',
444  $this->form_gui->getInput('hide_own_online_status')
445  );
446  }
447  if ($this->isSettingChangeable('bs_allow_to_contact_me')) {
448  $user_object->setPref(
449  'bs_allow_to_contact_me',
450  $this->form_gui->getInput('bs_allow_to_contact_me') ? 'y' : 'n'
451  );
452  }
453  if ($this->isSettingChangeable('chat_osc_accept_msg')) {
454  $user_object->setPref(
455  'chat_osc_accept_msg',
456  $this->form_gui->getInput('chat_osc_accept_msg') ? 'y' : 'n'
457  );
458  }
459  if ($this->isSettingChangeable('chat_broadcast_typing')) {
460  $user_object->setPref(
461  'chat_broadcast_typing',
462  $this->form_gui->getInput('chat_broadcast_typing') ? 'y' : 'n'
463  );
464  }
465  $user_object->writePrefs();
466 
467  //set role entries
468  $this->rbac_admin->assignUser(
469  (int) $this->form_gui->getInput('default_role'),
470  $user_object->getId(),
471  true
472  );
473 
474  $msg = $this->lng->txt('user_added');
475 
476  $this->user->setPref(
477  'send_info_mails',
478  ($this->form_gui->getInput('send_mail') == 'y') ? 'y' : 'n'
479  );
480  $this->user->writePrefs();
481 
482  $this->object = $user_object;
483 
484  if ($this->isSettingChangeable('upload')) {
485  $this->uploadUserPicture();
486  }
487 
488  if ($profile_maybe_incomplete
489  && $this->user_profile->isProfileIncomplete($this->object)) {
490  $this->object->setProfileIncomplete(true);
491  $this->object->update();
492  }
493 
494  // send new account mail
495  if ($this->form_gui->getInput('send_mail') == 'y') {
496  $acc_mail = new ilAccountMail();
497  $acc_mail->useLangVariablesAsFallback(true);
498  $acc_mail->setAttachConfiguredFiles(true);
499  $acc_mail->setUserPassword($this->form_gui->getInput('passwd'));
500  $acc_mail->setUser($user_object);
501 
502  if ($acc_mail->send()) {
503  $msg .= '<br />' . $this->lng->txt('mail_sent');
504  $this->tpl->setOnScreenMessage('success', $msg, true);
505  } else {
506  $msg .= '<br />' . $this->lng->txt('mail_not_sent');
507  $this->tpl->setOnScreenMessage('info', $msg, true);
508  }
509  } else {
510  $this->tpl->setOnScreenMessage('success', $msg, true);
511  }
512 
513  if (strtolower($this->requested_baseClass) == 'iladministrationgui') {
514  $this->ctrl->redirectByClass('ilobjuserfoldergui', 'view');
515  return;
516  }
517 
518  $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
519  }
520 
521  public function editObject(): void
522  {
523  $this->checkUserWriteRight();
524 
525  if ($this->usrf_ref_id != USER_FOLDER_ID) {
526  $this->tabs_gui->clearTargets();
527  }
528 
529  // get form
530  $this->initForm('edit');
531  $this->getValues();
532  $this->renderForm();
533  }
534 
535  protected function loadValuesFromForm(string $a_mode = 'create'): ilObjUser
536  {
537  $user = null;
538 
539  switch ($a_mode) {
540  case 'create':
541  $user = new ilObjUser();
542  break;
543 
544  case 'update':
546  break;
547  }
548 
549  $from = $this->form_gui->getItemByPostVar('time_limit_from')->getDate();
550  $user->setTimeLimitFrom($from
551  ? $from->get(IL_CAL_UNIX)
552  : null);
553 
554  $until = $this->form_gui->getItemByPostVar('time_limit_until')->getDate();
555  $user->setTimeLimitUntil($until
556  ? $until->get(IL_CAL_UNIX)
557  : null);
558 
559  $user->setTimeLimitUnlimited((bool) $this->form_gui->getInput('time_limit_unlimited'));
560 
561  if ($a_mode == 'create') {
562  $user->setTimeLimitOwner($this->usrf_ref_id);
563  }
564  if ($this->isSettingChangeable('birthday')) {
565  $bd = $this->form_gui->getItemByPostVar('birthday');
566  $bd = $bd->getDate();
567  $user->setBirthday($bd
568  ? $bd->get(IL_CAL_DATE)
569  : null);
570  }
571  $user->setLogin($this->form_gui->getInput('login'));
572  if ($this->isSettingChangeable('gender')) {
573  $user->setGender($this->form_gui->getInput('gender'));
574  }
575  if ($this->isSettingChangeable('title')) {
576  $user->setUTitle($this->form_gui->getInput('title'));
577  }
578  if ($this->isSettingChangeable('firstname')) {
579  $user->setFirstname($this->form_gui->getInput('firstname'));
580  }
581  if ($this->isSettingChangeable('lastname')) {
582  $user->setLastname($this->form_gui->getInput('lastname'));
583  }
584  $user->setFullname();
585  if ($this->isSettingChangeable('institution')) {
586  $user->setInstitution($this->form_gui->getInput('institution'));
587  }
588  if ($this->isSettingChangeable('department')) {
589  $user->setDepartment($this->form_gui->getInput('department'));
590  }
591  if ($this->isSettingChangeable('street')) {
592  $user->setStreet($this->form_gui->getInput('street'));
593  }
594  if ($this->isSettingChangeable('city')) {
595  $user->setCity($this->form_gui->getInput('city'));
596  }
597  if ($this->isSettingChangeable('zipcode')) {
598  $user->setZipcode($this->form_gui->getInput('zipcode'));
599  }
600  if ($this->isSettingChangeable('country')) {
601  $user->setCountry($this->form_gui->getInput('country'));
602  }
603  if ($this->isSettingChangeable('sel_country')) {
604  $user->setSelectedCountry($this->form_gui->getInput('sel_country'));
605  }
606  if ($this->isSettingChangeable('phone_office')) {
607  $user->setPhoneOffice($this->form_gui->getInput('phone_office'));
608  }
609  if ($this->isSettingChangeable('phone_home')) {
610  $user->setPhoneHome($this->form_gui->getInput('phone_home'));
611  }
612  if ($this->isSettingChangeable('phone_mobile')) {
613  $user->setPhoneMobile($this->form_gui->getInput('phone_mobile'));
614  }
615  if ($this->isSettingChangeable('fax')) {
616  $user->setFax($this->form_gui->getInput('fax'));
617  }
618  if ($this->isSettingChangeable('matriculation')) {
619  $user->setMatriculation($this->form_gui->getInput('matriculation'));
620  }
621  if ($this->isSettingChangeable('email')) {
622  $user->setEmail($this->form_gui->getInput('email'));
623  }
624  if ($this->isSettingChangeable('second_email')) {
625  $user->setSecondEmail($this->form_gui->getInput('second_email'));
626  }
627  if ($this->isSettingChangeable('hobby')) {
628  $user->setHobby($this->form_gui->getInput('hobby'));
629  }
630  if ($this->isSettingChangeable('referral_comment')) {
631  $user->setComment($this->form_gui->getInput('referral_comment'));
632  }
633 
634  $general_interests = is_array($this->form_gui->getInput('interests_general'))
635  ? $this->form_gui->getInput('interests_general')
636  : [];
637  $user->setGeneralInterests($general_interests);
638 
639  $offering_help = is_array($this->form_gui->getInput('interests_help_offered'))
640  ? $this->form_gui->getInput('interests_help_offered')
641  : [];
642  $user->setOfferingHelp($offering_help);
643 
644  $looking_for_help = is_array($this->form_gui->getInput('interests_help_looking'))
645  ? $this->form_gui->getInput('interests_help_looking')
646  : [];
647  $user->setLookingForHelp($looking_for_help);
648 
649  $user->setClientIP($this->form_gui->getInput('client_ip'));
650  $user->setLatitude($this->form_gui->getInput('latitude'));
651  $user->setLongitude($this->form_gui->getInput('longitude'));
652  $zoom = (int) $this->form_gui->getInput('loc_zoom');
653  if ($zoom == 0) {
654  $zoom = null;
655  }
656  $user->setLocationZoom($zoom);
657 
658  $user->setAuthMode($this->form_gui->getInput('auth_mode'));
659  $user->setExternalAccount($this->form_gui->getInput('ext_account'));
660 
661  if ((int) $user->getActive() != (int) $this->form_gui->getInput('active')) {
662  $user->setActive((bool) $this->form_gui->getInput('active'), $this->user->getId());
663  }
664 
665  return $user;
666  }
667 
668  protected function loadUserDefinedDataFromForm(?ilObjUser $user = null): void
669  {
670  if (!$user) {
672  }
673 
674  $user_defined_fields = ilUserDefinedFields::_getInstance();
675  if ($this->usrf_ref_id == USER_FOLDER_ID) {
676  $all_defs = $user_defined_fields->getDefinitions();
677  } else {
678  $all_defs = $user_defined_fields->getChangeableLocalUserAdministrationDefinitions();
679  }
680  $udf = [];
681  foreach ($all_defs as $definition) {
682  $f = "udf_" . $definition['field_id'];
683  $item = $this->form_gui->getItemByPostVar($f);
684  if ($item && !$item->getDisabled()) {
685  $udf[$definition['field_id']] = $this->form_gui->getInput($f);
686  }
687  }
688  $user->setUserDefinedData($udf);
689  }
690 
691  public function updateObject(): void
692  {
693  $this->checkUserWriteRight();
694  $this->initForm('edit');
695 
696  // Manipulate form so ignore required fields are no more required. This has to be done before ilPropertyFormGUI::checkInput() is called.
697  $profile_maybe_incomplete = false;
698  if ($this->form_gui->getInput('ignore_rf', false)) {
699  $profile_maybe_incomplete = $this->handleIgnoredRequiredFields();
700  }
701 
702  if ($this->form_gui->checkInput()) {
703  // @todo: external account; time limit
704  // if not allowed or empty -> do no change password
706  ilAuthUtils::_getAuthMode($this->form_gui->getInput('auth_mode'))
707  ) && trim($this->form_gui->getInput('passwd')) !== ''
708  && ($this->user->getId() === (int) SYSTEM_USER_ID
709  || !in_array(SYSTEM_ROLE_ID, $this->rbac_review->assignedRoles($this->object->getId()))
710  || in_array(SYSTEM_ROLE_ID, $this->rbac_review->assignedRoles($this->user->getId())))
711  ) {
712  $this->object->setPasswd($this->form_gui->getInput('passwd'), ilObjUser::PASSWD_PLAIN);
713  }
714 
715  if ((int) $this->form_gui->getInput('active') == 1) {
716  $this->object->setLoginAttempts(0);
717  }
718 
719  $this->loadValuesFromForm('update');
720 
722 
723  try {
724  $this->object->updateLogin($this->form_gui->getInput('login'));
725  } catch (ilUserException $e) {
726  $this->tpl->setOnScreenMessage('failure', $e->getMessage());
727  $this->form_gui->setValuesByPost();
728  $this->renderForm();
729  return;
730  }
731 
732  $this->object->setTitle($this->object->getFullname());
733  $this->object->setDescription($this->object->getEmail());
734 
735  if ($this->isSettingChangeable('language')) {
736  $this->object->setLanguage($this->form_gui->getInput('language'));
737  }
738 
739  if ($this->isSettingChangeable('skin_style')) {
740  //set user skin and style
741  $sknst = explode(':', $this->form_gui->getInput('skin_style'));
742 
743  if ($this->object->getPref('style') != $sknst[1] ||
744  $this->object->getPref('skin') != $sknst[0]) {
745  $this->object->setPref('skin', $sknst[0]);
746  $this->object->setPref('style', $sknst[1]);
747  }
748  }
749 
750  if ($this->isSettingChangeable('session_reminder')) {
751  $this->object->setPref('session_reminder_lead_time', (string) $this->form_gui->getInput('session_reminder_lead_time'));
752  }
753 
754  if ($this->isSettingChangeable('hide_own_online_status')) {
755  $this->object->setPref(
756  'hide_own_online_status',
757  ($this->form_gui->getInput('hide_own_online_status') ?? '0')
758  );
759  }
760  if ($this->isSettingChangeable('bs_allow_to_contact_me')) {
761  $this->object->setPref(
762  'bs_allow_to_contact_me',
763  ($this->form_gui->getInput('bs_allow_to_contact_me') ?? false) ? 'y' : 'n'
764  );
765  }
766  if ($this->isSettingChangeable('chat_osc_accept_msg')) {
767  $this->object->setPref(
768  'chat_osc_accept_msg',
769  ($this->form_gui->getInput('chat_osc_accept_msg') ?? false) ? 'y' : 'n'
770  );
771  }
772  if ($this->isSettingChangeable('chat_broadcast_typing')) {
773  $this->object->setPref(
774  'chat_broadcast_typing',
775  ($this->form_gui->getInput('chat_broadcast_typing') ?? false) ? 'y' : 'n'
776  );
777  }
778 
779  // set a timestamp for last_password_change
780  // this ts is needed by ilSecuritySettings
781  $this->object->setLastPasswordChangeTS(time());
782 
783  // #10054 - profile may have been completed, check below is only for incomplete
784  $this->object->setProfileIncomplete(false);
785 
786  $this->update = $this->object->update();
787 
788  // If the current user is editing its own user account,
789  // we update his preferences.
790  if ($this->user->getId() == $this->object->getId()) {
791  $this->user->readPrefs();
792  }
793  $this->user->setPref(
794  'send_info_mails',
795  ($this->form_gui->getInput('send_mail') === 'y') ? 'y' : 'n'
796  );
797  $this->user->writePrefs();
798 
799  $mail_message = $this->__sendProfileMail();
800  $msg = $this->lng->txt('saved_successfully') . $mail_message;
801 
802  // same personal image
803  if ($this->isSettingChangeable('upload')) {
804  $this->uploadUserPicture();
805  }
806 
807  if ($profile_maybe_incomplete) {
810  if ($this->user_profile->isProfileIncomplete($user)) {
811  $this->object->setProfileIncomplete(true);
812  $this->object->update();
813  }
814  }
815 
816  // feedback
817  $this->tpl->setOnScreenMessage('success', $msg, true);
818 
819  if (strtolower($this->requested_baseClass) == 'iladministrationgui') {
820  $this->ctrl->redirectByClass('ilobjuserfoldergui', 'view');
821  } else {
822  $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
823  }
824  } else {
825  $this->form_gui->setValuesByPost();
826  $this->tabs_gui->activateTab('properties');
827  $this->tpl->setContent($this->form_gui->getHtml());
828  }
829  }
830 
831  public function getValues(): void
832  {
833  $data = [];
834 
835  // login data
836  $data['auth_mode'] = $this->object->getAuthMode();
837  $data['login'] = $this->object->getLogin();
838  $data['ext_account'] = $this->object->getExternalAccount();
839  $data['create_date'] = ilDatePresentation::formatDate(new ilDateTime(
840  $this->object->getCreateDate(),
842  ));
843  $data['owner'] = ilObjUser::_lookupLogin($this->object->getOwner());
844  $data['approve_date'] = ($this->object->getApproveDate() != '')
845  ? ilDatePresentation::formatDate(new ilDateTime($this->object->getApproveDate(), IL_CAL_DATETIME))
846  : null;
847 
848  $data['last_login'] = ($this->object->getLastLogin() != '')
849  ? ilDatePresentation::formatDate(new ilDateTime($this->object->getLastLogin(), IL_CAL_DATETIME))
850  : null;
851  $data['active'] = $this->object->getActive();
852  $data['time_limit_unlimited'] = $this->object->getTimeLimitUnlimited() ? '1' : '0';
853 
854  $data['time_limit_from'] = $this->object->getTimeLimitFrom()
855  ? new ilDateTime($this->object->getTimeLimitFrom(), IL_CAL_UNIX)
856  : null;
857  $data['time_limit_until'] = $this->object->getTimeLimitUntil()
858  ? new ilDateTime($this->object->getTimeLimitUntil(), IL_CAL_UNIX)
859  : null;
860 
861  $data['gender'] = $this->object->getGender();
862  $data['firstname'] = $this->object->getFirstname();
863  $data['lastname'] = $this->object->getLastname();
864  $data['title'] = $this->object->getUTitle();
865  $data['birthday'] = $this->object->getBirthday()
866  ? new ilDate($this->object->getBirthday(), IL_CAL_DATE)
867  : null;
868  $data['institution'] = $this->object->getInstitution();
869  $data['department'] = $this->object->getDepartment();
870  $data['street'] = $this->object->getStreet();
871  $data['city'] = $this->object->getCity();
872  $data['zipcode'] = $this->object->getZipcode();
873  $data['country'] = $this->object->getCountry();
874  $data['sel_country'] = $this->object->getSelectedCountry();
875  $data['phone_office'] = $this->object->getPhoneOffice();
876  $data['phone_home'] = $this->object->getPhoneHome();
877  $data['phone_mobile'] = $this->object->getPhoneMobile();
878  $data['fax'] = $this->object->getFax();
879  $data['email'] = $this->object->getEmail();
880  $data['second_email'] = $this->object->getSecondEmail();
881  $data['hobby'] = $this->object->getHobby();
882  $data['referral_comment'] = $this->object->getComment();
883 
884  $data['interests_general'] = $this->object->getGeneralInterests();
885  $data['interests_help_offered'] = $this->object->getOfferingHelp();
886  $data['interests_help_looking'] = $this->object->getLookingForHelp();
887 
888  $data['matriculation'] = $this->object->getMatriculation();
889  $data['client_ip'] = $this->object->getClientIP();
890 
891  $this->user_defined_fields = ilUserDefinedFields::_getInstance();
892  $user_defined_data = $this->object->getUserDefinedData();
893  foreach ($this->user_defined_fields->getDefinitions() as $field_id => $definition) {
894  $data['udf_' . $field_id] = $user_defined_data['f_' . $field_id] ?? '';
895  }
896 
897  $data['language'] = $this->object->getLanguage();
898  $data['skin_style'] = $this->object->skin . ':' . $this->object->prefs['style'];
899  $data['session_reminder_lead_time'] =
900  $this->object->prefs['session_reminder_lead_time'] ??
901  ilSessionReminder::byLoggedInUser()->getGlobalSessionReminderLeadTime();
902  $data['hide_own_online_status'] = $this->object->prefs['hide_own_online_status'] ?? '';
903  $data['bs_allow_to_contact_me'] = ($this->object->prefs['bs_allow_to_contact_me'] ?? '') == 'y';
904  $data['chat_osc_accept_msg'] = ($this->object->prefs['chat_osc_accept_msg'] ?? '') == 'y';
905  $data['chat_broadcast_typing'] = ($this->object->prefs['chat_broadcast_typing'] ?? '') == 'y';
906 
907  $data['send_mail'] = (($this->object->prefs['send_info_mails'] ?? '') == 'y');
908 
909  $this->form_gui->setValuesByArray($data);
910  }
911 
915  public function initForm(string $a_mode): void
916  {
917  $settings = $this->settings->getAll();
918 
919  $this->form_gui = new ilPropertyFormGUI();
920  $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
921  if ($a_mode == 'create') {
922  $this->form_gui->setTitle($this->lng->txt('usr_new'));
923  } else {
924  $this->form_gui->setTitle($this->lng->txt('usr_edit'));
925  }
926 
927  // login data
928  $sec_l = new ilFormSectionHeaderGUI();
929  $sec_l->setTitle($this->lng->txt('login_data'));
930  $this->form_gui->addItem($sec_l);
931 
932  // authentication mode
933  $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
934  $am = new ilSelectInputGUI($this->lng->txt('auth_mode'), 'auth_mode');
935  $option = [];
936  foreach ($active_auth_modes as $auth_name => $auth_key) {
937  if ($auth_name == 'default') {
938  $name = $this->lng->txt('auth_' . $auth_name) . ' (' . $this->lng->txt('auth_' . ilAuthUtils::_getAuthModeName($auth_key)) . ')';
939  } else {
940  $name = ilAuthUtils::getAuthModeTranslation((string) $auth_key, $auth_name);
941  }
942  $option[$auth_name] = $name;
943  }
944  $am->setOptions($option);
945  $this->form_gui->addItem($am);
946 
947  if ($a_mode == 'edit') {
948  $id = new ilNonEditableValueGUI($this->lng->txt('usr_id'), 'id');
949  $id->setValue($this->object->getId());
950  $this->form_gui->addItem($id);
951  }
952 
953  $lo = new ilUserLoginInputGUI($this->lng->txt('login'), 'login');
954  $lo->setRequired(true);
955  if ($a_mode == 'edit') {
956  $lo->setCurrentUserId($this->object->getId());
957  try {
958  $last_history_entry = ilObjUser::_getLastHistoryDataByUserId($this->object->getId());
959  $lo->setInfo(
960  sprintf(
961  $this->lng->txt('usr_loginname_history_info'),
962  ilDatePresentation::formatDate(new ilDateTime($last_history_entry[1], IL_CAL_UNIX)),
963  $last_history_entry[0]
964  )
965  );
966  } catch (ilUserException $e) {
967  }
968  }
969 
970  $this->form_gui->addItem($lo);
971 
972  if ($this->user->getId() === (int) SYSTEM_USER_ID
973  || !in_array(SYSTEM_ROLE_ID, $this->rbac_review->assignedRoles($this->object->getId()))
974  || in_array(SYSTEM_ROLE_ID, $this->rbac_review->assignedRoles($this->user->getId()))) {
975  $pw = new ilPasswordInputGUI($this->lng->txt('passwd'), 'passwd');
976  $pw->setUseStripSlashes(false);
977  $pw->setSize(32);
978  $pw->setMaxLength(80);
979  $pw->setValidateAuthPost('auth_mode');
980  if ($a_mode == 'create') {
981  $pw->setRequiredOnAuth(true);
982  }
983  if ($this->user->getId() !== (int) SYSTEM_USER_ID
984  && in_array(SYSTEM_ROLE_ID, $this->rbac_review->assignedRoles($this->object->getId()))
985  && !in_array(SYSTEM_ROLE_ID, $this->rbac_review->assignedRoles($this->user->getId()))) {
986  $pw->setDisabled(true);
987  }
989  $this->form_gui->addItem($pw);
990  }
991 
993  $ext = new ilTextInputGUI($this->lng->txt('user_ext_account'), 'ext_account');
994  $ext->setSize(40);
995  $ext->setMaxLength(250);
996  $ext->setInfo($this->lng->txt('user_ext_account_desc'));
997  $this->form_gui->addItem($ext);
998  }
999 
1000  $sec_si = new ilFormSectionHeaderGUI();
1001  $sec_si->setTitle($this->lng->txt('system_information'));
1002  $this->form_gui->addItem($sec_si);
1003 
1004  // create date, approve date, agreement date, last login
1005  if ($a_mode == 'edit') {
1006  $sia = [
1007  'create_date' => '',
1008  'approve_date' => '',
1009  ...$this->legal_documents->userManagementFields($this->object),
1010  'last_login' => '',
1011  'owner' => '',
1012  ];
1013  foreach ($sia as $a => $v) {
1014  if (is_string($v)) {
1015  $siai = new ilNonEditableValueGUI($this->lng->txt($a), $a);
1016  $siai->setValue($v);
1017  $this->form_gui->addItem($siai);
1018  } else {
1019  $this->form_gui->addItem($v);
1020  }
1021  }
1022  }
1023 
1024  $ac = new ilCheckboxInputGUI($this->lng->txt('active'), 'active');
1025  $ac->setChecked(true);
1026  $this->form_gui->addItem($ac);
1027 
1028  $this->lng->loadLanguageModule('crs');
1029 
1030  $radg = new ilRadioGroupInputGUI($this->lng->txt('time_limit'), 'time_limit_unlimited');
1031  $radg->setValue('1');
1032  $radg->setRequired(true);
1033  $op1 = new ilRadioOption($this->lng->txt('user_access_unlimited'), '1');
1034  $radg->addOption($op1);
1035  $op2 = new ilRadioOption($this->lng->txt('user_access_limited'), '0');
1036  $radg->addOption($op2);
1037 
1038  $acfrom = new ilDateTimeInputGUI($this->lng->txt('crs_from'), 'time_limit_from');
1039  $acfrom->setRequired(true);
1040  $acfrom->setShowTime(true);
1041  $acfrom->setMinuteStepSize(1);
1042  $op2->addSubItem($acfrom);
1043 
1044  $acto = new ilDateTimeInputGUI($this->lng->txt('crs_to'), 'time_limit_until');
1045  $acto->setRequired(true);
1046  $acto->setShowTime(true);
1047  $acto->setMinuteStepSize(1);
1048  $op2->addSubItem($acto);
1049 
1050  $this->form_gui->addItem($radg);
1051 
1052  if ($this->isSettingChangeable('gender')
1053  || $this->isSettingChangeable('firstname')
1054  || $this->isSettingChangeable('lastname')
1055  || $this->isSettingChangeable('title')
1056  || $this->isSettingChangeable('personal_image')
1057  || $this->isSettingChangeable('birhtday')
1058  ) {
1059  $sec_pd = new ilFormSectionHeaderGUI();
1060  $sec_pd->setTitle($this->lng->txt('personal_data'));
1061  $this->form_gui->addItem($sec_pd);
1062  }
1063 
1064  if ($this->isSettingChangeable('gender')) {
1065  $gndr = new ilRadioGroupInputGUI($this->lng->txt('salutation'), 'gender');
1066  $gndr->setRequired(isset($settings['require_gender']) && $settings['require_gender']);
1067  $neutral = new ilRadioOption($this->lng->txt('salutation_n'), 'n');
1068  $gndr->addOption($neutral);
1069  $female = new ilRadioOption($this->lng->txt('salutation_f'), 'f');
1070  $gndr->addOption($female);
1071  $male = new ilRadioOption($this->lng->txt('salutation_m'), 'm');
1072  $gndr->addOption($male);
1073  $this->form_gui->addItem($gndr);
1074  }
1075 
1076  $fields = [
1077  'firstname' => true,
1078  'lastname' => true,
1079  'title' => isset($settings['require_title']) && $settings['require_title']
1080  ];
1081  foreach ($fields as $field => $req) {
1082  $max_len = $field === 'title' ? 32 : 128;
1083  if ($this->isSettingChangeable($field)) {
1084  // #18795
1085  $caption = ($field == 'title')
1086  ? 'person_title'
1087  : $field;
1088  $inp = new ilTextInputGUI($this->lng->txt($caption), $field);
1089  $inp->setSize(32);
1090  $inp->setMaxLength($max_len);
1091  $inp->setRequired($req);
1092  $this->form_gui->addItem($inp);
1093  }
1094  }
1095 
1096  // personal image
1097  if ($this->isSettingChangeable('upload')) {
1098  $pi = new ilImageFileInputGUI($this->lng->txt('personal_picture'), 'userfile');
1099  if ($a_mode == 'edit' || $a_mode == 'upload') {
1101  $this->object->getId(),
1102  'small',
1103  true,
1104  true
1105  ));
1106  }
1107  $this->form_gui->addItem($pi);
1108  }
1109 
1110  if ($this->isSettingChangeable('birthday')) {
1111  $birthday = new ilBirthdayInputGUI($this->lng->txt('birthday'), 'birthday');
1112  $birthday->setRequired(isset($settings['require_birthday']) && $settings['require_birthday']);
1113  $this->form_gui->addItem($birthday);
1114  }
1115 
1116  // institution, department, street, city, zip code, country, phone office
1117  // phone home, phone mobile, fax, e-mail
1118  $fields = [
1119  ['institution', 40, 80],
1120  ['department', 40, 80],
1121  ['street', 40, 40],
1122  ['city', 40, 40],
1123  ['zipcode', 10, 10],
1124  ['country', 40, 40],
1125  ['sel_country'],
1126  ['phone_office', 30, 30],
1127  ['phone_home', 30, 30],
1128  ['phone_mobile', 30, 30],
1129  ['fax', 30, 30]
1130  ];
1131 
1132  $counter = 0;
1133  foreach ($fields as $field) {
1134  if (!$counter++ and $this->isSettingChangeable($field[0])) {
1135  // contact data
1136  $sec_cd = new ilFormSectionHeaderGUI();
1137  $sec_cd->setTitle($this->lng->txt('contact_data'));
1138  $this->form_gui->addItem($sec_cd);
1139 
1140  // org units
1141  if ($a_mode == 'edit') {
1142  $orgus = new ilNonEditableValueGUI($this->lng->txt('objs_orgu'), 'org_units');
1143  $orgus->setValue($this->object->getOrgUnitsRepresentation());
1144  $this->form_gui->addItem($orgus);
1145  }
1146  }
1147  if ($this->isSettingChangeable($field[0])) {
1148  if ($field[0] != 'sel_country') {
1149  $inp = new ilTextInputGUI($this->lng->txt($field[0]), $field[0]);
1150  $inp->setSize($field[1]);
1151  $inp->setMaxLength($field[2]);
1152  $inp->setRequired(isset($settings['require_' . $field[0]]) &&
1153  $settings['require_' . $field[0]]);
1154  $this->form_gui->addItem($inp);
1155  } else {
1156  // country selection
1157  $cs = new ilCountrySelectInputGUI($this->lng->txt($field[0]), $field[0]);
1158  $cs->setRequired(isset($settings['require_' . $field[0]]) &&
1159  $settings['require_' . $field[0]]);
1160  $this->form_gui->addItem($cs);
1161  }
1162  }
1163  }
1164 
1165  if ($this->isSettingChangeable('email')) {
1166  $em = new ilEMailInputGUI($this->lng->txt('email'), 'email');
1167  $em->setRequired(isset($settings['require_email']) && $settings['require_email']);
1168  $em->setMaxLength(128);
1169  $this->form_gui->addItem($em);
1170  }
1171 
1172  if ($this->isSettingChangeable('second_email')) {
1173  $em = new ilEMailInputGUI($this->lng->txt('second_email'), 'second_email');
1174 
1175  $this->form_gui->addItem($em);
1176  }
1177 
1178  if ($this->isSettingChangeable('hobby')) {
1179  $hob = new ilTextAreaInputGUI($this->lng->txt('hobby'), 'hobby');
1180  $hob->setRows(3);
1181  $hob->setCols(40);
1182  $hob->setRequired(isset($settings['require_hobby']) &&
1183  $settings['require_hobby']);
1184  $this->form_gui->addItem($hob);
1185  }
1186 
1187  if ($this->isSettingChangeable('referral_comment')) {
1188  $rc = new ilTextAreaInputGUI($this->lng->txt('referral_comment'), 'referral_comment');
1189  $rc->setRows(3);
1190  $rc->setCols(40);
1191  $rc->setRequired(isset($settings['require_referral_comment']) &&
1192  $settings['require_referral_comment']);
1193  $this->form_gui->addItem($rc);
1194  }
1195 
1196  $sh = new ilFormSectionHeaderGUI();
1197  $sh->setTitle($this->lng->txt('interests'));
1198  $this->form_gui->addItem($sh);
1199 
1200  $multi_fields = ['interests_general', 'interests_help_offered', 'interests_help_looking'];
1201  foreach ($multi_fields as $multi_field) {
1202  if ($this->isSettingChangeable($multi_field)) {
1203  // see ilUserProfile
1204  $ti = new ilTextInputGUI($this->lng->txt($multi_field), $multi_field);
1205  $ti->setMulti(true);
1206  $ti->setMaxLength(40);
1207  $ti->setSize(40);
1208  $ti->setRequired(isset($settings['require_' . $multi_field]) &&
1209  $settings['require_' . $multi_field]);
1210  $this->form_gui->addItem($ti);
1211  }
1212  }
1213 
1214  if ($this->isSettingChangeable('user_profile_other')) {
1215  $sec_oi = new ilFormSectionHeaderGUI();
1216  $sec_oi->setTitle($this->lng->txt('user_profile_other'));
1217  $this->form_gui->addItem($sec_oi);
1218  }
1219 
1220  if ($this->isSettingChangeable('matriculation')) {
1221  $mr = new ilTextInputGUI($this->lng->txt('matriculation'), 'matriculation');
1222  $mr->setSize(40);
1223  $mr->setMaxLength(40);
1224  $mr->setRequired(isset($settings['require_matriculation']) &&
1225  $settings['require_matriculation']);
1226  $this->form_gui->addItem($mr);
1227  }
1228 
1229  $ip = new ilTextInputGUI($this->lng->txt('client_ip'), 'client_ip');
1230  $ip->setSize(40);
1231  $ip->setMaxLength(255);
1232  $ip->setInfo($this->lng->txt('current_ip') . ' ' . $_SERVER['REMOTE_ADDR'] . ' <br />' .
1233  '<span class="warning">' . $this->lng->txt('current_ip_alert') . '</span>');
1234  $this->form_gui->addItem($ip);
1235 
1236  $user_defined_fields = ilUserDefinedFields::_getInstance();
1237 
1238  if ($this->usrf_ref_id == USER_FOLDER_ID) {
1239  $all_defs = $user_defined_fields->getDefinitions();
1240  } else {
1241  $all_defs = $user_defined_fields->getChangeableLocalUserAdministrationDefinitions();
1242  }
1243 
1244  foreach ($all_defs as $definition) {
1245  $f_property = ilCustomUserFieldsHelper::getInstance()->getFormPropertyForDefinition($definition, true);
1246  if ($f_property instanceof ilFormPropertyGUI) {
1247  $this->form_gui->addItem($f_property);
1248  }
1249  }
1250 
1251  if ($a_mode == 'create'
1252  || $this->isSettingChangeable('language')
1253  || $this->isSettingChangeable('skin_style')
1254  || $this->isSettingChangeable('hide_own_online_status')
1255  || $this->isSettingChangeable('bs_allow_to_contact_me')
1256  || $this->isSettingChangeable('chat_osc_accept_msg')
1257  || $this->isSettingChangeable('chat_broadcast_typing')
1258  || ($this->isSettingChangeable('session_reminder'))
1259  ) {
1260  $sec_st = new ilFormSectionHeaderGUI();
1261  $sec_st->setTitle($this->lng->txt('settings'));
1262  $this->form_gui->addItem($sec_st);
1263  }
1264 
1265  if ($a_mode == 'create') {
1266  $role = new ilSelectInputGUI(
1267  $this->lng->txt('default_role'),
1268  'default_role'
1269  );
1270  $role->setRequired(true);
1271  $role->setValue($this->default_role);
1272  $role->setOptions($this->selectable_roles);
1273  $this->form_gui->addItem($role);
1274  }
1275 
1276  if ($this->isSettingChangeable('language')) {
1277  $languages = $this->lng->getInstalledLanguages();
1278  $this->lng->loadLanguageModule('meta');
1279  $options = [];
1280  foreach ($languages as $l) {
1281  $options[$l] = $this->lng->txt('meta_l_' . $l);
1282  }
1283  $lang = new ilSelectInputGUI(
1284  $this->lng->txt('language'),
1285  'language'
1286  );
1287  $lang->setOptions($options);
1288  $lang->setValue($this->settings->get('language'));
1289  if (count($options) <= 1) {
1290  $lang->setDisabled(true);
1291  }
1292  $this->form_gui->addItem($lang);
1293  }
1294 
1295  if ($this->isSettingChangeable('skin_style')) {
1296  $sk = new ilSelectInputGUI(
1297  $this->lng->txt('skin_style'),
1298  'skin_style'
1299  );
1300 
1301  $skins = ilStyleDefinition::getAllSkins();
1302 
1303  $options = [];
1304  if (is_array($skins)) {
1305  $sk = new ilSelectInputGUI($this->lng->txt('skin_style'), 'skin_style');
1306 
1307  $options = [];
1308  foreach ($skins as $skin) {
1309  foreach ($skin->getStyles() as $style) {
1310  if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId())) {
1311  continue;
1312  }
1313 
1314  $options[$skin->getId() . ':' . $style->getId()] = $skin->getName() . ' / ' . $style->getName();
1315  }
1316  }
1317  }
1318  $sk->setOptions($options);
1319  $sk->setValue($this->default_layout_and_style);
1320 
1321  $this->form_gui->addItem($sk);
1322  }
1323 
1324  if ($this->isSettingChangeable('hide_own_online_status')) {
1325  $this->lng->loadLanguageModule('awrn');
1326 
1327  $default = ($this->settings->get('hide_own_online_status') == 'n')
1328  ? $this->lng->txt('user_awrn_show')
1329  : $this->lng->txt('user_awrn_hide');
1330 
1331  $options = [
1332  '' => $this->lng->txt('user_awrn_default') . ' (' . $default . ')',
1333  'n' => $this->lng->txt('user_awrn_show'),
1334  'y' => $this->lng->txt('user_awrn_hide')
1335  ];
1336  $os = new ilSelectInputGUI($this->lng->txt('awrn_user_show'), 'hide_own_online_status');
1337  $os->setOptions($options);
1338  $os->setDisabled((bool) $this->settings->get('usr_settings_disable_hide_own_online_status'));
1339  $os->setInfo($this->lng->txt('awrn_hide_from_awareness_info'));
1340  $this->form_gui->addItem($os);
1341  }
1342 
1343  if ($this->isSettingChangeable('bs_allow_to_contact_me')) {
1344  $this->lng->loadLanguageModule('buddysystem');
1345  $os = new ilCheckboxInputGUI($this->lng->txt('buddy_allow_to_contact_me'), 'bs_allow_to_contact_me');
1346  if ($a_mode == 'create') {
1347  $os->setChecked(ilUtil::yn2tf($this->settings->get('bs_allow_to_contact_me', 'n')));
1348  }
1349  $this->form_gui->addItem($os);
1350  }
1351  if ($this->isSettingChangeable('chat_osc_accept_msg')) {
1352  $this->lng->loadLanguageModule('chatroom');
1353  $chat_osc_acm = new ilCheckboxInputGUI($this->lng->txt('chat_osc_accept_msg'), 'chat_osc_accept_msg');
1354  if ($a_mode == 'create') {
1355  $chat_osc_acm->setChecked(ilUtil::yn2tf($this->settings->get('chat_osc_accept_msg', 'n')));
1356  }
1357  $this->form_gui->addItem($chat_osc_acm);
1358  }
1359 
1360  if ($this->isSettingChangeable('session_reminder')) {
1361  $session_reminder = new ilNumberInputGUI(
1362  $this->lng->txt('session_reminder_input'),
1363  'session_reminder_lead_time'
1364  );
1365  $expires = ilSession::getSessionExpireValue();
1366  $session_reminder_object = ilSessionReminder::byLoggedInUser();
1367  $session_reminder->setInfo(
1368  sprintf(
1369  $this->lng->txt('session_reminder_lead_time_info'),
1372  ilDatePresentation::secondsToString($expires, true)
1373  )
1374  );
1375  $session_reminder->setValue(
1376  (string) $session_reminder_object->getGlobalSessionReminderLeadTime()
1377  );
1378  $session_reminder->setSize(3);
1379  $session_reminder->setMinValue(ilSessionReminder::LEAD_TIME_DISABLED);
1380  $session_reminder->setMaxValue($session_reminder_object->getMaxPossibleLeadTime());
1381  $this->form_gui->addItem($session_reminder);
1382  }
1383 
1384  if ($this->isSettingChangeable('send_mail')) {
1385  $sec_op = new ilFormSectionHeaderGUI();
1386  $sec_op->setTitle($this->lng->txt('options'));
1387  $this->form_gui->addItem($sec_op);
1388  }
1389 
1390  $se = new ilCheckboxInputGUI($this->lng->txt('inform_user_mail'), 'send_mail');
1391  $se->setInfo($this->lng->txt('inform_user_mail_info'));
1392  $se->setValue('y');
1393  $se->setChecked(($this->user->getPref('send_info_mails') == 'y'));
1394  $this->form_gui->addItem($se);
1395 
1396  $irf = new ilCheckboxInputGUI($this->lng->txt('ignore_required_fields'), 'ignore_rf');
1397  $irf->setInfo($this->lng->txt('ignore_required_fields_info'));
1398  $irf->setValue('1');
1399  $this->form_gui->addItem($irf);
1400 
1401  if ($a_mode == 'create' || $a_mode == 'save') {
1402  $this->form_gui->addCommandButton('save', $this->lng->txt('save'));
1403  }
1404  if ($a_mode == 'edit' || $a_mode == 'update') {
1405  $this->form_gui->addCommandButton('update', $this->lng->txt('save'));
1406  }
1407  $this->form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
1408  }
1409 
1410  protected function isSettingChangeable(string $a_field): bool
1411  {
1412  static $settings = null;
1413 
1414  if ($this->usrf_ref_id == USER_FOLDER_ID) {
1415  return true;
1416  }
1417 
1418  if ($settings == null) {
1419  $settings = $this->settings->getAll();
1420  }
1421  return (bool) ($settings['usr_settings_changeable_lua_' . $a_field] ?? false);
1422  }
1423 
1428  protected function uploadUserPicture(): void
1429  {
1430  $userfile_input = $this->form_gui->getItemByPostVar('userfile');
1431  if ($_FILES['userfile']['tmp_name'] == '') {
1432  if ($userfile_input->getDeletionFlag()) {
1433  $this->object->removeUserPicture();
1434  }
1435  return;
1436  }
1437  if ($_FILES['userfile']['size'] == 0) {
1438  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_file'));
1439  } else {
1440  $store_file = 'usr_' . $this->object->getId() . '.' . 'jpg';
1441 
1442  $rid = $this->moveFileToStorage();
1443 
1444  if ($rid === null) {
1445  return;
1446  }
1447 
1448  $this->object->setAvatarRid($rid->serialize());
1449  $this->irss->flavours()->ensure($rid, new ilUserProfilePictureDefinition());
1450 
1451  $this->object->setPref('profile_image', $store_file); // this may be dropped with the next release
1452  $this->object->update();
1453  }
1454  }
1455 
1457  {
1458  $uploads = $this->uploads->getResults();
1459  $upload_tmp_name = $_FILES['userfile']['tmp_name'];
1460  $avatar_upload_result = $uploads[$upload_tmp_name] ?? null;
1461 
1462  $existing_rid = null;
1463  if ($this->object->getAvatarRid() !== null) {
1464  $existing_rid = $this->irss->manage()->find($this->object->getAvatarRid());
1465  }
1466 
1467  $revision_title = 'Avatar for user ' . $this->object->getLogin();
1468  $this->stakeholder->setOwner($this->object->getId()); // The Resource is owned by the user we are editing
1469 
1470  if ($avatar_upload_result === null && file_exists($upload_tmp_name)) {
1471  $stream = Streams::ofResource(
1472  fopen($upload_tmp_name, 'r')
1473  );
1474 
1475  if ($existing_rid === null) {
1476  return $this->irss->manage()->stream($stream, $this->stakeholder, $revision_title);
1477  }
1478 
1479  $this->irss->manage()->appendNewRevisionFromStream(
1480  $existing_rid,
1481  $stream,
1482  $this->stakeholder,
1483  $revision_title
1484  );
1485  return $existing_rid;
1486  }
1487 
1488  if ($avatar_upload_result === null) {
1489  return null;
1490  }
1491 
1492  if ($existing_rid === null) {
1493  return $this->irss->manage()->upload(
1494  $avatar_upload_result,
1495  $this->stakeholder,
1496  $revision_title
1497  );
1498  }
1499 
1500  $this->irss->manage()->replaceWithUpload(
1501  $existing_rid,
1502  $avatar_upload_result,
1503  $this->stakeholder,
1504  $revision_title
1505  );
1506  return $existing_rid;
1507  }
1508 
1509  public function removeUserPictureObject(): void
1510  {
1511  $webspace_dir = ilFileUtils::getWebspaceDir();
1512  $image_dir = $webspace_dir . '/usr_images';
1513  $file = $image_dir . '/usr_' . $this->object->getId() . '.' . 'jpg';
1514  $thumb_file = $image_dir . '/usr_' . $this->object->getId() . '_small.jpg';
1515  $xthumb_file = $image_dir . '/usr_' . $this->object->getId() . '_xsmall.jpg';
1516  $xxthumb_file = $image_dir . '/usr_' . $this->object->getId() . '_xxsmall.jpg';
1517  $upload_file = $image_dir . '/upload_' . $this->object->getId();
1518 
1519  // remove user pref file name
1520  $this->object->setPref('profile_image', '');
1521  $this->object->update();
1522  $this->tpl->setOnScreenMessage('success', $this->lng->txt('user_image_removed'));
1523 
1524  if (is_file($file)) {
1525  unlink($file);
1526  }
1527  if (is_file($thumb_file)) {
1528  unlink($thumb_file);
1529  }
1530  if (is_file($xthumb_file)) {
1531  unlink($xthumb_file);
1532  }
1533  if (is_file($xxthumb_file)) {
1534  unlink($xxthumb_file);
1535  }
1536  if (is_file($upload_file)) {
1537  unlink($upload_file);
1538  }
1539 
1540  $this->editObject();
1541  }
1542 
1543  public function assignSaveObject(): void
1544  {
1545  if (!$this->rbac_system->checkAccess('edit_roleassignment', $this->usrf_ref_id)) {
1546  $this->ilias->raiseError(
1547  $this->lng->txt('msg_no_perm_assign_role_to_user'),
1548  $this->ilias->error_obj->MESSAGE
1549  );
1550  }
1551 
1552  $selected_roles = $this->user_request->getRoleIds();
1553  $posted_roles = $this->user_request->getPostedRoleIds();
1554 
1555  // prevent unassignment of system role from system user
1556  if ($this->object->getId() == SYSTEM_USER_ID && in_array(SYSTEM_ROLE_ID, $posted_roles)) {
1557  $selected_roles[] = SYSTEM_ROLE_ID;
1558  }
1559 
1560  $global_roles_all = $this->rbac_review->getGlobalRoles();
1561  $assigned_roles_all = $this->rbac_review->assignedRoles($this->object->getId());
1562  $assigned_roles = array_intersect($assigned_roles_all, $posted_roles);
1563  $assigned_global_roles_all = array_intersect($assigned_roles_all, $global_roles_all);
1564  $assigned_global_roles = array_intersect($assigned_global_roles_all, $posted_roles);
1565 
1566  $user_not_allowed_to_change_admin_role_assginements =
1567  !in_array(SYSTEM_ROLE_ID, $this->rbac_review->assignedRoles($this->user->getId()));
1568 
1569  if ($user_not_allowed_to_change_admin_role_assginements
1570  && in_array(SYSTEM_ROLE_ID, $assigned_roles_all)) {
1571  $selected_roles[] = SYSTEM_ROLE_ID;
1572  }
1573 
1574  $posted_global_roles = array_intersect($selected_roles, $global_roles_all);
1575 
1576  if (empty($selected_roles) && count($assigned_roles_all) === count($assigned_roles)
1577  || empty($posted_global_roles) && count($assigned_global_roles_all) === count($assigned_global_roles)) {
1578  $this->tpl->setOnScreenMessage(
1579  'failure',
1580  $this->lng->txt('msg_min_one_role') . '<br/>' . $this->lng->txt('action_aborted'),
1581  true
1582  );
1583  $this->ctrl->redirect($this, 'roleassignment');
1584  }
1585 
1586  foreach (array_diff($assigned_roles, $selected_roles) as $role) {
1587  if ($this->object->getId() === (int) SYSTEM_USER_ID && $role === SYSTEM_ROLE_ID
1588  || $user_not_allowed_to_change_admin_role_assginements && $role === SYSTEM_ROLE_ID) {
1589  continue;
1590  }
1591  $this->rbac_admin->deassignUser($role, $this->object->getId());
1592  }
1593 
1594  foreach (array_diff($selected_roles, $assigned_roles) as $role) {
1595  if ($this->object->getId() === (int) SYSTEM_USER_ID && $role === SYSTEM_ROLE_ID
1596  || $user_not_allowed_to_change_admin_role_assginements && $role === SYSTEM_ROLE_ID) {
1597  continue;
1598  }
1599  $this->rbac_admin->assignUser($role, $this->object->getId(), false);
1600  }
1601 
1602  $this->object->update();
1603 
1604  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_roleassignment_changed'), true);
1605 
1606  if (strtolower($this->requested_baseClass) == 'iladministrationgui') {
1607  $this->ctrl->redirect($this, 'roleassignment');
1608  } else {
1609  $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
1610  }
1611  }
1612 
1613  public function roleassignmentObject(): void
1614  {
1615  $this->tabs->activateTab('role_assignment');
1616 
1617  if (!$this->checkAccessToRolesTab()) {
1618  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_view_roles_of_user'), true);
1619  $this->ctrl->redirectByClass(self::class, 'edit');
1620  }
1621 
1622  $req_filtered_roles = $this->user_request->getFilteredRoles();
1624  'filtered_roles',
1625  ($req_filtered_roles > 0) ? $req_filtered_roles : ilSession::get('filtered_roles')
1626  );
1627 
1628  $filtered_roles = ilSession::get('filtered_roles');
1629  if ($filtered_roles > 5) {
1630  ilSession::set('filtered_roles', 0);
1631  }
1632 
1633  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.usr_role_assignment.html', 'components/ILIAS/User');
1634 
1635  // init table
1636  $tab = new ilRoleAssignmentTableGUI($this, 'roleassignment');
1637 
1638  $tab->parse($this->object->getId());
1639  $this->tpl->setVariable('ROLES_TABLE', $tab->getHTML());
1640  }
1641 
1642  public function applyFilterObject(): void
1643  {
1644  $table_gui = new ilRoleAssignmentTableGUI($this, 'roleassignment');
1645  $table_gui->writeFilterToSession();
1646  $table_gui->resetOffset();
1647  $this->roleassignmentObject();
1648  }
1649 
1650  public function resetFilterObject(): void
1651  {
1652  $table_gui = new ilRoleAssignmentTableGUI($this, 'roleassignment');
1653  $table_gui->resetOffset();
1654  $table_gui->resetFilter();
1655  $this->roleassignmentObject();
1656  }
1657 
1658  public function __getDateSelect(
1659  string $a_type,
1660  string $a_varname,
1661  string $a_selected
1662  ): string {
1663  $year = null;
1664  switch ($a_type) {
1665  case 'minute':
1666  for ($i = 0; $i <= 60; $i++) {
1667  $days[$i] = $i < 10 ? '0' . $i : $i;
1668  }
1669  return ilLegacyFormElementsUtil::formSelect($a_selected, $a_varname, $days, false, true);
1670 
1671  case 'hour':
1672  for ($i = 0; $i < 24; $i++) {
1673  $days[$i] = $i < 10 ? '0' . $i : $i;
1674  }
1675  return ilLegacyFormElementsUtil::formSelect($a_selected, $a_varname, $days, false, true);
1676 
1677  case 'day':
1678  for ($i = 1; $i < 32; $i++) {
1679  $days[$i] = $i < 10 ? '0' . $i : $i;
1680  }
1681  return ilLegacyFormElementsUtil::formSelect($a_selected, $a_varname, $days, false, true);
1682 
1683  case 'month':
1684  for ($i = 1; $i < 13; $i++) {
1685  $month[$i] = $i < 10 ? '0' . $i : $i;
1686  }
1687  return ilLegacyFormElementsUtil::formSelect($a_selected, $a_varname, $month, false, true);
1688 
1689  case 'year':
1690  if ($a_selected < date('Y')) {
1691  $start = $a_selected;
1692  } else {
1693  $start = date('Y');
1694  }
1695 
1696  for ($i = $start; $i < ((int) date('Y') + 11); ++$i) {
1697  $year[$i] = $i;
1698  }
1699  return ilLegacyFormElementsUtil::formSelect($a_selected, $a_varname, $year, false, true);
1700  }
1701  return '';
1702  }
1703 
1704  public function __toUnix(array $a_time_arr): int // Missing array type.
1705  {
1706  return mktime(
1707  $a_time_arr['hour'],
1708  $a_time_arr['minute'],
1709  $a_time_arr['second'],
1710  $a_time_arr['month'],
1711  $a_time_arr['day'],
1712  $a_time_arr['year']
1713  );
1714  }
1715 
1716  public function __unsetSessionVariables(): void
1717  {
1718  ilSession::clear('filtered_roles');
1719  }
1720 
1721  public function __buildFilterSelect(): string
1722  {
1723  $action[0] = $this->lng->txt('assigned_roles');
1724  $action[1] = $this->lng->txt('all_roles');
1725  $action[2] = $this->lng->txt('all_global_roles');
1726  $action[3] = $this->lng->txt('all_local_roles');
1727  $action[4] = $this->lng->txt('internal_local_roles_only');
1728  $action[5] = $this->lng->txt('non_internal_local_roles_only');
1729 
1731  ilSession::get('filtered_roles'),
1732  'filter',
1733  $action,
1734  false,
1735  true
1736  );
1737  }
1738 
1743  protected function addAdminLocatorItems(bool $do_not_add_object = false): void
1744  {
1745  $this->locator->clearItems();
1746 
1747  if ($this->admin_mode == 'settings') { // system settings
1748  $this->ctrl->setParameterByClass(
1749  'ilobjsystemfoldergui',
1750  'ref_id',
1752  );
1753  $this->locator->addItem(
1754  $this->lng->txt('administration'),
1755  $this->ctrl->getLinkTargetByClass(['iladministrationgui', 'ilobjsystemfoldergui'], ''),
1756  ilFrameTargetInfo::_getFrame('MainContent')
1757  );
1758 
1759  if ($this->requested_ref_id == USER_FOLDER_ID) {
1760  $this->locator->addItem(
1761  $this->lng->txt('obj_' . ilObject::_lookupType(
1762  ilObject::_lookupObjId($this->requested_ref_id)
1763  )),
1764  $this->ctrl->getLinkTargetByClass('ilobjuserfoldergui', 'view')
1765  );
1766  } elseif ($this->requested_ref_id == ROLE_FOLDER_ID) {
1767  $this->locator->addItem(
1768  $this->lng->txt('obj_' . ilObject::_lookupType(
1769  ilObject::_lookupObjId($this->requested_ref_id)
1770  )),
1771  $this->ctrl->getLinkTargetByClass('ilobjrolefoldergui', 'view')
1772  );
1773  }
1774 
1775  if ($this->obj_id > 0) {
1776  $this->locator->addItem(
1777  $this->object->getTitle(),
1778  $this->ctrl->getLinkTarget($this, 'view')
1779  );
1780  }
1781  }
1782  }
1783 
1784  public function __sendProfileMail(): string
1785  {
1786  if ($this->user_request->getSendMail() != 'y') {
1787  return '';
1788  }
1789  if (!strlen($this->object->getEmail())) {
1790  return '';
1791  }
1792 
1793  $usr_lang = new ilLanguage($this->object->getLanguage());
1794  $usr_lang->loadLanguageModule('crs');
1795  $usr_lang->loadLanguageModule('registration');
1796 
1797  $mmail = new ilMimeMail();
1798  $mmail->From($this->mail_sender_factory->system());
1799 
1800  $mailOptions = new ilMailOptions($this->object->getId());
1801  $mmail->To($mailOptions->getExternalEmailAddresses());
1802 
1803  $subject = $usr_lang->txt('profile_changed');
1804  $body = $usr_lang->txt('reg_mail_body_salutation')
1805  . ' ' . $this->object->getFullname() . ",\n\n";
1806 
1807  $date = $this->object->getApproveDate();
1808 
1809  if ($date !== null && (time() - strtotime($date)) < 10) {
1810  $body .= $usr_lang->txt('reg_mail_body_approve') . "\n\n";
1811  } else {
1812  $body .= $usr_lang->txt('reg_mail_body_profile_changed') . "\n\n";
1813  }
1814 
1815  // Append login info only if password has been changed
1816  if ($this->user_request->getPassword() != '') {
1817  $body .= $usr_lang->txt('reg_mail_body_text2') . "\n" .
1818  ILIAS_HTTP_PATH . '/login.php?client_id=' . $this->ilias->client_id . "\n" .
1819  $usr_lang->txt('login') . ': ' . $this->object->getLogin() . "\n" .
1820  $usr_lang->txt('passwd') . ': ' . $this->user_request->getPassword() . "\n\n";
1821  }
1822  $body .= $usr_lang->txt('reg_mail_body_text3') . "\n";
1823  $body .= $this->object->getProfileAsString($usr_lang);
1825 
1826 
1827  $mmail->Subject($subject, true);
1828  $mmail->Body($body);
1829  $mmail->Send();
1830 
1831  return '<br/>' . $this->lng->txt('mail_sent');
1832  }
1833 
1837  public static function _goto(string $a_target): void
1838  {
1839  global $DIC;
1840 
1841  $ilUser = $DIC['ilUser'];
1842 
1844  $ilCtrl = $DIC['ilCtrl'];
1845 
1846  // #10888
1847  if ($a_target == md5('usrdelown')) {
1848  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
1849  $ilUser->hasDeletionFlag()) {
1850  $ilCtrl->setTargetScript('ilias.php');
1851  $ilCtrl->redirectByClass(['ildashboardgui', 'ilpersonalsettingsgui'], 'deleteOwnAccountStep2');
1852  }
1853  exit('This account is not flagged for deletion.'); // #12160
1854  }
1855 
1856  // badges
1857  if (substr($a_target, -4) == '_bdg') {
1858  $ilCtrl->redirectByClass('ilDashboardGUI', 'jumpToBadges');
1859  }
1860 
1861  if ('registration' == $a_target) {
1862  $ilCtrl->redirectByClass(['ilStartUpGUI', 'ilAccountRegistrationGUI'], '');
1863  } elseif ('nameassist' == $a_target) {
1864  $ilCtrl->redirectByClass(['ilStartUpGUI', 'ilPasswordAssistanceGUI'], 'showUsernameAssistanceForm');
1865  } elseif ('pwassist' == $a_target) {
1866  $ilCtrl->redirectByClass(['ilStartUpGUI', 'ilPasswordAssistanceGUI'], '');
1867  } else {
1868  $target = $DIC['legalDocuments']->findGotoLink($a_target);
1869  if ($target->isOK()) {
1870  $ilCtrl->setTargetScript('ilias.php');
1871  foreach ($target->value()->queryParams() as $key => $value) {
1872  $ilCtrl->setParameterByClass($target->value()->guiName(), (string) $key, $value);
1873  }
1874  $ilCtrl->redirectByClass($target->value()->guiPath(), $target->value()->command());
1875  }
1876  }
1877 
1878  if (strpos($a_target, 'n') === 0) {
1879  $a_target = ilObjUser::_lookupId(ilUtil::stripSlashes(substr($a_target, 1)));
1880  }
1881 
1882  $target_user = 0;
1883  $target_cmd = '';
1884  if (is_numeric($a_target)) {
1885  $target_user = (int) $a_target;
1886  } elseif ($target_array = explode('_', $a_target, 3)) {
1887  $target_cmd = $target_array[2];
1888  $target_user = (int) $target_array[0];
1889  }
1890 
1891  if ($target_user > 0) {
1892  $ilCtrl->setParameterByClass(ilPublicUserProfileGUI::class, 'user_id', $target_user);
1893  }
1894 
1895  $cmd = 'view';
1896  if ($target_cmd === 'contact_approved') {
1897  $cmd = 'approveContactRequest';
1898  } elseif ($target_cmd === 'contact_ignored') {
1899  $cmd = 'ignoreContactRequest';
1900  }
1901  $ilCtrl->redirectByClass([ilPublicUserProfileGUI::class], $cmd);
1902  }
1903 
1908  protected function handleIgnoredRequiredFields(): bool
1909  {
1910  $profile_maybe_incomplete = false;
1911 
1912  foreach ($this->user_profile->getIgnorableRequiredSettings() as $fieldName) {
1913  $elm = $this->form_gui->getItemByPostVar($fieldName);
1914 
1915  if (!$elm) {
1916  continue;
1917  }
1918 
1919  if ($elm->getRequired()) {
1920  $profile_maybe_incomplete = true;
1921 
1922  // Flag as optional
1923  $elm->setRequired(false);
1924  }
1925  }
1926 
1927  $user_defined_fields = ilUserDefinedFields::_getInstance();
1928  foreach ($user_defined_fields->getDefinitions() as $definition) {
1929  $elm = $this->form_gui->getItemByPostVar('udf_' . $definition['field_id']);
1930 
1931  if (!$elm) {
1932  continue;
1933  }
1934 
1935  if ($elm->getRequired() && $definition['required']) {
1936  $profile_maybe_incomplete = true;
1937 
1938  // Flag as optional
1939  $elm->setRequired(false);
1940  }
1941  }
1942 
1943  return $profile_maybe_incomplete;
1944  }
1945 
1946  private function checkUserWriteRight(): void
1947  {
1948  if ($this->usrf_ref_id === USER_FOLDER_ID
1949  && (
1950  !$this->rbac_system->checkAccess('visible,read', $this->usrf_ref_id)
1951  || !$this->rbac_system->checkAccess('write', $this->usrf_ref_id)
1952  && (
1953  !$this->access->checkPositionAccess(\ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, $this->usrf_ref_id)
1954  || $this->access->checkPositionAccess(\ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, $this->usrf_ref_id)
1955  && !in_array(
1956  $this->object->getId(),
1957  $this->access->filterUserIdsByPositionOfCurrentUser(
1960  [$this->object->getId()]
1961  )
1962  )
1963  )
1964  )
1965  ) {
1966  $this->ilias->raiseError($this->lng->txt('msg_no_perm_modify_user'), $this->ilias->error_obj->MESSAGE);
1967  }
1968 
1969  // if called from local administration $this->usrf_ref_id is category id
1970  // Todo: this has to be fixed. Do not mix user folder id and category id
1971  if ($this->usrf_ref_id != USER_FOLDER_ID
1972  && !$this->rbac_system->checkAccess('cat_administrate_users', $this->object->getTimeLimitOwner())) {
1973  $this->ilias->raiseError($this->lng->txt('msg_no_perm_modify_user'), $this->ilias->error_obj->MESSAGE);
1974  }
1975  }
1976 
1977  private function renderForm(): void
1978  {
1979  $this->tpl->setContent($this->legal_documents->userManagementModals() . $this->form_gui->getHTML());
1980  }
1981 
1982  private function checkAccessToRolesTab(): bool
1983  {
1984  return $this->object->getId() !== (int) ANONYMOUS_USER_ID
1985  && (
1986  $this->rbac_system->checkAccess('edit_roleassignment', $this->usrf_ref_id)
1987  || $this->access->checkPositionAccess(\ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, $this->usrf_ref_id)
1988  && in_array(
1989  $this->object->getId(),
1990  $this->access->filterUserIdsByPositionOfCurrentUser(
1993  [$this->object->getId()]
1994  )
1995  )
1996  );
1997  }
1998 }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
setUTitle(string $a_str)
set user title (note: don&#39;t mix up this method with setTitle() that is derived from ilObject and sets...
string $default_layout_and_style
static get(string $a_var)
ilMailMimeSenderFactory $mail_sender_factory
setTimeLimitUnlimited(bool $a_unlimited)
This class represents an option in a radio group.
setClientIP(string $a_str)
ilUserDefinedFields $user_defined_fields
RepositoryGUIs $repository_guis
createObject()
Display user create form.
const IL_CAL_DATETIME
const ANONYMOUS_USER_ID
Definition: constants.php:27
const USER_FOLDER_ID
Definition: constants.php:33
static getAuthModeTranslation(string $a_auth_key, string $auth_name='')
static _getAuthMode(?string $a_auth_mode)
string $requested_baseClass
This class represents a selection list property in a property form.
static _lookupActivatedStyle(string $a_skin, string $a_style)
lookup if a style is activated
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
UserGUIRequest $user_request
handleIgnoredRequiredFields()
Handles ignored required fields by changing the required flag of form elements.
This class represents a selection list property in a property form.
setMatriculation(string $a_str)
Additional user data fields definition.
prepareOutput(bool $show_sub_objects=true)
setPhoneOffice(string $a_str)
const SYSTEM_ROLE_ID
Definition: constants.php:29
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
Help GUI class.
setSelectedCountry(string $a_val)
Set selected country (selection drop down)
setFullname()
builds a string with title + firstname + lastname method is used to build fullname in member variable...
const PASSWD_PLAIN
loadUserDefinedDataFromForm(?ilObjUser $user=null)
This class represents a user login property in a property form.
Class ilUserProfile.
FileUpload $uploads
initForm(string $a_mode)
Init user form.
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
static _lookupId($a_user_str)
addAdminLocatorItems(bool $do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded) ...
setOptions(array $a_options)
static _getActiveAuthModes()
This class represents a email property in a property form.
static prepareFormOutput($a_str, bool $a_strip=false)
const IL_CAL_UNIX
setTimeLimitUntil(?int $a_until)
static _getAuthModeName($a_auth_key)
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
isSettingChangeable(string $a_field)
uploadUserPicture()
upload user image (original method by ratana ty)
setInstitution(string $a_str)
setCity(string $a_str)
const SYSTEM_FOLDER_ID
Definition: constants.php:35
setBackTarget(string $a_text, string $a_link)
set back tab target
setLatitude(?string $a_latitude)
setComment(string $a_str)
setGender(string $a_str)
static _allowPasswordModificationByAuthMode($a_auth_mode)
Allow password modification.
This class represents a date/time property in a property form.
static _lookupObjId(int $ref_id)
setExternalAccount(string $a_str)
catch(\Exception $e) $req
Definition: xapiproxy.php:91
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setBirthday(?string $a_birthday)
static _getLastHistoryDataByUserId(int $a_usr_id)
Returns the last used loginname and the changedate of the passed user_id.
setLogin(string $a_str)
setActive(bool $a_active, int $a_owner=0)
set user active state and updates system fields appropriately
This class represents a property in a property form.
loadValuesFromForm(string $a_mode='create')
setDepartment(string $a_str)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setOfferingHelp(?array $value=null)
This class represents a number property in a property form.
ResourceStakeholder $stakeholder
setPhoneHome(string $a_str)
__toUnix(array $a_time_arr)
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
Class ilObjectGUI Basic methods of all Output classes.
global $DIC
Definition: shib_login.php:26
const UDF_TYPE_TEXT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Conductor $legal_documents
This class represents a password property in a property form.
Class ilObjForumAdministration.
setHobby(string $a_str)
getResults()
Returns the results of the processing and moving operation of the uploaded files. ...
Class FileUpload.
Definition: FileUpload.php:37
setUseStripSlashes(bool $a_stat)
En/disable use of stripslashes.
static _isExternalAccountEnabled()
Check if an external account name is required.
setRequired(bool $a_required)
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
const ROLE_FOLDER_ID
Definition: constants.php:34
exit
setCountry(string $a_str)
setEmail(string $a_str)
setFax(string $a_str)
$lang
Definition: xapiexit.php:25
setPhoneMobile(string $a_str)
setLastname(string $a_str)
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
setStreet(string $a_str)
This class represents an image file property in a property form.
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
const IL_CAL_DATE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
setTimeLimitOwner(int $a_owner)
This class represents a text area property in a property form.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
saveObject()
save user data
setSecondEmail(?string $second_email)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
updateObject()
updates object entry in object_data
setLongitude(?string $a_longitude)
setLocationZoom(?int $a_locationzoom)
This class represents a text property in a property form.
static yn2tf(string $a_yn)
setZipcode(string $a_str)
ilPropertyFormGUI $form_gui
setUserDefinedData(array $a_data)
static _getFrame(string $a_class)
Class ilObjUserGUI.
static _getAssignUsersStatus(int $a_role_id)
static _lookupType(int $id, bool $reference=false)
setGeneralInterests(?array $value=null)
setTimeLimitFrom(?int $a_from)
setFirstname(string $a_str)
static getSessionExpireValue()
Returns the session expiration value.
static clear(string $a_var)
ilSetting $settings
Class ilObjUserTrackingGUI.
static set(string $a_var, $a_val)
Set a value.
setAuthMode(?string $a_str)
ResourceStorageServices $irss
ilUserProfile $user_profile
__getDateSelect(string $a_type, string $a_varname, string $a_selected)
static _getInstallationSignature()
static _lookupLogin(int $a_user_id)
setLookingForHelp(?array $value=null)