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;
112 $context === Context::User || $context === Context::Registration
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 ===
'') {
176 if ($form?->getItemByPostVar($this->getIdentifier())->getDeletionFlag()) {
183 if (!$this->uploads->hasBeenProcessed()) {
184 $this->uploads->process();
188 $revision_title =
'Avatar for user ' . ($input[
'alias'] ?? $user->
getLogin());
189 $this->stakeholder->setOwner($user->
getId());
190 $uploads = $this->uploads->getResults();
192 if (is_file($input[
'tmp_name'])) {
193 $rid = $this->moveStreamToStorage(
197 file_get_contents($input[
'tmp_name'])
205 if (isset($uploads[$input[
'tmp_name']])) {
206 $rid = $this->moveUploadToStorage(
209 $uploads[$input[
'tmp_name']]
216 if ($capture ===
'') {
220 $data = base64_decode(
222 [
'data:image/png;base64,',
' '],
227 if (
$data ===
false) {
230 $rid = $this->moveStreamToStorage(
233 Streams::ofString(
$data)
242 string $revision_title,
245 if ($existing_rid === null) {
246 return $this->irss->manage()->upload(
253 $this->irss->manage()->replaceWithUpload(
260 return $existing_rid;
265 string $revision_title,
268 if ($existing_rid === null) {
269 return $this->irss->manage()->stream(
276 $this->irss->manage()->replaceWithStream(
282 return $existing_rid;
287 $from_upload = $this->post_wrapper->retrieve(
290 $this->refinery->kindlyTo()->string(),
291 $this->refinery->always(
'')
295 if ($from_upload !==
'') {
299 return $this->post_wrapper->retrieve(
300 'user_picture_carry',
302 $this->refinery->kindlyTo()->string(),
303 $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
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)
uploadUserPicture(\ilObjUser $user, array $input, ?\ilPropertyFormGUI $form)
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'))