ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPersonalProfileGUI Class Reference

GUI class for personal profile. More...

+ Collaboration diagram for ilPersonalProfileGUI:

Public Member Functions

 executeCommand ()
 
 workWithUserSetting (string $setting)
 
 userSettingVisible (string $setting)
 
 userSettingEnabled (string $setting)
 
 uploadUserPicture ()
 
 removeUserPicture ()
 
 showProfile ()
 show profile form More...
 
 addLocationToForm (ilPropertyFormGUI $a_form, ilObjUser $a_user)
 Add location fields to form if activated. More...
 
 setTabs ()
 
 __showOtherInformations ()
 
 __showUserDefinedFields ()
 
 setHeader ()
 
 showPersonalData (bool $a_no_init=false)
 
 initPersonalDataForm ()
 
 savePersonalData ()
 
 goToEmailConfirmation ()
 
 changeEmail ()
 
 showPublicProfile (bool $a_no_init=false)
 
 initPublicProfileForm ()
 
 showPublicProfileFields (ilPropertyFormGUI $form, array $prefs, ?object $parent=null, bool $anonymized=false, string $key_suffix='')
 
 savePublicProfile ()
 
 showExportImport ()
 
 exportPersonalData ()
 
 downloadPersonalData ()
 Download personal data export file. More...
 
 importPersonalDataSelection ()
 
 initPersonalDataImportForm ()
 
 importPersonalData ()
 

Data Fields

const CHANGE_EMAIL_CMD = 'changeEmail'
 

Protected Member Functions

 getProfilePortfolio ()
 
 getCheckedValues ()
 
 showChecklist (int $active_step)
 

Private Member Functions

 buildInfoText ()
 
 emailChanged ()
 
 emailCompletionForced ()
 
 addEmailChangeModal ()
 
 loginChanged ()
 
 updateLoginOrSetErrorMessages ()
 
 savePersonalDataForm ()
 
 tempStorePicture ()
 

Private Attributes

const PERSONAL_DATA_FORM_ID = 'pd'
 
ilGlobalTemplateInterface $tpl
 
ilUserDefinedFields $user_defined_fields = null
 
ilAppEventHandler $eventHandler
 
ilPropertyFormGUI $form
 
ilSetting $settings
 
ilObjUser $user
 
ilAuthSession $auth_session
 
StaticUrlServices $static_url
 
Language $lng
 
ilCtrl $ctrl
 
ilTabsGUI $tabs
 
ilToolbarGUI $toolbar
 
ilHelpGUI $help
 
ilErrorHandling $error_handler
 
ilProfileChecklistGUI $checklist
 
ilUserSettingsConfig $user_settings_config
 
ChecklistStatus $checklist_status
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
ChangeMailTokenRepository $change_mail_token_repo
 
PromptRepository $prompt_repository
 
GUIRequest $profile_request
 
ilLogger $logger
 
FileUpload $uploads
 
IRSS $irss
 
ResourceStakeholder $stakeholder
 
Interruptive $email_change_confirmation_modal = null
 

Detailed Description

Member Function Documentation

◆ __showOtherInformations()

ilPersonalProfileGUI::__showOtherInformations ( )

Definition at line 393 of file class.ilPersonalProfileGUI.php.

References userSettingVisible().

393  : bool
394  {
395  $d_set = new ilSetting('delicous');
396  if ($this->userSettingVisible('matriculation') or count($this->user_defined_fields->getVisibleDefinitions())
397  or $d_set->get('user_profile') == '1') {
398  return true;
399  }
400  return false;
401  }
+ Here is the call graph for this function:

◆ __showUserDefinedFields()

ilPersonalProfileGUI::__showUserDefinedFields ( )

Definition at line 403 of file class.ilPersonalProfileGUI.php.

References ilLegacyFormElementsUtil\formSelect(), ilLegacyFormElementsUtil\prepareFormOutput(), UDF_TYPE_TEXT, and ILIAS\Repository\user().

403  : bool
404  {
405  $user_defined_data = $this->user->getUserDefinedData();
406  foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
407  if ($definition['field_type'] == UDF_TYPE_TEXT) {
408  $this->tpl->setCurrentBlock('field_text');
409  $this->tpl->setVariable(
410  'FIELD_VALUE',
411  ilLegacyFormElementsUtil::prepareFormOutput($user_defined_data[$field_id])
412  );
413  if (!$definition['changeable']) {
414  $this->tpl->setVariable('DISABLED_FIELD', 'disabled="disabled"');
415  }
416  $this->tpl->setVariable('FIELD_NAME', 'udf[' . $definition['field_id'] . ']');
417  } else {
418  if ($definition['changeable']) {
419  $name = 'udf[' . $definition['field_id'] . ']';
420  $disabled = false;
421  } else {
422  $name = '';
423  $disabled = true;
424  }
425  $this->tpl->setCurrentBlock('field_select');
426  $this->tpl->setVariable(
427  'SELECT_BOX',
429  $user_defined_data[$field_id],
430  $name,
431  $this->user_defined_fields->fieldValuesToSelectArray(
432  $definition['field_values']
433  ),
434  false,
435  true,
436  0,
437  '',
438  [],
439  $disabled
440  )
441  );
442  }
443  $this->tpl->parseCurrentBlock();
444  $this->tpl->setCurrentBlock('user_defined');
445 
446  if ($definition['required']) {
447  $name = $definition['field_name'] . '<span class="asterisk">*</span>';
448  } else {
449  $name = $definition['field_name'];
450  }
451  $this->tpl->setVariable('TXT_FIELD_NAME', $name);
452  $this->tpl->parseCurrentBlock();
453  }
454  return true;
455  }
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 prepareFormOutput($a_str, bool $a_strip=false)
const UDF_TYPE_TEXT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ addEmailChangeModal()

ilPersonalProfileGUI::addEmailChangeModal ( )
private

Definition at line 620 of file class.ilPersonalProfileGUI.php.

References $id, $message, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilRegistrationSettings\IL_REG_ACTIVATION, ILIAS\Repository\lng(), ILIAS\Repository\settings(), and ILIAS\UI\Implementation\Component\withAdditionalOnLoadCode().

Referenced by savePersonalData().

620  : bool
621  {
622  $form_id = 'form_' . self::PERSONAL_DATA_FORM_ID;
623 
624  $message = $this->lng->txt('confirm_logout_for_email_change');
625  if ((int) $this->settings->get('new_registration_type', '1') === ilRegistrationSettings::IL_REG_ACTIVATION) {
626  $message .= '<br>' . $this->lng->txt('confirm_logout_for_email_change_with_confirmation');
627  }
628 
629  $modal = $this->ui_factory->modal()->interruptive(
630  $this->lng->txt('confirm'),
631  $message,
632  ''
633  )->withActionButtonLabel($this->lng->txt('change'));
634  $this->email_change_confirmation_modal = $modal->withOnLoad($modal->getShowSignal())
636  static function ($id) use ($form_id) {
637  return "var button = {$id}.querySelector('input[type=\"submit\"]'); "
638  . "button.addEventListener('click', (e) => {e.preventDefault();"
639  . "document.getElementById('{$form_id}').submit();});";
640  }
641  );
642 
643  $this->form->setFormAction($this->ctrl->getFormActionByClass(self::class, 'goToEmailConfirmation'));
644  return true;
645  }
form( $class_path, string $cmd, string $submit_caption="")
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addLocationToForm()

ilPersonalProfileGUI::addLocationToForm ( ilPropertyFormGUI  $a_form,
ilObjUser  $a_user 
)

Add location fields to form if activated.

Definition at line 302 of file class.ilPersonalProfileGUI.php.

References ilPropertyFormGUI\addItem(), ilObjUser\getCity(), ilObjUser\getCountry(), ilMapUtil\getDefaultSettings(), ilObjUser\getLatitude(), ilObjUser\getLocationZoom(), ilObjUser\getLongitude(), ilObjUser\getStreet(), ILIAS\Repository\int(), ilMapUtil\isActivated(), ILIAS\Repository\lng(), null, and ilLocationInputGUI\setLatitude().

Referenced by initPersonalDataForm().

302  : void
303  {
304  // check map activation
305  if (!ilMapUtil::isActivated()) {
306  return;
307  }
308 
309  // Don't really know if this is still necessary...
310  $this->lng->loadLanguageModule('maps');
311 
312  // Get user settings
313  $latitude = ($a_user->getLatitude() != '')
314  ? (float) $a_user->getLatitude()
315  : null;
316  $longitude = ($a_user->getLongitude() != '')
317  ? (float) $a_user->getLongitude()
318  : null;
319  $zoom = $a_user->getLocationZoom();
320 
321  // Get Default settings, when nothing is set
322  if ($latitude == null && $longitude == null && $zoom == 0) {
324  $latitude = (float) $def['latitude'];
325  $longitude = (float) $def['longitude'];
326  $zoom = (int) $def['zoom'];
327  }
328 
329  $street = $a_user->getStreet();
330  if (!$street) {
331  $street = $this->lng->txt('street');
332  }
333  $city = $a_user->getCity();
334  if (!$city) {
335  $city = $this->lng->txt('city');
336  }
337  $country = $a_user->getCountry();
338  if (!$country) {
339  $country = $this->lng->txt('country');
340  }
341 
342  // location property
343  $loc_prop = new ilLocationInputGUI(
344  $this->lng->txt('location'),
345  'location'
346  );
347  $loc_prop->setLatitude($latitude);
348  $loc_prop->setLongitude($longitude);
349  $loc_prop->setZoom($zoom);
350  $loc_prop->setAddress($street . ',' . $city . ',' . $country);
351 
352  $a_form->addItem($loc_prop);
353  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getDefaultSettings()
Get default longitude, latitude and zoom.
This class represents a location property in a property form.
static isActivated()
Checks whether Map feature is activated.
setLatitude(?float $a_latitude)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildInfoText()

ilPersonalProfileGUI::buildInfoText ( )
private

Definition at line 490 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by showPersonalData().

490  : string
491  {
492  $change_mail_info = '';
493  if ($this->change_mail_token_repo->hasUserValidEmailConfirmationToken($this->user)) {
494  $change_mail_info = $this->lng->txt('change_email_info_message');
495  }
496 
497  $it = '';
498  if ($this->profile_request->getPrompted() === 1) {
499  $it = $this->prompt_repository->getSettings()->getPromptText($this->user->getLanguage());
500  }
501  if ($it === '') {
502  $it = $this->prompt_repository->getSettings()->getInfoText($this->user->getLanguage());
503  }
504  if (trim($it) === '') {
505  return $change_mail_info === ''
506  ? ''
507  : $this->ui_renderer->render($this->ui_factory->messageBox()->info($change_mail_info));
508  }
509 
510  if ($change_mail_info !== '') {
511  $it .= '<br>' . $change_mail_info;
512  }
513 
514  $pub_prof = in_array($this->user->prefs['public_profile'] ?? '', ['y', 'n', 'g'])
515  ? $this->user->prefs['public_profile']
516  : 'n';
517  $box = $this->ui_factory->messageBox()->info($it);
518  if ($pub_prof === 'n') {
519  $box = $box->withLinks(
520  [$this->ui_factory->link()->standard(
521  $this->lng->txt('user_make_profile_public'),
522  $this->ctrl->getLinkTarget($this, 'showPublicProfile')
523  )]
524  );
525  }
526  return $this->ui_renderer->render($box);
527  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ changeEmail()

ilPersonalProfileGUI::changeEmail ( )

Definition at line 788 of file class.ilPersonalProfileGUI.php.

References $token, $user, ilRegistrationSettings\IL_REG_ACTIVATION, ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), null, send(), ILIAS\Repository\settings(), showPublicProfile(), and ILIAS\Repository\user().

788  : void
789  {
790  $token = $this->change_mail_token_repo->getTokenForTokenString(
791  $this->profile_request->getToken(),
793  );
794 
795  if ($token === null) {
796  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('email_could_not_be_changed'));
797  $this->showPublicProfile();
798  return;
799  }
800 
801  if ($token->getStatus() === ChangeMailStatus::Login
802  && (int) $this->settings->get('new_registration_type', '1') === ilRegistrationSettings::IL_REG_ACTIVATION) {
803  (new ChangeMailMail(
804  $this->user,
805  $this->change_mail_token_repo->moveToNextStep($token, time())
806  ->getUriForStatus($this->static_url->builder()),
807  $this->lng,
808  $this->logger
809  ))->send($token->getNewEmail(), ChangeMailStatus::EmailConfirmation->getValidity($this->settings));
810  $this->tpl->setOnScreenMessage('info', $this->lng->txt('change_email_email_sent'));
811  $this->showPublicProfile();
812  return;
813  }
814 
815  $this->user->setEmail($token->getNewEmail());
816  $this->user->update();
817  $this->change_mail_token_repo->deleteEntryByToken($token->getToken());
818  $this->change_mail_token_repo->deleteExpiredEntries();
819 
820  $this->tpl->setOnScreenMessage(
821  'success',
822  $this->lng->txt('saved_successfully')
823  );
824  $this->showPublicProfile();
825  return;
826  }
showPublicProfile(bool $a_no_init=false)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$token
Definition: xapitoken.php:70
catch(ilCmiXapiException $e) send($response)
Definition: xapitoken.php:100
+ Here is the call graph for this function:

◆ downloadPersonalData()

ilPersonalProfileGUI::downloadPersonalData ( )

Download personal data export file.

Definition at line 1225 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\user().

1225  : void
1226  {
1227  $this->user->sendPersonalDataFile();
1228  }
+ Here is the call graph for this function:

◆ emailChanged()

ilPersonalProfileGUI::emailChanged ( )
private

Definition at line 595 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\form(), null, and ILIAS\Repository\user().

Referenced by savePersonalData().

595  : bool
596  {
597  $email_input = $this->form->getItemByPostVar('usr_email');
598  if ($email_input !== null && !$email_input->getDisabled()
599  && $this->form->getInput('usr_email') !== $this->user->getEmail()) {
600  return true;
601  }
602 
603  return false;
604  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ emailCompletionForced()

ilPersonalProfileGUI::emailCompletionForced ( )
private

Definition at line 606 of file class.ilPersonalProfileGUI.php.

References null, ILIAS\Repository\settings(), and ILIAS\Repository\user().

Referenced by savePersonalData(), and savePersonalDataForm().

606  : bool
607  {
608  $current_email = $this->user->getEmail();
609  if (
610  $this->user->getProfileIncomplete()
611  && $this->settings->get('require_email') === '1'
612  && ($current_email === null || $current_email === '')
613  ) {
614  return true;
615  }
616 
617  return false;
618  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPersonalProfileGUI::executeCommand ( )

Definition at line 136 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\ctrl(), ilPublicUserProfileGUI\setBackUrl(), setHeader(), setTabs(), showChecklist(), ILIAS\Repository\tabs(), and ILIAS\Repository\user().

136  : void
137  {
138  $next_class = $this->ctrl->getNextClass();
139 
140  switch ($next_class) {
141  case 'ilpublicuserprofilegui':
142  $pub_profile_gui = new ilPublicUserProfileGUI($this->user->getId());
143  $pub_profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'showPersonalData'));
144  $this->ctrl->forwardCommand($pub_profile_gui);
145  $this->tpl->printToStdout();
146  break;
147 
148  case 'iluserprivacysettingsgui':
149  $this->setHeader();
150  $this->setTabs();
151  $this->tabs->activateTab('visibility_settings');
152  $this->showChecklist(ChecklistStatus::STEP_VISIBILITY_OPTIONS);
153  $gui = new ilUserPrivacySettingsGUI();
154  $this->ctrl->forwardCommand($gui);
155  break;
156 
157  case strtolower(ilLegalDocumentsAgreementGUI::class):
158  $this->ctrl->forwardCommand(new ilLegalDocumentsAgreementGUI());
159  $this->tpl->printToStdout();
160  break;
161 
162  case strtolower(ilLegalDocumentsWithdrawalGUI::class):
163  $this->ctrl->forwardCommand(new ilLegalDocumentsWithdrawalGUI());
164  $this->tpl->printToStdout();
165  break;
166 
167  default:
168  $this->setTabs();
169  $cmd = $this->ctrl->getCmd('showPersonalData');
170  $this->$cmd();
171  break;
172  }
173  }
setBackUrl(string $backurl)
Set Back Link URL.
GUI class for public user profile presentation.
+ Here is the call graph for this function:

◆ exportPersonalData()

ilPersonalProfileGUI::exportPersonalData ( )

Definition at line 1215 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\user().

1215  : void
1216  {
1217  $this->user->exportPersonalData();
1218  $this->user->sendPersonalDataFile();
1219  $this->ctrl->redirect($this, 'showExportImport');
1220  }
+ Here is the call graph for this function:

◆ getCheckedValues()

ilPersonalProfileGUI::getCheckedValues ( )
protected

Definition at line 1151 of file class.ilPersonalProfileGUI.php.

References $post, and ILIAS\Repository\form().

Referenced by savePublicProfile().

1151  : array
1152  {
1153  $key_suffix = '';
1154  switch ($this->form->getInput('public_profile')) {
1155  case 'y':
1156  $key_suffix = '-1';
1157  break;
1158  case 'g':
1159  $key_suffix = '-2';
1160  break;
1161  }
1162 
1163  $checked_values = [];
1164  $post = $this->profile_request->getParsedBody();
1165  foreach ($post as $k => $v) {
1166  if (strpos($k, 'chk_') !== 0) {
1167  continue;
1168  }
1169  if (substr($k, -2) === $key_suffix) {
1170  $k = str_replace(['-1', '-2'], '', $k);
1171  }
1172  $checked_values[$k] = $v;
1173  }
1174  foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
1175  if (isset($post['chk_udf_' . $definition['field_id'] . $key_suffix])) {
1176  $checked_values['chk_udf_' . $definition['field_id']] = '1';
1177  }
1178  }
1179  return $checked_values;
1180  }
form( $class_path, string $cmd, string $submit_caption="")
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProfilePortfolio()

ilPersonalProfileGUI::getProfilePortfolio ( )
protected

Definition at line 843 of file class.ilPersonalProfileGUI.php.

References ilObjPortfolio\getDefaultPortfolio(), null, ILIAS\Repository\settings(), and ILIAS\Repository\user().

Referenced by initPublicProfileForm().

843  : ?int
844  {
845  if ($this->settings->get('user_portfolios')) {
846  return ilObjPortfolio::getDefaultPortfolio($this->user->getId());
847  }
848  return null;
849  }
static getDefaultPortfolio(int $a_user_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ goToEmailConfirmation()

ilPersonalProfileGUI::goToEmailConfirmation ( )

Definition at line 685 of file class.ilPersonalProfileGUI.php.

References $token, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), initPersonalDataForm(), loginChanged(), savePersonalDataForm(), ilSession\SESSION_CLOSE_USER, ilSession\setClosingContext(), showPersonalData(), updateLoginOrSetErrorMessages(), and ILIAS\Repository\user().

685  : void
686  {
687  $this->initPersonalDataForm();
688  if (!$this->form->checkInput()
689  || $this->loginChanged() && !$this->updateLoginOrSetErrorMessages()) {
690  $this->form->setValuesByPost();
691  $this->showPersonalData(true);
692  return;
693  }
694  $this->savePersonalDataForm();
695 
697  $this->auth_session->logout();
698  session_unset();
699  $token = $this->change_mail_token_repo->getNewTokenForUser(
700  $this->user,
701  $this->form->getInput('usr_email'),
702  time()
703  );
704  $this->ctrl->redirectToURL(
705  $token->getUriForStatus($this->static_url->builder())->__toString()
706  );
707  }
$token
Definition: xapitoken.php:70
const SESSION_CLOSE_USER
showPersonalData(bool $a_no_init=false)
form( $class_path, string $cmd, string $submit_caption="")
static setClosingContext(int $a_context)
set closing context (for statistics)
+ Here is the call graph for this function:

◆ importPersonalData()

ilPersonalProfileGUI::importPersonalData ( )

Definition at line 1274 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\form(), initPersonalDataImportForm(), ILIAS\Repository\lng(), setHeader(), ILIAS\Repository\tabs(), and ILIAS\Repository\user().

1274  : void
1275  {
1276  $this->initPersonalDataImportForm();
1277  if ($this->form->checkInput()) {
1278  $this->user->importPersonalData(
1279  $_FILES['file'],
1280  (bool) $this->form->getInput('profile_data'),
1281  (bool) $this->form->getInput('settings'),
1282  (bool) $this->form->getInput('notes'),
1283  (bool) $this->form->getInput('calendar')
1284  );
1285  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
1286  $this->ctrl->redirect($this, '');
1287  } else {
1288  $this->tabs->activateTab('export');
1289  $this->setHeader();
1290  $this->form->setValuesByPost();
1291  $this->tpl->setContent($this->form->getHTML());
1292  $this->tpl->printToStdout();
1293  }
1294  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:

◆ importPersonalDataSelection()

ilPersonalProfileGUI::importPersonalDataSelection ( )

Definition at line 1230 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\form(), initPersonalDataImportForm(), setHeader(), and ILIAS\Repository\tabs().

1230  : void
1231  {
1232  $this->tabs->activateTab('export');
1233  $this->setHeader();
1234 
1235  $this->initPersonalDataImportForm();
1236 
1237  $this->tpl->setContent($this->form->getHTML());
1238  $this->tpl->printToStdout();
1239  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:

◆ initPersonalDataForm()

ilPersonalProfileGUI::initPersonalDataForm ( )

Definition at line 529 of file class.ilPersonalProfileGUI.php.

References addLocationToForm(), ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilCustomUserFieldsHelper\getInstance(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by goToEmailConfirmation(), savePersonalData(), and showPersonalData().

529  : void
530  {
531  $input = [];
532 
533  $this->form = new ilPropertyFormGUI();
534  $this->form->setFormAction($this->ctrl->getFormAction($this));
535  $this->form->setId(self::PERSONAL_DATA_FORM_ID);
536 
537  $user_defined_data = $this->user->getUserDefinedData();
538 
539  foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
540  $value = $user_defined_data['f_' . $field_id] ?? '';
541  $changeable = $definition['changeable'] === 1 ? true : false;
542  $fprop = ilCustomUserFieldsHelper::getInstance()->getFormPropertyForDefinition(
543  $definition,
544  $changeable,
545  $value
546  );
547  if ($fprop instanceof ilFormPropertyGUI) {
548  $input['udf_' . $definition['field_id']] = $fprop;
549  }
550  }
551 
552  // standard fields
553  $up = new ilUserProfile();
554  $up->skipField('password');
555  $up->skipGroup('settings');
556  $up->skipGroup('preferences');
557 
558  $up->setAjaxCallback(
559  $this->ctrl->getLinkTargetByClass('ilPublicUserProfileGUI', 'doProfileAutoComplete', '', true)
560  );
561 
562  // standard fields
563  $up->addStandardFieldsToForm($this->form, $this->user, $input);
564 
565  $this->addLocationToForm($this->form, $this->user);
566 
567  $this->form->addCommandButton('savePersonalData', $this->lng->txt('user_save_continue'));
568  }
Class ilUserProfile.
form( $class_path, string $cmd, string $submit_caption="")
addLocationToForm(ilPropertyFormGUI $a_form, ilObjUser $a_user)
Add location fields to form if activated.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPersonalDataImportForm()

ilPersonalProfileGUI::initPersonalDataImportForm ( )

Definition at line 1241 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setRequired().

Referenced by importPersonalData(), and importPersonalDataSelection().

1241  : void
1242  {
1243  $this->form = new ilPropertyFormGUI();
1244 
1245  // input file
1246  $fi = new ilFileInputGUI($this->lng->txt('file'), 'file');
1247  $fi->setRequired(true);
1248  $fi->setSuffixes(['zip']);
1249  $this->form->addItem($fi);
1250 
1251  // profile data
1252  $cb = new ilCheckboxInputGUI($this->lng->txt('pd_profile_data'), 'profile_data');
1253  $this->form->addItem($cb);
1254 
1255  // settings
1256  $cb = new ilCheckboxInputGUI($this->lng->txt('settings'), 'settings');
1257  $this->form->addItem($cb);
1258 
1259  // personal notes
1260  $cb = new ilCheckboxInputGUI($this->lng->txt('notes'), 'notes');
1261  $this->form->addItem($cb);
1262 
1263  // calendar entries
1264  $cb = new ilCheckboxInputGUI($this->lng->txt('pd_private_calendars'), 'calendar');
1265  $this->form->addItem($cb);
1266 
1267  $this->form->addCommandButton('importPersonalData', $this->lng->txt('import'));
1268  $this->form->addCommandButton('showExportImport', $this->lng->txt('cancel'));
1269 
1270  $this->form->setTitle($this->lng->txt('pd_import_personal_data'));
1271  $this->form->setFormAction($this->ctrl->getFormAction($this));
1272  }
This class represents a file property in a property form.
setRequired(bool $a_required)
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPublicProfileForm()

ilPersonalProfileGUI::initPublicProfileForm ( )

Definition at line 851 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\form(), getProfilePortfolio(), ILIAS\Repository\lng(), ilFormPropertyGUI\setInfo(), ILIAS\Repository\settings(), showPublicProfileFields(), and ILIAS\Repository\user().

Referenced by savePublicProfile(), and showPublicProfile().

851  : void
852  {
853  $this->form = new ilPropertyFormGUI();
854 
855  $this->form->setTitle($this->lng->txt('user_publish_options'));
856  $this->form->setDescription($this->lng->txt('user_public_profile_info'));
857  $this->form->setFormAction($this->ctrl->getFormAction($this));
858 
859  $portfolio_id = $this->getProfilePortfolio();
860 
861  if (!$portfolio_id) {
862  // Activate public profile
863  $radg = new ilRadioGroupInputGUI($this->lng->txt('user_activate_public_profile'), 'public_profile');
864  $info = $this->lng->txt('user_activate_public_profile_info');
865  $profile_mode = new ProfileMode($this->lng, $this->settings, $this->user);
866  $pub_prof = $profile_mode->getMode();
867  $radg->setValue($pub_prof);
868  $op1 = new ilRadioOption($this->lng->txt('usr_public_profile_disabled'), 'n', $this->lng->txt('usr_public_profile_disabled_info'));
869  $radg->addOption($op1);
870  $op2 = new ilRadioOption($this->lng->txt('usr_public_profile_logged_in'), 'y');
871  $radg->addOption($op2);
872  if ($this->settings->get('enable_global_profiles')) {
873  $op3 = new ilRadioOption($this->lng->txt('usr_public_profile_global'), 'g');
874  $radg->addOption($op3);
875  }
876  $this->form->addItem($radg);
877 
878  // #11773
879  if ($this->settings->get('user_portfolios')) {
880  // #10826
881  $href = $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToPortfolio');
882  $prtf = '<br />' . $this->lng->txt('user_profile_portfolio');
883  $prtf .= '<br /><a href="' . $href . '">&raquo; ' .
884  $this->lng->txt('user_portfolios') . '</a>';
885  $info .= $prtf;
886  }
887 
888  $radg->setInfo($info);
889  } else {
890  $this->ctrl->setParameterByClass(ilDashboardGUI::class, 'prt_id', $portfolio_id);
891  $href = $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToPortfolio');
892  $this->ctrl->clearParameterByClass(ilDashboardGUI::class, 'prt_id');
893  $prtf = $this->lng->txt('user_profile_portfolio_selected');
894  $prtf .= '<br /><a href="' . $href . '">&raquo; ' .
895  $this->lng->txt('portfolio') . '</a>';
896 
897  $info = new ilCustomInputGUI($this->lng->txt('user_activate_public_profile'));
898  $info->setHtml($prtf);
899  $this->form->addItem($info);
900  $this->showPublicProfileFields($this->form, $this->user->prefs);
901  }
902 
903  if (isset($op2)) {
904  $this->showPublicProfileFields($this->form, $this->user->prefs, $op2, false, '-1');
905  }
906  if (isset($op3)) {
907  $this->showPublicProfileFields($this->form, $this->user->prefs, $op3, false, '-2');
908  }
909  $this->form->setForceTopButtons(true);
910  $this->form->addCommandButton('savePublicProfile', $this->lng->txt('user_save_continue'));
911  }
This class represents an option in a radio group.
This class represents a property in a property form.
form( $class_path, string $cmd, string $submit_caption="")
showPublicProfileFields(ilPropertyFormGUI $form, array $prefs, ?object $parent=null, bool $anonymized=false, string $key_suffix='')
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loginChanged()

ilPersonalProfileGUI::loginChanged ( )
private

Definition at line 647 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\form(), ILIAS\Repository\settings(), and ILIAS\Repository\user().

Referenced by goToEmailConfirmation(), and savePersonalData().

647  : bool
648  {
649  $login = $this->form->getInput('username');
650  if ((int) $this->settings->get('allow_change_loginname')
651  && $login !== $this->user->getLogin()) {
652  return true;
653  }
654 
655  return false;
656  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeUserPicture()

ilPersonalProfileGUI::removeUserPicture ( )

Definition at line 284 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\user().

284  : void
285  {
286  $this->user->removeUserPicture();
287  }
+ Here is the call graph for this function:

◆ savePersonalData()

ilPersonalProfileGUI::savePersonalData ( )

Definition at line 570 of file class.ilPersonalProfileGUI.php.

References addEmailChangeModal(), ILIAS\Repository\ctrl(), emailChanged(), emailCompletionForced(), ILIAS\Repository\form(), initPersonalDataForm(), ILIAS\Repository\lng(), loginChanged(), savePersonalDataForm(), showPersonalData(), tempStorePicture(), and updateLoginOrSetErrorMessages().

570  : void
571  {
572  $this->initPersonalDataForm();
573 
574  $this->uploads->process();
575 
576  if (!$this->form->checkInput()
577  || !$this->emailCompletionForced()
578  && $this->emailChanged()
579  && $this->addEmailChangeModal()
580  || $this->loginChanged() && !$this->updateLoginOrSetErrorMessages()) {
581  $this->form->setValuesByPost();
582  $this->tempStorePicture();
583  $this->showPersonalData(true);
584  return;
585  }
586 
587  $this->savePersonalDataForm();
588 
589  $this->checklist_status->saveStepSucess(ChecklistStatus::STEP_PROFILE_DATA);
590  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
591 
592  $this->ctrl->redirect($this, 'showPublicProfile');
593  }
showPersonalData(bool $a_no_init=false)
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:

◆ savePersonalDataForm()

ilPersonalProfileGUI::savePersonalDataForm ( )
private

Definition at line 709 of file class.ilPersonalProfileGUI.php.

References Vendor\Package\$f, $location, emailCompletionForced(), ILIAS\Repository\form(), IL_CAL_DATE, ilMapUtil\isActivated(), null, uploadUserPicture(), and ILIAS\Repository\user().

Referenced by goToEmailConfirmation(), and savePersonalData().

709  : void
710  {
711  // if form field name differs from setter
712  $map = [
713  'firstname' => 'FirstName',
714  'lastname' => 'LastName',
715  'title' => 'UTitle',
716  'sel_country' => 'SelectedCountry',
717  'phone_office' => 'PhoneOffice',
718  'phone_home' => 'PhoneHome',
719  'phone_mobile' => 'PhoneMobile',
720  'referral_comment' => 'Comment',
721  'interests_general' => 'GeneralInterests',
722  'interests_help_offered' => 'OfferingHelp',
723  'interests_help_looking' => 'LookingForHelp'
724  ];
725  $up = new ilUserProfile();
726  foreach ($up->getStandardFields() as $f => $p) {
727  // if item is part of form, it is currently valid (if not disabled)
728  $item = $this->form->getItemByPostVar('usr_' . $f);
729  if ($item && !$item->getDisabled()) {
730  $value = $this->form->getInput('usr_' . $f);
731  switch ($f) {
732  case 'email':
733  if ($this->emailCompletionForced()) {
734  $this->user->setEmail($value);
735  }
736  break;
737  case 'birthday':
738  $value = $item->getDate();
739  $this->user->setBirthday($value
740  ? $value->get(IL_CAL_DATE)
741  : '');
742  break;
743  case 'second_email':
744  $this->user->setSecondEmail($value);
745  break;
746  default:
747  $m = $map[$f] ?? ucfirst($f);
748  $this->user->{'set' . $m}($value);
749  break;
750  }
751  }
752  }
753  $this->user->setFullname();
754 
755  // check map activation
756  if (ilMapUtil::isActivated()) {
757  // #17619 - proper escaping
758  $location = $this->form->getInput('location');
759  $this->user->setLatitude(is_numeric($location['latitude']) ? (string) $location['latitude'] : null);
760  $this->user->setLongitude(is_numeric($location['longitude']) ? (string) $location['longitude'] : null);
761  $this->user->setLocationZoom(is_numeric($location['zoom']) ? $location['zoom'] : null);
762  }
763 
764  // Set user defined data
765  $defs = $this->user_defined_fields->getVisibleDefinitions();
766  $udf = [];
767  foreach ($defs as $definition) {
768  $f = 'udf_' . $definition['field_id'];
769  $item = $this->form->getItemByPostVar($f);
770  if ($item && !$item->getDisabled()) {
771  $udf[$definition['field_id']] = $this->form->getInput($f);
772  }
773  }
774  $this->user->setUserDefinedData($udf);
775 
776  $this->uploadUserPicture();
777 
778  // profile ok
779  $this->user->setProfileIncomplete(false);
780 
781  // save user data & object_data
782  $this->user->setTitle($this->user->getFullname());
783  $this->user->setDescription($this->user->getEmail());
784 
785  $this->user->update();
786  }
$location
Definition: buildRTE.php:22
Class ilUserProfile.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static isActivated()
Checks whether Map feature is activated.
form( $class_path, string $cmd, string $submit_caption="")
const IL_CAL_DATE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePublicProfile()

ilPersonalProfileGUI::savePublicProfile ( )

Definition at line 1071 of file class.ilPersonalProfileGUI.php.

References $handler, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilSession\get(), getCheckedValues(), ilBadgeHandler\getInstance(), initPublicProfileForm(), ILIAS\Repository\lng(), ilUtil\redirect(), ilSession\set(), ilLuceneIndexer\updateLuceneIndex(), ilBadgeAssignment\updatePositions(), and ILIAS\Repository\user().

1071  : void
1072  {
1073  $key_suffix = '';
1074 
1075  $this->initPublicProfileForm();
1076  if ($this->form->checkInput()) {
1077  // with active portfolio no options are presented
1078  if ($this->form->getInput('public_profile') != '') {
1079  $this->user->setPref('public_profile', $this->form->getInput('public_profile'));
1080  }
1081 
1082  // if check on Institute
1083  $val_array = ['title', 'birthday', 'gender', 'org_units',
1084  'institution', 'department', 'upload', 'street', 'zipcode',
1085  'city', 'country', 'sel_country', 'phone_office', 'phone_home',
1086  'phone_mobile', 'fax', 'email', 'second_email', 'hobby',
1087  'matriculation', 'location', 'interests_general',
1088  'interests_help_offered', 'interests_help_looking'];
1089 
1090  // set public profile preferences
1091  $checked_values = $this->getCheckedValues();
1092  foreach ($val_array as $key => $value) {
1093  if ($checked_values['chk_' . $value] ?? false) {
1094  $this->user->setPref('public_' . $value, 'y');
1095  } else {
1096  $this->user->setPref('public_' . $value, 'n');
1097  }
1098  }
1099  // additional defined user data fields
1100  foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
1101  if ($checked_values['chk_udf_' . $definition['field_id']] ?? false) {
1102  $this->user->setPref('public_udf_' . $definition['field_id'], 'y');
1103  } else {
1104  $this->user->setPref('public_udf_' . $definition['field_id'], 'n');
1105  }
1106  }
1107 
1108  $this->user->update();
1109 
1110  switch ($this->form->getInput('public_profile')) {
1111  case 'y':
1112  $key_suffix = '-1';
1113  break;
1114  case 'g':
1115  $key_suffix = '-2';
1116  break;
1117  }
1118 
1120  if ($handler->isActive()) {
1121  $badgePositions = [];
1122  $bpos = $this->form->getInput('bpos' . $key_suffix);
1123  if (isset($bpos) && is_array($bpos)) {
1124  $badgePositions = $bpos;
1125  }
1126 
1127  if (count($badgePositions) > 0) {
1128  ilBadgeAssignment::updatePositions($this->user->getId(), $badgePositions);
1129  }
1130  }
1131 
1132  // update lucene index
1133  ilLuceneIndexer::updateLuceneIndex([(int) $this->user->getId()]);
1134 
1135  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
1136 
1137  $this->checklist_status->saveStepSucess(ChecklistStatus::STEP_PUBLISH_OPTIONS);
1138 
1139  if (ilSession::get('orig_request_target')) {
1140  $target = ilSession::get('orig_request_target');
1141  ilSession::set('orig_request_target', '');
1142  ilUtil::redirect($target);
1143  } else {
1144  $this->ctrl->redirectByClass('iluserprivacysettingsgui', '');
1145  }
1146  }
1147  $this->form->setValuesByPost();
1148  $this->tpl->showPublicProfile(true);
1149  }
static get(string $a_var)
static updateLuceneIndex(array $a_obj_ids)
Update lucene index.
static updatePositions(int $a_user_id, array $a_positions)
static redirect(string $a_script)
$handler
Definition: oai.php:30
form( $class_path, string $cmd, string $submit_caption="")
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ setHeader()

ilPersonalProfileGUI::setHeader ( )

Definition at line 457 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\lng().

Referenced by executeCommand(), importPersonalData(), importPersonalDataSelection(), showExportImport(), showPersonalData(), and showPublicProfile().

457  : void
458  {
459  $this->tpl->setTitle($this->lng->txt('personal_profile'));
460  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTabs()

ilPersonalProfileGUI::setTabs ( )

Definition at line 356 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\help(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by executeCommand().

356  : void
357  {
358  $this->help->setScreenIdComponent('user');
359 
360  // personal data
361  $this->tabs->addTab(
362  'personal_data',
363  $this->lng->txt('user_profile_data'),
364  $this->ctrl->getLinkTarget($this, 'showPersonalData')
365  );
366 
367  // publishing options
368  $this->tabs->addTab(
369  'public_profile',
370  $this->lng->txt('user_publish_options'),
371  $this->ctrl->getLinkTarget($this, 'showPublicProfile')
372  );
373 
374  // visibility settings
375  $txt_visibility = $this->checklist_status->anyVisibilitySettings()
376  ? $this->lng->txt('user_visibility_settings')
377  : $this->lng->txt('preview');
378  $this->tabs->addTab(
379  'visibility_settings',
380  $txt_visibility,
381  $this->ctrl->getLinkTargetByClass('ilUserPrivacySettingsGUI', '')
382  );
383 
384  // export
385  $this->tabs->addTab(
386  'export',
387  $this->lng->txt('export') . '/' . $this->lng->txt('import'),
388  $this->ctrl->getLinkTarget($this, 'showExportImport')
389  );
390  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showChecklist()

ilPersonalProfileGUI::showChecklist ( int  $active_step)
protected

Definition at line 1296 of file class.ilPersonalProfileGUI.php.

References $tpl, and ILIAS\UICore\GlobalTemplate\setRightContent().

Referenced by executeCommand(), showPersonalData(), and showPublicProfile().

1296  : void
1297  {
1298  $main_tpl = $this->tpl;
1299  $main_tpl->setRightContent($this->checklist->render($active_step));
1300  }
setRightContent(string $a_html)
Sets content of right column.
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showExportImport()

ilPersonalProfileGUI::showExportImport ( )

Definition at line 1182 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), setHeader(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

1182  : void
1183  {
1184  $this->tabs->activateTab('export');
1185  $this->setHeader();
1186 
1187  $button = $this->ui_factory->link()->standard(
1188  $this->lng->txt('pd_export_profile'),
1189  $this->ctrl->getLinkTarget($this, 'exportPersonalData')
1190  );
1191  $this->toolbar->addStickyItem($button);
1192 
1193  $exp_file = $this->user->getPersonalDataExportFile();
1194  if ($exp_file != '') {
1195  $this->toolbar->addSeparator();
1196  $this->toolbar->addComponent(
1197  $this->ui_factory->link()->standard(
1198  $this->lng->txt("pd_download_last_export_file"),
1199  $this->ctrl->getLinkTarget($this, "downloadPersonalData")
1200  )
1201  );
1202  }
1203 
1204  $this->toolbar->addSeparator();
1205  $this->toolbar->addComponent(
1206  $this->ui_factory->link()->standard(
1207  $this->lng->txt("pd_import_personal_data"),
1208  $this->ctrl->getLinkTarget($this, "importPersonalDataSelection")
1209  )
1210  );
1211 
1212  $this->tpl->printToStdout();
1213  }
+ Here is the call graph for this function:

◆ showPersonalData()

ilPersonalProfileGUI::showPersonalData ( bool  $a_no_init = false)

Definition at line 462 of file class.ilPersonalProfileGUI.php.

References buildInfoText(), ILIAS\Repository\form(), initPersonalDataForm(), ILIAS\Repository\lng(), null, setHeader(), showChecklist(), ILIAS\Repository\tabs(), and ILIAS\Repository\user().

Referenced by goToEmailConfirmation(), savePersonalData(), and showProfile().

464  : void {
465  $this->tabs->activateTab('personal_data');
466 
467 
468  $this->setHeader();
469 
470  $this->showChecklist(ChecklistStatus::STEP_PROFILE_DATA);
471 
472  if (!$a_no_init) {
473  $this->initPersonalDataForm();
474  // catch feedback message
475  if ($this->user->getProfileIncomplete()) {
476  $this->tpl->setOnScreenMessage('info', $this->lng->txt('profile_incomplete'));
477  }
478  }
479 
480  $modal = '';
481  if ($this->email_change_confirmation_modal !== null) {
482  $modal = $this->ui_renderer->render($this->email_change_confirmation_modal);
483  }
484 
485  $this->tpl->setContent($this->buildInfoText() . $this->form->getHTML() . $modal);
486 
487  $this->tpl->printToStdout();
488  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showProfile()

ilPersonalProfileGUI::showProfile ( )

show profile form

/OLD IMPLEMENTATION DEPRECATED

Definition at line 294 of file class.ilPersonalProfileGUI.php.

References showPersonalData().

294  : void
295  {
296  $this->showPersonalData();
297  }
showPersonalData(bool $a_no_init=false)
+ Here is the call graph for this function:

◆ showPublicProfile()

ilPersonalProfileGUI::showPublicProfile ( bool  $a_no_init = false)

Definition at line 828 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\form(), initPublicProfileForm(), setHeader(), showChecklist(), and ILIAS\Repository\tabs().

Referenced by changeEmail().

828  : void
829  {
830  $this->tabs->activateTab('public_profile');
831  $this->showChecklist(ChecklistStatus::STEP_PUBLISH_OPTIONS);
832 
833  $this->setHeader();
834 
835  if (!$a_no_init) {
836  $this->initPublicProfileForm();
837  }
838 
839  $this->tpl->setContent($this->form->getHTML());
840  $this->tpl->printToStdout();
841  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showPublicProfileFields()

ilPersonalProfileGUI::showPublicProfileFields ( ilPropertyFormGUI  $form,
array  $prefs,
?object  $parent = null,
bool  $anonymized = false,
string  $key_suffix = '' 
)

Definition at line 913 of file class.ilPersonalProfileGUI.php.

References $handler, ilObjUser\_getPersonalPicturePath(), ilPropertyFormGUI\addItem(), ilDatePresentation\formatDate(), ilBadgeHandler\getInstance(), ilBadgeAssignment\getInstancesByUserId(), IL_CAL_DATE, ILIAS\Repository\int(), ilMapUtil\isActivated(), ILIAS\Repository\lng(), null, ILIAS\Repository\user(), and userSettingVisible().

Referenced by initPublicProfileForm().

919  : void {
920  $birthday = $this->user->getBirthday();
921  if ($birthday) {
922  $birthday = ilDatePresentation::formatDate(new ilDate($birthday, IL_CAL_DATE));
923  }
924  $gender = $this->user->getGender();
925  if ($gender) {
926  $gender = $this->lng->txt('gender_' . $gender);
927  }
928 
929  $txt_sel_country = '';
930  if ($this->user->getSelectedCountry() != '') {
931  $this->lng->loadLanguageModule('meta');
932  $txt_sel_country = $this->lng->txt('meta_c_' . $this->user->getSelectedCountry());
933  }
934 
935  // profile picture
936  $pic = ilObjUser::_getPersonalPicturePath($this->user->getId(), 'xsmall', true, true);
937  if ($pic) {
938  $pic = "<img src='{$pic}' alt='{$this->lng->txt('user_avatar')}' />";
939  }
940 
941  // personal data
942  $val_array = [
943  'title' => $this->user->getUTitle(),
944  'birthday' => $birthday,
945  'gender' => $gender,
946  'upload' => $pic,
947  'interests_general' => $this->user->getGeneralInterestsAsText(),
948  'interests_help_offered' => $this->user->getOfferingHelpAsText(),
949  'interests_help_looking' => $this->user->getLookingForHelpAsText(),
950  'org_units' => $this->user->getOrgUnitsRepresentation(),
951  'institution' => $this->user->getInstitution(),
952  'department' => $this->user->getDepartment(),
953  'street' => $this->user->getStreet(),
954  'zipcode' => $this->user->getZipcode(),
955  'city' => $this->user->getCity(),
956  'country' => $this->user->getCountry(),
957  'sel_country' => $txt_sel_country,
958  'phone_office' => $this->user->getPhoneOffice(),
959  'phone_home' => $this->user->getPhoneHome(),
960  'phone_mobile' => $this->user->getPhoneMobile(),
961  'fax' => $this->user->getFax(),
962  'email' => $this->user->getEmail(),
963  'second_email' => $this->user->getSecondEmail(),
964  'hobby' => $this->user->getHobby(),
965  'matriculation' => $this->user->getMatriculation()
966  ];
967 
968  // location
969  if (ilMapUtil::isActivated()) {
970  $val_array['location'] = ((int) $this->user->getLatitude() +
971  (int) $this->user->getLongitude()
972  + (int) $this->user->getLocationZoom() > 0)
973  ? ' '
974  : '';
975  }
976  foreach ($val_array as $key => $value) {
977  if (in_array($value, ['', '-']) && !$anonymized) {
978  continue;
979  }
980  if ($anonymized) {
981  $value = null;
982  }
983 
984  if ($this->userSettingVisible($key)) {
985  // #18795 - we should use ilUserProfile
986  switch ($key) {
987  case 'upload':
988  $caption = 'personal_picture';
989  break;
990 
991  case 'title':
992  $caption = 'person_title';
993  break;
994 
995  default:
996  $caption = $key;
997  }
998  $cb = new ilCheckboxInputGUI($this->lng->txt($caption), 'chk_' . $key . $key_suffix);
999  if (isset($prefs['public_' . $key]) && $prefs['public_' . $key] == 'y') {
1000  $cb->setChecked(true);
1001  }
1002  $cb->setOptionTitle((string) $value);
1003 
1004  if (!$parent) {
1005  $form->addItem($cb);
1006  } else {
1007  $parent->addSubItem($cb);
1008  }
1009  }
1010  }
1011 
1012  // additional defined user data fields
1013  $user_defined_data = [];
1014  if (!$anonymized) {
1015  $user_defined_data = $this->user->getUserDefinedData();
1016  }
1017  foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
1018  // public setting
1019  $cb = new ilCheckboxInputGUI($definition['field_name'], 'chk_udf_' . $definition['field_id'] . $key_suffix);
1020  $cb->setOptionTitle($user_defined_data['f_' . $definition['field_id']] ?? '');
1021  $public_udf = (string) ($prefs['public_udf_' . $definition['field_id']] ?? '');
1022  if ($public_udf === 'y') {
1023  $cb->setChecked(true);
1024  }
1025 
1026  if (!$parent) {
1027  $form->addItem($cb);
1028  } else {
1029  $parent->addSubItem($cb);
1030  }
1031  }
1032 
1033  if (!$anonymized) {
1035  if ($handler->isActive()) {
1036  $badge_options = [];
1037 
1038  foreach (ilBadgeAssignment::getInstancesByUserId($this->user->getId()) as $ass) {
1039  // only active
1040  if ($ass->getPosition()) {
1041  $badge = new ilBadge($ass->getBadgeId());
1042  $badge_options[] = $badge->getTitle();
1043  }
1044  }
1045 
1046  if (count($badge_options) > 1) {
1047  $badge_order = new ilNonEditableValueGUI($this->lng->txt('obj_bdga'), 'bpos' . $key_suffix);
1048  $badge_order->setMultiValues($badge_options);
1049  $badge_order->setValue(array_shift($badge_options));
1050  $badge_order->setMulti(true, true, false);
1051 
1052  if (!$parent) {
1053  $form->addItem($badge_order);
1054  } else {
1055  $parent->addSubItem($badge_order);
1056  }
1057  }
1058  }
1059  }
1060 
1061  // permalink
1062  $ne = new ilNonEditableValueGUI($this->lng->txt('perma_link'), '');
1063  $ne->setValue(ilLink::_getLink($this->user->getId(), 'usr'));
1064  if (!$parent) {
1065  $form->addItem($ne);
1066  } else {
1067  $parent->addSubItem($ne);
1068  }
1069  }
static getInstancesByUserId(int $a_user_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static isActivated()
Checks whether Map feature is activated.
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)
$handler
Definition: oai.php:30
const IL_CAL_DATE
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tempStorePicture()

ilPersonalProfileGUI::tempStorePicture ( )
private

Definition at line 1302 of file class.ilPersonalProfileGUI.php.

References ILIAS\Repository\form().

Referenced by savePersonalData().

1302  : void
1303  {
1304  $capture = $this->profile_request->getUserFileCapture();
1305 
1306  if ($capture !== '') {
1307  $this->form->getItemByPostVar('userfile')->setImage($capture);
1308  $hidden_user_picture_carry = new ilHiddenInputGUI('user_picture_carry');
1309  $hidden_user_picture_carry->setValue($capture);
1310  $this->form->addItem($hidden_user_picture_carry);
1311  }
1312  }
This class represents a hidden form property in a property form.
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateLoginOrSetErrorMessages()

ilPersonalProfileGUI::updateLoginOrSetErrorMessages ( )
private

Definition at line 658 of file class.ilPersonalProfileGUI.php.

References Vendor\Package\$e, ilObjUser\_loginExists(), ILIAS\Repository\form(), ilUtil\isLogin(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by goToEmailConfirmation(), and savePersonalData().

658  : bool
659  {
660  $login = $this->form->getInput('username');
661  if ($login === '' || !ilUtil::isLogin($login)) {
662  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
663  $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('login_invalid'));
664  return false;
665  }
666 
667  if (ilObjUser::_loginExists($login, $this->user->getId())) {
668  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
669  $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('loginname_already_exists'));
670  return false;
671  }
672 
673  $this->user->setLogin($login);
674 
675  try {
676  $this->user->updateLogin($this->user->getLogin());
677  return true;
678  } catch (ilUserException $e) {
679  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
680  $this->form->getItemByPostVar('username')->setAlert($e->getMessage());
681  return false;
682  }
683  }
static _loginExists(string $a_login, int $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
static isLogin(string $a_login)
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uploadUserPicture()

ilPersonalProfileGUI::uploadUserPicture ( )

Definition at line 191 of file class.ilPersonalProfileGUI.php.

References $data, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ILIAS\Repository\lng(), null, ILIAS\Repository\user(), and workWithUserSetting().

Referenced by savePersonalDataForm().

191  : void
192  {
193  if (!$this->workWithUserSetting('upload')) {
194  return;
195  }
196 
197  if (!$this->form->hasFileUpload('userfile')
198  && $this->profile_request->getUserFileCapture() === '') {
199  if ($this->form->getItemByPostVar('userfile')->getDeletionFlag()) {
200  $this->user->removeUserPicture();
201  }
202  return;
203  }
204 
205  // User has uploaded a file of a captured image
206  if (!$this->uploads->hasBeenProcessed()) {
207  $this->uploads->process();
208  }
209  $existing_rid = $this->irss->manage()->find($this->user->getAvatarRid());
210  $revision_title = 'Avatar for user ' . $this->user->getLogin();
211 
212  // move uploaded file
213  if ($this->form->hasFileUpload('userfile') && $this->uploads->hasBeenProcessed()) {
214  $stream = Streams::ofResource(
215  fopen(
216  $this->form->getFileUpload('userfile')['tmp_name'],
217  'r'
218  )
219  );
220 
221  if ($existing_rid === null) {
222  $rid = $this->irss->manage()->stream(
223  $stream,
224  $this->stakeholder,
225  $revision_title
226  );
227  } else {
228  $rid = $existing_rid;
229  $this->irss->manage()->replaceWithStream(
230  $existing_rid,
231  $stream,
232  $this->stakeholder,
233  $revision_title
234  );
235  }
236 
237  if (!isset($rid)) {
238  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('upload_error_file_not_found'), true);
239  $this->ctrl->redirect($this, 'showProfile');
240  }
241  $this->user->setAvatarRid($rid->serialize());
242  $this->irss->flavours()->ensure($rid, new ilUserProfilePictureDefinition()); // Create different sizes
243  $this->user->update();
244  return;
245  }
246 
247  $capture = $this->profile_request->getUserFileCapture();
248  if ($capture === null) {
249  return;
250  }
251 
252  $img = str_replace(
253  ['data:image/png;base64,', ' '],
254  ['', '+'],
255  $capture
256  );
257  $data = base64_decode($img);
258  if ($data === false) {
259  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('upload_error_file_not_found'), true);
260  $this->ctrl->redirect($this, 'showProfile');
261  }
262  $stream = Streams::ofString($data);
263 
264  if ($existing_rid === null) {
265  $rid = $this->irss->manage()->stream(
266  $stream,
267  $this->stakeholder,
268  $revision_title
269  );
270  } else {
271  $rid = $existing_rid;
272  $this->irss->manage()->replaceWithStream(
273  $rid,
274  $stream,
275  $this->stakeholder,
276  $revision_title
277  );
278  }
279  $this->user->setAvatarRid($rid->serialize());
280  $this->irss->flavours()->ensure($rid, new ilUserProfilePictureDefinition()); // Create different sizes
281  $this->user->update();
282  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ userSettingEnabled()

ilPersonalProfileGUI::userSettingEnabled ( string  $setting)

Definition at line 186 of file class.ilPersonalProfileGUI.php.

186  : bool
187  {
188  return $this->user_settings_config->isChangeable($setting);
189  }

◆ userSettingVisible()

ilPersonalProfileGUI::userSettingVisible ( string  $setting)

Definition at line 181 of file class.ilPersonalProfileGUI.php.

Referenced by __showOtherInformations(), and showPublicProfileFields().

181  : bool
182  {
183  return $this->user_settings_config->isVisible($setting);
184  }
+ Here is the caller graph for this function:

◆ workWithUserSetting()

ilPersonalProfileGUI::workWithUserSetting ( string  $setting)

Definition at line 176 of file class.ilPersonalProfileGUI.php.

Referenced by uploadUserPicture().

176  : bool
177  {
178  return $this->user_settings_config->isVisibleAndChangeable($setting);
179  }
+ Here is the caller graph for this function:

Field Documentation

◆ $auth_session

ilAuthSession ilPersonalProfileGUI::$auth_session
private

Definition at line 55 of file class.ilPersonalProfileGUI.php.

◆ $change_mail_token_repo

ChangeMailTokenRepository ilPersonalProfileGUI::$change_mail_token_repo
private

Definition at line 69 of file class.ilPersonalProfileGUI.php.

◆ $checklist

ilProfileChecklistGUI ilPersonalProfileGUI::$checklist
private

Definition at line 63 of file class.ilPersonalProfileGUI.php.

◆ $checklist_status

ChecklistStatus ilPersonalProfileGUI::$checklist_status
private

Definition at line 65 of file class.ilPersonalProfileGUI.php.

◆ $ctrl

ilCtrl ilPersonalProfileGUI::$ctrl
private

Definition at line 58 of file class.ilPersonalProfileGUI.php.

◆ $email_change_confirmation_modal

Interruptive ilPersonalProfileGUI::$email_change_confirmation_modal = null
private

Definition at line 78 of file class.ilPersonalProfileGUI.php.

◆ $error_handler

ilErrorHandling ilPersonalProfileGUI::$error_handler
private

Definition at line 62 of file class.ilPersonalProfileGUI.php.

◆ $eventHandler

ilAppEventHandler ilPersonalProfileGUI::$eventHandler
private

Definition at line 51 of file class.ilPersonalProfileGUI.php.

◆ $form

ilPropertyFormGUI ilPersonalProfileGUI::$form
private

Definition at line 52 of file class.ilPersonalProfileGUI.php.

◆ $help

ilHelpGUI ilPersonalProfileGUI::$help
private

Definition at line 61 of file class.ilPersonalProfileGUI.php.

◆ $irss

IRSS ilPersonalProfileGUI::$irss
private

Definition at line 75 of file class.ilPersonalProfileGUI.php.

◆ $lng

Language ilPersonalProfileGUI::$lng
private

Definition at line 57 of file class.ilPersonalProfileGUI.php.

◆ $logger

ilLogger ilPersonalProfileGUI::$logger
private

Definition at line 73 of file class.ilPersonalProfileGUI.php.

◆ $profile_request

GUIRequest ilPersonalProfileGUI::$profile_request
private

Definition at line 71 of file class.ilPersonalProfileGUI.php.

◆ $prompt_repository

PromptRepository ilPersonalProfileGUI::$prompt_repository
private

Definition at line 70 of file class.ilPersonalProfileGUI.php.

◆ $settings

ilSetting ilPersonalProfileGUI::$settings
private

Definition at line 53 of file class.ilPersonalProfileGUI.php.

◆ $stakeholder

ResourceStakeholder ilPersonalProfileGUI::$stakeholder
private

Definition at line 76 of file class.ilPersonalProfileGUI.php.

◆ $static_url

StaticUrlServices ilPersonalProfileGUI::$static_url
private

Definition at line 56 of file class.ilPersonalProfileGUI.php.

◆ $tabs

ilTabsGUI ilPersonalProfileGUI::$tabs
private

Definition at line 59 of file class.ilPersonalProfileGUI.php.

◆ $toolbar

ilToolbarGUI ilPersonalProfileGUI::$toolbar
private

Definition at line 60 of file class.ilPersonalProfileGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilPersonalProfileGUI::$tpl
private

Definition at line 49 of file class.ilPersonalProfileGUI.php.

Referenced by showChecklist().

◆ $ui_factory

UIFactory ilPersonalProfileGUI::$ui_factory
private

Definition at line 66 of file class.ilPersonalProfileGUI.php.

◆ $ui_renderer

UIRenderer ilPersonalProfileGUI::$ui_renderer
private

Definition at line 67 of file class.ilPersonalProfileGUI.php.

◆ $uploads

FileUpload ilPersonalProfileGUI::$uploads
private

Definition at line 74 of file class.ilPersonalProfileGUI.php.

◆ $user

ilObjUser ilPersonalProfileGUI::$user
private

Definition at line 54 of file class.ilPersonalProfileGUI.php.

Referenced by changeEmail().

◆ $user_defined_fields

ilUserDefinedFields ilPersonalProfileGUI::$user_defined_fields = null
private

Definition at line 50 of file class.ilPersonalProfileGUI.php.

◆ $user_settings_config

ilUserSettingsConfig ilPersonalProfileGUI::$user_settings_config
private

Definition at line 64 of file class.ilPersonalProfileGUI.php.

◆ CHANGE_EMAIL_CMD

const ilPersonalProfileGUI::CHANGE_EMAIL_CMD = 'changeEmail'

◆ PERSONAL_DATA_FORM_ID

const ilPersonalProfileGUI::PERSONAL_DATA_FORM_ID = 'pd'
private

Definition at line 46 of file class.ilPersonalProfileGUI.php.


The documentation for this class was generated from the following file: