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();
125 if ($picture_path !==
'') {
126 $input->setImage($picture_path);
127 $input->setAlt($this->
getLabel($lng));
137 return $this->uploadUserPicture($user, $input, $form);
142 $define = new \ilUserAvatarResolver($user->
getId());
143 if (!$define->hasProfilePicture()) {
146 $define->setSize(
'xsmall');
147 return $this->ui_renderer->render($define->getAvatar());
156 $capture = $this->retrieveCapture();
157 if ($capture ===
'') {
161 $hidden_user_picture_carry = new \ilHiddenInputGUI(
'user_picture_carry');
162 $hidden_user_picture_carry->setValue($capture);
163 $form->
addItem($hidden_user_picture_carry);
172 $capture = $this->retrieveCapture();
173 if ($input[
'tmp_name'] ===
'' && $capture ===
'') {
181 if (!$this->uploads->hasBeenProcessed()) {
182 $this->uploads->process();
186 $revision_title =
'Avatar for user ' . $user->
getLogin();
187 $this->stakeholder->setOwner($user->
getId());
188 $uploads = $this->uploads->getResults();
190 if (isset($uploads[$input[
'tmp_name']])) {
191 $rid = $this->moveUploadToStorage(
194 $uploads[$input[
'tmp_name']]
201 if ($capture ===
'') {
205 $data = base64_decode(
207 [
'data:image/png;base64,',
' '],
212 if (
$data ===
false) {
215 $rid = $this->moveStreamToStorage(
218 Streams::ofString(
$data)
227 string $revision_title,
230 if ($existing_rid === null) {
231 return $this->irss->manage()->upload(
238 $this->irss->manage()->replaceWithUpload(
245 return $existing_rid;
250 string $revision_title,
253 if ($existing_rid === null) {
254 return $this->irss->manage()->stream(
261 $this->irss->manage()->replaceWithStream(
267 return $existing_rid;
272 $from_upload = $this->post_wrapper->retrieve(
275 $this->refinery->kindlyTo()->string(),
276 $this->refinery->always(
'')
280 if ($from_upload !==
'') {
284 return $this->post_wrapper->retrieve(
285 'user_picture_carry',
287 $this->refinery->kindlyTo()->string(),
288 $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'))