19declare(strict_types=1);
24use ILIAS\User\Profile\Fields\NoOverrides;
46 private readonly IRSS $irss,
49 private readonly UIRenderer $ui_renderer,
52 $this->stakeholder = new \ilUserProfilePictureStakeholder();
62 return $lng->txt(
'personal_picture');
67 return AvailableSections::PersonalData;
115 if (($_FILES[$this->
getIdentifier()][
'tmp_name'] ??
'') !==
'') {
116 $input->setPending($_FILES[$this->
getIdentifier()][
'tmp_name']);
120 if ($user ===
null) {
124 $picture_path = $user->getPersonalPicturePath(
'small',
true);
125 if ($picture_path !==
'') {
126 $input->setImage($picture_path);
127 $input->setAlt($this->
getLabel($lng));
137 return $this->uploadUserPicture($user, $input, $form);
146 $define = new \ilUserAvatarResolver($user->
getId());
147 $define->setSize(
'xsmall');
148 $define->setForcePicture(
true);
149 return $define->getLegacyPictureURL();
158 $capture = $this->retrieveCapture();
159 if ($capture ===
'') {
163 $hidden_user_picture_carry = new \ilHiddenInputGUI(
'user_picture_carry');
164 $hidden_user_picture_carry->setValue($capture);
165 $form->
addItem($hidden_user_picture_carry);
174 $capture = $this->retrieveCapture();
175 if ($input[
'tmp_name'] ===
'' && $capture ===
'') {
183 if (!$this->uploads->hasBeenProcessed()) {
184 $this->uploads->process();
188 $revision_title =
'Avatar for user ' . $user->
getLogin();
189 $this->stakeholder->setOwner($user->
getId());
190 $uploads = $this->uploads->getResults();
192 if (isset($uploads[$input[
'tmp_name']])) {
193 $rid = $this->moveUploadToStorage(
196 $uploads[$input[
'tmp_name']]
203 if ($capture ===
'') {
207 $data = base64_decode(
209 [
'data:image/png;base64,',
' '],
214 if (
$data ===
false) {
217 $rid = $this->moveStreamToStorage(
220 Streams::ofString(
$data)
229 string $revision_title,
232 if ($existing_rid === null) {
233 return $this->irss->manage()->upload(
240 $this->irss->manage()->replaceWithUpload(
247 return $existing_rid;
252 string $revision_title,
255 if ($existing_rid === null) {
256 return $this->irss->manage()->stream(
263 $this->irss->manage()->replaceWithStream(
269 return $existing_rid;
274 $from_upload = $this->post_wrapper->retrieve(
277 $this->refinery->kindlyTo()->string(),
278 $this->refinery->always(
'')
282 if ($from_upload !==
'') {
286 return $this->post_wrapper->retrieve(
287 'user_picture_carry',
289 $this->refinery->kindlyTo()->string(),
290 $this->refinery->always(
'')
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Class ArrayBasedRequestWrapper.
Class ResourceIdentification.
ResourceStakeholder $stakeholder
uploadUserPicture(\ilObjUser $user, array $input, \ilPropertyFormGUI $form)
addValueToUserObject(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
getLegacyInput(Language $lng, Context $context, ?\ilObjUser $user=null)
You don't need to add a post_var to the input as the User will handle this for you,...
__construct(private readonly IRSS $irss, private readonly FileUpload $uploads, private readonly ArrayBasedRequestWrapper $post_wrapper, private readonly UIRenderer $ui_renderer, private readonly Refinery $refinery)
tempStorePicture(\ilPropertyFormGUI $form)
moveUploadToStorage(?ResourceIdentification $existing_rid, string $revision_title, UploadResult $upload_result)
availableInCertificatesForcedTo()
moveStreamToStorage(?ResourceIdentification $existing_rid, string $revision_title, Stream $stream)
visibleInStudyProgrammesForcedTo()
visibleInCoursesForcedTo()
visibleInGroupsForcedTo()
retrieveValueFromUser(\ilObjUser $user)
setAvatarRid(?ResourceIdentification $avatar_rid)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ResourceStakeholder.
An entity that renders components to a string output.
if(!file_exists('../ilias.ini.php'))