Allow to edit user avatar via user admin page.

This commit is contained in:
Jan Böhmer 2023-01-23 23:58:11 +01:00
parent 97b87dee5f
commit daba6edf5d
4 changed files with 17 additions and 7 deletions

View file

@ -5,7 +5,7 @@ liip_imagine:
filter_sets:
thumbnail_sm:
quality: 70
quality: 90
filters:
thumbnail:
size: [150, 150]
@ -13,14 +13,14 @@ liip_imagine:
thumbnail_md:
quality: 75
quality: 90
filters:
thumbnail:
size: [250, 250]
mode: inset
thumbnail_xs:
quality: 70
quality: 90
filters:
thumbnail:
size: [50, 50]

View file

@ -28,6 +28,7 @@ use App\Entity\UserSystem\Group;
use App\Entity\UserSystem\User;
use App\Form\Permissions\PermissionsType;
use App\Form\Type\CurrencyEntityType;
use App\Form\Type\MasterPictureAttachmentType;
use App\Form\Type\StructuralEntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@ -227,7 +228,14 @@ class UserAdminForm extends AbstractType
'data_class' => $options['attachment_class'],
],
'by_reference' => false,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit_infos', $entity),
]);
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
'required' => false,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit_infos', $entity),
'label' => 'part.edit.master_attachment',
'entity' => $entity,
]);
$builder->add('log_comment', TextType::class, [

View file

@ -50,7 +50,7 @@ class UserAvatarHelper
{
//Check if the user has a master attachment defined (meaning he has explicitly defined a profile picture)
if ($user->getMasterPictureAttachment() !== null) {
return $this->attachmentURLGenerator->getThumbnailURL($user->getMasterPictureAttachment());
return $this->attachmentURLGenerator->getThumbnailURL($user->getMasterPictureAttachment(), 'thumbnail_md');
}
//If not check if gravatar is enabled (then use gravatar URL)

View file

@ -16,8 +16,6 @@
<li class="nav-item"><a data-bs-toggle="tab" class="nav-link link-anchor" href="#permissions">{% trans %}user.edit.permissions{% endtrans %}</a></li>
{% endblock %}
{% block master_picture_block %}{% endblock %}
{% block additional_controls %}
{{ form_row(form.group) }}
{{ form_row(form.first_name) }}
@ -88,3 +86,7 @@
{% block new_title %}
{% trans %}user.new{% endtrans %}
{% endblock %}
{% block quick_links %}
<img src="{{ avatar_helper.avatarURL(entity) }}" style="height: 50px; width: 50px; object-fit: cover;">
{% endblock %}